From d219926278716edb811e309e1aaa808b51b1bc9d Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Thu, 5 Dec 2024 10:14:01 +0200 Subject: [PATCH] Add functionality to use SCS repo token as env var --- internal/commands/scan.go | 5 ++++- internal/params/binds.go | 1 + internal/params/envs.go | 1 + internal/params/keys.go | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/commands/scan.go b/internal/commands/scan.go index d5b8c29f8..bdea574f1 100644 --- a/internal/commands/scan.go +++ b/internal/commands/scan.go @@ -1000,7 +1000,10 @@ func addSCSScan(cmd *cobra.Command, resubmitConfig []wrappers.Config, hasEnterpr SCSMapConfig := make(map[string]interface{}) SCSMapConfig[resultsMapType] = commonParams.MicroEnginesType // scs is still microengines in the scans API userScanTypes, _ := cmd.Flags().GetString(commonParams.ScanTypes) - scsRepoToken, _ := cmd.Flags().GetString(commonParams.SCSRepoTokenFlag) + scsRepoToken := viper.GetString(commonParams.ScsRepoTokenKey) + if token, _ := cmd.Flags().GetString(commonParams.SCSRepoTokenFlag); token != "" { + scsRepoToken = token + } viper.Set(commonParams.SCSRepoTokenFlag, scsRepoToken) // sanitizeLogs uses viper to get the value scsRepoURL, _ := cmd.Flags().GetString(commonParams.SCSRepoURLFlag) viper.Set(commonParams.SCSRepoURLFlag, scsRepoURL) // sanitizeLogs uses viper to get the value diff --git a/internal/params/binds.go b/internal/params/binds.go index cbdb064b1..75315fadd 100644 --- a/internal/params/binds.go +++ b/internal/params/binds.go @@ -68,4 +68,5 @@ var EnvVarsBinds = []struct { {AiProxyAzureAiRouteKey, AiProxyAzureAiRouteEnv, "api/ai-proxy/redirect/externalAzure"}, {AiProxyCheckmarxAiRouteKey, AiProxyCheckmarxAiRouteEnv, "api/ai-proxy/redirect/azure"}, {ASCAPortKey, ASCAPortEnv, ""}, + {ScsRepoTokenKey, ScsRepoTokenEnv, ""}, } diff --git a/internal/params/envs.go b/internal/params/envs.go index 23ece827e..a4ed087ee 100644 --- a/internal/params/envs.go +++ b/internal/params/envs.go @@ -67,4 +67,5 @@ const ( AiProxyAzureAiRouteEnv = "CX_AIPROXY_AZUREAI_ROUTE" AiProxyCheckmarxAiRouteEnv = "CX_AIPROXY_CHECKMARXAI_ROUTE" ASCAPortEnv = "CX_ASCA_PORT" + ScsRepoTokenEnv = "SCS_REPO_TOKEN" ) diff --git a/internal/params/keys.go b/internal/params/keys.go index 6cfd007f9..37c0de34d 100644 --- a/internal/params/keys.go +++ b/internal/params/keys.go @@ -67,4 +67,5 @@ var ( AiProxyAzureAiRouteKey = strings.ToLower(AiProxyAzureAiRouteEnv) AiProxyCheckmarxAiRouteKey = strings.ToLower(AiProxyCheckmarxAiRouteEnv) ASCAPortKey = strings.ToLower(ASCAPortEnv) + ScsRepoTokenKey = strings.ToLower(ScsRepoTokenEnv) )