package-security-check
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePackage Security Check
包安全检查
Workflow
工作流程
- Treat this as a base JS supply-chain check first. Do not force the result around one CVE, vendor, package family, or incident.
- Before running installs, package-manager mutation commands, or file edits, perform only read-only inspection and present a traffic-light issue analysis:
- 🔴 Blocker: compromise signal, unsafe install path, secret exposure, or policy that allows unreviewed code execution.
- 🟡 Risk: hardening gap, stale package-manager major, broad spec, lifecycle script needing review, or CI weakness.
- 🟢 OK: verified control or no finding.
- After the traffic-light analysis, ask for approval before changing files or executing package-manager operations that can install, update, publish, or rewrite lockfiles.
- From this skill directory, run the baseline scanner against the repo or workspace root:
bash
python3 scripts/check_js_supply_chain.py --root <repo-or-workspace-root>Use when the check should fail on hardening gaps. Use when another tool needs machine-readable output. Use only when exists and installed package lifecycle metadata matters.
--strict--json--include-installednode_modules- For a specific active incident, add one or more IOC profiles:
bash
python3 scripts/check_js_supply_chain.py \
--root <repo-or-workspace-root> \
--ioc data/iocs/npm-supply-chain-2026-05.json \
--since 2026-05-11T19:20:00ZRefresh incident facts from current advisory sources before relying on a profile. IOC profiles are detection data, not the base policy.
- Inspect the report in this order:
package_manager_policy- and
repo_config_findingseffective_config_findings risky_direct_specs- , then
package_lifecycle_scriptswhen requestedinstalled_lifecycle_scripts - , including GitHub Actions privilege/cache warnings
ci_install_findings ioc_hitsrecent_package_manager_files
- If any IOC hits appear, stop normal package work. Do not run installs or lifecycle scripts. Report exact files/packages and recommend isolation, credential rotation, and reinstall from a known-good lockfile.
- If no compromise is visible but policy is weak and the user approves changes, patch toward the canonical pnpm 11 policy. Keep one package manager, one lockfile, and one repo-local policy source.
- 首先将其视为基础JS供应链检查,不要围绕单一CVE、供应商、包家族或事件强制判定结果。
- 在运行安装、包管理器变更命令或文件编辑前,仅执行只读检查并呈现红绿灯式问题分析:
- 🔴 阻塞项:存在入侵信号、不安全安装路径、密钥泄露或允许未审核代码执行的策略。
- 🟡 风险项:加固缺口、包管理器主版本过时、宽泛版本规范、需审核的生命周期脚本或CI薄弱点。
- 🟢 正常:已验证的控制措施或未发现问题。
- 完成红绿灯分析后,在执行可安装、更新、发布或重写锁文件的包管理器操作或修改文件前,需请求批准。
- 从该技能目录出发,针对仓库或工作区根目录运行基线扫描器:
bash
python3 scripts/check_js_supply_chain.py --root <repo-or-workspace-root>当检查需在加固缺口处失败时使用参数。当其他工具需要机器可读输出时使用参数。仅当存在且已安装包的生命周期元数据重要时,使用参数。
--strict--jsonnode_modules--include-installed- 针对特定活跃事件,添加一个或多个IOC配置文件:
bash
python3 scripts/check_js_supply_chain.py \
--root <repo-or-workspace-root> \
--ioc data/iocs/npm-supply-chain-2026-05.json \
--since 2026-05-11T19:20:00Z在依赖配置文件前,先从当前公告源刷新事件事实。IOC配置文件是检测数据,而非基础策略。
- 按以下顺序检查报告:
package_manager_policy- 和
repo_config_findingseffective_config_findings risky_direct_specs- ,当请求时再查看
package_lifecycle_scriptsinstalled_lifecycle_scripts - ,包括GitHub Actions权限/缓存警告
ci_install_findings ioc_hitsrecent_package_manager_files
- 若出现任何IOC命中,立即停止正常包操作。不要运行安装或生命周期脚本。上报具体文件/包,并建议隔离、凭证轮换以及从可信锁文件重新安装。
- 若未发现入侵迹象但策略薄弱且用户批准修改,则向标准pnpm 11策略修补。保持单一包管理器、单一锁文件和单一仓库本地策略源。
Canonical Policy
标准策略
Use pnpm 11 or newer as the single package manager because it has the best current pnpm security model: release-age gating, lifecycle-script approval, exotic-subdependency blocking, and trust policy controls.
Verify the current pnpm release before writing :
packageManagerbash
npm view pnpm dist-tags --jsonRequire pnpm 11 or newer. As of 2026-05-12, npm reports as pnpm . Do not hardcode that value without rechecking. If the repo's Node runtime cannot run pnpm 11, report it as a compatibility blocker instead of silently falling back to pnpm 10.
latest11.1.1Use to declare the required major:
devEngines.packageManagerjson
{
"devEngines": {
"packageManager": {
"name": "pnpm",
"version": ">=11.0.0",
"onFail": "download"
}
}
}Also pin the verified current stable version in for reproducibility:
packageManagerjson
{
"packageManager": "pnpm@11.1.1"
}Treat pnpm 10 or older as unless the user explicitly approves a temporary exception.
legacy-pnpm-major使用pnpm 11或更新版本作为单一包管理器,因为它具备当前最佳的pnpm安全模型:发布时长准入、生命周期脚本批准、阻止非常规子依赖以及信任策略控制。
在写入前,验证当前pnpm版本:
packageManagerbash
npm view pnpm dist-tags --json要求使用pnpm 11或更新版本。截至2026-05-12,npm显示版本为pnpm 。未经重新检查不要硬编码该值。若仓库的Node运行时无法运行pnpm 11,需将其报告为兼容性阻塞项,而非静默回退到pnpm 10。
latest11.1.1使用声明所需主版本:
devEngines.packageManagerjson
{
"devEngines": {
"packageManager": {
"name": "pnpm",
"version": ">=11.0.0",
"onFail": "download"
}
}
}同时在中固定已验证的当前稳定版本以保证可复现性:
packageManagerjson
{
"packageManager": "pnpm@11.1.1"
}除非用户明确批准临时例外,否则将pnpm 10或更旧版本视为。
legacy-pnpm-majorPackage Manager Posture
包管理器配置状态
- : canonical baseline. Prefer this for new hardening work.
pnpm >=11 - : accepted only when the repo intentionally uses Bun and has equivalent local hardening.
bun - : fallback only. Recommend migration to pnpm 11 unless the repo has a clear documented reason to stay npm.
npm - : not accepted baseline for this skill. Recommend pnpm 11 or hardened Bun.
yarn
Do not present npm as equivalent to pnpm 11. Bun can be accepted as a project-level choice, but still gets checked against Bun-specific hardening.
For npm fallback repos, require exact saves and reproducible CI while recommending pnpm migration:
ini
save-exact=trueDo not claim npm has a supported release-age gate unless verified in current npm docs and local .
npm config ls -lFor Bun fallback repos, require repo-local :
bunfig.tomltoml
[install]
minimumReleaseAge = 604800
exact = true
frozenLockfile = true
saveTextLockfile = trueDo not set without a reviewed, package-specific reason.
minimumReleaseAgeExcludesAdd or update root :
pnpm-workspace.yamlyaml
minimumReleaseAge: 10080
minimumReleaseAgeStrict: true
minimumReleaseAgeIgnoreMissingTime: false
blockExoticSubdeps: true
trustPolicy: no-downgrade
trustPolicyIgnoreAfter: 43200
dangerouslyAllowAllBuilds: false
savePrefix: ""
allowBuilds: {}Use 7 days () for normal repos. Use 3 days only when the repo has a real dependency freshness requirement. Do not set or without a reviewed, package-specific reason.
10080minimumReleaseAgeExcludetrustPolicyExcludeAllow dependency build scripts only after review:
yaml
allowBuilds:
esbuild: true
core-js: false- :标准基线。新加固工作优先选用。
pnpm >=11 - :仅当仓库有意使用Bun且具备等效本地加固措施时才接受。
bun - :仅作为备选方案。建议迁移到pnpm 11,除非仓库有明确记录的理由继续使用npm。
npm - :本技能不接受作为基线。建议使用pnpm 11或加固后的Bun。
yarn
不要将npm等同于pnpm 11。Bun可作为项目级选择被接受,但仍需针对Bun特定的加固措施进行检查。
对于使用npm备选方案的仓库,要求精确保存和可复现CI,同时建议迁移到pnpm:
ini
save-exact=true除非在当前npm文档和本地中验证过,否则不要声称npm支持发布时长准入。
npm config ls -l对于使用Bun备选方案的仓库,要求仓库本地存在:
bunfig.tomltoml
[install]
minimumReleaseAge = 604800
exact = true
frozenLockfile = true
saveTextLockfile = true未经针对特定包的审核理由,不要设置。
minimumReleaseAgeExcludes添加或更新根目录下的:
pnpm-workspace.yamlyaml
minimumReleaseAge: 10080
minimumReleaseAgeStrict: true
minimumReleaseAgeIgnoreMissingTime: false
blockExoticSubdeps: true
trustPolicy: no-downgrade
trustPolicyIgnoreAfter: 43200
dangerouslyAllowAllBuilds: false
savePrefix: ""
allowBuilds: {}普通仓库使用7天()。仅当仓库有真实的依赖新鲜度需求时才使用3天。未经针对特定包的审核理由,不要设置或。
10080minimumReleaseAgeExcludetrustPolicyExclude仅在审核后允许依赖构建脚本:
yaml
allowBuilds:
esbuild: true
core-js: falseCI Rules
CI规则
Require frozen pnpm installs:
bash
pnpm install --frozen-lockfileTreat these as findings unless the repo has a written reason:
- non-pnpm lockfiles in a pnpm repo
- CI using ,
npm install, unfrozenyarn install, or unfrozenbun installpnpm install - npm repos that do not use with a committed lockfile while migration is pending
npm ci - Bun repos missing release-age, exact, frozen-lockfile, or text-lockfile policy
bunfig.toml - workflows; these are allowed only with a reviewed reason and must not checkout or run untrusted PR code
pull_request_target - shared caches in publish/release pipelines, including GitHub Actions cache, Turborepo, and Nx cache
- any path where PR-controlled cache content can feed a privileged publish/release workflow
- lockfile rewrite during CI/deploy
- ,
latest, broad ranges, Git/GitHub shorthands, HTTP tarballs, or external*specsfile: - dependency lifecycle scripts that are not explicitly approved
dangerouslyAllowAllBuilds: true- workflow use of or publish credentials in broad build jobs
toJSON(secrets)
要求使用冻结的pnpm安装:
bash
pnpm install --frozen-lockfile除非仓库有书面理由,否则以下情况视为问题:
- pnpm仓库中存在非pnpm锁文件
- CI使用、
npm install、未冻结的yarn install或未冻结的bun installpnpm install - 迁移期间,npm仓库未配合提交的锁文件使用
npm ci - Bun仓库缺少中的发布时长、精确版本、冻结锁文件或文本锁文件策略
bunfig.toml - 工作流;仅当有审核通过的理由时才允许,且不得检出或运行不可信PR代码
pull_request_target - 发布/发布流水线中的共享缓存,包括GitHub Actions缓存、Turborepo和Nx缓存
- PR控制的缓存内容可进入特权发布/发布工作流的任何路径
- CI/部署期间重写锁文件
- 使用、
latest、宽泛版本范围、Git/GitHub简写、HTTP tar包或外部*规范file: - 未明确批准的依赖生命周期脚本
dangerouslyAllowAllBuilds: true- 工作流使用或在宽泛构建任务中使用发布凭证
toJSON(secrets)
Script
脚本
scripts/check_js_supply_chain.py- detects package-manager and lockfile policy
- checks repo-local and effective pnpm hardening settings
- reports npm fallback and Bun fallback hardening gaps
- reports risky direct dependency specs
- reports lifecycle scripts in workspace manifests and optionally installed packages
- reports risky GitHub Actions install/publish/secret patterns
- warns on and shared cache patterns that can become supply-chain escalation paths
pull_request_target - reports package-manager file mtimes after
--since - applies optional IOC JSON profiles for incident-specific fingerprints, payload files, persistence paths, workflow markers, and known bad package versions
Keep incident profiles under . Do not add incident-specific constants to the scanner unless they are generic across npm supply-chain attacks.
data/iocs/scripts/check_js_supply_chain.py- 检测包管理器和锁文件策略
- 检查仓库本地和生效的pnpm加固设置
- 上报npm备选方案和Bun备选方案的加固缺口
- 上报高风险直接依赖规范
- 上报工作区清单中的生命周期脚本,以及可选的已安装包中的生命周期脚本
- 上报高风险GitHub Actions安装/发布/密钥模式
- 对可成为供应链升级路径的和共享缓存模式发出警告
pull_request_target - 上报参数指定时间后的包管理器文件修改时间
--since - 应用可选的IOC JSON配置文件,针对特定事件的指纹、 payload文件、持久化路径、工作流标记以及已知恶意包版本
将事件配置文件保存在下。除非是npm供应链攻击通用的内容,否则不要将事件特定常量添加到扫描器中。
data/iocs/