Python detector + dependency-addition detector#4
Closed
Conalh wants to merge 1 commit into
Closed
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.
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.
Summary
Closes the audit's biggest coverage gap and addresses the missing manifest-layer capability signal. Stacked on top of #3 (Harden GitHub Action runtime) — merge #3 first, then this.
What changed
Python detector (
src/detectors/py-capability.ts)Why: agents that ship Python were previously invisible to CapabilityEcho even though Python is the dominant agent runtime.
requests/httpx/urllibcalls (requests.get,httpx.post,urllib.request.urlopen, bareurlopenafterfrom urllib.request import urlopen,aiohttp.ClientSession), gated on a literal URL on the same line — parallels the JS gate.subprocess.run/call/Popen/check_*,os.system/popen/execv*/spawn*,pty.spawn, legacycommands.getoutput— high severity.eval,exec,compile,__import__,importlib.import_module— critical (medium in test files).pickle.load/loads,marshal.load/loads,yaml.loadwithoutSafeLoader— critical.#) and test files (tests/,test_*.py,*_test.py) handled.Dependency-addition detector (
src/detectors/package-deps.ts)Why: a PR that adds
puppeteerto dependencies is materially more interesting than a PR that just imports something already declared.Diffs
package.jsonacrossdependencies/devDependencies/optionalDependencies/peerDependencieson both sides:high_capability_dep_added(high) — headless browsers (puppeteer,playwright,cypress,webdriverio,selenium-webdriver,nightwatch), subprocess/PTY wrappers (execa,cross-spawn,node-pty,shelljs,zx), arbitrary HTTP clients (node-fetch,undici,got,axios,request,superagent), VM/eval libs (vm2,isolated-vm), SSH/proxy primitives.telemetry_dep_added(medium) — Sentry/Segment/Mixpanel/Amplitude/PostHog SDKs (ship outbound network by default).Reuses
package-scripts.tsdiff infrastructure (PackageDiffMode,readPackageTextAt,listChangedPackageJsonFilesare now exported).Plumbing
paths.tsrecognizes.py/.pywinisScannable, addsisPyFile, treats#as a comment, extendsisTestFilefor Python conventions.diff.tswires both new detectors in.detectPackageScriptsanddetectPackageDepsrun in parallel viaPromise.all.Verification
Test plan