Skip to content

Commit

Permalink
Ignore gosec lint for execs
Browse files Browse the repository at this point in the history
  • Loading branch information
chainchad committed Nov 24, 2024
1 parent c37c8f5 commit 5f60e09
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ func (m *moduleOperator) GetGitInfo(remote, branch string) (string, time.Time, e
ctx, cancel := context.WithTimeout(context.Background(), gitTimeout)
defer cancel()

// Get latest SHA
// Safe to use remote/branch after validateGitInput ensures they match:
// - remote: ^[a-zA-Z0-9][-a-zA-Z0-9_.]*$
// - branch: ^[a-zA-Z0-9][-a-zA-Z0-9/_]*$
//nolint:gosec // Inputs are validated by regex patterns above
cmd := exec.CommandContext(ctx, "git", "ls-remote", remote, "refs/heads/"+branch)
out, err := cmd.Output()
if err != nil {
Expand All @@ -85,7 +88,7 @@ func (m *moduleOperator) GetGitInfo(remote, branch string) (string, time.Time, e
return "", time.Time{}, fmt.Errorf("%w: empty SHA from git ls-remote", ErrModOperation)
}

// Get commit timestamp
//nolint:gosec // SHA is obtained from git ls-remote output above

Check failure on line 91 in tools/gomod-required-updater/internal/updater/module_operator.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:gosec // SHA is obtained from git ls-remote output above` is unused for linter "gosec" (nolintlint)
cmd = exec.CommandContext(ctx, "git", "show", "-s", "--format=%cI", sha)
out, err = cmd.Output()
if err != nil {
Expand Down

0 comments on commit 5f60e09

Please sign in to comment.