sap-dependency-security

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SAP 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依赖项安全工作流
  • .mcp.json
    中固定或审核SAP MCP服务器
  • 审核SAP CAP、UI5/Fiori、HANA、Datasphere、SAC、SAP Cloud SDK、BTP/CF/mbt或ABAP/gCTS依赖项工作流

Common Issues

常见问题

IssueRecommended response
Floating MCP package or
@latest
in
.mcp.json
Replace with an exact version or approved source commit and run
npm run validate:mcp-security
.
Lockfile changed unexpectedlyReview package manager config, block lifecycle scripts, and regenerate only after dependency intent is clear.
Dependency is too new for cooldown policyHold the upgrade unless a documented security exception justifies immediate adoption.
Tenant-connected tool changed sourceVerify the source URL, commit, and build steps before using credentials.
问题推荐解决方案
.mcp.json
中存在浮动MCP包或
@latest
替换为精确版本或已批准的源提交,并运行
npm run validate:mcp-security
锁文件意外变更审核包管理器配置,拦截生命周期脚本,仅在明确依赖项意图后重新生成锁文件。
依赖项版本过新,不符合冷却期策略暂缓升级,除非有文档记录的安全例外情况证明需立即采用。
租户关联工具的源已变更在使用凭据前,验证源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
@latest
, source commit pins for local MCP servers, and manual review for tenant-connected tools.
交互式 — 通过设置问题引导生成定制化配置。适用于全新设置场景。
默认模式 — 立即应用推荐的默认配置:7天冷却期、拦截所有脚本、冻结锁文件、锁文件校验、带冷却期的Dependabot。可按需自定义。
SAP开发模式 — 采用更严格的SAP安全策略:14天冷却期、MCP服务器和可执行工具使用精确版本固定、禁止使用浮动
@latest
、本地MCP服务器使用源提交固定、租户关联工具需人工审核。

SAP 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:
  1. Default to 14-day cooldown for SAP enterprise projects. Record explicit exceptions in the SAP MCP inventory or project review notes.
  2. Treat MCP servers as executable dependencies. In
    .mcp.json
    , use exact npm pins such as
    @ui5/mcp-server@0.2.11
    , never
    @latest
    or bare package names.
  3. Pin local-source MCPs by commit. SAC uses the trusted
    secondsky/sap_analytics_cloud_mcp
    fork and must record commit
    2020235505d98111c2889598ab2217c1619b6943
    .
  4. Keep runtime authorization separate. This skill covers package/source/executable trust; use the relevant SAP skill for tenant role design and business authorization.
  5. Validate MCP drift with
    npm run validate:mcp-security
    after any
    .mcp.json
    or SAP MCP inventory change.
Load
references/sap-dependency-risk-matrix.md
for SAP stack coverage and
references/sap-mcp-security.md
for MCP update workflow and SAC source-install policy. Use
references/sap-mcp-inventory.json
as the machine-readable approved MCP package/source list.
当依赖项工作涉及SAP项目、SAP BTP部署工具、SAP SDK或本仓库提供的任何MCP服务器时,使用SAP开发模式。
核心规则:
  1. SAP企业项目默认采用14天冷却期。在SAP MCP清单或项目审核记录中记录明确的例外情况。
  2. 将MCP服务器视为可执行依赖项。在
    .mcp.json
    中使用精确的npm版本固定,例如
    @ui5/mcp-server@0.2.11
    ,绝不使用
    @latest
    或裸包名。
  3. 本地源MCP使用提交记录固定。SAC使用可信的
    secondsky/sap_analytics_cloud_mcp
    分支,且必须记录提交
    2020235505d98111c2889598ab2217c1619b6943
  4. 运行时授权与依赖项安全分离。本技能覆盖包/源/可执行文件信任;租户角色设计和业务授权请使用相关SAP技能。
  5. 验证MCP漂移:在任何
    .mcp.json
    或SAP MCP清单变更后,运行
    npm run validate:mcp-security
如需了解SAP栈覆盖范围,请加载
references/sap-dependency-risk-matrix.md
;如需了解MCP更新工作流和SAC源安装策略,请加载
references/sap-mcp-security.md
。使用
references/sap-mcp-inventory.json
作为机器可读的已批准MCP包/源列表。

