Skip to content

Commit

Permalink
add scan_result_link in extras parameter in SendNotification
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmahanth committed Jul 1, 2024
1 parent 6f5bd96 commit eb0a5b9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions deepfence_server/pkg/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ func SupportsSummaryLink(integrationType string) bool {
switch integrationType {
case constants.Slack,
constants.Teams,
constants.Email,
constants.Jira:
constants.Email:
return true
}
return false
Expand Down
2 changes: 1 addition & 1 deletion deepfence_server/pkg/integration/jira/jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,5 @@ func (j Jira) IsValidCredential(ctx context.Context) (bool, error) {
}

func (a Jira) SendSummaryLink() bool {
return a.Config.SendSummary
return false
}
1 change: 0 additions & 1 deletion deepfence_server/pkg/integration/jira/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type Config struct {
IsAuthToken bool `json:"isAuthToken"`
APIToken string `json:"api_token" validate:"omitempty,min=32,max=300,jira_auth_key"`
CustomFields []string `json:"custom_fields"`
SendSummary bool `json:"send_summary"`
}

func (j Jira) ValidateConfig(validate *validator.Validate) error {
Expand Down
13 changes: 7 additions & 6 deletions deepfence_worker/cronjobs/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,18 @@ func processIntegration[T any](ctx context.Context, intg postgresql_db.Integrati
return err
}

consoleURL, err := setting.GetManagementConsoleURL(ctx, pgClient)
if err != nil {
log.Error().Err(err).Msg("failed to get console url")
return err
}

// format data to send it as a summary and link
if integrationModel.SendSummaryLink() {

log.Info().Msgf("sending scan summary for integration %d type %s for %s",
intg.ID, intg.IntegrationType, intg.Resource)

consoleURL, err := setting.GetManagementConsoleURL(ctx, pgClient)
if err != nil {
log.Error().Err(err).Msg("failed to get console url")
return err
}

scans := []map[string]interface{}{}
for _, scan := range scansList {
// This map is required as we might have
Expand Down Expand Up @@ -481,6 +481,7 @@ func processIntegration[T any](ctx context.Context, intg postgresql_db.Integrati

extras := utils.ToMap[any](common)
extras["scan_type"] = intg.Resource
extras["scan_result_link"] = scanResultLink(consoleURL, scan.NodeType, intg.Resource, scan.ScanID)

profileStart = time.Now()

Expand Down

0 comments on commit eb0a5b9

Please sign in to comment.