Skip to content

Commit

Permalink
ensure shbang check only checks valid shbangs
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Wolf <josh@wolfs.io>
  • Loading branch information
joshrwolf committed Apr 23, 2024
1 parent 03bc0ff commit 6fd96bb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/sca/sca.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func getShbang(fp fs.File) (string, error) {
return "", err
}

if buf[0] != '#' && buf[1] != '!' {
if buf[0] != '#' || buf[1] != '!' {
return "", nil
}

Expand Down
Binary file modified pkg/sca/testdata/shbang-test-1-r1.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions pkg/sca/testdata/shbang-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ pipeline:
}
EOF
wbin "ignore1" <<"EOF"
## Ingore1
EOF
wbin "ignore5" <<"EOF"
!! Ignore5
EOF
wbin "ignore2" <<"EOF"
!# Ignore2
EOF
wbin "ignore3" <<"EOF"
! Ignore3
EOF
wbin "ignore4" <<"EOF"
# Ignore4
EOF
gcc -o hello hello.c && strip hello && cp hello "$BD/usr/bin/hello"
update:
Expand Down

0 comments on commit 6fd96bb

Please sign in to comment.