Repository navigation
Use compatible local zizmor and poutine scanners when available #66918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
69668d8
022f812
ecf98bf
6270c64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "context" | ||
| "os/exec" | ||
| "regexp" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/github/gh-aw/pkg/fileutil" | ||
| "github.com/github/gh-aw/pkg/semverutil" | ||
| ) | ||
|
|
||
| const ( | ||
| minZizmorVersion = "1.30.1" | ||
| minPoutineVersion = "1.1.6" | ||
| ) | ||
|
|
||
| var scannerVersionPattern = regexp.MustCompile(`(?i)\bv?[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9a-z.-]+)?\b`) | ||
|
|
||
| // localScannerPath returns a compatible local scanner, or empty when Docker | ||
| // should be used instead. An unrecognized version is not assumed compatible. | ||
| func localScannerPath(ctx context.Context, name string) string { | ||
| var minimum string | ||
| switch name { | ||
| case "zizmor": | ||
| minimum = minZizmorVersion | ||
| case "poutine": | ||
| minimum = minPoutineVersion | ||
| default: | ||
| return "" | ||
| } | ||
|
|
||
| path, err := fileutil.ResolveExecutablePath(name) | ||
| if err != nil { | ||
| return "" | ||
| } | ||
| versionCtx, cancel := context.WithTimeout(ctx, 5*time.Second) | ||
| defer cancel() | ||
| output, err := exec.CommandContext(versionCtx, path, "--version").CombinedOutput() | ||
|
Copilot marked this conversation as resolved.
Resolved
|
||
| if err != nil { | ||
| return "" | ||
| } | ||
| version := scannerVersionPattern.FindString(strings.TrimSpace(string(output))) | ||
| if !semverutil.IsValid(version) || semverutil.Compare(version, minimum) < 0 { | ||
| return "" | ||
| } | ||
| return path | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an isolated PATH to Docker-fallback tests that request zizmor or poutine, preventing host-installed scanners from bypassing the Docker mocks. Commit:
6270c641.