sap-dependency-security
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSAP Dependency Security
SAP依赖项安全
Related Skills
相关技能
- sap-hana-cli: For dependency-aware database tooling workflows and upgrade guidance
- sap-cap-capire: For CAP dependency-safe runtime and service configuration guidance
- sap-fiori-tools: For secure UI5/Fiori dependency strategy when tooling touches frontend packages
- sapui5: For SAPUI5/OpenUI5 frontend dependency and MCP tooling review
- sap-datasphere: For tenant-connected Datasphere MCP and CLI dependency review
- sap-sac-scripting: For source-pinned SAC MCP setup and local install records
Manage SAP dependency security and upgrades with supply chain protection, compatibility analysis, staged rollout, and comprehensive testing across all major package managers.
- sap-hana-cli: 用于依赖感知型数据库工具工作流和升级指导
- sap-cap-capire: 用于CAP依赖项安全的运行时和服务配置指导
- sap-fiori-tools: 当工具涉及前端包时,提供安全的UI5/Fiori依赖项策略
- sapui5: 用于SAPUI5/OpenUI5前端依赖项和MCP工具审核
- sap-datasphere: 用于租户关联的Datasphere MCP和CLI依赖项审核
- sap-sac-scripting: 用于源固定的SAC MCP设置和本地安装记录
借助供应链防护、兼容性分析、分阶段发布以及针对所有主流包管理器的全面测试,管理SAP依赖项安全与升级。
When to Use This Skill
适用场景
- Upgrading major framework or library versions
- Configuring supply chain attack prevention (cooldown, script blocking, lockfile hardening)
- Setting up secure package manager configuration
- Resolving dependency conflicts or peer dependency issues
- Planning incremental upgrade paths with testing
- Automating dependency updates with Renovate, Dependabot, or Snyk
- Auditing dependencies for vulnerabilities
- Setting up CI/CD dependency security workflows
- Pinning or reviewing SAP MCP servers in
.mcp.json - Reviewing SAP CAP, UI5/Fiori, HANA, Datasphere, SAC, SAP Cloud SDK, BTP/CF/mbt, or ABAP/gCTS dependency workflows
- 升级主要框架或库版本
- 配置供应链攻击防范措施(冷却期、脚本拦截、锁文件加固)
- 设置安全的包管理器配置
- 解决依赖项冲突或对等依赖项问题
- 规划带测试的增量升级路径
- 使用Renovate、Dependabot或Snyk自动化依赖项更新
- 审核依赖项的漏洞
- 设置CI/CD依赖项安全工作流
- 在中固定或审核SAP MCP服务器
.mcp.json - 审核SAP CAP、UI5/Fiori、HANA、Datasphere、SAC、SAP Cloud SDK、BTP/CF/mbt或ABAP/gCTS依赖项工作流
Common Issues
常见问题
| Issue | Recommended response |
|---|---|
Floating MCP package or | Replace with an exact version or approved source commit and run |
| Lockfile changed unexpectedly | Review package manager config, block lifecycle scripts, and regenerate only after dependency intent is clear. |
| Dependency is too new for cooldown policy | Hold the upgrade unless a documented security exception justifies immediate adoption. |
| Tenant-connected tool changed source | Verify the source URL, commit, and build steps before using credentials. |
| 问题 | 推荐解决方案 |
|---|---|
| 替换为精确版本或已批准的源提交,并运行 |
| 锁文件意外变更 | 审核包管理器配置,拦截生命周期脚本,仅在明确依赖项意图后重新生成锁文件。 |
| 依赖项版本过新,不符合冷却期策略 | 暂缓升级,除非有文档记录的安全例外情况证明需立即采用。 |
| 租户关联工具的源已变更 | 在使用凭据前,验证源URL、提交记录和构建步骤。 |
Two Modes of Operation
两种操作模式
Interactive — Walk through setup questions to generate tailored config. Use for fresh setup.
Default — Apply recommended defaults immediately: 7-day cooldown, block all scripts, frozen-lockfile, lockfile-lint, Dependabot with cooldown. Customization optional.
SAP Development Mode — Use a stricter SAP posture: 14-day cooldown, exact pins for MCP servers and executable tooling, no floating , source commit pins for local MCP servers, and manual review for tenant-connected tools.
@latest交互式 — 通过设置问题引导生成定制化配置。适用于全新设置场景。
默认模式 — 立即应用推荐的默认配置:7天冷却期、拦截所有脚本、冻结锁文件、锁文件校验、带冷却期的Dependabot。可按需自定义。
SAP开发模式 — 采用更严格的SAP安全策略:14天冷却期、MCP服务器和可执行工具使用精确版本固定、禁止使用浮动、本地MCP服务器使用源提交固定、租户关联工具需人工审核。
@latestSAP Development Mode
SAP开发模式
Use SAP Development Mode when dependency work touches SAP projects, SAP BTP deployment tooling, SAP SDKs, or any MCP server shipped by this repository.
Core rules:
- Default to 14-day cooldown for SAP enterprise projects. Record explicit exceptions in the SAP MCP inventory or project review notes.
- Treat MCP servers as executable dependencies. In , use exact npm pins such as
.mcp.json, never@ui5/mcp-server@0.2.11or bare package names.@latest - Pin local-source MCPs by commit. SAC uses the trusted fork and must record commit
secondsky/sap_analytics_cloud_mcp.2020235505d98111c2889598ab2217c1619b6943 - Keep runtime authorization separate. This skill covers package/source/executable trust; use the relevant SAP skill for tenant role design and business authorization.
- Validate MCP drift with after any
npm run validate:mcp-securityor SAP MCP inventory change..mcp.json
Load for SAP stack coverage and for MCP update workflow and SAC source-install policy. Use as the machine-readable approved MCP package/source list.
references/sap-dependency-risk-matrix.mdreferences/sap-mcp-security.mdreferences/sap-mcp-inventory.json当依赖项工作涉及SAP项目、SAP BTP部署工具、SAP SDK或本仓库提供的任何MCP服务器时,使用SAP开发模式。
核心规则:
- SAP企业项目默认采用14天冷却期。在SAP MCP清单或项目审核记录中记录明确的例外情况。
- 将MCP服务器视为可执行依赖项。在中使用精确的npm版本固定,例如
.mcp.json,绝不使用@ui5/mcp-server@0.2.11或裸包名。@latest - 本地源MCP使用提交记录固定。SAC使用可信的分支,且必须记录提交
secondsky/sap_analytics_cloud_mcp。2020235505d98111c2889598ab2217c1619b6943 - 运行时授权与依赖项安全分离。本技能覆盖包/源/可执行文件信任;租户角色设计和业务授权请使用相关SAP技能。
- 验证MCP漂移:在任何或SAP MCP清单变更后,运行
.mcp.json。npm run validate:mcp-security
如需了解SAP栈覆盖范围,请加载;如需了解MCP更新工作流和SAC源安装策略,请加载。使用作为机器可读的已批准MCP包/源列表。
references/sap-dependency-risk-matrix.mdreferences/sap-mcp-security.mdreferences/sap-mcp-inventory.jsonInteractive Setup Flow
交互式设置流程
When the user wants tailored configuration, walk through these decisions. Skip this section entirely if using default mode.
当用户需要定制化配置时,引导完成以下决策。若使用默认模式,可完全跳过本节。
Tier 1: Required Decisions
第一层:必填决策
Always ask these 3 questions before generating any config:
1. Package Manager
"Which package manager does this project use?"
| Answer | Generates |
|---|---|
| npm | |
| Bun | |
| pnpm | |
| Yarn | |
| Deno | |
2. Cooldown Period
"How many days should newly published packages age before install? This prevents supply chain attacks where malicious packages are discovered and unpublished within days."
| Option | Days | Use Case |
|---|---|---|
| Aggressive | 3 | Catches most typosquatting |
| Recommended | 7 | Good balance for most projects |
| Conservative | 14 | Critical/production systems |
| Paranoid | 21 | Matches Snyk's built-in default |
| Custom | N | User specifies |
3. Post-Install Script Policy
"How should lifecycle scripts (postinstall, preinstall) be handled? These are the #1 attack vector for supply chain attacks."
| Option | Behavior |
|---|---|
| Block all (recommended) | |
| Allowlist | Block by default, allow specific trusted packages |
| Review only | Warn but don't block |
在生成任何配置前,务必询问以下3个问题:
1. 包管理器
“此项目使用哪种包管理器?”
| 回答 | 生成配置文件 |
|---|---|
| npm | |
| Bun | |
| pnpm | |
| Yarn | |
| Deno | |
2. 冷却期
“新发布的包需等待多少天才能安装?这可防范供应链攻击——恶意包通常在数小时内被发现并下架。”
| 选项 | 天数 | 使用场景 |
|---|---|---|
| 激进型 | 3 | 拦截大部分打字 squatting 攻击 |
| 推荐型 | 7 | 适合大多数项目的平衡策略 |
| 保守型 | 14 | 关键/生产系统 |
| 极端保守型 | 21 | 与Snyk内置默认值匹配 |
| 自定义 | N | 用户指定天数 |
3. 安装后脚本策略
“应如何处理生命周期脚本(postinstall、preinstall)?这是供应链攻击的头号攻击载体。”
| 选项 | 行为 |
|---|---|
| 拦截所有(推荐) | |
| 白名单模式 | 默认拦截,允许特定可信包的脚本 |
| 仅审核 | 发出警告但不拦截 |
Tier 2: Security Tooling (Offer as Batch)
第二层:安全工具(批量提供选项)
"Which of these security features would you like to configure? Select any that apply."
4. CI/CD Automation Tool
| Answer | Generates |
|---|---|
| Dependabot | |
| Renovate | |
| Snyk | No config needed (21-day cooldown built-in) |
| None | Skip |
5. Automerge Policy
| Option | Behavior |
|---|---|
| None | All updates require manual review |
| Minor+Patch only | Auto-merge safe updates, review majors |
| All with approval | Auto-merge after team approval |
6. Update Schedule
| Option | Config Value |
|---|---|
| Daily | |
| Weekly (default) | |
| Biweekly | |
| Monthly | |
7. Install-Time Security Tooling
"Which security tools should protect dependency installation?"
| Option | Free? | What It Does |
|---|---|---|
| socket npm wrapper | Yes (beta) | Wraps npm/npx, blocks malicious packages before install. Run |
| npq | Yes | Pre-install auditor (CVE, typosquat, age, provenance checks) |
| Socket Firewall (sfw) | No | Real-time deep analysis, blocks malicious packages |
| socket npm + npq | Yes | Both free tools combined |
| None | — | Skip |
Load for full Socket CLI setup including authentication and free vs authenticated features.
references/socket-cli-guide.md8. Lockfile Validation
| Option | Behavior |
|---|---|
| Yes (recommended) | Adds |
| No | Skip |
“您希望配置以下哪些安全功能?可多选。”
4. CI/CD自动化工具
| 回答 | 生成配置文件 |
|---|---|
| Dependabot | 带冷却期的 |
| Renovate | 带minimumReleaseAge的 |
| Snyk | 无需配置(内置21天冷却期) |
| 无 | 跳过 |
5. 自动合并策略
| 选项 | 行为 |
|---|---|
| 无 | 所有更新需人工审核 |
| 仅次要/补丁版本 | 自动合并安全更新,主要版本需审核 |
| 需批准后自动合并 | 经团队批准后自动合并 |
6. 更新计划
| 选项 | 配置值 |
|---|---|
| 每日 | |
| 每周(默认) | |
| 每两周 | |
| 每月 | |
7. 安装时安全工具
“应使用哪些安全工具保护依赖项安装?”
| 选项 | 是否免费 | 功能 |
|---|---|---|
| socket npm wrapper | 是(测试版) | 包装npm/npx,在安装前拦截恶意包。运行 |
| npq | 是 | 安装前审核工具(检查CVE、打字squatting、版本时长、来源证明) |
| Socket Firewall (sfw) | 否 | 实时深度分析,拦截恶意包 |
| socket npm + npq | 是 | 组合使用两款免费工具 |
| 无 | — | 跳过 |
如需完整的Socket CLI设置(包括身份验证和免费/付费功能),请加载。
references/socket-cli-guide.md8. 锁文件验证
| 选项 | 行为 |
|---|---|
| 是(推荐) | 添加 |
| 否 | 跳过 |
Tier 3: Advanced Options (Only If User Opts In)
第三层:高级选项(仅当用户选择时)
"Would you like to configure any advanced options?"
9. Dev Containers — Generate hardened (Yes/No)
.devcontainer/devcontainer.json10. Secrets Manager — 1Password CLI / Infisical / None
11. pnpm Trust Policy — Enable (pnpm 10.21+ only, Yes/No)
trustPolicy: no-downgrade12. Cooldown Exclusions — Package names that bypass cooldown (e.g., , , )
@types/reacttypescriptesbuild“您希望配置任何高级选项吗?”
9. Dev Containers — 生成加固的(是/否)
.devcontainer/devcontainer.json10. 密钥管理器 — 1Password CLI / Infisical / 无
11. pnpm信任策略 — 启用(仅适用于pnpm 10.21+,是/否)
trustPolicy: no-downgrade12. 冷却期例外 — 绕过冷却期的包名(例如、、)
@types/reacttypescriptesbuildSecurity-First Upgrade Principles
安全优先的升级原则
- Cooldown before installing — Wait 7 days for general projects or 14 days for SAP enterprise/MCP workflows so new package versions are vetted by the community
- Block post-install scripts — Prevent arbitrary code execution during
npm install - Freeze lockfiles in CI — Use deterministic installs (,
npm ci)--frozen-lockfile - Validate lockfile integrity — Use to detect injection
lockfile-lint - Audit before trusting — Use or Socket CLI to check packages before installing
npq - Upgrade incrementally — One major version at a time with testing between each
- Never blindly upgrade — Avoid or
npm updatewithout reviewnpm-check-updates -u - Scan before and after — Use to detect supply chain issues beyond CVEs
socket scan - Pin SAP MCP executables — Use exact npm versions or source commit pins before letting MCP servers access SAP projects or tenants
- 安装前等待冷却期 — 普通项目等待7天,SAP企业/MCP工作流等待14天,让新包版本经社区验证
- 拦截安装后脚本 — 防止期间执行任意代码
npm install - CI中冻结锁文件 — 使用确定性安装命令(、
npm ci)--frozen-lockfile - 验证锁文件完整性 — 使用检测注入攻击
lockfile-lint - 信任前先审核 — 使用或Socket CLI在安装前检查包
npq - 增量升级 — 每次升级一个主要版本,升级后进行测试
- 绝不盲目升级 — 未经审核,避免使用或
npm updatenpm-check-updates -u - 升级前后扫描 — 使用检测CVE之外的供应链问题
socket scan - 固定SAP MCP可执行文件 — 在允许MCP服务器访问SAP项目或租户前,使用精确npm版本或源提交固定
Cooldown Period: Prevent Supply Chain Attacks
冷却期:防范供应链攻击
Newly published packages may contain malicious code discovered within hours. Configure a cooldown period to delay installation.
新发布的包可能包含恶意代码,通常在数小时内被发现。配置冷却期可延迟安装。
Quick Setup
快速设置
npm ():
.npmrcini
min-release-age=7Bun ():
bunfig.tomltoml
[install]
minimumReleaseAge = 604800 # 7 days in seconds
minimumReleaseAgeExcludes = ["@types/bun", "typescript"]pnpm ():
pnpm-workspace.yamlyaml
minimumReleaseAge: 10080 # 7 days in minutes
minimumReleaseAgeExclude:
- '@types/react'
- typescriptYarn ():
.yarnrc.ymlyaml
npmMinimalAgeGate: "7d"
npmPreapprovedPackages:
- "@types/react"
- "typescript"Load for detailed per-PM configuration, CI tool integration, and exclusion patterns.
references/cooldown-config-guide.mdUse for copy-paste ready config files.
templates/<pm>-security.tmplnpm():
.npmrcini
min-release-age=7Bun():
bunfig.tomltoml
[install]
minimumReleaseAge = 604800 # 7天(秒)
minimumReleaseAgeExcludes = ["@types/bun", "typescript"]pnpm():
pnpm-workspace.yamlyaml
minimumReleaseAge: 10080 # 7天(分钟)
minimumReleaseAgeExclude:
- '@types/react'
- typescriptYarn():
.yarnrc.ymlyaml
npmMinimalAgeGate: "7d"
npmPreapprovedPackages:
- "@types/react"
- "typescript"如需针对特定包管理器的详细配置、CI工具集成和排除模式,请加载。
references/cooldown-config-guide.md使用获取可直接复制粘贴的配置文件。
templates/<pm>-security.tmplDisable Post-Install Scripts
禁用安装后脚本
Post-install scripts are the most common supply chain attack vector (Shai-Hulud, Nx, event-stream incidents).
安装后脚本是最常见的供应链攻击载体(Shai-Hulud、Nx、event-stream事件)。
Quick Setup
快速设置
npm:
bash
npm config set ignore-scripts true
npm config set allow-git noneBun: Disabled by default. Allow specific packages in :
package.jsonjson
{ "trustedDependencies": ["esbuild", "sharp"] }pnpm (10.0+): Disabled by default. Allow specific packages in :
pnpm-workspace.yamlyaml
allowBuilds:
esbuild: true
strictDepBuilds: true # Hard error on unreviewed scriptsLoad for full per-PM hardening including pnpm , , and .
references/package-manager-security.mdtrustPolicyblockExoticSubdeps@lavamoat/allow-scriptsnpm:
bash
npm config set ignore-scripts true
npm config set allow-git noneBun:默认禁用。在中允许特定包:
package.jsonjson
{ "trustedDependencies": ["esbuild", "sharp"] }pnpm (10.0+):默认禁用。在中允许特定包:
pnpm-workspace.yamlyaml
allowBuilds:
esbuild: true
strictDepBuilds: true # 对未审核的脚本触发严重错误如需完整的包管理器加固指南(包括pnpm 、和),请加载。
trustPolicyblockExoticSubdeps@lavamoat/allow-scriptsreferences/package-manager-security.mdDeterministic & Frozen Installs
确定性与冻结安装
Always use frozen install commands in CI to ensure reproducible builds:
| Package Manager | Command | What It Does |
|---|---|---|
| npm | | Deletes node_modules, installs exact lockfile versions |
| Bun | | Fails if lockfile is out of sync |
| pnpm | | Fails if lockfile is out of sync |
| Yarn | | Validates lockfile and cache |
| Deno | | Frozen installation |
Commit all lockfiles to version control: , , , , .
package-lock.jsonbun.lockpnpm-lock.yamlyarn.lockdeno.lock在CI中始终使用冻结安装命令,确保构建可重现:
| 包管理器 | 命令 | 功能 |
|---|---|---|
| npm | | 删除node_modules,安装锁文件中的精确版本 |
| Bun | | 若锁文件不同步则失败 |
| pnpm | | 若锁文件不同步则失败 |
| Yarn | | 验证锁文件和缓存 |
| Deno | | 冻结安装 |
将所有锁文件提交到版本控制:、、、、。
package-lock.jsonbun.lockpnpm-lock.yamlyarn.lockdeno.lockLockfile Validation
锁文件验证
Install and configure to detect lockfile injection attacks:
lockfile-lintbash
npm install --save-dev lockfile-lintjson
{
"scripts": {
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https",
"preinstall": "npm run lint:lockfile"
}
}Note: does not currently support Bun's / formats.
lockfile-lintbun.lockbun.lockb安装并配置以检测锁文件注入攻击:
lockfile-lintbash
npm install --save-dev lockfile-lintjson
{
"scripts": {
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https",
"preinstall": "npm run lint:lockfile"
}
}注意:目前不支持Bun的 / 格式。
lockfile-lintbun.lockbun.lockbPre-Install Security Auditing
安装前安全审核
npq — Pre-Install Auditor
npq — 安装前审核工具
bash
npm install -g npq
npq install <package> # Audit before installing
npq install <package> --dry-run # Audit without installingbash
npm install -g npq
npq install <package> # 安装前审核
npq install <package> --dry-run # 仅审核不安装Shell alias for seamless use
Shell别名实现无缝使用
alias npm='npq-hero'
alias npm='npq-hero'
Use with other PMs
与其他包管理器配合使用
NPQ_PKG_MGR=pnpm npq install <package>
NPQ_PKG_MGR=bun npq install <package>
undefinedNPQ_PKG_MGR=pnpm npq install <package>
NPQ_PKG_MGR=bun npq install <package>
undefinedSocket Firewall (sfw) — Real-Time Blocker
Socket Firewall (sfw) — 实时拦截器
bash
npm install -g sfw
sfw npm install <package> # Blocks malicious packages
sfw pnpm add <package>
sfw yarn add <package>Load for full comparison of npq vs sfw and what each validates.
references/supply-chain-security.mdbash
npm install -g sfw
sfw npm install <package> # 拦截恶意包
sfw pnpm add <package>
sfw yarn add <package>如需npq与sfw的完整对比及各自验证内容,请加载。
references/supply-chain-security.mdSocket CLI Integration
Socket CLI集成
Socket CLI provides proactive supply chain security beyond basic vulnerability scanning — covering malware detection, typosquatting, protestware, install script risks, and license compliance.
Socket CLI提供超越基础漏洞扫描的主动供应链安全防护——涵盖恶意软件检测、打字squatting、抗议软件、安装脚本风险和许可证合规性。
Proactive Upgrade Workflow
主动升级工作流
1. PRE-UPGRADE: socket scan create --report → establish baseline
2. EVALUATE: socket package score npm <pkg>@<ver> → assess target package safety
3. SAFE INSTALL: socket npm install <pkg> → block malicious packages
4. POST-UPGRADE: socket scan create --report → verify no new alerts
5. DIFF: socket scan diff <before> <after> → see exactly what changed
6. FIX: socket fix --minimum-release-age 7d → auto-fix any new CVEs
7. OPTIMIZE: socket optimize → apply security overrides1. 升级前: socket scan create --report → 建立基线
2. 评估: socket package score npm <pkg>@<ver> → 评估目标包安全性
3. 安全安装: socket npm install <pkg> → 拦截恶意包
4. 升级后: socket scan create --report → 验证无新警报
5. 对比: socket scan diff <before> <after> → 查看具体变更
6. 修复: socket fix --minimum-release-age 7d → 自动修复新发现的CVE
7. 优化: socket optimize → 应用安全覆盖规则Quick Reference
快速参考
bash
undefinedbash
undefinedInstall
安装
npm install -g socket
npm install -g socket
Authenticate (required for scans, fixes, package scores)
身份验证(扫描、修复、包评分需要)
socket login
socket login
Check a package before upgrading
升级前检查包
socket package score npm <package>
socket package score npm <package>
Scan your whole project
扫描整个项目
socket scan create --report
socket scan create --report
Auto-fix CVEs (complements Dependabot/Renovate)
自动修复CVE(补充Dependabot/Renovate)
socket fix --minimum-release-age 7d
socket fix --minimum-release-age 7d
Gate CI on security policy
在CI中设置安全门
socket ci
socket ci
Safe npm wrapper (free, no auth needed)
安全npm包装器(免费,无需身份验证)
socket wrapper on
Load `references/socket-cli-guide.md` for comprehensive command reference, CI workflow templates, alert categories, and free vs authenticated feature matrix.socket wrapper on
如需完整的命令参考、CI工作流模板、警报类别以及免费/付费功能对比,请加载`references/socket-cli-guide.md`。Dependency Analysis
依赖项分析
bash
undefinedbash
undefinedAudit for vulnerabilities
审核漏洞
bun audit # Bun
npm audit # npm
yarn audit # Yarn
bun audit # Bun
npm audit # npm
yarn audit # Yarn
Socket: deep security assessment (CVEs + supply chain + license)
Socket: 深度安全评估(CVE + 供应链 + 许可证)
socket package score npm <package>
socket scan create --report
socket package score npm <package>
socket scan create --report
Check for outdated packages
检查过时包
bun outdated
npm outdated
bun outdated
npm outdated
Interactive upgrade (safe — review each)
交互式升级(安全——逐个审核)
bunx npm-check-updates --interactive
bunx npm-check-updates --interactive
Analyze dependency tree
分析依赖树
npm ls <package-name>
yarn why <package-name>
undefinednpm ls <package-name>
yarn why <package-name>
undefinedStaged Upgrade Strategy
分阶段升级策略
Upgrade one dependency at a time with testing between each:
bash
undefined每次升级一个依赖项,升级后进行测试:
bash
undefined1. Create feature branch
1. 创建功能分支
git checkout -b upgrade/<package>-<version>
git checkout -b upgrade/<package>-<version>
2. (Optional) Baseline scan — capture current state
2. (可选)基线扫描——记录当前状态
socket scan create --report
socket scan create --report
3. Evaluate target package before upgrading
3. 升级前评估目标包
socket package score npm <package>@<version>
socket package score npm <package>@<version>
4. Upgrade single package
4. 升级单个包
bun add <package>@<version>
bun add <package>@<version>
5. Test immediately
5. 立即测试
bun test && bunx tsc --noEmit && bun run build
bun test && bunx tsc --noEmit && bun run build
6. (Optional) Post-upgrade scan — verify no new alerts
6. (可选)升级后扫描——验证无新警报
socket scan create --report
socket scan create --report
7. Commit and continue
7. 提交并继续
git add -A && git commit -m "chore: upgrade <package> to <version>"
Load `references/staged-upgrades.md` for codemod automation, custom migration scripts, and peer dependency handling.
Load `references/compatibility-matrix.md` for version compatibility tables (React 18/19, Next.js 13-15, TypeScript, Tailwind 3/4).git add -A && git commit -m "chore: upgrade <package> to <version>"
如需代码转换自动化、自定义迁移脚本和对等依赖项处理,请加载`references/staged-upgrades.md`。
如需版本兼容性表(React 18/19、Next.js 13-15、TypeScript、Tailwind 3/4),请加载`references/compatibility-matrix.md`。Automated Updates with Cooldown
带冷却期的自动化更新
Configure CI/CD tools to respect cooldown periods:
配置CI/CD工具以遵守冷却期:
Dependabot (.github/dependabot.yml
)
.github/dependabot.ymlDependabot(.github/dependabot.yml
)
.github/dependabot.ymlyaml
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7yaml
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7Renovate (renovate.json
)
renovate.jsonRenovate(renovate.json
)
renovate.jsonjson
{
"extends": ["config:base"],
"minimumReleaseAge": "7 days",
"packageRules": [
{
"matchUpdateTypes": ["minor", "patch"],
"automerge": true
},
{
"matchUpdateTypes": ["major"],
"automerge": false,
"minimumReleaseAge": "14 days"
}
]
}json
{
"extends": ["config:base"],
"minimumReleaseAge": "7 days",
"packageRules": [
{
"matchUpdateTypes": ["minor", "patch"],
"automerge": true
},
{
"matchUpdateTypes": ["major"],
"automerge": false,
"minimumReleaseAge": "14 days"
}
]
}Snyk
Snyk
Snyk includes a built-in 21-day cooldown for upgrade PRs. No configuration needed.
Snyk为升级PR内置21天冷却期,无需配置。
Socket Fix (complements Dependabot/Renovate)
Socket Fix(补充Dependabot/Renovate)
Socket Fix automatically resolves CVEs with intelligent upgrade planning. Runs alongside other automation tools — it focuses on CVE remediation specifically:
bash
undefinedSocket Fix通过智能升级规划自动解决CVE问题。可与其他自动化工具配合使用——专注于CVE修复:
bash
undefinedFix all fixable CVEs with cooldown alignment
修复所有可修复的CVE,并对齐冷却期
socket fix --minimum-release-age 7d
socket fix --minimum-release-age 7d
Conservative: no major version bumps
保守模式:不升级主要版本
socket fix --minimum-release-age 7d --no-major-updates
socket fix --minimum-release-age 7d --no-major-updates
Target specific CVEs
修复特定CVE
socket fix --id GHSA-hhq3-ff78-jv3g --minimum-release-age 7d
socket fix --id GHSA-hhq3-ff78-jv3g --minimum-release-age 7d
Preview without applying
预览修复但不应用
socket fix --no-apply-fixes --minimum-release-age 7d
For CI autopilot mode (auto-creates and auto-merges fix PRs), use `templates/socket-fix-ci.tmpl`.
Load `references/socket-cli-guide.md` for full `socket fix` options including `--autopilot`, `--range-style`, and `--pr-limit`.
Use `templates/dependabot-security.tmpl` or `templates/renovate-security.tmpl` for complete config files.socket fix --no-apply-fixes --minimum-release-age 7d
如需CI自动驾驶模式(自动创建并合并修复PR),请使用`templates/socket-fix-ci.tmpl`。
如需完整的`socket fix`选项(包括`--autopilot`、`--range-style`和`--pr-limit`),请加载`references/socket-cli-guide.md`。
使用`templates/dependabot-security.tmpl`或`templates/renovate-security.tmpl`获取完整配置文件。Publishing Security
发布安全
For package maintainers:
bash
undefined针对包维护者:
bash
undefinedEnable 2FA
启用双因素认证
npm profile enable-2fa auth-and-writes
npm profile enable-2fa auth-and-writes
Publish with provenance (cryptographic build proof)
带来源证明发布(加密构建证明)
npm publish --provenance
npm publish --provenance
Trusted publishing via OIDC (eliminates long-lived tokens)
通过OIDC进行可信发布(消除长期令牌)
Configure on npmjs.com, then:
在npmjs.com上配置,然后:
In GitHub Actions: permissions: id-token: write
在GitHub Actions中设置:permissions: id-token: write
Load `references/supply-chain-security.md` for full publishing security guide including OIDC setup and dependency tree reduction.
如需完整的发布安全指南(包括OIDC设置和依赖树精简),请加载`references/supply-chain-security.md`。Dev Environment Hardening
开发环境加固
Isolate dependency execution from the host system:
- Dev containers — limit blast radius of malicious packages
- Secrets management — use 1Password CLI or Infisical instead of plaintext files
.env - Dependency tree reduction — replace common packages with native JS
Use for a hardened dev container config.
templates/devcontainer-security.tmplLoad for dev container setup, secrets management, and dependency reduction patterns.
references/secrets-and-containers.md将依赖项执行与主机系统隔离:
- Dev containers — 限制恶意包的影响范围
- 密钥管理 — 使用1Password CLI或Infisical替代明文文件
.env - 依赖树精简 — 使用原生JS替代常用包
使用获取加固的开发容器配置。
templates/devcontainer-security.tmpl如需开发容器设置、密钥管理和依赖树精简模式,请加载。
references/secrets-and-containers.mdTesting Strategy
测试策略
Run tests at every level after each upgrade:
bash
undefined每次升级后,在所有层级运行测试:
bash
undefined1. Static analysis (fastest)
1. 静态分析(最快)
bunx tsc --noEmit && bun run lint
bunx tsc --noEmit && bun run lint
2. Unit tests
2. 单元测试
bun test
bun test
3. Build check
3. 构建检查
bun run build
bun run build
4. Integration / E2E (after major upgrades)
4. 集成/端到端测试(主要版本升级后)
bun run test:e2e
Load `references/testing-strategy.md` for full testing pyramid, CI integration, and bundle analysis.bun run test:e2e
如需完整的测试金字塔、CI集成和包分析,请加载`references/testing-strategy.md`。Rollback Plan
回滚计划
bash
#!/bin/bash
git stash
git checkout -b upgrade/<package>
bun add <package>@latest
if bun test && bun run build; then
git add package.json bun.lock
git commit -m "chore: upgrade <package>"
else
echo "Upgrade failed, rolling back"
git checkout main
git branch -D upgrade/<package>
bun install
fibash
#!/bin/bash
git stash
git checkout -b upgrade/<package>
bun add <package>@latest
if bun test && bun run build; then
git add package.json bun.lock
git commit -m "chore: upgrade <package>"
else
echo "升级失败,正在回滚"
git checkout main
git branch -D upgrade/<package>
bun install
fiUpgrade Checklist
升级检查清单
markdown
Pre-Upgrade:
- [ ] Review current dependency versions
- [ ] Read changelogs for breaking changes
- [ ] Create feature branch
- [ ] Tag current state (git tag pre-upgrade)
- [ ] Run full test suite (baseline)
- [ ] Verify cooldown period is configured
- [ ] For SAP MCP changes, verify exact package/source pins against `references/sap-mcp-inventory.json`
Security Pre-Checks:
- [ ] Post-install scripts are disabled
- [ ] Lockfile validation is active
- [ ] Install auditing tools configured (if applicable)
- [ ] CI uses frozen-lockfile install
- [ ] Run `socket scan create --report` for baseline (if Socket available)
During Upgrade:
- [ ] Upgrade one dependency at a time
- [ ] Check target package: `socket package score npm <pkg>` (if Socket available)
- [ ] Respect cooldown period (don't force latest)
- [ ] Update peer dependencies
- [ ] Fix TypeScript errors
- [ ] Run test suite after each upgrade
- [ ] Check bundle size impact
Post-Upgrade:
- [ ] Post-upgrade scan: `socket scan diff` to verify no new alerts (if Socket available)
- [ ] Consider `socket fix --minimum-release-age 7d` for any new CVEs
- [ ] Full regression testing
- [ ] Performance testing
- [ ] Update documentation
- [ ] Deploy to staging
- [ ] Monitor for errors
- [ ] Deploy to productionmarkdown
升级前:
- [ ] 审核当前依赖项版本
- [ ] 阅读变更日志中的破坏性变更
- [ ] 创建功能分支
- [ ] 标记当前状态(git tag pre-upgrade)
- [ ] 运行完整测试套件(基线)
- [ ] 验证冷却期已配置
- [ ] 若涉及SAP MCP变更,对照`references/sap-mcp-inventory.json`验证精确的包/源固定
安全预检查:
- [ ] 安装后脚本已禁用
- [ ] 锁文件验证已启用
- [ ] 安装审核工具已配置(如适用)
- [ ] CI使用冻结锁文件安装
- [ ] 运行`socket scan create --report`获取基线(如Socket可用)
升级中:
- [ ] 每次升级一个依赖项
- [ ] 检查目标包:`socket package score npm <pkg>`(如Socket可用)
- [ ] 遵守冷却期(不强制升级到最新版本)
- [ ] 更新对等依赖项
- [ ] 修复TypeScript错误
- [ ] 每次升级后运行测试套件
- [ ] 检查包大小影响
升级后:
- [ ] 升级后扫描:`socket scan diff`验证无新警报(如Socket可用)
- [ ] 考虑使用`socket fix --minimum-release-age 7d`修复新发现的CVE
- [ ] 完整回归测试
- [ ] 性能测试
- [ ] 更新文档
- [ ] 部署到预发布环境
- [ ] 监控错误
- [ ] 部署到生产环境Common Pitfalls
常见陷阱
- Upgrading all dependencies at once (use incremental upgrades)
- Blindly running or
npm updatewithout reviewnpm-check-updates -u - Not testing after each individual upgrade
- Ignoring peer dependency warnings
- Forgetting to update or commit the lock file
- Not reading breaking change notes in changelogs
- Skipping major versions instead of stepping through them
- Not having a rollback plan
- Trusting npmjs.org displayed source code (can differ from actual tarball)
- Leaving post-install scripts enabled (most common attack vector)
- Not configuring a cooldown period for new package versions
- Shipping SAP MCP configs with , bare
@latestpackages, or unpinned local source pathsnpx
- 一次性升级所有依赖项(应使用增量升级)
- 未经审核盲目运行或
npm updatenpm-check-updates -u - 每次单独升级后未进行测试
- 忽略对等依赖项警告
- 忘记更新或提交锁文件
- 未阅读变更日志中的破坏性变更说明
- 跳过主要版本,而非逐步升级
- 未制定回滚计划
- 信任npmjs.org显示的源代码(可能与实际tarball不同)
- 未禁用安装后脚本(最常见的攻击载体)
- 未为新包版本配置冷却期
- 发布的SAP MCP配置使用、裸
@latest包或未固定的本地源路径npx
When to Load References
何时加载参考文件
Load these reference files when the user needs detailed information beyond the quick-reference in SKILL.md:
| Load This File | When |
|---|---|
| Configuring cooldown for a specific PM, CI tool integration, or exclusion patterns |
| Full per-PM hardening guide including pnpm trust policy, blockExoticSubdeps, cross-PM cheat sheet |
| Understanding attack vectors, incident history, npq vs sfw vs Socket CLI comparison, publisher security (2FA, provenance, OIDC) |
| Setting up dev containers, secrets management with 1Password/Infisical |
| Using Socket CLI for scans, fixes, package scoring, CI integration, wrapper mode, alert categories |
| Checking version compatibility for React, Next.js, TypeScript, Tailwind upgrades |
| Codemod automation, custom migration scripts, peer dependency handling, workspace upgrades |
| Full testing pyramid, CI integration, bundle analysis, performance testing |
| SAP stack-specific dependency review across Node, Java, Python, containers, BTP/CF/mbt, ABAP/gCTS, and MCP |
| SAP MCP exact-pin policy, SAC source-install policy, and MCP update workflow |
| Machine-readable approved SAP MCP package/source pins used by |
当用户需要SKILL.md快速参考之外的详细信息时,加载以下参考文件:
| 加载文件 | 适用场景 |
|---|---|
| 为特定包管理器配置冷却期、CI工具集成或排除模式 |
| 完整的包管理器加固指南,包括pnpm信任策略、blockExoticSubdeps、跨包管理器速查表 |
| 了解攻击载体、事件历史、npq vs sfw vs Socket CLI对比、发布者安全(双因素认证、来源证明、OIDC) |
| 设置开发容器、使用1Password/Infisical进行密钥管理 |
| 使用Socket CLI进行扫描、修复、包评分、CI集成、包装器模式、警报类别 |
| 检查React、Next.js、TypeScript、Tailwind升级的版本兼容性 |
| 代码转换自动化、自定义迁移脚本、对等依赖项处理、工作区升级 |
| 完整的测试金字塔、CI集成、包分析、性能测试 |
| SAP栈特定的依赖项审核,涵盖Node、Java、Python、容器、BTP/CF/mbt、ABAP/gCTS和MCP |
| SAP MCP精确版本固定策略、SAC源安装策略和MCP更新工作流 |
| 机器可读的已批准SAP MCP包/源固定列表,供 |
Template Files
模板文件
Ready-to-use config files in :
templates/| Template | Purpose |
|---|---|
| Secure |
| Secure |
| Secure |
| Secure |
| Dependabot config with 7-day cooldown |
| Renovate config with minimumReleaseAge + automerge rules |
| Hardened dev container with security options |
| GitHub Actions: Socket Fix autopilot with cooldown-aligned CVE remediation |
| GitHub Actions: Socket CI security gate for every push/PR |
| Review-ready SAP MCP config candidate with exact-pin checklist |
| Maven checksum/enforcer/dependency scan fragment for SAP Java projects |
| Gradle dependency locking and verification fragment |
| Python lock/audit workflow for SAP AI SDK, HANA ML, and data tooling |
| Container image scan workflow with Trivy and digest-pin reminders |
| BTP, Cloud Foundry, and MBT dependency/deployment review checklist |
| ABAP, gCTS, and transport dependency review checklist |
templates/| 模板 | 用途 |
|---|---|
| 带脚本禁用+冷却期的安全 |
| 带冷却期+排除项的安全 |
| 带冷却期、allowBuilds、trustPolicy的安全 |
| 带年龄限制+预批准包的安全 |
| 带7天冷却期的Dependabot配置 |
| 带minimumReleaseAge+自动合并规则的Renovate配置 |
| 带安全选项的加固开发容器 |
| GitHub Actions:Socket Fix自动驾驶模式,对齐冷却期的CVE修复 |
| GitHub Actions:每次推送/PR的Socket CI安全门 |
| 带精确版本固定检查清单的SAP MCP候选配置 |
| SAP Java项目的Maven校验和/强制执行/依赖扫描片段 |
| Gradle依赖项锁定和验证片段 |
| SAP AI SDK、HANA ML和数据工具的Python锁定/审核工作流 |
| 带Trivy的容器镜像扫描工作流和摘要固定提醒 |
| BTP、Cloud Foundry和MBT依赖项/部署审核检查清单 |
| ABAP、gCTS和传输依赖项审核检查清单 |