fix(cli): panic: attempt to get os.Args[1] when len(os.Args) < 2 (#9206)

Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
This commit is contained in:
AndreyChupin
2025-07-16 10:32:14 +03:00
committed by GitHub
parent 51aa022260
commit adfa879e4e

View File

@@ -126,7 +126,7 @@ func NewRunner(ctx context.Context, cliOptions flag.Options, opts ...RunnerOptio
TraceHTTP: cliOptions.TraceHTTP,
}))
// get the sub command that is being used or fallback to "trivy"
commandName := lo.Ternary(len(os.Args) > 1, os.Args[1], "trivy")
commandName := lo.NthOr(os.Args, 1, "trivy")
r.versionChecker = notification.NewVersionChecker(commandName, &cliOptions)
// Update the vulnerability database if needed.