Python detector + dependency-addition detector#5
Merged
Conversation
Closes the audit's biggest coverage gap and addresses the missing manifest-layer capability signal. Python detector (src/detectors/py-capability.ts): - requests / httpx / urllib network calls, gated on a literal URL on the same line (parallel to the JS gate, same false-positive posture). - subprocess, os.system, os.popen, pty.spawn — high severity. - eval, exec, compile, __import__, importlib.import_module — critical when not in test files. - pickle.load/loads, marshal.load/loads, yaml.load without SafeLoader — separate 'unsafe_deserialize_added' finding kind. - Test-file downgrade applies to .py via the existing isTestFile, extended to recognize 'tests/', 'test_*.py', and '*_test.py'. - isScannable and the comment-line check were extended to include .py/.pyw and '#' comments respectively. Dependency-addition detector (src/detectors/package-deps.ts): - Diffs package.json across dependencies / devDependencies / optionalDependencies / peerDependencies on both sides of the change. - Emits 'high_capability_dep_added' (high) for headless browsers (puppeteer, playwright, cypress, etc.), subprocess/PTY wrappers (execa, cross-spawn, node-pty, shelljs, zx), arbitrary HTTP clients (node-fetch, undici, got, axios), VM/eval libs (vm2, isolated-vm), and SSH/proxy primitives. - Emits 'telemetry_dep_added' (medium) for Sentry/Segment/Mixpanel/ Amplitude/PostHog SDKs. - Reuses the diff infrastructure from package-scripts.ts (PackageDiffMode, readPackageTextAt, listChangedPackageJsonFiles are now exported). Diff pipeline wires both detectors in. Python adds 11 unit tests and the dependency detector adds 5 fixture-based tests; total suite is 30/30 green. Why this matters: agents that ship Python were previously invisible to CapabilityEcho even though Python is the dominant agent runtime. And a PR that adds 'puppeteer' to dependencies is materially more interesting than a PR that just imports something already declared.
dfe9a70 to
57f7026
Compare
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.
Reopened against
mainafter PR #3 merged (the original PR was auto-closed when its base branchcodey/harden-action-runtimewas deleted on merge).Adds:
src/detectors/py-capability.ts) —requests/httpx/urllibnetwork calls, subprocess/os.system/pty.spawn, eval/exec/compile/__import__/importlib.import_module, and unsafe deserialization (pickle.load,marshal.load,yaml.loadwithout SafeLoader).src/detectors/package-deps.ts) —high_capability_dep_addedfor puppeteer/playwright/execa/node-fetch/etc.;telemetry_dep_addedfor Sentry/Segment/Mixpanel/Amplitude/PostHog.Total: 30/30 tests passing (14 prior + 11 Python + 5 dependency). See closed #4 for full discussion.