From eb5460eec71aa393e11d2eb50e43ec5ffefd5a88 Mon Sep 17 00:00:00 2001 From: Pedro Lopes Date: Wed, 6 Sep 2023 11:39:45 +0100 Subject: [PATCH] add new flag to ignore proxy --- internal/commands/root.go | 2 +- internal/params/binds.go | 1 + internal/params/envs.go | 1 + internal/params/keys.go | 1 + internal/wrappers/client.go | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/commands/root.go b/internal/commands/root.go index 42a567f97..43fcd2367 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -125,13 +125,13 @@ func NewAstCLI( _ = viper.BindPFlag(params.BaseAuthURIKey, rootCmd.PersistentFlags().Lookup(params.BaseAuthURIFlag)) _ = viper.BindPFlag(params.AstAPIKey, rootCmd.PersistentFlags().Lookup(params.AstAPIKeyFlag)) _ = viper.BindPFlag(params.AgentNameKey, rootCmd.PersistentFlags().Lookup(params.AgentFlag)) + _ = viper.BindPFlag(params.IgnoreProxyKey, rootCmd.PersistentFlags().Lookup(params.IgnoreProxyFlag)) // Key here is the actual flag since it doesn't use an environment variable _ = viper.BindPFlag(params.DebugFlag, rootCmd.PersistentFlags().Lookup(params.DebugFlag)) _ = viper.BindPFlag(params.InsecureFlag, rootCmd.PersistentFlags().Lookup(params.InsecureFlag)) _ = viper.BindPFlag(params.RetryFlag, rootCmd.PersistentFlags().Lookup(params.RetryFlag)) _ = viper.BindPFlag(params.RetryDelayFlag, rootCmd.PersistentFlags().Lookup(params.RetryDelayFlag)) _ = viper.BindPFlag(params.ApikeyOverrideFlag, rootCmd.PersistentFlags().Lookup(params.ApikeyOverrideFlag)) - _ = viper.BindPFlag(params.IgnoreProxyFlag, rootCmd.PersistentFlags().Lookup(params.IgnoreProxyFlag)) // Set help func rootCmd.SetHelpFunc( diff --git a/internal/params/binds.go b/internal/params/binds.go index eaa981939..b89a745f3 100644 --- a/internal/params/binds.go +++ b/internal/params/binds.go @@ -10,6 +10,7 @@ var EnvVarsBinds = []struct { {ProxyDomainKey, ProxyDomainEnv, ""}, {BaseAuthURIKey, BaseAuthURIEnv, ""}, {AstAPIKey, AstAPIKeyEnv, ""}, + {IgnoreProxyKey, IgnoreProxyEnv, ""}, {AgentNameKey, AgentNameEnv, "ASTCLI"}, {CodeBashingPathKey, ScansPathEnv, "api/codebashing/lessons"}, {ScansPathKey, ScansPathEnv, "api/scans"}, diff --git a/internal/params/envs.go b/internal/params/envs.go index 8eddef211..1df60d00d 100644 --- a/internal/params/envs.go +++ b/internal/params/envs.go @@ -56,4 +56,5 @@ const ( FeatureFlagsEnv = "CX_FEATURE_FLAGS_PATH" UploadURLEnv = "CX_UPLOAD_URL" PolicyEvaluationPathEnv = "CX_POLICY_EVALUATION_PATH" + IgnoreProxyEnv = "CX_IGNORE_PROXY" ) diff --git a/internal/params/keys.go b/internal/params/keys.go index 9ee188312..4426ad8ae 100644 --- a/internal/params/keys.go +++ b/internal/params/keys.go @@ -15,6 +15,7 @@ var ( ScansPathKey = strings.ToLower(ScansPathEnv) GroupsPathKey = strings.ToLower(GroupsPathEnv) AgentNameKey = strings.ToLower(AgentNameEnv) + IgnoreProxyKey = strings.ToLower(IgnoreProxyEnv) CodeBashingPathKey = strings.ToLower(CodeBashingPathEnv) ProjectsPathKey = strings.ToLower(ProjectsPathEnv) ResultsPathKey = strings.ToLower(ResultsPathEnv) diff --git a/internal/wrappers/client.go b/internal/wrappers/client.go index 9af9ed146..9b179e0da 100644 --- a/internal/wrappers/client.go +++ b/internal/wrappers/client.go @@ -70,7 +70,7 @@ func setAgentName(req *http.Request) { func GetClient(timeout uint) *http.Client { proxyTypeStr := viper.GetString(commonParams.ProxyTypeKey) proxyStr := viper.GetString(commonParams.ProxyKey) - ignoreProxy := viper.GetBool(commonParams.IgnoreProxyFlag) + ignoreProxy := viper.GetBool(commonParams.IgnoreProxyKey) if ignoreProxy { proxyStr = ""