patch-diff
Diff two npm-package versions for added/removed security-control invocations (T3.1). Per-target wrapper around bin/npm_version_diff.py. Use when a target ships a vulnerable library version and a fix e
SKILL.md.claude/skills/patch-diff/SKILL.md
GitHubpatch-diff
Purpose
Bug bounty value: when a CVE points at a library, the fix commit usually adds a sanitizer / role check / encoding step. Diff the two versions to extract the exact control delta — then search the target for callsites of the OLD api that are still missing the NEW control.
Inputs
targets/<name>/status.json<package>from npm<old_version>(vulnerable) and<new_version>(fixed)npmin PATH
Steps
- Identify the package + versions to compare. Pull from one of:
package.jsonof the target- the CVE description on npm advisories
- GHSA database (
gh-advisory-database)
- Run:
python3 bin/npm_version_diff.py targets/<name> <package> <old> <new> - Review
targets/<name>/diffs/<package>_<old>_<new>.md. Each row:<file> | <control_pattern> | <delta>. Positive delta = control was ADDED in the fix. Negative = removed. - For each ADDED control, grep
targets/<name>/sources/for callers of the same APIs that DON'T invoke the control. Cross-reference withopus-gap-auditusing the new control as the qname.
Outputs
targets/<name>/diffs/<package>_<old>_<new>.mdstatus.json.phases.patch_diff_<package>
Failure modes
npmmissing → script writesstatus: skipped. Installnode+npm.- Package version unpublished / yanked →
npm packfails; checknpmjs.com/package/<package>for the version list. - Control delta = 0 across all files → either the fix is non-source
(e.g. dependency bump) or the patterns in
CONTROL_PATTERNSdon't cover this library's idiom. Add new patterns tobin/npm_version_diff.py:CONTROL_PATTERNS.
Result block
"phases": { "patch_diff_<package>": {
"status": "done", "ts": "<iso>",
"package": "...", "old": "...", "new": "...",
"files_added": N, "files_removed": N, "files_common": N,
"control_changes": N,
"output": "diffs/<package>_<old>_<new>.md" } }