Skip to content

Python detector + dependency-addition detector#5

Merged
Conalh merged 1 commit into
mainfrom
feat/python-and-dep-detectors
May 21, 2026
Merged

Python detector + dependency-addition detector#5
Conalh merged 1 commit into
mainfrom
feat/python-and-dep-detectors

Conversation

@Conalh
Copy link
Copy Markdown
Owner

@Conalh Conalh commented May 21, 2026

Reopened against main after PR #3 merged (the original PR was auto-closed when its base branch codey/harden-action-runtime was deleted on merge).

Adds:

  • Python detector (src/detectors/py-capability.ts) — requests/httpx/urllib network calls, subprocess/os.system/pty.spawn, eval/exec/compile/__import__/importlib.import_module, and unsafe deserialization (pickle.load, marshal.load, yaml.load without SafeLoader).
  • Dependency-addition detector (src/detectors/package-deps.ts) — high_capability_dep_added for puppeteer/playwright/execa/node-fetch/etc.; telemetry_dep_added for Sentry/Segment/Mixpanel/Amplitude/PostHog.

Total: 30/30 tests passing (14 prior + 11 Python + 5 dependency). See closed #4 for full discussion.

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.
@Conalh Conalh force-pushed the feat/python-and-dep-detectors branch from dfe9a70 to 57f7026 Compare May 21, 2026 20:30
@Conalh Conalh merged commit 0bcd959 into main May 21, 2026
2 checks passed
@Conalh Conalh deleted the feat/python-and-dep-detectors branch May 21, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant