@tiny-owl-kit/tiny-owl-npm-scan

中文文档
1.1.11发布于 2026/11/02MITTypeScriptCommonJS零依赖构建来源已验证

Scan your project's package.json for malicious packages from a CSV list

原始使用文档
文档目录29 节
  1. Features
  2. Installation
  3. Global installation (CLI usage)
  4. Local installation (programmatic usage)
  5. CLI Usage
  6. Quick scan with bundled malicious package list
  7. Scan with a custom local CSV file
  8. Scan with a custom remote CSV file
  9. Using npx (no installation required)
  10. Programmatic Usage
  11. API
  12. scanPackages(packageListSource?, options?)
  13. Utility Functions
  14. CSV Format
  15. Exit Codes
  16. Examples
  17. Quick security scan (recommended)
  18. Using with a custom GitHub URL
  19. Integration in CI/CD
  20. Custom scanning in Node.js
  21. Development
  22. Build
  23. Test
  24. Run tests in watch mode
  25. Coverage
  26. Contributing
  27. License
  28. Security
  29. Acknowledgments

@tiny-owl-kit/tiny-owl-npm-scan

npm version npm downloads License: MIT Node.js Version

🦉 Scan your project's package.json for malicious npm packages from a curated CSV list.

Features

  • ✅ Built-in malicious package database - Scans using a curated list by default
  • ✅ Scan both dependencies and devDependencies
  • 🌐 Support for custom CSV files (local or remote URLs)
  • 📦 Use as a CLI tool or programmatically in your code
  • 🚀 Fast and lightweight
  • 💯 TypeScript support

Installation

Global installation (CLI usage)

npm install -g @tiny-owl-kit/tiny-owl-npm-scan

Local installation (programmatic usage)

npm install --save-dev @tiny-owl-kit/tiny-owl-npm-scan

CLI Usage

Important: Run this command from the root directory of your project (where your package.json file is located).

cd path-to-your-project

Quick scan with bundled malicious package list

tiny-owl-npm-scan

The tool includes a curated list of known malicious npm packages. Simply run the command without arguments to scan your project.

Scan with a custom local CSV file

tiny-owl-npm-scan path/to/malicious-packages.csv

Scan with a custom remote CSV file

tiny-owl-npm-scan https://example.com/malicious-packages.csv

Using npx (no installation required)

# Scan with bundled list
npx @tiny-owl-kit/tiny-owl-npm-scan

# Scan with custom list
npx @tiny-owl-kit/tiny-owl-npm-scan path/to/malicious-packages.csv

Programmatic Usage

import { scanPackages } from "@tiny-owl-kit/tiny-owl-npm-scan";

// Scan with bundled malicious package list (recommended)
const result = await scanPackages();

console.log(`Found ${result.found.length} malicious packages:`);
result.found.forEach((pkg) => console.log(`- ${pkg}`));

// Scan with custom CSV file
const customResult = await scanPackages("path/to/malicious-packages.csv");

// Scan with custom options
const advancedResult = await scanPackages("https://example.com/list.csv", {
  packageJsonPath: "/path/to/package.json",
  includeDevDependencies: false,
});

API

scanPackages(packageListSource?, options?)

Main scanning function that checks if any packages from a malicious list are in your project.

Parameters

  • packageListSource (string, optional): Path to CSV file or URL. If not provided, uses the bundled malicious package list.
  • options (ScanOptions, optional):
    • packageJsonPath (string): Path to package.json file. Defaults to package.json in current working directory
    • includeDevDependencies (boolean): Whether to include devDependencies in scan. Defaults to true
    • csvParser (function): Custom CSV parser function

Returns

Promise<ScanResult>:

{
  found: string[];        // List of malicious packages found
  totalScanned: number;   // Total number of packages scanned
  packageJsonPath: string; // Path to package.json that was scanned
}

Utility Functions

getDefaultCsvPath(): string

Returns the path to the bundled malicious package list CSV file.

isUrl(str: string): boolean

Checks if a string is a valid URL.

fetchUrl(url: string): Promise<string>

Fetches content from a URL.

parsePackageListCsv(csvContent: string): string[]

Parses CSV content and extracts package names from the first column (skips header row).

readDependencies(packageJsonPath: string, includeDevDependencies?: boolean): Record<string, string>

Reads package.json and extracts dependencies.

CSV Format

The CSV file should have package names in the first column:

package_name,description,severity
malicious-pkg-1,Description of issue,high
malicious-pkg-2,Another issue,medium

The first row (header) is automatically skipped.

Exit Codes

When used as a CLI tool:

  • 0: No malicious packages found
  • 1: Malicious packages found or error occurred

Examples

# Use bundled malicious package list
tiny-owl-npm-scan

Using with a custom GitHub URL

tiny-owl-npm-scan https://raw.githubusercontent.com/org/repo/main/malicious-packages.csv

Integration in CI/CD

Add to your package.json scripts:

{
  "scripts": {
    "security:scan": "tiny-owl-npm-scan"
  }
}

Then run in your CI pipeline:

npm run security:scan

Custom scanning in Node.js

import { scanPackages, ScanResult } from "@tiny-owl-kit/tiny-owl-npm-scan";

async function auditProject() {
  // Use bundled list (recommended)
  const result: ScanResult = await scanPackages();

  if (result.found.length > 0) {
    console.error("Security Alert!");
    result.found.forEach((pkg) => {
      console.error(`Malicious package detected: ${pkg}`);
    });
    process.exit(1);
  }
}

auditProject();

Development

Build

npm run build

Test

npm test

Run tests in watch mode

npm run test:watch

Coverage

npm run test:coverage

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Security

If you discover a security vulnerability, please email [[email protected]].

Acknowledgments

Built with 🦉 by the Tiny Owl team.

版本与发布记录

@tiny-owl-kit/tiny-owl-npm-scan 共发布 12 个版本,首次发布于 2025/11/27;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.11latest2026/11/02今天
1.1.102026/10/268 天前
1.1.92026/10/1915 天前
1.1.82026/10/1221 天前
1.1.72026/10/0528 天前
1.1.62026/09/281 个月前

关于 @tiny-owl-kit/tiny-owl-npm-scan 的常见问题

@tiny-owl-kit/tiny-owl-npm-scan 是什么?

扫描项目的包。来自CSV列表的恶意包

如何安装 @tiny-owl-kit/tiny-owl-npm-scan?

在项目目录运行 npm install @tiny-owl-kit/tiny-owl-npm-scan,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 tiny-owl-npm-scan,可以用 npx tiny-owl-npm-scan 直接运行。

@tiny-owl-kit/tiny-owl-npm-scan 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@tiny-owl-kit/tiny-owl-npm-scan 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@tiny-owl-kit/tiny-owl-npm-scan 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@tiny-owl-kit/tiny-owl-npm-scan 可以商用吗?

@tiny-owl-kit/tiny-owl-npm-scan 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@tiny-owl-kit/tiny-owl-npm-scan 还在维护吗?

最新版本 1.1.11 发布于 2026/11/02(今天);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2025/11/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。