Interactive 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?"
AnswerGenerates
npm
.npmrc
Bun
bunfig.toml
pnpm
pnpm-workspace.yaml
Yarn
.yarnrc.yml
Deno
deno.json
config
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."
OptionDaysUse Case
Aggressive3Catches most typosquatting
Recommended7Good balance for most projects
Conservative14Critical/production systems
Paranoid21Matches Snyk's built-in default
CustomNUser specifies
3. Post-Install Script Policy
"How should lifecycle scripts (postinstall, preinstall) be handled? These are the #1 attack vector for supply chain attacks."
OptionBehavior
Block all (recommended)
--ignore-scripts
+ allow-git=none
AllowlistBlock by default, allow specific trusted packages
Review onlyWarn but don't block
在生成任何配置前,务必询问以下3个问题:
1. 包管理器
“此项目使用哪种包管理器?”
回答生成配置文件
npm
.npmrc
Bun
bunfig.toml
pnpm
pnpm-workspace.yaml
Yarn
.yarnrc.yml
Deno
deno.json
配置
2. 冷却期
“新发布的包需等待多少天才能安装?这可防范供应链攻击——恶意包通常在数小时内被发现并下架。”
选项天数使用场景
激进型3拦截大部分打字 squatting 攻击
推荐型7适合大多数项目的平衡策略
保守型14关键/生产系统
极端保守型21与Snyk内置默认值匹配
自定义N用户指定天数
3. 安装后脚本策略
“应如何处理生命周期脚本(postinstall、preinstall)?这是供应链攻击的头号攻击载体。”
选项行为
拦截所有(推荐)
--ignore-scripts
+ allow-git=none
白名单模式默认拦截,允许特定可信包的脚本
仅审核发出警告但不拦截

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
AnswerGenerates
Dependabot
.github/dependabot.yml
with cooldown
Renovate
renovate.json
with minimumReleaseAge
SnykNo config needed (21-day cooldown built-in)
NoneSkip
5. Automerge Policy
OptionBehavior
NoneAll updates require manual review
Minor+Patch onlyAuto-merge safe updates, review majors
All with approvalAuto-merge after team approval
6. Update Schedule
OptionConfig Value
Daily
"daily"
Weekly (default)
"weekly"
Biweekly
"biweekly"
Monthly
"monthly"
7. Install-Time Security Tooling
"Which security tools should protect dependency installation?"
OptionFree?What It Does
socket npm wrapperYes (beta)Wraps npm/npx, blocks malicious packages before install. Run
socket wrapper on
to enable system-wide.
npqYesPre-install auditor (CVE, typosquat, age, provenance checks)
Socket Firewall (sfw)NoReal-time deep analysis, blocks malicious packages
socket npm + npqYesBoth free tools combined
NoneSkip
Load
references/socket-cli-guide.md
for full Socket CLI setup including authentication and free vs authenticated features.
8. Lockfile Validation
OptionBehavior
Yes (recommended)Adds
lockfile-lint
+ CI script
NoSkip
“您希望配置以下哪些安全功能?可多选。”
4. CI/CD自动化工具
回答生成配置文件
Dependabot带冷却期的
.github/dependabot.yml
Renovate带minimumReleaseAge的
renovate.json
Snyk无需配置(内置21天冷却期)
跳过
5. 自动合并策略
选项行为
所有更新需人工审核
仅次要/补丁版本自动合并安全更新,主要版本需审核
需批准后自动合并经团队批准后自动合并
6. 更新计划
选项配置值
每日
"daily"
每周(默认)
"weekly"
每两周
"biweekly"
每月
"monthly"
7. 安装时安全工具
“应使用哪些安全工具保护依赖项安装?”
选项是否免费功能
socket npm wrapper是(测试版)包装npm/npx,在安装前拦截恶意包。运行
socket wrapper on
启用系统级防护。
npq安装前审核工具(检查CVE、打字squatting、版本时长、来源证明)
Socket Firewall (sfw)实时深度分析,拦截恶意包
socket npm + npq组合使用两款免费工具
跳过
如需完整的Socket CLI设置(包括身份验证和免费/付费功能),请加载
references/socket-cli-guide.md
8. 锁文件验证
选项行为
是(推荐)添加
lockfile-lint
+ CI脚本
跳过

