diff --git a/pkg/sca/sca.go b/pkg/sca/sca.go index 959fae76d..19e72b1e5 100644 --- a/pkg/sca/sca.go +++ b/pkg/sca/sca.go @@ -594,8 +594,11 @@ func getShbang(fp fs.File) (string, error) { if bin == "/usr/bin/env" { if len(toks) == 1 { return "", fmt.Errorf("a shbang of only '/usr/bin/env'") + } else if len(toks) == 2 { + bin = toks[1] + } else { + return "", fmt.Errorf("a shbang of only '/usr/bin/env' with multiple arguments") } - bin = toks[1] } if isIgnored := ignores[filepath.Base(bin)]; isIgnored { diff --git a/pkg/sca/testdata/shbang-test.yaml b/pkg/sca/testdata/shbang-test.yaml index 28a8ebd71..61cba6bb9 100644 --- a/pkg/sca/testdata/shbang-test.yaml +++ b/pkg/sca/testdata/shbang-test.yaml @@ -57,6 +57,11 @@ pipeline: print("hello world") EOF + wbin "python-via-env" <<"EOF" + #!/usr/bin/env -S python3 foo + print("hello world") + EOF + wbin "python-straight" <<"EOF" #!/usr/bin/python3.12 print("hello world")