From ad048385b8b898e62abf361783d71f656850ea2d Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 16 May 2024 09:46:59 -0400 Subject: [PATCH] Only read the first line for shbang. 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) Signed-off-by: Scott Moser --- pkg/sca/sca.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/sca/sca.go b/pkg/sca/sca.go index 8c71a5b4c..204ac0051 100644 --- a/pkg/sca/sca.go +++ b/pkg/sca/sca.go @@ -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