From fa30ba64a60d5f17943a9828db4130dd652bc4d7 Mon Sep 17 00:00:00 2001 From: Stephen Augustus Date: Wed, 16 Mar 2022 19:00:41 -0400 Subject: [PATCH] options: If empty, set `GITHUB_AUTH_TOKEN` from `INPUT_REPO_TOKEN` Signed-off-by: Stephen Augustus --- options/options.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/options/options.go b/options/options.go index f0f8751c..54df64ea 100644 --- a/options/options.go +++ b/options/options.go @@ -69,11 +69,6 @@ type Options struct { InputResultsFile string `env:"INPUT_RESULTS_FILE"` InputResultsFormat string `env:"INPUT_RESULTS_FORMAT"` InputPublishResults string `env:"INPUT_PUBLISH_RESULTS"` - - // Repo tokens - // TODO(auth): DO NOT STORE AUTH - EnvGithubAuthToken string `env:"GITHUB_AUTH_TOKEN"` - EnvInputRepoToken string `env:"INPUT_REPO_TOKEN"` } const ( @@ -132,10 +127,6 @@ func New() (*Options, error) { return opts, errResultsPathEmpty } - if opts.EnvGithubAuthToken == "" { - opts.EnvGithubAuthToken = opts.EnvInputRepoToken - } - if err := opts.Validate(); err != nil { return opts, fmt.Errorf("validating scorecard-action options: %w", err) } @@ -158,6 +149,12 @@ func (o *Options) Initialize() error { // o.EnableLicense = "1" // o.EnableDangerousWorkflow = "1" + _, tokenSet := os.LookupEnv(EnvGithubAuthToken) + if !tokenSet { + inputToken := os.Getenv(EnvInputRepoToken) + os.Setenv(EnvGithubAuthToken, inputToken) + } + return o.SetRepoInfo() }