Skip to content

Commit

Permalink
Only read the first line for shbang.
Browse files Browse the repository at this point in the history
I noticed this when I was playing with a shbang program like:

   #!/usr/bin/env busybox sh
   echo hello world

Melange would give a warning like this:

   Error reading shbang from usr/bin/hello-busybox:
      a shbang of only '/usr/bin/env' with multiple arguments
         (6 /usr/bin/env busybox sh echo "hello world")

The new message would be:

   Error reading shbang from usr/bin/hello-busybox:
      a shbang of only '/usr/bin/env' with multiple arguments
         (3 /usr/bin/env busybox sh)
  • Loading branch information
smoser committed May 16, 2024
1 parent 5cbb58a commit eed1e30
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/sca/sca.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ func getShbang(fp fs.File) (string, error) {
return "", nil
}

toks := strings.Fields(string(buf[2 : blen-2]))
line1 := strings.Split(string(buf[2:blen-2]), "\n")[0]
toks := strings.Fields(line1)
bin := toks[0]

// if #! is '/usr/bin/env foo', then use next arg as the dep
Expand Down

0 comments on commit eed1e30

Please sign in to comment.