Skip to content

Commit e6f8d99

Browse files
committed
Audit some command executions and tell the linter that they're OK
1 parent 93e2cd5 commit e6f8d99

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

git/git.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ func NewRepository(path string) (*Repository, error) {
101101
)
102102
}
103103

104+
//nolint:gosec // `gitBin` is chosen carefully, and `path` is the
105+
// path to the repository.
104106
cmd := exec.Command(gitBin, "-C", path, "rev-parse", "--git-dir")
105107
out, err := cmd.Output()
106108
if err != nil {
@@ -119,6 +121,7 @@ func NewRepository(path string) (*Repository, error) {
119121
}
120122
gitDir := smartJoin(path, string(bytes.TrimSpace(out)))
121123

124+
//nolint:gosec // `gitBin` is chosen carefully.
122125
cmd = exec.Command(gitBin, "rev-parse", "--git-path", "shallow")
123126
cmd.Dir = gitDir
124127
out, err = cmd.Output()
@@ -152,6 +155,8 @@ func (repo *Repository) gitCommand(callerArgs ...string) *exec.Cmd {
152155

153156
args = append(args, callerArgs...)
154157

158+
//nolint:gosec // `gitBin` is chosen carefully, and the rest of
159+
// the args have been checked.
155160
cmd := exec.Command(repo.gitBin, args...)
156161

157162
cmd.Env = append(

internal/testutils/repoutils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ func (repo *TestRepo) Init(t *testing.T, bare bool) {
4949
// exist yet:
5050
var cmd *exec.Cmd
5151
if bare {
52+
//nolint:gosec // `repo.Path` is a path that we created.
5253
cmd = exec.Command("git", "init", "--bare", repo.Path)
5354
} else {
55+
//nolint:gosec // `repo.Path` is a path that we created.
5456
cmd = exec.Command("git", "init", repo.Path)
5557
}
5658
cmd.Env = CleanGitEnv()
@@ -143,6 +145,8 @@ func (repo *TestRepo) GitCommand(t *testing.T, args ...string) *exec.Cmd {
143145

144146
gitArgs := []string{"-C", repo.Path}
145147
gitArgs = append(gitArgs, args...)
148+
149+
//nolint:gosec // The args all come from the test code.
146150
cmd := exec.Command("git", gitArgs...)
147151
cmd.Env = CleanGitEnv()
148152
return cmd

0 commit comments

Comments
 (0)