Communitygithub.com

YepAPI/技能:依赖安全

依赖安全性——npm审计、锁文件验证、供应链攻击防御。

技能:依赖安全 是什么?

该技能专注于保障 JavaScript/Node.js 项目的依赖安全性。它通过强制在 CI 中运行 `npm audit` 来修复高危漏洞,并使用 `lockfile-lint` 验证所有包均来自官方 npm 注册表,从而防止供应链攻击。技能还建议在 `package.json` 中指定主版本范围(如 `^`),避免使用 `*` 或 `latest`,并提倡在安装前审查新依赖的下载量、发布时间和维护者数量。支持的平台包括 GitHub Actions、Snyk、Socket.dev 和 Dependabot,以实现实时漏洞警报。此外,技能强调定期更新依赖(建议每周一次),以防止已知漏洞累积,并警告避免信任未经审查的 `postinstall` 脚本或热门包(如 `event-stream` 案例)。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/dependency-security

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

依赖安全性

规则

  • 在 CI 中运行 npm audit —— 在高危/严重漏洞时构建失败
  • 使用 lockfile-lint 验证所有包均解析至官方 npm 注册表
  • 在 package.json 中锁定主版本:使用 ^ 进行次要版本更新,绝不使用 * 或 latest
  • 安装新依赖前进行审查:检查 npm 下载量、最后发布日期、维护者数量
  • 使用 npm ls --all 审计传递性依赖 —— 你的直接依赖会拉入数百个更多依赖
  • 配置 Snyk、Socket.dev 或 GitHub Dependabot 以获取实时漏洞警报
  • 每周更新依赖 —— 过时的依赖会累积已知漏洞
# GitHub Actions —— 在 CI 中审计
- name: 审计依赖
  run: npm audit --audit-level=high

- name: 验证锁文件完整性
  run: npx lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https
// package.json —— 锁定主版本
{
  "dependencies": {
    "next": "^14.0.0",
    "react": "^18.0.0",
    "zod": "^3.0.0"
  }
}

应避免的行为

  • 未经检查直接 npm install random-package —— 域名仿冒攻击真实存在
  • 忽略 npm audit 警告 —— 已知漏洞是最简单的攻击向量
  • 使用 * 或 latest 作为版本范围 —— 被攻陷的发布会立刻影响你的构建
  • 未经审查运行来自不可信包的 postinstall 脚本
  • 假设热门包是安全的 —— 即使是 event-stream(数百万次下载)也曾被攻陷

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

相关技能