Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix sca detection case for env with multiple arguments.
Signed-off-by: Dan Lorenc <dlorenc@chainguard.dev>
  • Loading branch information
dlorenc committed Apr 20, 2024
commit 5718844d890f0e708422454be8b39e85b06a938a
5 changes: 4 additions & 1 deletion pkg/sca/sca.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions pkg/sca/testdata/shbang-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down