You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The linter reports a variable executing a shell command when the variable is hard-coded and not changed.
Steps to reproduce the behavior
// first element of each slice is the hard-coded commandosCommand:=map[string][]string{
"darwin": {"open"},
"freebsd": {"xdg-open"},
"linux": {"xdg-open"},
"netbsd": {"xdg-open"},
"openbsd": {"xdg-open"},
"windows": {"cmd", "/c", "start"},
}
// (probably irrelevant detail, but keeping it here just in case)ifruntime.GOOS=="windows" {
// escape characters not allowed by cmdurl=strings.ReplaceAll(url, "&", `^&`)
}
// read from the map -- no mutationsall:=osCommand[runtime.GOOS]
// extract the command from the args -- again, no mutationsexe:=all[0]
args:=all[1:]
// false positive herecmd:=exec.Command(exe, append(args, url)...)
// it also fires if it's just exec.Command(exe)
gosec version
v2.20
Go version (output of 'go version')
go version go1.22.6 linux/amd64
Operating system / Environment
See above
Expected behavior
The command does not rely on external input in any way, so there should be no lint warning.
Actual behavior
G204 fires.
The text was updated successfully, but these errors were encountered:
Summary
The linter reports a variable executing a shell command when the variable is hard-coded and not changed.
Steps to reproduce the behavior
gosec version
v2.20
Go version (output of 'go version')
go version go1.22.6 linux/amd64
Operating system / Environment
See above
Expected behavior
The command does not rely on external input in any way, so there should be no lint warning.
Actual behavior
G204 fires.
The text was updated successfully, but these errors were encountered: