跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
安全

dependency-audit

Dependency supply-chain audit: reading pnpm/npm audit output and exit codes, a license and poisoning risk checklist, and lockfile-drift detection commands. Use when the task requires auditing a project dependencies known vulnerabilities, license risks, suspicious packages, or lockfile consistency and writing a conclusion; installing/upgrading one dependency or plain feature work does not expand this flow.

PerryLink · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add PerryLink/dsh-skill-pack-security --skill dependency-audit

技能说明


name: dependency-audit description: 'Dependency supply-chain audit: reading pnpm/npm audit output and exit codes, a license and poisoning risk checklist, and lockfile-drift detection commands. Use when the task requires auditing a project dependencies known vulnerabilities, license risks, suspicious packages, or lockfile consistency and writing a conclusion; installing/upgrading one dependency or plain feature work does not expand this flow.' whenToUse: 'Use when the user asks to audit or inventory project dependency security (vulnerabilities, licenses, poisoning, lockfile drift), to interpret an audit report, to judge whether a dependency may be introduced, or to write a dependency-audit conclusion. Upgrading a single dependency and plain feature development do not trigger this skill.' metadata: pack: dsh-skill-pack-security version: '2.2.24'

Dependency audit (dependency-audit)

Goal: produce an audit of the repository's dependency surface in which every conclusion carries command evidence. The output has seven blocks: known vulnerabilities, licenses, poisoning risk, lockfile drift, multi-ecosystem vulnerabilities, the SBOM inventory, and provenance/signatures.

Automated pre-check: the plugin_vet tool

plugin_vet already runs the static parts of sections 3/4/7 (license verdicts, the poisoning checklist, the SBOM dependency tree), and its findings cite those section numbers. After an automated hit, verify the evidence and rule out false positives with each section's commands.

1. Locate the package manager and lockfile

git ls-files -- 'package.json' 'pnpm-lock.yaml' 'package-lock.json' 'yarn.lock' 'bun.lockb' 'npm-shrinkwrap.json'
node --version; pnpm --version
osv-scanner --version

Sample output (a pnpm repository): one line each for package.json and pnpm-lock.yaml. Criterion: the lockfile decides the command family (pnpm → Section 2; npm → the npm variant in the same section); multiple lockfiles side by side = repository anomaly, write it as a finding; version numbers go into the report (audit data varies with the registry and tool versions); a missing osv-scanner only affects Section 6 — note it.

2. Known vulnerabilities: pnpm audit

pnpm audit --prod --json > audit.json; echo $LASTEXITCODE

(bash uses $?; PowerShell uses $LASTEXITCODE.)

  • Exit code: 0 = no known vulnerabilities; non-zero = vulnerabilities or an unreachable registry (stderr containing fetch/ECONNREFUSED/ETIMEDOUT means a network failure, not findings — retry before concluding).
  • --prod audits production dependencies only; for a full view, also run pnpm audit --json and apply the devDependencies downgrade rule below to that part.
  • Sample output (advisories is an object keyed by advisory id; the example below is one of its values — fields per the actual output):
{ "id": "GHSA-xxxx-yyyy-zzzz", "severity": "high",
  "module_name": "example-lib", "vulnerable_versions": "<2.3.0",
  "patched_versions": ">=2.3.1", "recommendation": "Upgrade to 2.3.1",
  "found": { "paths": ["prod-dep@1.0.0 > example-lib@2.2.9"] } }
  • Reading rules:
    • severity: trust only the registry value (low/moderate/high/critical); never infer your own.
    • Check every advisory for patched_versions; when absent there is no fixed version — record "no fixed version", never claim "upgrade and it is fixed".
    • Impact paths only inside devDependencies → report one tier lower by default, unless that devDep enters the build output (proved with code evidence, never asserted verbally).
  • False-positive criteria (full table in references/pnpm-audit-reading.md): advisory status disputed/withdrawn, version range not covering the installed version, unreachable path (unreachable needs call-site evidence: pnpm why <package> plus source grep with no references).
  • npm project variant: npm audit --json (same 0/non-zero exit-code semantics; the structure is a vulnerabilities object instead of an advisories object — sample in the references).

3. License check

pnpm licenses list --json

Sample row: { "name": "example-lib", "license": "MIT" } (structure per the actual output). Hunt for three problem classes:

  1. Undeclared: license field empty/null → record "no license declaration" (usage itself is a compliance risk).
  2. Strong copyleft: GPL/AGPL/SSPL/CPAL etc. among direct dependencies (full list in references/license-and-lockfile.md) → locate the purpose: pnpm why <package> gives the dependency chain.
  3. Non-SPDX: value containing SEE LICENSE IN <file> → git ls-files -- '<package dir>/**/LICENSE*' or unpack and read that file before concluding.

Criterion: a license-risk conclusion = package name + dependency chain + license + purpose; a package whose purpose cannot be found (no import in source) is recorded separately as "unused dependency".

4. Poisoning-risk checklist (check each item for every "new/suspicious" dependency)

The complete commands and threshold table live in references/license-and-lockfile.md; the five items in shorthand:

  1. Name similarity: npm view <package> time.created (sample: 2026-08-10T02:00:00.000Z). Criterion: created < 30 days ago with extremely low downloads → high-risk flag; hand to supply-chain-review for the typosquat judgment.
  2. Install scripts: npm view <package> scripts --json (sample: { "postinstall": "node scripts/download.js" }). Non-empty → hand to supply-chain-review Section 1 to check the dangerous patterns one by one.
  3. Publisher and repository: npm view <package> repository.url maintainers --json. Criterion: missing repository / pointing at a suspicious fork + zero maintainer history → record.
  4. Network behavior: npm pack <package> --pack-destination .tmp then grep -rnE 'https?://' .tmp/<package>/ to inspect requested domains. Criterion: domains unrelated to the package's purpose → record and review manually.
  5. Provenance: `npm v
阅读完整来源 ↗