@@ -53,6 +53,7 @@ the environment: https://go.dev/ref/mod#module-cache`,
5353 go func () { <- signals ; cancel () }()
5454
5555 // Create the target directory.
56+ //nolint:gosec // G703: Path is provided by trusted command-line argument.
5657 if err := os .MkdirAll (flags .Arg (0 ), 0o755 ); err != nil {
5758 fmt .Fprintln (os .Stderr , err )
5859 os .Exit (1 )
@@ -90,6 +91,7 @@ the environment: https://go.dev/ref/mod#module-cache`,
9091 err := ctx .Err ()
9192
9293 if err == nil {
94+ //nolint:gosec // G703: Path is derived from module cache directory.
9395 err = os .MkdirAll (filepath .Dir (destination ), 0o755 )
9496 }
9597 if err == nil {
@@ -98,9 +100,11 @@ the environment: https://go.dev/ref/mod#module-cache`,
98100 if err == nil {
99101 // When we copy the licenses in the Dockerfiles, make sure
100102 // to `--chmod` them to an appropriate permissions, e.g., 0o444
103+ //nolint:gosec // G703: Path is derived from module cache directory.
101104 err = os .WriteFile (destination , data , 0o600 )
102105 }
103106 if err == nil {
107+ //nolint:gosec // G705: Output is file paths, not user input rendered in HTML.
104108 fmt .Fprintln (os .Stdout , license , "=>" , destination )
105109 }
106110 if err != nil {
@@ -116,7 +120,7 @@ func downloadModules(ctx context.Context, modules ...string) map[string]string {
116120
117121 // Download modules and read their details into a series of JSON objects.
118122 // - https://go.dev/ref/mod#go-mod-download
119- //gosec:disable G204 -- Use this environment variable to switch Go versions without touching PATH
123+ //nolint:gosec // G702: GO env var allows switching Go versions without touching PATH.
120124 cmd := exec .CommandContext (ctx , os .Getenv ("GO" ), append ([]string {"mod" , "download" , "-json" }, modules ... )... )
121125 if cmd .Path == "" {
122126 cmd .Path , cmd .Err = exec .LookPath ("go" )
@@ -196,7 +200,7 @@ func identifyModules(ctx context.Context, executables ...string) []string {
196200
197201 // Use `go version -m` to read the embedded module information as a text table.
198202 // - https://go.dev/ref/mod#go-version-m
199- //gosec:disable G204 -- Use this environment variable to switch Go versions without touching PATH
203+ //nolint:gosec // G702: GO env var allows switching Go versions without touching PATH.
200204 cmd := exec .CommandContext (ctx , os .Getenv ("GO" ), append ([]string {"version" , "-m" }, executables ... )... )
201205 if cmd .Path == "" {
202206 cmd .Path , cmd .Err = exec .LookPath ("go" )
@@ -230,6 +234,7 @@ func identifyModules(ctx context.Context, executables ...string) []string {
230234 // The `go version -m` command returns no information for empty files, and it
231235 // is possible for a Go executable to have no main module and no dependencies.
232236 if len (result ) == 0 {
237+ //nolint:gosec // G705: Output is file paths, not user input rendered in HTML.
233238 fmt .Fprintf (os .Stderr , "no Go modules in %v\n " , executables )
234239 os .Exit (0 )
235240 }
0 commit comments