proof-of-commitment 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +261 -58
- package/index.js +137 -5
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -1,66 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Proof of Commitment
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://getcommit.dev/audit?packages=proof-of-commitment)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
npx proof-of-commitment axios zod chalk
|
|
7
|
-
```
|
|
5
|
+
> **Stars lie. Behavioral signals don't.**
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
──────────────────────────────────────────────────────────────────────────
|
|
11
|
-
Package Risk Score Publishers Downloads Age
|
|
12
|
-
──────────────────────────────────────────────────────────────────────────
|
|
13
|
-
axios 🔴 CRITICAL 89 1 102.0M/wk 11.6y
|
|
14
|
-
↳ 30+ GitHub contributors — publish-access concentration risk despite active community
|
|
15
|
-
└ longevity=25 momentum=25 releases=20 publishers=4 github=15
|
|
16
|
-
zod 🔴 CRITICAL 83 1 154.0M/wk 6.1y
|
|
17
|
-
↳ 30+ GitHub contributors — publish-access concentration risk despite active community
|
|
18
|
-
└ longevity=25 momentum=25 releases=18 publishers=4 github=11
|
|
19
|
-
chalk 🔴 CRITICAL 75 1 414.6M/wk 12.7y
|
|
20
|
-
↳ 30+ GitHub contributors — publish-access concentration risk despite active community
|
|
21
|
-
└ longevity=25 momentum=22 releases=13 publishers=4 github=11
|
|
22
|
-
──────────────────────────────────────────────────────────────────────────
|
|
23
|
-
|
|
24
|
-
⚠ 3 CRITICAL packages found.
|
|
25
|
-
CRITICAL = sole npm publisher + >10M weekly downloads (publish-access concentration risk)
|
|
26
|
-
Full breakdown: https://getcommit.dev/audit?packages=axios,zod,chalk
|
|
27
|
-
```
|
|
7
|
+
An MCP server and web tool that scores npm packages, PyPI packages, Rust crates, and GitHub repos on **behavioral commitment** — signals that are harder to fake than stars, READMEs, or download counts.
|
|
28
8
|
|
|
29
|
-
##
|
|
9
|
+
## The supply chain problem
|
|
30
10
|
|
|
31
|
-
|
|
11
|
+
26 of the 91 npm packages with >10M weekly downloads have a **single npm publisher**. Together they account for over 3 billion downloads per week. `npm audit` doesn't surface this. Stars don't either.
|
|
32
12
|
|
|
33
|
-
|
|
13
|
+
Four packages in a typical Node.js project are CRITICAL right now:
|
|
14
|
+
- **chalk** — 413M downloads/week, **1 npm publisher**
|
|
15
|
+
- **zod** — 163M downloads/week, **1 npm publisher** (30+ GitHub contributors)
|
|
16
|
+
- **lodash** — 145M downloads/week, **1 npm publisher**
|
|
17
|
+
- **axios** — 99M downloads/week, **1 npm publisher** (attacked March 30, 2026)
|
|
34
18
|
|
|
35
|
-
|
|
36
|
-
- **
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
- **Publisher Depth** (15 pts) — npm publish-access holders
|
|
40
|
-
- **GitHub Backing** (15 pts) — organization/team support
|
|
19
|
+
They won't appear in your `package.json` either — but these are in almost every project:
|
|
20
|
+
- **minimatch** — 562M downloads/week, **1 npm publisher**
|
|
21
|
+
- **glob** — 333M downloads/week, **1 npm publisher**
|
|
22
|
+
- **cross-spawn** — 190M downloads/week, **1 npm publisher**
|
|
41
23
|
|
|
42
|
-
|
|
24
|
+
Behavioral signals surface this. Stars and READMEs don't.
|
|
43
25
|
|
|
44
|
-
##
|
|
26
|
+
## Try it now
|
|
45
27
|
|
|
28
|
+
**Terminal (zero install):**
|
|
46
29
|
```bash
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# Score PyPI packages
|
|
51
|
-
npx proof-of-commitment --pypi litellm langchain requests numpy
|
|
52
|
-
|
|
53
|
-
# Auto-detect from package.json or requirements.txt
|
|
30
|
+
npx proof-of-commitment axios zod chalk
|
|
31
|
+
# scan your own project:
|
|
54
32
|
npx proof-of-commitment --file package.json
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
#
|
|
58
|
-
npx
|
|
33
|
+
# scan ALL transitive dependencies via lock file (finds the hidden CRITICAL packages):
|
|
34
|
+
npx proof-of-commitment --file package-lock.json # npm
|
|
35
|
+
npx proof-of-commitment --file yarn.lock # yarn
|
|
36
|
+
npx proof-of-commitment --file pnpm-lock.yaml # pnpm
|
|
37
|
+
# pnpm monorepo — scans all workspace packages, deduplicates:
|
|
38
|
+
npx proof-of-commitment --file pnpm-workspace.yaml # pnpm workspaces
|
|
39
|
+
# JSON output for CI/CD pipelines (exits 1 if CRITICAL found):
|
|
40
|
+
npx proof-of-commitment --file package-lock.json --json | jq '.criticalCount'
|
|
41
|
+
# PyPI too:
|
|
42
|
+
npx proof-of-commitment --pypi litellm langchain requests
|
|
43
|
+
# Cargo (Rust) via API:
|
|
44
|
+
curl -s https://poc-backend.amdal-dev.workers.dev/api/audit \
|
|
45
|
+
-X POST -H "Content-Type: application/json" \
|
|
46
|
+
-d '{"packages":["serde","tokio","reqwest"],"ecosystem":"cargo"}'
|
|
59
47
|
```
|
|
60
48
|
|
|
61
|
-
|
|
49
|
+
**Web demo (no install):** [getcommit.dev/audit](https://getcommit.dev/audit) — paste your packages, see risk scores in seconds.
|
|
50
|
+
|
|
51
|
+
**MCP server (zero install):**
|
|
62
52
|
|
|
63
|
-
Add to your AI tool's config:
|
|
64
53
|
```json
|
|
65
54
|
{
|
|
66
55
|
"mcpServers": {
|
|
@@ -72,20 +61,234 @@ Add to your AI tool's config:
|
|
|
72
61
|
}
|
|
73
62
|
```
|
|
74
63
|
|
|
75
|
-
|
|
64
|
+
Add to Claude Desktop, Cursor, Windsurf, or any MCP-compatible AI tool. Then ask:
|
|
65
|
+
|
|
66
|
+
> "Audit my package.json for supply chain risk"
|
|
67
|
+
> "Score axios, zod, chalk, lodash — which is highest risk?"
|
|
68
|
+
> "Is vercel/ai actively maintained?"
|
|
76
69
|
|
|
77
70
|
## GitHub Action
|
|
78
71
|
|
|
79
|
-
|
|
72
|
+
Add supply chain auditing to any CI pipeline in 30 seconds — auto-detects packages from `package.json` or `requirements.txt`, **posts results as a PR comment**, writes to GitHub Step Summary, and optionally fails on CRITICAL packages.
|
|
73
|
+
|
|
74
|
+
Use the dedicated action at [piiiico/commit-action](https://github.com/piiiico/commit-action):
|
|
75
|
+
|
|
80
76
|
```yaml
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
# .github/workflows/supply-chain.yml
|
|
78
|
+
name: Supply Chain Audit
|
|
79
|
+
on:
|
|
80
|
+
pull_request:
|
|
81
|
+
paths: ['package.json', 'package-lock.json', 'bun.lock']
|
|
82
|
+
|
|
83
|
+
jobs:
|
|
84
|
+
audit:
|
|
85
|
+
runs-on: ubuntu-latest
|
|
86
|
+
permissions:
|
|
87
|
+
pull-requests: write
|
|
88
|
+
steps:
|
|
89
|
+
- uses: actions/checkout@v4
|
|
90
|
+
- uses: piiiico/commit-action@v1
|
|
91
|
+
with:
|
|
92
|
+
fail-on-critical: true # blocks merges on CRITICAL packages
|
|
93
|
+
comment-on-pr: true # posts results as a PR comment
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
When `comment-on-pr: true` (default), the action automatically posts the audit table as a comment on the pull request — and **updates the same comment** on re-run, so you don't get comment spam. Reviewers see the risk table without leaving the PR.
|
|
97
|
+
|
|
98
|
+
**Inputs:**
|
|
99
|
+
|
|
100
|
+
| Input | Default | Description |
|
|
101
|
+
|-------|---------|-------------|
|
|
102
|
+
| `packages` | _(auto)_ | Comma-separated package names (auto-detected from `package.json`/`requirements.txt` if not set) |
|
|
103
|
+
| `packages-file` | _(auto)_ | Path to `package.json` or `requirements.txt` (default: auto-detect in workspace root) |
|
|
104
|
+
| `fail-on-critical` | `true` | Fail the workflow if CRITICAL packages are found |
|
|
105
|
+
| `max-packages` | `20` | Max packages to audit when auto-detecting |
|
|
106
|
+
| `include-dev-dependencies` | `false` | Include `devDependencies` from `package.json` |
|
|
107
|
+
| `comment-on-pr` | `true` | Post audit results as a PR comment (requires `pull-requests: write` permission) |
|
|
108
|
+
| `api-key` | _(none)_ | [Commit Pro](https://getcommit.dev/pricing) API key — enables batch requests and 10K requests/month |
|
|
109
|
+
| `api-url` | _(prod)_ | Override API endpoint (useful for self-hosting) |
|
|
110
|
+
|
|
111
|
+
**Outputs:** `has-critical`, `critical-count`, `audit-summary` (markdown table, also written to Step Summary).
|
|
112
|
+
|
|
113
|
+
**Free vs Pro:** Without an API key, packages are audited one at a time (with delays to respect rate limits). With a Pro API key, all packages are audited in a single batch request — faster and with higher monthly limits.
|
|
114
|
+
|
|
115
|
+
Example PR comment / Step Summary output:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
| Package | Risk | Score | Publishers | Downloads/wk | Age |
|
|
119
|
+
|---------|-------------|-------|------------|--------------|-------|
|
|
120
|
+
| chalk | 🔴 CRITICAL | 75 | 1 | 380M | 12.7y |
|
|
121
|
+
| zod | 🔴 CRITICAL | 83 | 1 | 133M | 6.1y |
|
|
122
|
+
| axios | 🔴 CRITICAL | 89 | 1 | 93M | 11.6y |
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## README Badges
|
|
126
|
+
|
|
127
|
+
Add a Commit Trust badge to any npm package you maintain or depend on:
|
|
128
|
+
|
|
129
|
+
```markdown
|
|
130
|
+

|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Examples:
|
|
134
|
+
|
|
135
|
+
| Package | Badge URL |
|
|
136
|
+
|---------|-----------|
|
|
137
|
+
| chalk | `` |
|
|
138
|
+
| react | `` |
|
|
139
|
+
| express | `` |
|
|
140
|
+
| @babel/core | `` |
|
|
141
|
+
|
|
142
|
+
Grades: 🟢 OK (75+) · 🟠 WARNING (40–74) · 🔴 CRITICAL (<40 or sole npm publisher with 10M+ weekly downloads)
|
|
143
|
+
|
|
144
|
+
Badges are cached 1 hour. No API key needed.
|
|
145
|
+
|
|
146
|
+
Also supports PyPI, Cargo, and the full ecosystem-specific format:
|
|
147
|
+
|
|
148
|
+
```markdown
|
|
149
|
+

|
|
150
|
+

|
|
151
|
+

|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## REST API
|
|
155
|
+
|
|
156
|
+
No API key. No install.
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
curl https://poc-backend.amdal-dev.workers.dev/api/audit \
|
|
160
|
+
-X POST \
|
|
161
|
+
-H "Content-Type: application/json" \
|
|
162
|
+
-d '{"packages": ["axios", "zod", "chalk", "lodash", "express"]}'
|
|
85
163
|
```
|
|
86
164
|
|
|
87
|
-
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"count": 5,
|
|
168
|
+
"results": [
|
|
169
|
+
{
|
|
170
|
+
"name": "chalk",
|
|
171
|
+
"ecosystem": "npm",
|
|
172
|
+
"score": 75,
|
|
173
|
+
"maintainers": 1,
|
|
174
|
+
"weeklyDownloads": 398397580,
|
|
175
|
+
"ageYears": 12.7,
|
|
176
|
+
"trend": "stable",
|
|
177
|
+
"riskFlags": ["CRITICAL"],
|
|
178
|
+
"scorecardScore": 3.6, // null if no GitHub repo
|
|
179
|
+
"hasDangerousWorkflow": false // null if no Scorecard data
|
|
180
|
+
},
|
|
181
|
+
...
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 8 MCP tools
|
|
187
|
+
|
|
188
|
+
| Tool | Description |
|
|
189
|
+
|------|-------------|
|
|
190
|
+
| `audit_dependencies` | Batch risk audit for up to 20 npm/PyPI/Cargo packages |
|
|
191
|
+
| `lookup_npm_package` | Single npm package behavioral profile |
|
|
192
|
+
| `lookup_pypi_package` | Single PyPI package behavioral profile |
|
|
193
|
+
| `lookup_cargo_crate` | Single Rust crate behavioral profile (crates.io) |
|
|
194
|
+
| `lookup_github_repo` | GitHub repo commitment score (longevity, commit frequency, contributor depth) |
|
|
195
|
+
| `lookup_business` | Norwegian business register — operating years, employees, financials |
|
|
196
|
+
| `lookup_business_by_org` | Same, by org number |
|
|
197
|
+
| `query_commitment` | Browser extension behavioral data (unique verified visitors, repeat rate) |
|
|
198
|
+
|
|
199
|
+
## What the score measures
|
|
200
|
+
|
|
201
|
+
Each package is scored 0–100 across:
|
|
202
|
+
|
|
203
|
+
- **Longevity** — How long has the package existed? Abandoned packages get reactivated for attacks.
|
|
204
|
+
- **Publisher depth** — Single npm publisher + millions of weekly downloads = the attack surface LiteLLM exploited. (Publisher = person with npm publish access, distinct from GitHub contributors.)
|
|
205
|
+
- **Release consistency** — Regular releases signal active oversight. Long gaps = vulnerability accumulation.
|
|
206
|
+
- **Download trend** — Growing packages attract more scrutiny (and attacks). Stable = lower profile.
|
|
207
|
+
- **OpenSSF Scorecard** — Process security (code review enforcement, branch protection, CI/CD safety). Separate from behavioral signals. High Scorecard ≠ safe from credential theft attacks.
|
|
208
|
+
|
|
209
|
+
> Both axios (8.1/10 Scorecard) and chalk (3.6/10 Scorecard) score CRITICAL on behavioral signals. They measure different attack surfaces — Scorecard catches process gaps, behavioral signals catch publisher concentration.
|
|
210
|
+
|
|
211
|
+
**Risk flags:**
|
|
212
|
+
- `CRITICAL` — single npm publisher + >10M weekly downloads (exact LiteLLM/axios attack profile)
|
|
213
|
+
- `HIGH` — package <1yr old + rapid adoption
|
|
214
|
+
- `WARN` — no release in 12+ months
|
|
215
|
+
|
|
216
|
+
## Real data points
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
# packages you know about:
|
|
220
|
+
chalk — score 75, 1 publisher, 413M/week ⚑ CRITICAL
|
|
221
|
+
zod — score 86, 1 publisher, 163M/week ⚑ CRITICAL (30+ GitHub contributors)
|
|
222
|
+
lodash — score 81, 1 publisher, 145M/week ⚑ CRITICAL
|
|
223
|
+
axios — score 86, 1 publisher, 99M/week ⚑ CRITICAL (attacked Mar 30 2026)
|
|
224
|
+
express — score 90, 5 publishers, 95M/week
|
|
225
|
+
|
|
226
|
+
# packages probably not in your package.json, definitely in your lock file:
|
|
227
|
+
minimatch — score 78, 1 publisher, 562M/week ⚑ CRITICAL
|
|
228
|
+
glob — score 80, 1 publisher, 333M/week ⚑ CRITICAL
|
|
229
|
+
cross-spawn — score 72, 1 publisher, 190M/week ⚑ CRITICAL
|
|
230
|
+
|
|
231
|
+
# post-attack:
|
|
232
|
+
litellm — score 74, 1 publisher ⚑ CRITICAL (supply chain attack Mar 2026)
|
|
233
|
+
|
|
234
|
+
# Rust crates (new in v1.3.0):
|
|
235
|
+
serde — score 78, 1 owner, 13M/week ⚑ CRITICAL (dtolnay sole owner)
|
|
236
|
+
tokio — score 89, 2 owners, 10M/week
|
|
237
|
+
reqwest — score 85, 1 owner, 8M/week ⚑ HIGH
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Why behavioral signals
|
|
241
|
+
|
|
242
|
+
The LiteLLM attack (March 2026) and axios attack (March 30, 2026) followed the same pattern: stolen credentials → malicious package pushed → 97M+ machines exposed. Both packages scored CRITICAL by these metrics *before* the attacks.
|
|
88
243
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
244
|
+
Declarative signals (stars, README quality, CI badges) don't capture this risk. Behavioral commitment does.
|
|
245
|
+
|
|
246
|
+
## Stack
|
|
247
|
+
|
|
248
|
+
| Layer | Technology |
|
|
249
|
+
|-------|-----------|
|
|
250
|
+
| Backend | Cloudflare Workers + D1 |
|
|
251
|
+
| MCP | Model Context Protocol SDK |
|
|
252
|
+
| Data | npm registry, PyPI, crates.io, GitHub API, Brønnøysund (NO) |
|
|
253
|
+
| Landing | Astro + Cloudflare Pages |
|
|
254
|
+
|
|
255
|
+
## Roadmap
|
|
256
|
+
|
|
257
|
+
Planned, not promised. The project is early-stage — contributions welcome on any of these.
|
|
258
|
+
|
|
259
|
+
| Feature | Status | Notes |
|
|
260
|
+
|---------|--------|-------|
|
|
261
|
+
| **Cargo (Rust) registry support** | ✅ Live | MCP tool, REST API, badge endpoint — `ecosystem: "cargo"` |
|
|
262
|
+
| **Go modules support** | Planned | pkg.go.dev API + GitHub backing score |
|
|
263
|
+
| **Score breakdown visualization** | Planned | Chart component for the 5 dimensions on getcommit.dev/audit |
|
|
264
|
+
| **`--json` flag for CLI** | ✅ Live | `npx proof-of-commitment --file package-lock.json --json \| jq '.criticalCount'` |
|
|
265
|
+
| **pnpm workspace monorepo support** | ✅ Live | `--file pnpm-workspace.yaml` or auto-detected from `pnpm-lock.yaml` |
|
|
266
|
+
| **Historical score tracking** | Planned | Trend charts — was this package getting riskier over time? |
|
|
267
|
+
| **Org-level dashboards** | Planned | Aggregate risk view across all repos in a GitHub org |
|
|
268
|
+
|
|
269
|
+
See [open issues](https://github.com/piiiico/proof-of-commitment/issues) for things you can help with today.
|
|
270
|
+
|
|
271
|
+
## The broader vision
|
|
272
|
+
|
|
273
|
+
Supply chain auditing is the first tool. The underlying primitive is a **commitment graph** — behavioral signals that replace content-based trust across any domain.
|
|
274
|
+
|
|
275
|
+
When content is free to fake (reviews, stars, READMEs), commitment becomes the signal. A publisher who has shipped 847 releases over 12 years is a different kind of commitment than one who published once in 2023.
|
|
276
|
+
|
|
277
|
+
The same logic applies to websites, businesses, and AI agents. Two card networks have independently named this gap: Mastercard Verifiable Intent §9.2 explicitly lists behavioral trust as "not covered." Visa TAP identifies agents without answering whether to trust them.
|
|
278
|
+
|
|
279
|
+
Proof of Commitment is the trust layer they're pointing at.
|
|
280
|
+
|
|
281
|
+
→ [getcommit.dev](https://getcommit.dev)
|
|
282
|
+
|
|
283
|
+
## Run locally
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
bun install
|
|
287
|
+
bun run dev:backend # local server with SQLite
|
|
288
|
+
bun run test:e2e # E2E test with mock World ID
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Deploy:
|
|
292
|
+
```bash
|
|
293
|
+
bun run deploy # deploys to Cloudflare Workers
|
|
294
|
+
```
|
package/index.js
CHANGED
|
@@ -144,12 +144,13 @@ ${clr(c.bold, 'Usage:')}
|
|
|
144
144
|
npx proof-of-commitment --file package-lock.json Audit ALL dependencies (lock file)
|
|
145
145
|
npx proof-of-commitment --file yarn.lock Audit from yarn lock file
|
|
146
146
|
npx proof-of-commitment --file pnpm-lock.yaml Audit from pnpm lock file
|
|
147
|
+
npx proof-of-commitment --file pnpm-workspace.yaml Audit entire pnpm monorepo
|
|
147
148
|
npx proof-of-commitment --file requirements.txt Audit Python packages
|
|
148
149
|
|
|
149
150
|
${clr(c.bold, 'Options:')}
|
|
150
151
|
--json Output results as JSON (exits 1 if any CRITICAL found — useful in CI)
|
|
151
152
|
--pypi Score PyPI packages instead of npm
|
|
152
|
-
--file, -f Read packages from package.json, lock file, or requirements.txt
|
|
153
|
+
--file, -f Read packages from package.json, lock file, pnpm-workspace.yaml, or requirements.txt
|
|
153
154
|
|
|
154
155
|
${clr(c.bold, 'Examples:')}
|
|
155
156
|
npx proof-of-commitment axios zod chalk
|
|
@@ -229,12 +230,124 @@ function parseLockPnpm(content) {
|
|
|
229
230
|
return [...pkgs];
|
|
230
231
|
}
|
|
231
232
|
|
|
232
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Parse pnpm-workspace.yaml and resolve all workspace package dependencies.
|
|
235
|
+
* Reads package.json from each workspace, merges deps, deduplicates.
|
|
236
|
+
* Internal workspace packages are excluded from the audit list.
|
|
237
|
+
*/
|
|
238
|
+
async function parsePnpmWorkspace(filePath) {
|
|
233
239
|
const fs = await import('fs');
|
|
234
240
|
const path = await import('path');
|
|
235
241
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
242
|
+
const dir = path.dirname(path.resolve(filePath));
|
|
243
|
+
|
|
244
|
+
// Parse packages list from YAML
|
|
245
|
+
// Format: "packages:\n - 'apps/*'\n - 'packages/*'"
|
|
246
|
+
const patterns = [];
|
|
247
|
+
const lines = content.split('\n');
|
|
248
|
+
let inPackages = false;
|
|
249
|
+
for (const line of lines) {
|
|
250
|
+
if (/^packages\s*:/.test(line)) { inPackages = true; continue; }
|
|
251
|
+
if (inPackages) {
|
|
252
|
+
if (/^\s+-/.test(line)) {
|
|
253
|
+
const pattern = line.replace(/^\s+-\s*/, '').replace(/['"]/g, '').trim();
|
|
254
|
+
if (pattern) patterns.push(pattern);
|
|
255
|
+
} else if (/^\S/.test(line) && line.trim()) {
|
|
256
|
+
inPackages = false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (patterns.length === 0) {
|
|
262
|
+
throw new Error('No workspace packages found in pnpm-workspace.yaml');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Split into includes and excludes
|
|
266
|
+
const excludes = patterns.filter(p => p.startsWith('!')).map(p => p.slice(1));
|
|
267
|
+
const includes = patterns.filter(p => !p.startsWith('!'));
|
|
268
|
+
|
|
269
|
+
// Resolve patterns to directories containing package.json
|
|
270
|
+
const workspaceDirs = [];
|
|
271
|
+
for (const pattern of includes) {
|
|
272
|
+
if (pattern.endsWith('/*') || pattern.endsWith('/**')) {
|
|
273
|
+
// Glob: 'apps/*' -> list all subdirectories of apps/
|
|
274
|
+
const parentDir = path.join(dir, pattern.replace(/\/\*\*?$/, ''));
|
|
275
|
+
try {
|
|
276
|
+
const entries = fs.readdirSync(parentDir, { withFileTypes: true });
|
|
277
|
+
for (const entry of entries) {
|
|
278
|
+
if (entry.isDirectory()) {
|
|
279
|
+
const fullPath = path.join(parentDir, entry.name);
|
|
280
|
+
const isExcluded = excludes.some(ex => fullPath.includes(ex) || entry.name === ex);
|
|
281
|
+
if (!isExcluded) workspaceDirs.push(fullPath);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
} catch { /* directory doesn't exist — skip */ }
|
|
285
|
+
} else {
|
|
286
|
+
// Direct path: 'packages/shared'
|
|
287
|
+
const fullPath = path.join(dir, pattern);
|
|
288
|
+
try {
|
|
289
|
+
fs.statSync(fullPath);
|
|
290
|
+
workspaceDirs.push(fullPath);
|
|
291
|
+
} catch { /* doesn't exist — skip */ }
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Collect workspace package names (to exclude from audit — they're internal)
|
|
296
|
+
const workspacePackageNames = new Set();
|
|
297
|
+
for (const wsDir of workspaceDirs) {
|
|
298
|
+
try {
|
|
299
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(wsDir, 'package.json'), 'utf-8'));
|
|
300
|
+
if (pkg.name) workspacePackageNames.add(pkg.name);
|
|
301
|
+
} catch { /* no package.json — skip */ }
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Read root package.json + all workspace package.json files, merge deps
|
|
305
|
+
const allDeps = new Set();
|
|
306
|
+
let workspaceCount = 0;
|
|
307
|
+
|
|
308
|
+
// Root
|
|
309
|
+
try {
|
|
310
|
+
const rootPkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
|
|
311
|
+
if (rootPkg.dependencies) Object.keys(rootPkg.dependencies).forEach(d => allDeps.add(d));
|
|
312
|
+
if (rootPkg.devDependencies) Object.keys(rootPkg.devDependencies).forEach(d => allDeps.add(d));
|
|
313
|
+
} catch { /* no root package.json */ }
|
|
314
|
+
|
|
315
|
+
// Workspaces
|
|
316
|
+
for (const wsDir of workspaceDirs) {
|
|
317
|
+
try {
|
|
318
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(wsDir, 'package.json'), 'utf-8'));
|
|
319
|
+
if (pkg.dependencies) Object.keys(pkg.dependencies).forEach(d => allDeps.add(d));
|
|
320
|
+
if (pkg.devDependencies) Object.keys(pkg.devDependencies).forEach(d => allDeps.add(d));
|
|
321
|
+
workspaceCount++;
|
|
322
|
+
} catch { /* no package.json in workspace dir */ }
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Remove internal workspace packages from audit list
|
|
326
|
+
for (const name of workspacePackageNames) {
|
|
327
|
+
allDeps.delete(name);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return {
|
|
331
|
+
packages: [...allDeps],
|
|
332
|
+
ecosystem: 'npm',
|
|
333
|
+
lockfile: false,
|
|
334
|
+
totalInFile: allDeps.size,
|
|
335
|
+
workspaceCount,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async function readPackagesFromFile(filePath) {
|
|
340
|
+
const fs = await import('fs');
|
|
341
|
+
const path = await import('path');
|
|
236
342
|
const basename = path.basename(filePath).toLowerCase();
|
|
237
343
|
|
|
344
|
+
// pnpm-workspace.yaml — monorepo workspace scanner
|
|
345
|
+
if (basename === 'pnpm-workspace.yaml' || basename === 'pnpm-workspace.yml') {
|
|
346
|
+
return parsePnpmWorkspace(filePath);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
350
|
+
|
|
238
351
|
// package-lock.json
|
|
239
352
|
if (basename === 'package-lock.json') {
|
|
240
353
|
const pkgs = parseLockNpm(content);
|
|
@@ -247,8 +360,20 @@ async function readPackagesFromFile(filePath) {
|
|
|
247
360
|
return { packages: pkgs, ecosystem: 'npm', lockfile: true, totalInFile: pkgs.length };
|
|
248
361
|
}
|
|
249
362
|
|
|
250
|
-
// pnpm-lock.yaml
|
|
363
|
+
// pnpm-lock.yaml — also check for workspace file to give better detection
|
|
251
364
|
if (basename === 'pnpm-lock.yaml' || basename === 'pnpm-lock.yml') {
|
|
365
|
+
const dir = path.dirname(path.resolve(filePath));
|
|
366
|
+
const workspaceFile = path.join(dir, 'pnpm-workspace.yaml');
|
|
367
|
+
let hasWorkspace = false;
|
|
368
|
+
try { fs.statSync(workspaceFile); hasWorkspace = true; } catch {}
|
|
369
|
+
|
|
370
|
+
if (hasWorkspace) {
|
|
371
|
+
// Monorepo detected — use workspace-aware parsing
|
|
372
|
+
const result = await parsePnpmWorkspace(workspaceFile);
|
|
373
|
+
result.monorepoDetected = true;
|
|
374
|
+
return result;
|
|
375
|
+
}
|
|
376
|
+
|
|
252
377
|
const pkgs = parseLockPnpm(content);
|
|
253
378
|
return { packages: pkgs, ecosystem: 'npm', lockfile: true, totalInFile: pkgs.length };
|
|
254
379
|
}
|
|
@@ -274,7 +399,7 @@ async function readPackagesFromFile(filePath) {
|
|
|
274
399
|
return { packages: pkgs, ecosystem: 'pypi', lockfile: false };
|
|
275
400
|
}
|
|
276
401
|
|
|
277
|
-
throw new Error(`Unsupported file: ${basename}. Supported: package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, requirements.txt`);
|
|
402
|
+
throw new Error(`Unsupported file: ${basename}. Supported: package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, pnpm-workspace.yaml, requirements.txt`);
|
|
278
403
|
}
|
|
279
404
|
|
|
280
405
|
/**
|
|
@@ -359,7 +484,14 @@ async function main() {
|
|
|
359
484
|
ecosystem = result.ecosystem;
|
|
360
485
|
isLockfile = result.lockfile || false;
|
|
361
486
|
totalInFile = result.totalInFile || packages.length;
|
|
362
|
-
if (
|
|
487
|
+
if (result.workspaceCount) {
|
|
488
|
+
if (!jsonOutput) console.log(clr(c.dim, `Monorepo: ${result.workspaceCount} workspace${result.workspaceCount > 1 ? 's' : ''} → ${totalInFile} unique external dependencies (${ecosystem})`));
|
|
489
|
+
if (result.monorepoDetected && !jsonOutput) {
|
|
490
|
+
console.log(clr(c.dim, ` (auto-detected pnpm-workspace.yaml next to ${filePath})`));
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
if (!jsonOutput) console.log(clr(c.dim, `Detected ${totalInFile} packages from ${filePath} (${ecosystem})`));
|
|
494
|
+
}
|
|
363
495
|
} catch (err) {
|
|
364
496
|
console.error(`Error reading ${filePath}: ${err.message}`);
|
|
365
497
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proof-of-commitment",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Supply chain risk scorer for npm and
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Supply chain risk scorer for npm, PyPI, and Cargo packages — behavioral signals that can't be faked",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"proof-of-commitment": "./index.js",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"security",
|
|
18
18
|
"npm",
|
|
19
19
|
"pypi",
|
|
20
|
+
"cargo",
|
|
21
|
+
"rust",
|
|
22
|
+
"pnpm",
|
|
23
|
+
"monorepo",
|
|
24
|
+
"workspace",
|
|
20
25
|
"dependencies",
|
|
21
26
|
"audit",
|
|
22
27
|
"risk",
|