Skip to content

Commit

Permalink
Remove deprecated repo whitelist flag (runatlantis#3922)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemassa authored and ijames-gc committed Feb 13, 2024
1 parent c6dc452 commit a617a37
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 46 deletions.
70 changes: 26 additions & 44 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,31 @@ const (
RedisInsecureSkipVerify = "redis-insecure-skip-verify"
RepoConfigFlag = "repo-config"
RepoConfigJSONFlag = "repo-config-json"
// RepoWhitelistFlag is deprecated for RepoAllowlistFlag.
RepoWhitelistFlag = "repo-whitelist"
RepoAllowlistFlag = "repo-allowlist"
RequireApprovalFlag = "require-approval"
RequireMergeableFlag = "require-mergeable"
SilenceNoProjectsFlag = "silence-no-projects"
SilenceForkPRErrorsFlag = "silence-fork-pr-errors"
SilenceVCSStatusNoPlans = "silence-vcs-status-no-plans"
SilenceAllowlistErrorsFlag = "silence-allowlist-errors"
SkipCloneNoChanges = "skip-clone-no-changes"
SlackTokenFlag = "slack-token"
SSLCertFileFlag = "ssl-cert-file"
SSLKeyFileFlag = "ssl-key-file"
RestrictFileList = "restrict-file-list"
TFDownloadFlag = "tf-download"
TFDownloadURLFlag = "tf-download-url"
UseTFPluginCache = "use-tf-plugin-cache"
VarFileAllowlistFlag = "var-file-allowlist"
VCSStatusName = "vcs-status-name"
TFEHostnameFlag = "tfe-hostname"
TFELocalExecutionModeFlag = "tfe-local-execution-mode"
TFETokenFlag = "tfe-token"
WriteGitCredsFlag = "write-git-creds" // nolint: gosec
WebBasicAuthFlag = "web-basic-auth"
WebUsernameFlag = "web-username"
WebPasswordFlag = "web-password"
WebsocketCheckOrigin = "websocket-check-origin"
RepoAllowlistFlag = "repo-allowlist"
RequireApprovalFlag = "require-approval"
RequireMergeableFlag = "require-mergeable"
SilenceNoProjectsFlag = "silence-no-projects"
SilenceForkPRErrorsFlag = "silence-fork-pr-errors"
SilenceVCSStatusNoPlans = "silence-vcs-status-no-plans"
SilenceAllowlistErrorsFlag = "silence-allowlist-errors"
SkipCloneNoChanges = "skip-clone-no-changes"
SlackTokenFlag = "slack-token"
SSLCertFileFlag = "ssl-cert-file"
SSLKeyFileFlag = "ssl-key-file"
RestrictFileList = "restrict-file-list"
TFDownloadFlag = "tf-download"
TFDownloadURLFlag = "tf-download-url"
UseTFPluginCache = "use-tf-plugin-cache"
VarFileAllowlistFlag = "var-file-allowlist"
VCSStatusName = "vcs-status-name"
TFEHostnameFlag = "tfe-hostname"
TFELocalExecutionModeFlag = "tfe-local-execution-mode"
TFETokenFlag = "tfe-token"
WriteGitCredsFlag = "write-git-creds" // nolint: gosec
WebBasicAuthFlag = "web-basic-auth"
WebUsernameFlag = "web-username"
WebPasswordFlag = "web-password"
WebsocketCheckOrigin = "websocket-check-origin"

// NOTE: Must manually set these as defaults in the setDefaults function.
DefaultADBasicUser = ""
Expand Down Expand Up @@ -369,10 +367,6 @@ var stringFlags = map[string]stringFlag{
"all repos: '*' (not secure), an entire hostname: 'internalgithub.com/*' or an organization: 'github.com/runatlantis/*'." +
" For Bitbucket Server, {owner} is the name of the project (not the key).",
},
RepoWhitelistFlag: {
description: "[Deprecated for --repo-allowlist].",
hidden: true,
},
SlackTokenFlag: {
description: "API token for Slack notifications.",
},
Expand Down Expand Up @@ -918,16 +912,9 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error {
return vcsErr
}

// Handle deprecation of repo whitelist.
if userConfig.RepoWhitelist == "" && userConfig.RepoAllowlist == "" {
if userConfig.RepoAllowlist == "" {
return fmt.Errorf("--%s must be set for security purposes", RepoAllowlistFlag)
}
if userConfig.RepoAllowlist != "" && userConfig.RepoWhitelist != "" {
return fmt.Errorf("both --%s and --%s cannot be set–use --%s", RepoAllowlistFlag, RepoWhitelistFlag, RepoAllowlistFlag)
}
if strings.Contains(userConfig.RepoWhitelist, "://") {
return fmt.Errorf("--%s cannot contain ://, should be hostnames only", RepoWhitelistFlag)
}
if strings.Contains(userConfig.RepoAllowlist, "://") {
return fmt.Errorf("--%s cannot contain ://, should be hostnames only", RepoAllowlistFlag)
}
Expand Down Expand Up @@ -1132,11 +1119,6 @@ func (s *ServerCmd) deprecationWarnings(userConfig *server.UserConfig) error {
fmt.Println(warning)
}

// Handle repo whitelist deprecation.
if userConfig.RepoWhitelist != "" {
userConfig.RepoAllowlist = userConfig.RepoWhitelist
}

return nil
}

Expand Down
2 changes: 0 additions & 2 deletions server/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ type UserConfig struct {
RepoConfig string `mapstructure:"repo-config"`
RepoConfigJSON string `mapstructure:"repo-config-json"`
RepoAllowlist string `mapstructure:"repo-allowlist"`
// RepoWhitelist is deprecated in favour of RepoAllowlist.
RepoWhitelist string `mapstructure:"repo-whitelist"`

// RequireApproval is whether to require pull request approval before
// allowing terraform apply's to be run.
Expand Down

0 comments on commit a617a37

Please sign in to comment.