Validate uv package names against PEP 508 before uv pip show - #51016
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sighthound flagged five Critical command-injection findings around
exec.Commandcalls built from dynamic data. Four of the five are already mitigated in the current code; the exception is theuvvalidation path, which only rejected--prefixed names.Audit of reported findings
pip_validation.go—pip index versions <pkg> --prevalidatePipPackageName(PEP 508 allowlist)dependabot.go—npm install --package-lock-onlynpmPathresolved viafileutil.ResolveExecutablePathpoutine.go—docker run -v <volumeMount>buildDockerVolumeMountcanonicalizes and validates host path (absolute, no:) and container pathpip_validation.go—uv pip show <pkg> --no-cacheChanges
pkg/workflow/pip_validation.go:validateUvPackagesnow appliesvalidatePipPackageNameto each extracted package name before theexec.Commandcall, matching the pip path. Invalid names are collected into the existingerrorsslice and surfaced as a validation error rather than reachinguv. Added a#nosec G204justification consistent with the pip call site.pkg/workflow/argument_injection_test.go: regression test asserting a malformed name is rejected.Package extraction is permissive enough to yield names like
pkg;whoamifromuvx pkg;whoamiin workflow custom steps, which previously flowed straight into the argv:Note on the test guard: it skips when
uvis absent, becausevalidateUvPackagesthen falls back to the pip path where invalid names are warnings rather than errors. Worth a second opinion on whether that fallback should also hard-fail.Run context: https://github.com/github/gh-aw/actions/runs/31185909757> Generated by 👨🍳 PR Sous Chef · gpt54 · 9.44 AIC · ⊞ 8.3K · ◷