npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

npm-vuln-checker

v1.1.0

Published

A CLI tool to audit npm projects for vulnerable package versions

Readme

npm-checker

一个用于审计 npm 项目依赖漏洞的 CLI 工具。可以递归检查项目中的 package.json 文件,确定是否包含指定版本或低版本的某个包。

功能特性

  • 🔍 递归扫描目录中的所有 package.json 文件
  • 📋 支持策略文件(JSON 格式)定义漏洞规则
  • 🌐 支持从本地文件或 URL 加载策略文件
  • ✅ 检查 dependencies、devDependencies、peerDependencies、optionalDependencies
  • 🎯 精确的版本匹配和范围检查
  • 📊 友好的命令行输出和 JSON 格式输出
  • 🚫 自动排除 node_modules、.git 等目录

安装

npm install
npm run build

使用方法

基本用法

# 使用 npx 运行(推荐,无需全局安装)
npx npm-vuln-checker check -p policy.json

# 或者全局安装后使用
npm install -g npm-vuln-checker
npm-vuln-checker check -p policy.json

从 URL 加载策略文件

# 使用 npx 运行(无需全局安装)
npx npm-vuln-checker check -p https://raw.githubusercontent.com/v1xingyue/npm-checker/main/policy.json

# 或者使用 GitHub raw URL
npx npm-vuln-checker check -p https://raw.githubusercontent.com/v1xingyue/npm-checker/main/policy.json -d /path/to/project

指定扫描目录

npx npm-vuln-checker check -p policy.json -d /path/to/project

排除特定目录

npx npm-vuln-checker check -p policy.json -e vendor build

JSON 格式输出

npx npm-vuln-checker check -p policy.json --json

检查多个策略文件(支持混合使用本地文件和 URL)

npx npm-vuln-checker check-multiple -p policy1.json https://raw.githubusercontent.com/v1xingyue/npm-checker/main/policy.json

策略文件格式

策略文件是一个 JSON 文件,定义要检查的漏洞规则。可以从本地文件路径或 URL 加载。

支持两种格式:

单个策略对象

{
  "cve": "CVE-2025-66478",
  "cvss": 10.0,
  "description": "React Server Components 漏洞",
  "packages": [
    "react-server-dom-webpack",
    "react-server-dom-parcel",
    "react-server-dom-turbopack"
  ],
  "affectedVersions": [
    "19.0",
    "19.1.0",
    "19.1.1",
    "19.2.0"
  ],
  "fixedVersions": [
    "19.0.1",
    "19.1.2",
    "19.2.1"
  ]
}

策略数组(支持多个 CVE)

[
  {
    "cve": "CVE-2025-66478",
    "cvss": 10.0,
    "description": "React Server Components 漏洞",
    "packages": ["react-server-dom-webpack"],
    "affectedVersions": ["19.0", "19.1.0"],
    "fixedVersions": ["19.0.1", "19.1.2"]
  },
  {
    "cve": "CVE-2025-XXXXX",
    "cvss": 9.8,
    "description": "Next.js App Router 漏洞",
    "packages": ["next"],
    "affectedVersions": [">=15", ">=16"],
    "fixedVersions": ["16.0.7", "15.5.7"]
  }
]

字段说明

  • cve (可选): CVE 编号
  • cvss (可选): CVSS 评分
  • description (可选): 漏洞描述
  • packages (必需): 受影响的包名数组
  • affectedVersions (必需): 受影响的版本列表,支持:
    • 精确版本:"19.0.1"
    • 主版本:"19"
    • 主次版本:"19.0"
    • 版本范围:">=14.3.0-canary.77"
  • fixedVersions (必需): 已修复的版本列表

输出示例

审计结果
============================================================
CVE: CVE-2025-66478
CVSS 评分: 10

检查的包: react-server-dom-webpack, react-server-dom-parcel
受影响版本: 19.0, 19.1.0, 19.1.1, 19.2.0
已修复版本: 19.0.1, 19.1.2, 19.2.1

总计检查: 5 个依赖
发现漏洞: 2 个

漏洞详情:
------------------------------------------------------------

1. react-server-dom-webpack
   路径: /path/to/project/package.json
   当前版本: 19.0
   受影响版本: 19.0, 19.1.0, 19.1.1, 19.2.0
   建议升级到: 19.0.1
   CVE: CVE-2025-66478
   CVSS: 10

2. react-server-dom-parcel
   路径: /path/to/project/package.json
   当前版本: 19.1.0
   受影响版本: 19.0, 19.1.0, 19.1.1, 19.2.0
   建议升级到: 19.1.2
   CVE: CVE-2025-66478
   CVSS: 10

============================================================

退出码

  • 0: 未发现漏洞
  • 1: 发现漏洞或发生错误

开发

# 编译 TypeScript
npm run build

# 开发模式运行
npm run dev check -p policy.json

许可证

MIT