Tier 3: Advanced Options (Only If User Opts In)

第三层:高级选项(仅当用户选择时)

"Would you like to configure any advanced options?"
9. Dev Containers — Generate hardened
.devcontainer/devcontainer.json
(Yes/No)
10. Secrets Manager — 1Password CLI / Infisical / None
11. pnpm Trust Policy — Enable
trustPolicy: no-downgrade
(pnpm 10.21+ only, Yes/No)
12. Cooldown Exclusions — Package names that bypass cooldown (e.g.,
@types/react
,
typescript
,
esbuild
)
“您希望配置任何高级选项吗?”
9. Dev Containers — 生成加固的
.devcontainer/devcontainer.json
(是/否)
10. 密钥管理器 — 1Password CLI / Infisical / 无
11. pnpm信任策略 — 启用
trustPolicy: no-downgrade
(仅适用于pnpm 10.21+,是/否)
12. 冷却期例外 — 绕过冷却期的包名(例如
@types/react
typescript
esbuild

Security-First Upgrade Principles

安全优先的升级原则

  1. 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
  2. Block post-install scripts — Prevent arbitrary code execution during
    npm install
  3. Freeze lockfiles in CI — Use deterministic installs (
    npm ci
    ,
    --frozen-lockfile
    )
  4. Validate lockfile integrity — Use
    lockfile-lint
    to detect injection
  5. Audit before trusting — Use
    npq
    or Socket CLI to check packages before installing
  6. Upgrade incrementally — One major version at a time with testing between each
  7. Never blindly upgrade — Avoid
    npm update
    or
    npm-check-updates -u
    without review
  8. Scan before and after — Use
    socket scan
    to detect supply chain issues beyond CVEs
  9. Pin SAP MCP executables — Use exact npm versions or source commit pins before letting MCP servers access SAP projects or tenants
  1. 安装前等待冷却期 — 普通项目等待7天,SAP企业/MCP工作流等待14天,让新包版本经社区验证
  2. 拦截安装后脚本 — 防止
    npm install
    期间执行任意代码
  3. CI中冻结锁文件 — 使用确定性安装命令(
    npm ci
    --frozen-lockfile
  4. 验证锁文件完整性 — 使用
    lockfile-lint
    检测注入攻击
  5. 信任前先审核 — 使用
    npq
    或Socket CLI在安装前检查包
  6. 增量升级 — 每次升级一个主要版本,升级后进行测试
  7. 绝不盲目升级 — 未经审核,避免使用
    npm update
    npm-check-updates -u
  8. 升级前后扫描 — 使用
    socket scan
    检测CVE之外的供应链问题
  9. 固定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 (
.npmrc
):
ini
min-release-age=7
Bun (
bunfig.toml
):
toml
[install]
minimumReleaseAge = 604800  # 7 days in seconds
minimumReleaseAgeExcludes = ["@types/bun", "typescript"]
pnpm (
pnpm-workspace.yaml
):
yaml
minimumReleaseAge: 10080  # 7 days in minutes
minimumReleaseAgeExclude:
  - '@types/react'
  - typescript
Yarn (
.yarnrc.yml
):
yaml
npmMinimalAgeGate: "7d"
npmPreapprovedPackages:
  - "@types/react"
  - "typescript"
Load
references/cooldown-config-guide.md
for detailed per-PM configuration, CI tool integration, and exclusion patterns.
Use
templates/<pm>-security.tmpl
for copy-paste ready config files.
npm
.npmrc
):
ini
min-release-age=7
Bun
bunfig.toml
):
toml
[install]
minimumReleaseAge = 604800  # 7天(秒)
minimumReleaseAgeExcludes = ["@types/bun", "typescript"]
pnpm
pnpm-workspace.yaml
):
yaml
minimumReleaseAge: 10080  # 7天(分钟)
minimumReleaseAgeExclude:
  - '@types/react'
  - typescript
Yarn
.yarnrc.yml
):
yaml
npmMinimalAgeGate: "7d"
npmPreapprovedPackages:
  - "@types/react"
  - "typescript"
如需针对特定包管理器的详细配置、CI工具集成和排除模式,请加载
references/cooldown-config-guide.md
使用
templates/<pm>-security.tmpl
获取可直接复制粘贴的配置文件。

Disable 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 none
Bun: Disabled by default. Allow specific packages in
package.json
:
json
{ "trustedDependencies": ["esbuild", "sharp"] }
pnpm (10.0+): Disabled by default. Allow specific packages in
pnpm-workspace.yaml
:
yaml
allowBuilds:
  esbuild: true
strictDepBuilds: true  # Hard error on unreviewed scripts
Load
references/package-manager-security.md
for full per-PM hardening including pnpm
trustPolicy
,
blockExoticSubdeps
, and
@lavamoat/allow-scripts
.
npm
bash
npm config set ignore-scripts true
npm config set allow-git none
Bun:默认禁用。在
package.json
中允许特定包:
json
{ "trustedDependencies": ["esbuild", "sharp"] }
pnpm (10.0+):默认禁用。在
pnpm-workspace.yaml
中允许特定包:
yaml
allowBuilds:
  esbuild: true
strictDepBuilds: true  # 对未审核的脚本触发严重错误
如需完整的包管理器加固指南(包括pnpm
trustPolicy
blockExoticSubdeps
@lavamoat/allow-scripts
),请加载
references/package-manager-security.md

Deterministic & Frozen Installs

确定性与冻结安装

Always use frozen install commands in CI to ensure reproducible builds:
Package ManagerCommandWhat It Does
npm
npm ci
Deletes node_modules, installs exact lockfile versions
Bun
bun install --frozen-lockfile
Fails if lockfile is out of sync
pnpm
pnpm install --frozen-lockfile
Fails if lockfile is out of sync
Yarn
yarn install --immutable --immutable-cache
Validates lockfile and cache
Deno
deno install --frozen
Frozen installation
Commit all lockfiles to version control:
package-lock.json
,
bun.lock
,
pnpm-lock.yaml
,
yarn.lock
,
deno.lock
.
在CI中始终使用冻结安装命令,确保构建可重现:
包管理器命令功能
npm
npm ci
删除node_modules,安装锁文件中的精确版本
Bun
bun install --frozen-lockfile
若锁文件不同步则失败
pnpm
pnpm install --frozen-lockfile
若锁文件不同步则失败
Yarn
yarn install --immutable --immutable-cache
验证锁文件和缓存
Deno
deno install --frozen
冻结安装
将所有锁文件提交到版本控制:
package-lock.json
bun.lock
pnpm-lock.yaml
yarn.lock
deno.lock

Lockfile Validation

锁文件验证

Install and configure
lockfile-lint
to detect lockfile injection attacks:
bash
npm install --save-dev lockfile-lint
json
{
  "scripts": {
    "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https",
    "preinstall": "npm run lint:lockfile"
  }
}
Note:
lockfile-lint
does not currently support Bun's
bun.lock
/
bun.lockb
formats.
安装并配置
lockfile-lint
以检测锁文件注入攻击:
bash
npm install --save-dev lockfile-lint
json
{
  "scripts": {
    "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https",
    "preinstall": "npm run lint:lockfile"
  }
}
注意:
lockfile-lint
目前不支持Bun的
bun.lock
/
bun.lockb
格式。

Pre-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 installing
bash
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>
undefined
NPQ_PKG_MGR=pnpm npq install <package> NPQ_PKG_MGR=bun npq install <package>
undefined

Socket 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
references/supply-chain-security.md
for full comparison of npq vs sfw and what each validates.
bash
npm install -g sfw
sfw npm install <package>      # 拦截恶意包
sfw pnpm add <package>
sfw yarn add <package>
如需npq与sfw的完整对比及各自验证内容,请加载
references/supply-chain-security.md

Socket 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 overrides
1. 升级前:   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
undefined
bash
undefined

Install

安装

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
undefined
bash
undefined

Audit 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>
undefined
npm ls <package-name> yarn why <package-name>
undefined

Staged Upgrade Strategy

分阶段升级策略

Upgrade one dependency at a time with testing between each:
bash
undefined
每次升级一个依赖项,升级后进行测试:
bash
undefined

1. 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
)

Dependabot(
.github/dependabot.yml

yaml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
    cooldown:
      default-days: 7
yaml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
    cooldown:
      default-days: 7

Renovate (
renovate.json
)

Renovate(
renovate.json

json
{
  "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
undefined
Socket Fix通过智能升级规划自动解决CVE问题。可与其他自动化工具配合使用——专注于CVE修复:
bash
undefined

Fix 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
undefined

Enable 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
    .env
    files
  • Dependency tree reduction — replace common packages with native JS
Use
templates/devcontainer-security.tmpl
for a hardened dev container config.
Load
references/secrets-and-containers.md
for dev container setup, secrets management, and dependency reduction patterns.
将依赖项执行与主机系统隔离:
  • Dev containers — 限制恶意包的影响范围
  • 密钥管理 — 使用1Password CLI或Infisical替代明文
    .env
    文件
  • 依赖树精简 — 使用原生JS替代常用包
使用
templates/devcontainer-security.tmpl
获取加固的开发容器配置。
如需开发容器设置、密钥管理和依赖树精简模式,请加载
references/secrets-and-containers.md

Testing Strategy

测试策略

Run tests at every level after each upgrade:
bash
undefined
每次升级后,在所有层级运行测试:
bash
undefined

1. 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
fi
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 "升级失败,正在回滚"
  git checkout main
  git branch -D upgrade/<package>
  bun install
fi

Upgrade 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 production
markdown
升级前:
- [ ] 审核当前依赖项版本
- [ ] 阅读变更日志中的破坏性变更
- [ ] 创建功能分支
- [ ] 标记当前状态(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
    npm update
    or
    npm-check-updates -u
    without review
  • 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
    @latest
    , bare
    npx
    packages, or unpinned local source paths
  • 一次性升级所有依赖项(应使用增量升级)
  • 未经审核盲目运行
    npm update
    npm-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 FileWhen
references/cooldown-config-guide.md
Configuring cooldown for a specific PM, CI tool integration, or exclusion patterns
references/package-manager-security.md
Full per-PM hardening guide including pnpm trust policy, blockExoticSubdeps, cross-PM cheat sheet
references/supply-chain-security.md
Understanding attack vectors, incident history, npq vs sfw vs Socket CLI comparison, publisher security (2FA, provenance, OIDC)
references/secrets-and-containers.md
Setting up dev containers, secrets management with 1Password/Infisical
references/socket-cli-guide.md
Using Socket CLI for scans, fixes, package scoring, CI integration, wrapper mode, alert categories
references/compatibility-matrix.md
Checking version compatibility for React, Next.js, TypeScript, Tailwind upgrades
references/staged-upgrades.md
Codemod automation, custom migration scripts, peer dependency handling, workspace upgrades
references/testing-strategy.md
Full testing pyramid, CI integration, bundle analysis, performance testing
references/sap-dependency-risk-matrix.md
SAP stack-specific dependency review across Node, Java, Python, containers, BTP/CF/mbt, ABAP/gCTS, and MCP
references/sap-mcp-security.md
SAP MCP exact-pin policy, SAC source-install policy, and MCP update workflow
references/sap-mcp-inventory.json
Machine-readable approved SAP MCP package/source pins used by
npm run validate:mcp-security
当用户需要SKILL.md快速参考之外的详细信息时,加载以下参考文件:
加载文件适用场景
references/cooldown-config-guide.md
为特定包管理器配置冷却期、CI工具集成或排除模式
references/package-manager-security.md
完整的包管理器加固指南,包括pnpm信任策略、blockExoticSubdeps、跨包管理器速查表
references/supply-chain-security.md
了解攻击载体、事件历史、npq vs sfw vs Socket CLI对比、发布者安全(双因素认证、来源证明、OIDC)
references/secrets-and-containers.md
设置开发容器、使用1Password/Infisical进行密钥管理
references/socket-cli-guide.md
使用Socket CLI进行扫描、修复、包评分、CI集成、包装器模式、警报类别
references/compatibility-matrix.md
检查React、Next.js、TypeScript、Tailwind升级的版本兼容性
references/staged-upgrades.md
代码转换自动化、自定义迁移脚本、对等依赖项处理、工作区升级
references/testing-strategy.md
完整的测试金字塔、CI集成、包分析、性能测试
references/sap-dependency-risk-matrix.md
SAP栈特定的依赖项审核,涵盖Node、Java、Python、容器、BTP/CF/mbt、ABAP/gCTS和MCP
references/sap-mcp-security.md
SAP MCP精确版本固定策略、SAC源安装策略和MCP更新工作流
references/sap-mcp-inventory.json
机器可读的已批准SAP MCP包/源固定列表,供
npm run validate:mcp-security
使用

Template Files

模板文件

Ready-to-use config files in
templates/
:
TemplatePurpose
npmrc-security.tmpl
Secure
.npmrc
with scripts disabled + cooldown
bunfig-security.tmpl
Secure
bunfig.toml
with cooldown + exclusions
pnpm-workspace-security.tmpl
Secure
pnpm-workspace.yaml
with cooldown, allowBuilds, trustPolicy
yarnrc-security.tmpl
Secure
.yarnrc.yml
with age gate + preapproved packages
dependabot-security.tmpl
Dependabot config with 7-day cooldown
renovate-security.tmpl
Renovate config with minimumReleaseAge + automerge rules
devcontainer-security.tmpl
Hardened dev container with security options
socket-fix-ci.tmpl
GitHub Actions: Socket Fix autopilot with cooldown-aligned CVE remediation
socket-scan-ci.tmpl
GitHub Actions: Socket CI security gate for every push/PR
sap-mcp-config.tmpl
Review-ready SAP MCP config candidate with exact-pin checklist
maven-security.tmpl
Maven checksum/enforcer/dependency scan fragment for SAP Java projects
gradle-security.tmpl
Gradle dependency locking and verification fragment
python-security.tmpl
Python lock/audit workflow for SAP AI SDK, HANA ML, and data tooling
container-trivy.tmpl
Container image scan workflow with Trivy and digest-pin reminders
btp-cf-mbt-review.tmpl
BTP, Cloud Foundry, and MBT dependency/deployment review checklist
abap-gcts-review.tmpl
ABAP, gCTS, and transport dependency review checklist
templates/
目录下的即用型配置文件:
模板用途
npmrc-security.tmpl
带脚本禁用+冷却期的安全
.npmrc
bunfig-security.tmpl
带冷却期+排除项的安全
bunfig.toml
pnpm-workspace-security.tmpl
带冷却期、allowBuilds、trustPolicy的安全
pnpm-workspace.yaml
yarnrc-security.tmpl
带年龄限制+预批准包的安全
.yarnrc.yml
dependabot-security.tmpl
带7天冷却期的Dependabot配置
renovate-security.tmpl
带minimumReleaseAge+自动合并规则的Renovate配置
devcontainer-security.tmpl
带安全选项的加固开发容器
socket-fix-ci.tmpl
GitHub Actions:Socket Fix自动驾驶模式,对齐冷却期的CVE修复
socket-scan-ci.tmpl
GitHub Actions:每次推送/PR的Socket CI安全门
sap-mcp-config.tmpl
带精确版本固定检查清单的SAP MCP候选配置
maven-security.tmpl
SAP Java项目的Maven校验和/强制执行/依赖扫描片段
gradle-security.tmpl
Gradle依赖项锁定和验证片段
python-security.tmpl
SAP AI SDK、HANA ML和数据工具的Python锁定/审核工作流
container-trivy.tmpl
带Trivy的容器镜像扫描工作流和摘要固定提醒
btp-cf-mbt-review.tmpl
BTP、Cloud Foundry和MBT依赖项/部署审核检查清单
abap-gcts-review.tmpl
ABAP、gCTS和传输依赖项审核检查清单