Skip to content

Commit 9d41471

Browse files
authored
fix: do not store empty credentials (#254)
Signed-off-by: Grant Linville <[email protected]>
1 parent d0844c5 commit 9d41471

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pkg/runner/runner.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,19 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
390390
Env: envMap.Env,
391391
}
392392

393-
// Only store the credential if the tool is on GitHub.
393+
isEmpty := true
394+
for _, v := range cred.Env {
395+
if v != "" {
396+
isEmpty = false
397+
break
398+
}
399+
}
400+
401+
// Only store the credential if the tool is on GitHub, and the credential is non-empty.
394402
if isGitHubTool(credToolName) && callCtx.Program.ToolSet[credToolID].Source.Repo != nil {
395-
if err := store.Add(*cred); err != nil {
403+
if isEmpty {
404+
log.Warnf("Not saving empty credential for tool %s", credToolName)
405+
} else if err := store.Add(*cred); err != nil {
396406
return nil, fmt.Errorf("failed to add credential for tool %s: %w", credToolName, err)
397407
}
398408
} else {

0 commit comments

Comments
 (0)