fix(security): scan .sh files for dependency confusion in pre-commit …#2241
Merged
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
🤖 AI Agent: test-generator — `scripts/check_dependency_confusion.py`
|
🤖 AI Agent: security-scanner — View detailsNo security issues found. |
🤖 AI Agent: docs-sync-checker — Docs SyncDocs Sync
|
🤖 AI Agent: breaking-change-detector — API CompatibilityAPI CompatibilityNo breaking changes detected. |
🤖 AI Agent: code-reviewer — View detailsTL;DR: 0 blockers, 0 warnings. Clean and robust security fix.
No action items. |
|
🟡 Contributor Check: MEDIUM
Automated check by AGT Contributor Check. |
PR Review Summary
Verdict: ✅ Ready for human review |
2450e31 to
edfa460
Compare
…2207) Pre-commit mode now includes .sh and .bash files when filtering staged files for dependency-confusion scanning. To avoid false positives in shell scripts, check_file() skips pip install matches that fall inside a comment (#) or an echo/printf invocation, scoped to the current shell command segment (split on ;, &&, ||, |) so real installs after a separator (e.g. 'echo done; pip install foo') are still flagged. Suppression is gated to .sh/.bash so behavior for .md/.py/.txt/.ipynb is unchanged. Adds twine to REGISTERED_PACKAGES (used by existing build_and_publish.sh scripts). Regression tests cover shell-script scanning behavior. Closes #2207. Signed-off-by: Ricky Gummadi <[email protected]>
153463e to
39bfd41
Compare
imran-siddique
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Closes #2207
Description
Pre-commit mode of
scripts/check_dependency_confusion.pypreviously filtered staged files by extension and excluded.sh/.bash, so realpip installcommands inside shell scripts (e.g.agent-governance-python/agent-os/modules/control-plane/build_and_publish.sh,.../scak/build_and_publish.sh) were never scanned for dependency-confusion risks.This PR closes that gap:
.shand.bashto the staged-file extension filter inmain().check_file(),pip installmatches that fall inside a shell comment (#) or anecho/printfinvocation are skipped. The check is scoped to the current shell command segment (split on;,&&,||,|), so a real install after a separator (e.g.echo done; pip install foo) is still flagged..sh/.bash, so.md,.py,.txt,.ipynbscanning is unchanged (e.g.# Install: pip install <unregistered>in markdown is still flagged).twinetoREGISTERED_PACKAGESsince the now-scanned existingbuild_and_publish.shscripts use it and it is a legitimate PyPI package.tests/ci/test_check_dependency_confusion.pycover: realpip install <unregistered>in.shis flagged;echo "pip install <unregistered>"is not;printf "... pip install <unregistered>"is not; full-line and inline#comments are not; known package (pydantic) in.shis not;echo done; pip install <unregistered>(segment edge case) is flagged; markdown#lines still flagged;.txtbehavior unchanged; pre-commit extension filter sanity checks for.sh/.bashand existing.py/.md/.txt/.ipynb.Out of scope (intentional, per issue): Dockerfile support, heredoc bodies, and multi-line
pip install \continuations. These are tracked as follow-ups.Type of Change
Package(s) Affected
Checklist
ruff checkpasses)pytest tests/ci/test_check_dependency_confusion.py— 15/15)Attribution & Prior Art
Prior art / related projects: None.
AI Assistance
GitHub Copilot was used to scaffold the regression tests and the segment-based suppression logic; all output was reviewed, tested, and validated against the issue requirements.
IP, Patents, and Licensing
Related Issues
Closes #2207
Follow-ups
FROM/RUN pip install) scanning in pre-commit mode<<EOF ... EOF)pip install \continuation parsing