Skip to content

Commit 9e8d144

Browse files
authored
fix: credentials: don't store creds for local credential tools (#239)
Signed-off-by: Grant Linville <[email protected]>
1 parent 89efaa9 commit 9e8d144

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

pkg/runner/runner.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"os"
88
"path/filepath"
9+
"strings"
910
"sync"
1011
"time"
1112

@@ -340,9 +341,18 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
340341
}
341342

342343
for _, credToolName := range callCtx.Tool.Credentials {
343-
cred, exists, err := store.Get(credToolName)
344-
if err != nil {
345-
return nil, fmt.Errorf("failed to get credentials for tool %s: %w", credToolName, err)
344+
var (
345+
cred *credentials.Credential
346+
exists bool
347+
err error
348+
)
349+
350+
// Only try to look up the cred if the tool is on GitHub.
351+
if isGitHubTool(credToolName) {
352+
cred, exists, err = store.Get(credToolName)
353+
if err != nil {
354+
return nil, fmt.Errorf("failed to get credentials for tool %s: %w", credToolName, err)
355+
}
346356
}
347357

348358
// If the credential doesn't already exist in the store, run the credential tool in order to get the value,
@@ -375,7 +385,7 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
375385
}
376386

377387
// Only store the credential if the tool is on GitHub.
378-
if callCtx.Program.ToolSet[credToolID].Source.Repo != nil {
388+
if isGitHubTool(credToolName) && callCtx.Program.ToolSet[credToolID].Source.Repo != nil {
379389
if err := store.Add(*cred); err != nil {
380390
return nil, fmt.Errorf("failed to add credential for tool %s: %w", credToolName, err)
381391
}
@@ -391,3 +401,7 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
391401

392402
return env, nil
393403
}
404+
405+
func isGitHubTool(toolName string) bool {
406+
return strings.HasPrefix(toolName, "github.com")
407+
}

0 commit comments

Comments
 (0)