From eb0a5b97bda6f5f743baaf50878099dff93e2d86 Mon Sep 17 00:00:00 2001 From: gnmahanth Date: Mon, 1 Jul 2024 14:29:38 +0000 Subject: [PATCH] add scan_result_link in extras parameter in SendNotification --- deepfence_server/pkg/integration/integration.go | 3 +-- deepfence_server/pkg/integration/jira/jira.go | 2 +- deepfence_server/pkg/integration/jira/types.go | 1 - deepfence_worker/cronjobs/notification.go | 13 +++++++------ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/deepfence_server/pkg/integration/integration.go b/deepfence_server/pkg/integration/integration.go index eb44d296d0..f77725d7e1 100644 --- a/deepfence_server/pkg/integration/integration.go +++ b/deepfence_server/pkg/integration/integration.go @@ -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 diff --git a/deepfence_server/pkg/integration/jira/jira.go b/deepfence_server/pkg/integration/jira/jira.go index 3f4b63d01e..49b3992f46 100644 --- a/deepfence_server/pkg/integration/jira/jira.go +++ b/deepfence_server/pkg/integration/jira/jira.go @@ -170,5 +170,5 @@ func (j Jira) IsValidCredential(ctx context.Context) (bool, error) { } func (a Jira) SendSummaryLink() bool { - return a.Config.SendSummary + return false } diff --git a/deepfence_server/pkg/integration/jira/types.go b/deepfence_server/pkg/integration/jira/types.go index f98399f387..1e3e48972d 100644 --- a/deepfence_server/pkg/integration/jira/types.go +++ b/deepfence_server/pkg/integration/jira/types.go @@ -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 { diff --git a/deepfence_worker/cronjobs/notification.go b/deepfence_worker/cronjobs/notification.go index 81f5a60499..fa2bb04363 100644 --- a/deepfence_worker/cronjobs/notification.go +++ b/deepfence_worker/cronjobs/notification.go @@ -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 @@ -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()