opmsec 0.1.4 → 0.1.51
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/.env.example +1 -1
- package/README.md +71 -275
- package/bun.lock +3 -3
- package/docs/architecture/agents.mdx +11 -59
- package/docs/architecture/benchmarks.mdx +20 -46
- package/docs/architecture/overview.mdx +31 -38
- package/docs/architecture/scanner.mdx +11 -37
- package/docs/cli/audit.mdx +9 -12
- package/docs/cli/check.mdx +12 -26
- package/docs/cli/fix.mdx +10 -30
- package/docs/cli/info.mdx +12 -19
- package/docs/cli/install.mdx +27 -39
- package/docs/cli/push.mdx +40 -57
- package/docs/cli/register-agent.mdx +21 -53
- package/docs/cli/view.mdx +12 -29
- package/docs/concepts/ens-records.mdx +44 -0
- package/docs/concepts/multi-agent-consensus.mdx +18 -36
- package/docs/concepts/on-chain-registry.mdx +22 -49
- package/docs/concepts/security-model.mdx +20 -52
- package/docs/concepts/zk-agent-verification.mdx +26 -64
- package/docs/contract/events.mdx +13 -74
- package/docs/contract/functions.mdx +40 -126
- package/docs/contract/overview.mdx +17 -36
- package/docs/introduction.mdx +22 -25
- package/docs/mint.json +1 -0
- package/docs/quickstart.mdx +34 -70
- package/docs/system-design.png +0 -0
- package/package.json +5 -5
- package/packages/cli/src/commands/audit.tsx +72 -5
- package/packages/cli/src/commands/author-view.tsx +87 -2
- package/packages/cli/src/commands/check.tsx +95 -14
- package/packages/cli/src/commands/fix.tsx +25 -12
- package/packages/cli/src/commands/info.tsx +92 -4
- package/packages/cli/src/commands/install.tsx +54 -8
- package/packages/cli/src/commands/push.tsx +151 -2
- package/packages/cli/src/commands/register-agent.tsx +72 -31
- package/packages/cli/src/index.tsx +4 -4
- package/packages/cli/src/services/dep-graph.ts +298 -0
- package/packages/cli/src/services/ens-records.ts +530 -0
- package/packages/cli/src/services/lockfile.ts +224 -0
- package/packages/cli/src/services/merkle.ts +52 -0
- package/packages/cli/src/services/osv.ts +50 -0
- package/packages/core/src/benchmarks.ts +116 -0
- package/packages/core/src/constants.ts +19 -6
- package/packages/core/src/model-rankings.ts +49 -16
- package/packages/core/src/types.ts +48 -0
- package/packages/core/src/utils.ts +21 -3
- package/packages/scanner/src/agents/base-agent.ts +22 -10
- package/packages/scanner/src/index.ts +2 -1
- package/packages/scanner/src/queue/memory-queue.ts +30 -11
- package/packages/scanner/src/services/benchmark-runner.ts +86 -1
- package/packages/scanner/src/services/fileverse.ts +61 -12
- package/packages/web/.next/BUILD_ID +1 -1
- package/packages/web/.next/app-build-manifest.json +7 -6
- package/packages/web/.next/build-manifest.json +7 -7
- package/packages/web/.next/images-manifest.json +1 -1
- package/packages/web/.next/prerender-manifest.json +7 -7
- package/packages/web/.next/required-server-files.json +2 -2
- package/packages/web/.next/server/app/_not-found/page.js +2 -2
- package/packages/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/packages/web/.next/server/app/_not-found.html +1 -1
- package/packages/web/.next/server/app/_not-found.rsc +4 -2
- package/packages/web/.next/server/app/index.html +6 -1
- package/packages/web/.next/server/app/index.rsc +5 -3
- package/packages/web/.next/server/app/page.js +8 -2
- package/packages/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/packages/web/.next/server/middleware-build-manifest.js +1 -1
- package/packages/web/.next/server/next-font-manifest.js +1 -1
- package/packages/web/.next/server/next-font-manifest.json +1 -1
- package/packages/web/.next/server/pages/404.html +1 -1
- package/packages/web/.next/server/pages/500.html +1 -1
- package/packages/web/.next/server/pages-manifest.json +1 -1
- package/packages/web/.next/static/chunks/174-5b5efcb3b8efcc01.js +1 -0
- package/packages/web/.next/static/chunks/app/layout-de8e841104500505.js +1 -0
- package/packages/web/.next/static/chunks/app/page-7d2a23ad744d529a.js +1 -0
- package/packages/web/.next/static/chunks/{main-ee293fa6aa18bdd1.js → main-4e8d71b5ef7ee7e3.js} +1 -1
- package/packages/web/.next/static/chunks/webpack-0dcd67569eb46132.js +1 -0
- package/packages/web/.next/static/css/102562cf2d0ae9b0.css +3 -0
- package/packages/web/.next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
- package/packages/web/.next/static/media/747892c23ea88013-s.woff2 +0 -0
- package/packages/web/.next/static/media/8d697b304b401681-s.woff2 +0 -0
- package/packages/web/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
- package/packages/web/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
- package/packages/web/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
- package/packages/web/.next/trace +2 -2
- package/packages/web/app/globals.css +197 -51
- package/packages/web/app/layout.tsx +6 -3
- package/packages/web/app/page.tsx +789 -312
- package/packages/web/bun.lock +66 -105
- package/packages/web/next.config.ts +8 -1
- package/packages/web/package.json +5 -2
- package/packages/web/postcss.config.mjs +2 -2
- package/packages/web/public/apple-icon.png +1 -0
- package/packages/web/public/dependency-bottleneck.png +0 -0
- package/packages/web/public/icon-dark-32x32.png +1 -0
- package/packages/web/public/icon-light-32x32.png +1 -0
- package/packages/web/public/icon.svg +1 -0
- package/packages/web/public/nextjs-cve-announcement.png +0 -0
- package/packages/web/public/phantomraven-npm-attack.png +0 -0
- package/packages/web/public/placeholder-logo.png +1 -0
- package/packages/web/public/placeholder-logo.svg +1 -0
- package/packages/web/public/placeholder-user.jpg +1 -0
- package/packages/web/public/placeholder.jpg +1 -0
- package/packages/web/public/placeholder.svg +1 -0
- package/packages/web/public/react-cve-meme.png +0 -0
- package/packages/web/public/wallet-drain-exploit.png +0 -0
- package/packages/web/styles/globals.css +125 -0
- package/packages/web/.next/static/chunks/app/layout-28a489fb4398663f.js +0 -1
- package/packages/web/.next/static/chunks/app/page-e58ccdb78625bce6.js +0 -1
- package/packages/web/.next/static/chunks/webpack-e1ae44446e7f7355.js +0 -1
- package/packages/web/.next/static/css/21d69157e271f2ab.css +0 -3
- package/packages/web/tailwind.config.ts +0 -48
- /package/packages/web/.next/static/{2XIFCTTKVZwN_RsNE-Rrr → jwpVFtQGO17b1LATsewLl}/_buildManifest.js +0 -0
- /package/packages/web/.next/static/{2XIFCTTKVZwN_RsNE-Rrr → jwpVFtQGO17b1LATsewLl}/_ssgManifest.js +0 -0
package/.env.example
CHANGED
|
@@ -21,4 +21,4 @@ FILEVERSE_API_KEY= # from ddocs.new → Settings → Developer
|
|
|
21
21
|
# ETH_SEPOLIA_RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
|
|
22
22
|
# FILEVERSE_API_URL=http://localhost:8001
|
|
23
23
|
# CHAINPATROL_API_KEY= # optional, for blocklist checks
|
|
24
|
-
# ARTIFICIAL_ANALYSIS_API_KEY= # optional, for model-weighted scoring
|
|
24
|
+
# ARTIFICIAL_ANALYSIS_API_KEY= # optional, for model-weighted scoring
|
package/README.md
CHANGED
|
@@ -2,347 +2,143 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/opmsec)
|
|
4
4
|
[](https://github.com/dhananjaypai08/opm)
|
|
5
|
-
[](https://sepolia.basescan.org/address/0x16684391fc9bf48246B08Afe16d1a57BFa181d48)
|
|
6
6
|
|
|
7
|
-
OPM is a
|
|
7
|
+
OPM is a drop-in npm replacement that adds **cryptographic signing**, **multi-agent AI security scanning**, **on-chain audit registries**, and **zero-knowledge agent verification** to the JavaScript supply chain.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Every package publish is scanned by 3 AI agents in parallel. Risk scores are submitted on-chain. Audit reports are stored encrypted on IPFS via Fileverse. Install-time checks verify signatures, query CVEs, and enforce risk thresholds — all from the terminal.
|
|
10
10
|
|
|
11
|
-
## System
|
|
11
|
+
## System Design
|
|
12
12
|
|
|
13
|
-
OPM
|
|
13
|
+

|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
OPM addresses the following attack surfaces:
|
|
18
|
-
|
|
19
|
-
- **Supply chain injection**: Malicious postinstall scripts, obfuscated payloads, environment variable exfiltration, and runtime code generation detected by AI agents.
|
|
20
|
-
- **Typosquatting**: Package names are compared against npm registry search results and download-count differentials. AI agents independently assess name similarity to known packages.
|
|
21
|
-
- **Dependency confusion**: Scoped versus unscoped name conflicts and internal package shadowing are surfaced during `opm check`.
|
|
22
|
-
- **Silent maintainer takeover**: Version history analysis detects sudden dependency graph mutations, new maintainer additions, and anomalous size deltas between releases.
|
|
23
|
-
- **Known vulnerability exploitation**: Real-time CVE and GHSA data from the Open Source Vulnerabilities (OSV) API is integrated into install-time blocking and upgrade recommendations, with CVSS v3 base score computation for severity classification.
|
|
24
|
-
- **Malicious / spamming agents**: Permissionless agent registration requires passing a 10-case benchmark suite with 100% accuracy, verified via zero-knowledge proofs, preventing unqualified agents from polluting the on-chain risk registry.
|
|
25
|
-
|
|
26
|
-
### Data Flow
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
opm push
|
|
30
|
-
|
|
|
31
|
-
+-- Compute SHA-256 checksum over packed tarball
|
|
32
|
-
+-- Sign checksum with author's Ethereum private key (ECDSA secp256k1)
|
|
33
|
-
+-- Resolve author ENS identity (Sepolia, Mainnet fallback)
|
|
34
|
-
+-- Dispatch 3+ AI agents in parallel (permissionless agents included)
|
|
35
|
-
| +-- Each agent: static analysis, risk scoring (0-100), structured JSON output
|
|
36
|
-
| +-- Agent wallets submit scores to OPMRegistry.submitScore()
|
|
37
|
-
| +-- Aggregate risk computed; publish blocked if score >= 80
|
|
38
|
-
| +-- BaseScan tx links shown for every score submission
|
|
39
|
-
+-- Upload formatted markdown report to Fileverse dDocs (encrypted, on-chain synced)
|
|
40
|
-
+-- Publish tarball to npm (automation token or OTP for 2FA)
|
|
41
|
-
+-- Register package metadata on OPMRegistry.registerPackage()
|
|
42
|
-
| +-- Stores: checksum, signature, ENS name, report URI
|
|
43
|
-
| +-- BaseScan tx link + contract link shown in terminal
|
|
44
|
-
+-- Set report URI on-chain via OPMRegistry.setReportURI()
|
|
45
|
-
|
|
46
|
-
opm register-agent --name <name> --model <model>
|
|
47
|
-
|
|
|
48
|
-
+-- Validate agent configuration and environment
|
|
49
|
-
+-- Generate ZK commitment over expected benchmark outputs
|
|
50
|
-
+-- Run candidate agent against 10 labeled security test cases
|
|
51
|
-
| +-- Categories: clean, typosquat, malicious, CVE, obfuscated, exfiltration, dependency confusion
|
|
52
|
-
| +-- Each case evaluated against expected risk level and score range
|
|
53
|
-
+-- Generate zero-knowledge proof of accuracy
|
|
54
|
-
| +-- Hash commitment scheme: hash(salt, expected) → commitment
|
|
55
|
-
| +-- Proof: hash(commitment, result_hash, accuracy_flag, salt)
|
|
56
|
-
| +-- Proves 100% accuracy without revealing test data or individual results
|
|
57
|
-
+-- Verify ZK proof integrity
|
|
58
|
-
+-- Register agent on OPMRegistry.registerAgent() if 100% accuracy
|
|
59
|
-
| +-- Stores: name, model, systemPromptHash, proofHash on-chain
|
|
60
|
-
| +-- Auto-authorizes agent for submitScore and setReportURI
|
|
61
|
-
+-- Show BaseScan tx link and contract link
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Prerequisites
|
|
65
|
-
|
|
66
|
-
- [Bun](https://bun.sh) >= 1.2
|
|
67
|
-
- Node.js >= 20
|
|
68
|
-
- Ethereum wallet funded with Base Sepolia ETH (required for gas during `opm push`)
|
|
69
|
-
|
|
70
|
-
## Installation
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
git clone https://github.com/dhananjaypai08/opm.git && cd opm
|
|
74
|
-
cp .env.example .env
|
|
75
|
-
bun install
|
|
76
|
-
bun link
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Or install from npm:
|
|
15
|
+
## Quick Start
|
|
80
16
|
|
|
81
17
|
```bash
|
|
18
|
+
# Install globally
|
|
82
19
|
npm i -g opmsec
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
The `bun link` command registers `opm` as a globally available CLI binary.
|
|
86
|
-
|
|
87
|
-
## Smart Contract Deployment
|
|
88
20
|
|
|
89
|
-
|
|
90
|
-
cd
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
npx hardhat run scripts/deploy.ts --network baseSepolia
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Record the deployed contract address and set it as `CONTRACT_ADDRESS` in `.env`, or rely on the default address hardcoded in `packages/core/src/constants.ts`.
|
|
97
|
-
|
|
98
|
-
The contract is live on Base Sepolia: [`0x16684391fc9bf48246B08Afe16d1a57BFa181d48`](https://sepolia.basescan.org/address/0x16684391fc9bf48246B08Afe16d1a57BFa181d48)
|
|
99
|
-
|
|
100
|
-
## Fileverse dDocs Configuration
|
|
101
|
-
|
|
102
|
-
OPM persists AI scan reports as encrypted, on-chain-synced documents via the Fileverse dDocs protocol.
|
|
103
|
-
|
|
104
|
-
1. Navigate to [ddocs.new](https://ddocs.new), open Settings, enable Developer Mode, and generate an API key.
|
|
105
|
-
2. Set `FILEVERSE_API_KEY` in `.env`.
|
|
106
|
-
3. Start the local Fileverse API server:
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
npx @fileverse/api --apiKey <YOUR_API_KEY>
|
|
21
|
+
# Or clone and link
|
|
22
|
+
git clone https://github.com/dhananjaypai08/opm.git && cd opm
|
|
23
|
+
cp .env.example .env
|
|
24
|
+
bun install && bun link
|
|
110
25
|
```
|
|
111
26
|
|
|
112
|
-
The server binds to `http://localhost:8001` by default. This is configurable via `FILEVERSE_API_URL`.
|
|
113
|
-
|
|
114
27
|
## Commands
|
|
115
28
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
| Command | Description |
|
|
29
|
+
| Command | What it does |
|
|
119
30
|
|---------|-------------|
|
|
120
|
-
| `opm push` | Sign, scan, publish to npm,
|
|
121
|
-
| `opm
|
|
122
|
-
| `opm
|
|
123
|
-
| `opm
|
|
124
|
-
| `opm
|
|
125
|
-
| `opm
|
|
126
|
-
| `opm
|
|
127
|
-
| `opm
|
|
128
|
-
| `opm info <pkg>` | Display on-chain security metadata for a specific package |
|
|
129
|
-
| `opm view <name.eth>` | Display ENS author profile, published packages, and reputation |
|
|
130
|
-
| `opm whois <name>` | ENS identity lookup (appends `.eth` if omitted) |
|
|
131
|
-
|
|
132
|
-
### Agent Commands
|
|
133
|
-
|
|
134
|
-
| Command | Description |
|
|
135
|
-
|---------|-------------|
|
|
136
|
-
| `opm register-agent --name <n> --model <m>` | Register a new security agent with ZK-verified benchmarks |
|
|
137
|
-
| `opm register-agent --system-prompt <p>` | Optional custom system prompt (defaults to OPM security auditor) |
|
|
31
|
+
| `opm push` | Sign, scan with 3 AI agents, publish to npm, register on-chain, write ENS records |
|
|
32
|
+
| `opm install <pkg>` | Verify signature, check CVEs, query on-chain risk, then install |
|
|
33
|
+
| `opm install` | Bulk scan all package.json deps with ENS resolution and auto-bumping |
|
|
34
|
+
| `opm check` | Scan deps for typosquats, CVEs, and AI-detected risks |
|
|
35
|
+
| `opm fix` | Auto-patch typosquats and upgrade vulnerable versions |
|
|
36
|
+
| `opm info <pkg>` | On-chain metadata, ENS records, audit report, CVEs |
|
|
37
|
+
| `opm view <name.eth>` | Author profile, reputation, published packages |
|
|
38
|
+
| `opm register-agent` | Onboard a new AI agent with ZK-verified benchmarks |
|
|
138
39
|
|
|
139
|
-
|
|
40
|
+
Standard npm commands (`init`, `run`, `test`, `build`, `start`, etc.) pass through transparently.
|
|
140
41
|
|
|
141
|
-
|
|
42
|
+
## How It Works
|
|
142
43
|
|
|
143
|
-
|
|
144
|
-
opm init opm run <script> opm test
|
|
145
|
-
opm start opm build opm uninstall <pkg>
|
|
146
|
-
opm outdated opm update opm list
|
|
147
|
-
opm link opm pack
|
|
148
|
-
```
|
|
44
|
+
### `opm push`
|
|
149
45
|
|
|
150
|
-
|
|
46
|
+
Pack tarball → SHA-256 checksum → ECDSA sign → resolve ENS → scan with 3 AI agents in parallel → weighted consensus → block if score ≥ 80 → publish to npm → register on-chain → upload report to Fileverse → write ENS text records → set IPFS contenthash from Fileverse contract.
|
|
151
47
|
|
|
152
|
-
|
|
48
|
+
### `opm install`
|
|
153
49
|
|
|
154
|
-
|
|
50
|
+
Parse ENS version (e.g. `pkg@name.eth`) → resolve author on-chain → get safest version → check CVEs → verify checksum + signature → ChainPatrol check → npm install. Auto-bumps to safer versions if CVEs or high risk detected.
|
|
155
51
|
|
|
156
|
-
###
|
|
52
|
+
### `opm register-agent`
|
|
157
53
|
|
|
158
|
-
|
|
159
|
-
2. **Agent Evaluation**: The candidate agent runs against all 10 cases. Each response is evaluated against expected risk levels and score ranges.
|
|
160
|
-
3. **ZK Proof Generation**: A zero-knowledge proof is generated using a hash-commitment scheme:
|
|
161
|
-
- Expected outputs are committed: `hash(salt, expected_verdicts) → commitment`
|
|
162
|
-
- Agent outputs are hashed: `hash(salt, actual_verdicts) → result_hash`
|
|
163
|
-
- Proof binds everything: `hash(commitment, result_hash, accuracy_flag, salt) → proof`
|
|
164
|
-
- Only a binary pass/fail is disclosed — test data and individual results remain hidden
|
|
165
|
-
4. **On-chain Registration**: If accuracy is 100%, the agent's proof hash is stored on-chain via `OPMRegistry.registerAgent()`, and the agent is auto-authorized to submit scores.
|
|
54
|
+
Generate 10 benchmark cases → commit expected results → run candidate agent → compare actual vs expected → if 100% accuracy: generate ZK proof → register on-chain with proof hash. Agent becomes authorized to submit scores.
|
|
166
55
|
|
|
167
|
-
|
|
56
|
+
## AI Agents
|
|
168
57
|
|
|
169
|
-
|
|
58
|
+
Three models scan every publish in parallel. Diversity reduces single-model blind spots.
|
|
170
59
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
circom accuracy_verifier.circom --r1cs --wasm --sym -o build/
|
|
174
|
-
|
|
175
|
-
# Trusted setup
|
|
176
|
-
snarkjs groth16 setup build/accuracy_verifier.r1cs pot12_final.ptau build/accuracy_verifier_0000.zkey
|
|
177
|
-
snarkjs zkey contribute build/accuracy_verifier_0000.zkey build/accuracy_verifier_final.zkey --name="opm-ceremony"
|
|
178
|
-
|
|
179
|
-
# Export Solidity verifier (for on-chain verification)
|
|
180
|
-
snarkjs zkey export solidityverifier build/accuracy_verifier_final.zkey contracts/AccuracyVerifier.sol
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## AI Agent Architecture
|
|
184
|
-
|
|
185
|
-
Three language models evaluate every package publish in parallel. Model diversity is enforced to reduce single-model blind spots and improve consensus reliability. Additional agents can be registered permissionlessly.
|
|
186
|
-
|
|
187
|
-
| Agent | OpenRouter (preferred) | OpenAI (fallback) |
|
|
188
|
-
|-------|----------------------|-------------------|
|
|
60
|
+
| Agent | Model (OpenRouter) | Fallback (OpenAI) |
|
|
61
|
+
|-------|-------------------|-------------------|
|
|
189
62
|
| agent-1 | Claude Sonnet 4 | GPT-4.1 |
|
|
190
63
|
| agent-2 | Gemini 2.5 Flash | GPT-4.1 Mini |
|
|
191
64
|
| agent-3 | DeepSeek Chat | GPT-4.1 Nano |
|
|
192
65
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
Each agent produces a structured JSON assessment containing:
|
|
196
|
-
|
|
197
|
-
- **Risk score** (0-100) with categorical classification (LOW, MEDIUM, HIGH, CRITICAL)
|
|
198
|
-
- **Vulnerability enumeration** with severity, category, file path, and evidence
|
|
199
|
-
- **Supply chain indicators**: install scripts, native bindings, obfuscated code, network calls, filesystem access, process spawning, eval usage, environment variable access
|
|
200
|
-
- **Version history analysis**: changelog risk, maintainer changes, dependency graph mutations
|
|
201
|
-
- **Recommendation**: SAFE, CAUTION, WARN, or BLOCK
|
|
202
|
-
|
|
203
|
-
Agent scores are weighted by model intelligence and coding indices sourced from the Artificial Analysis API, producing an intelligence-weighted aggregate risk score.
|
|
204
|
-
|
|
205
|
-
## Smart Contract: OPMRegistry
|
|
206
|
-
|
|
207
|
-
Solidity 0.8.20, deployed on [Base Sepolia](https://sepolia.basescan.org/address/0x16684391fc9bf48246B08Afe16d1a57BFa181d48). The contract implements a domain-specific form of the three-registry architecture defined by [ERC-8004 (Trustless Agents)](https://eips.ethereum.org/EIPS/eip-8004), adapted for package security rather than general-purpose agent economies.
|
|
208
|
-
|
|
209
|
-
### Key Functions
|
|
210
|
-
|
|
211
|
-
| Function | Access | Description |
|
|
212
|
-
|----------|--------|-------------|
|
|
213
|
-
| `registerPackage` | Public | Register a new package version with checksum, signature, and ENS binding |
|
|
214
|
-
| `submitScore` | Authorized agents | Submit a risk score (0-100) and reasoning string for a package version |
|
|
215
|
-
| `setReportURI` | Authorized agents | Attach a Fileverse report URI to a package version |
|
|
216
|
-
| `registerAgent` | Public | Permissionless agent registration with ZK proof hash |
|
|
217
|
-
| `revokeAgent` | Owner | Deactivate a registered agent |
|
|
218
|
-
| `getAggregateScore` | View | Compute mean risk score across all agent submissions |
|
|
219
|
-
| `getSafestVersion` | View | Return the lowest-risk version within a configurable lookback window |
|
|
220
|
-
| `getScores` | View | Return all individual agent scores for a version |
|
|
221
|
-
| `getPackageInfo` | View | Retrieve full metadata and aggregate score for a package version |
|
|
222
|
-
| `getRegisteredAgent` | View | Retrieve registered agent details |
|
|
223
|
-
| `getAgentCount` | View | Total number of registered agents |
|
|
224
|
-
|
|
225
|
-
### On-chain Activity
|
|
226
|
-
|
|
227
|
-
Every transaction is surfaced in the terminal UI with clickable BaseScan links:
|
|
228
|
-
|
|
229
|
-
- **Score submissions**: Each agent's `submitScore` tx → `https://sepolia.basescan.org/tx/{hash}`
|
|
230
|
-
- **Package registration**: `registerPackage` tx → clickable link
|
|
231
|
-
- **Agent registration**: `registerAgent` tx → clickable link
|
|
232
|
-
- **Contract reference**: Direct link to the OPM Registry contract
|
|
233
|
-
|
|
234
|
-
### Risk Thresholds
|
|
235
|
-
|
|
236
|
-
| Threshold | Value | Effect |
|
|
237
|
-
|-----------|-------|--------|
|
|
238
|
-
| `HIGH_RISK_THRESHOLD` | 70 | Packages above this score trigger warnings |
|
|
239
|
-
| `MEDIUM_RISK_THRESHOLD` | 40 | Packages above this score are flagged for caution |
|
|
240
|
-
| Critical gate (CLI) | 80 | `opm push` blocks publication; `opm install` blocks installation |
|
|
66
|
+
Scores are weighted by model intelligence + coding index from the Artificial Analysis API. Anyone can register additional agents permissionlessly via ZK-verified benchmarks.
|
|
241
67
|
|
|
242
|
-
##
|
|
68
|
+
## Smart Contract
|
|
243
69
|
|
|
244
|
-
|
|
70
|
+
`OPMRegistry.sol` on [Base Sepolia](https://sepolia.basescan.org/address/0x16684391fc9bf48246B08Afe16d1a57BFa181d48).
|
|
245
71
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
72
|
+
| Function | What it does |
|
|
73
|
+
|----------|-------------|
|
|
74
|
+
| `registerPackage` | Store version checksum, signature, ENS binding |
|
|
75
|
+
| `submitScore` | Agent submits risk score + reasoning |
|
|
76
|
+
| `setReportURI` | Attach Fileverse report link |
|
|
77
|
+
| `registerAgent` | Permissionless agent registration with ZK proof hash |
|
|
78
|
+
| `getSafestVersion` | Lowest-risk version in lookback window |
|
|
79
|
+
| `getPackageInfo` | Full metadata + aggregate score |
|
|
253
80
|
|
|
254
|
-
|
|
81
|
+
Every transaction surfaces as a clickable BaseScan link in the terminal.
|
|
255
82
|
|
|
256
|
-
##
|
|
83
|
+
## ENS Integration
|
|
257
84
|
|
|
258
|
-
|
|
85
|
+
Package metadata is written to ENS text records on the author's name:
|
|
259
86
|
|
|
260
|
-
|
|
87
|
+
`url` · `opm.version` · `opm.checksum` · `opm.fileverse` · `opm.risk_score` · `opm.packages` · `opm.signature` · `opm.contract`
|
|
261
88
|
|
|
262
|
-
|
|
263
|
-
npm i -g mintlify
|
|
264
|
-
cd docs
|
|
265
|
-
mintlify dev
|
|
266
|
-
```
|
|
89
|
+
Per-package records: `opm.pkg.<name>.version`, `opm.pkg.<name>.checksum`, etc.
|
|
267
90
|
|
|
268
|
-
|
|
91
|
+
Contenthash is set to the Fileverse IPFS CID (read directly from the Fileverse Portal smart contract on-chain).
|
|
269
92
|
|
|
270
|
-
|
|
271
|
-
- **Core Concepts**: Security Model, Multi-Agent Consensus, On-chain Registry, ZK Agent Verification
|
|
272
|
-
- **CLI Reference**: All commands with usage, flags, and examples
|
|
273
|
-
- **Smart Contract**: Functions, Events, Deployment
|
|
274
|
-
- **Architecture**: Scanner engine, Agent system, Benchmark suite
|
|
275
|
-
|
|
276
|
-
### Deploy to Mintlify
|
|
277
|
-
|
|
278
|
-
Push your repo to GitHub and connect it to [Mintlify](https://mintlify.com/start) — it auto-deploys from the `docs/` directory.
|
|
93
|
+
Install with ENS: `opm install express@djpai.eth` resolves the author, verifies they're registered, and installs the safest on-chain version.
|
|
279
94
|
|
|
280
95
|
## Project Structure
|
|
281
96
|
|
|
282
97
|
```
|
|
283
98
|
packages/
|
|
284
|
-
core/
|
|
285
|
-
contracts/
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
components/ Header, StatusLine, RiskBadge, Hyperlink, PackageCard, AuthorInfo, AgentScores
|
|
291
|
-
services/ contract, ens, osv, signature, chainpatrol, fileverse, avatar, typosquat, version
|
|
292
|
-
web/ Next.js landing page (dark mode, Tailwind CSS)
|
|
293
|
-
docs/ Mintlify documentation (mint.json + MDX pages)
|
|
99
|
+
core/ Types, constants, ABI, prompts, model rankings, benchmarks
|
|
100
|
+
contracts/ OPMRegistry.sol, Hardhat config, Circom ZK circuit
|
|
101
|
+
scanner/ AI agent runner, LLM client, Fileverse upload, ZK verifier
|
|
102
|
+
cli/ Ink terminal UI, commands, services
|
|
103
|
+
web/ Next.js landing page
|
|
104
|
+
docs/ Mintlify documentation
|
|
294
105
|
```
|
|
295
106
|
|
|
296
107
|
## Environment Variables
|
|
297
108
|
|
|
298
|
-
|
|
109
|
+
**Required for `opm push`:**
|
|
299
110
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
|
303
|
-
|
|
304
|
-
| `
|
|
305
|
-
| `
|
|
306
|
-
| `NPM_TOKEN` | npm automation token (alternative to `--token` CLI flag) |
|
|
307
|
-
| `OPENAI_API_KEY` | OpenAI API key; selects GPT-4.1 / Mini / Nano agents |
|
|
308
|
-
| `OPENROUTER_API_KEY` | OpenRouter API key; enables Claude, Gemini, DeepSeek model diversity |
|
|
309
|
-
| `FILEVERSE_API_KEY` | Fileverse API key (generate at ddocs.new, Settings, Developer Mode) |
|
|
310
|
-
|
|
311
|
-
Agent registration (`register-agent`) requires:
|
|
312
|
-
|
|
313
|
-
| Variable | Description |
|
|
314
|
-
|----------|-------------|
|
|
315
|
-
| `AGENT_PRIVATE_KEY` | Wallet that becomes the agent identity on-chain |
|
|
316
|
-
| `OPENROUTER_API_KEY` or `OPENAI_API_KEY` | Required to run LLM benchmark calls |
|
|
111
|
+
| Variable | Purpose |
|
|
112
|
+
|----------|---------|
|
|
113
|
+
| `OPM_SIGNING_KEY` | Ethereum private key for package signing |
|
|
114
|
+
| `AGENT_PRIVATE_KEY` | Agent wallet for on-chain score submission |
|
|
115
|
+
| `OPENROUTER_API_KEY` or `OPENAI_API_KEY` | LLM access for AI agents |
|
|
116
|
+
| `FILEVERSE_API_KEY` | Report storage ([ddocs.new](https://ddocs.new) → Settings → Developer Mode) |
|
|
317
117
|
|
|
318
|
-
Optional
|
|
118
|
+
**Optional:**
|
|
319
119
|
|
|
320
120
|
| Variable | Default |
|
|
321
121
|
|----------|---------|
|
|
122
|
+
| `NPM_TOKEN` | npm automation token |
|
|
322
123
|
| `CONTRACT_ADDRESS` | `0x16684391fc9bf48246B08Afe16d1a57BFa181d48` |
|
|
323
|
-
| `
|
|
324
|
-
| `CHAINPATROL_API_KEY` | Optional; enables blocklist checks |
|
|
325
|
-
| `ARTIFICIAL_ANALYSIS_API_KEY` | Optional; enables intelligence-weighted scoring |
|
|
124
|
+
| `CHAINPATROL_API_KEY` | Blocklist checks |
|
|
326
125
|
|
|
327
|
-
|
|
126
|
+
Client commands (`install`, `check`, `info`, `view`) work with zero config.
|
|
328
127
|
|
|
329
|
-
|
|
128
|
+
## Fileverse Setup
|
|
330
129
|
|
|
331
130
|
```bash
|
|
332
|
-
|
|
131
|
+
npx @fileverse/api --apiKey <YOUR_API_KEY>
|
|
333
132
|
```
|
|
334
133
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
bun run scan -- <package-name> <version>
|
|
339
|
-
```
|
|
134
|
+
Runs at `http://localhost:8001`. Reports are encrypted, synced to IPFS, and the content hash is stored on the Fileverse Portal smart contract.
|
|
340
135
|
|
|
341
136
|
## Links
|
|
342
137
|
|
|
343
138
|
- **npm**: [npmjs.com/package/opmsec](https://www.npmjs.com/package/opmsec)
|
|
344
139
|
- **GitHub**: [github.com/dhananjaypai08/opm](https://github.com/dhananjaypai08/opm)
|
|
345
140
|
- **Contract**: [BaseScan](https://sepolia.basescan.org/address/0x16684391fc9bf48246B08Afe16d1a57BFa181d48)
|
|
141
|
+
- **Docs**: [Mintlify](https://mintlify.com)
|
|
346
142
|
|
|
347
143
|
## License
|
|
348
144
|
|
package/bun.lock
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"ethers": "^6.13.0",
|
|
11
11
|
"ink": "^5.2.1",
|
|
12
12
|
"react": "^18.3.1",
|
|
13
|
-
"react-devtools-core": "^
|
|
13
|
+
"react-devtools-core": "^7.0.1",
|
|
14
14
|
"terminal-image": "^4.2.0",
|
|
15
15
|
"viem": "^2.47.4",
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"bun-types": "
|
|
18
|
+
"bun-types": "latest",
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
"packages/cli": {
|
|
@@ -347,7 +347,7 @@
|
|
|
347
347
|
|
|
348
348
|
"react": ["react@18.3.1", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ=="],
|
|
349
349
|
|
|
350
|
-
"react-devtools-core": ["react-devtools-core@
|
|
350
|
+
"react-devtools-core": ["react-devtools-core@7.0.1", "", { "dependencies": { "shell-quote": "^1.6.1", "ws": "^7" } }, "sha512-C3yNvRHaizlpiASzy7b9vbnBGLrhvdhl1CbdU6EnZgxPNbai60szdLtl+VL76UNOt5bOoVTOz5rNWZxgGt+Gsw=="],
|
|
351
351
|
|
|
352
352
|
"react-reconciler": ["react-reconciler@0.29.2", "", { "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" }, "peerDependencies": { "react": "^18.3.1" } }, "sha512-zZQqIiYgDCTP/f1N/mAR10nJGrPD2ZR+jDSEsKWJHYC7Cm2wodlwbR3upZRdC3cjIjSlTLNVyO7Iu0Yy7t2AYg=="],
|
|
353
353
|
|
|
@@ -1,77 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: 'Agent Architecture'
|
|
3
|
-
description: 'Agent config,
|
|
3
|
+
description: 'Agent config, LLM flow, prompts, and model ranking.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Agent Architecture
|
|
7
7
|
|
|
8
8
|
Security agents are LLM-powered analyzers that score packages and submit results on-chain.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Agent Flow
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
```
|
|
12
|
+
1. **Fetch data** — Package metadata and source from npm (or local tarball)
|
|
13
|
+
2. **Query OSV** — Known CVEs for the package and version
|
|
14
|
+
3. **Call LLM** — System prompt + user prompt → structured JSON response
|
|
15
|
+
4. **Submit on-chain** — `OPMRegistry.submitScore()` with the agent wallet
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
## Prompts
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
The **system prompt** defines a security auditor persona and enforces a JSON output schema: risk score (0-100), risk level, reasoning, vulnerability list.
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
<Step title="Fetch data">
|
|
25
|
-
Fetches package metadata and version history from npm (or uses local tarball for pre-publish scans).
|
|
26
|
-
</Step>
|
|
27
|
-
<Step title="Query OSV">
|
|
28
|
-
Looks up known CVEs for the package and version.
|
|
29
|
-
</Step>
|
|
30
|
-
<Step title="Call LLM">
|
|
31
|
-
Sends system prompt + user prompt to the configured model. Expects JSON with <code>risk_score</code>, <code>risk_level</code>, <code>reasoning</code>, <code>vulnerabilities</code>.
|
|
32
|
-
</Step>
|
|
33
|
-
<Step title="Submit score on-chain">
|
|
34
|
-
Calls <code>OPMRegistry.submitScore()</code> with the agent wallet.
|
|
35
|
-
</Step>
|
|
36
|
-
</Steps>
|
|
37
|
-
|
|
38
|
-
## System Prompt
|
|
39
|
-
|
|
40
|
-
The system prompt defines a **security auditor persona** and enforces a structured JSON output schema:
|
|
41
|
-
|
|
42
|
-
- Risk score (0–100)
|
|
43
|
-
- Risk level (LOW, MEDIUM, HIGH, CRITICAL)
|
|
44
|
-
- Reasoning
|
|
45
|
-
- List of vulnerabilities with severity
|
|
46
|
-
|
|
47
|
-
## User Prompt
|
|
48
|
-
|
|
49
|
-
The user prompt includes:
|
|
50
|
-
|
|
51
|
-
- Package metadata (name, version, description, author, license, dependencies, scripts)
|
|
52
|
-
- Version history (recent versions, publish dates, changes)
|
|
53
|
-
- Source code (extracted from tarball, truncated to size limits)
|
|
54
|
-
- Known CVEs from OSV
|
|
21
|
+
The **user prompt** includes package metadata, version history, extracted source code (size-limited), and any known CVEs.
|
|
55
22
|
|
|
56
23
|
## Model Ranking
|
|
57
24
|
|
|
58
|
-
When
|
|
59
|
-
|
|
60
|
-
- **Intelligence index**: General reasoning capability
|
|
61
|
-
- **Coding index**: Code-related task performance
|
|
62
|
-
|
|
63
|
-
These indices are used to compute a **weight** for each agent. The aggregate score is intelligence-weighted across agents.
|
|
64
|
-
|
|
65
|
-
<Tip>
|
|
66
|
-
Without the Artificial Analysis API, agents are weighted equally.
|
|
67
|
-
</Tip>
|
|
25
|
+
When `ARTIFICIAL_ANALYSIS_API_KEY` is set, model Intelligence Index and Coding Index are fetched and used as weights for score aggregation. Without it, equal weighting applies.
|
|
68
26
|
|
|
69
27
|
## Extensibility
|
|
70
28
|
|
|
71
|
-
New agents
|
|
72
|
-
|
|
73
|
-
1. Pass 10 benchmark cases with 100% accuracy
|
|
74
|
-
2. Generate a ZK proof
|
|
75
|
-
3. Call <code>OPMRegistry.registerAgent()</code>
|
|
76
|
-
|
|
77
|
-
Once registered, the agent participates in package scans alongside existing agents.
|
|
29
|
+
New agents register permissionlessly via `opm register-agent` — pass 10 benchmarks with 100% accuracy, generate a ZK proof, and the agent participates in all future scans.
|
|
@@ -5,61 +5,35 @@ description: '10 labeled test cases for agent verification.'
|
|
|
5
5
|
|
|
6
6
|
# Benchmark Suite
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Validates agent accuracy before permissionless registration. Agents must score **100% accuracy** and produce a valid ZK proof.
|
|
9
9
|
|
|
10
|
-
## Test
|
|
10
|
+
## Test Cases
|
|
11
11
|
|
|
12
|
-
Each
|
|
12
|
+
Each case includes: package metadata, version history, source files, known CVEs, and expected output (risk level + score range).
|
|
13
13
|
|
|
14
|
-
|
|
|
15
|
-
|-------|-------------|
|
|
16
|
-
| **id** | Unique identifier (e.g. <code>bench-001-clean-utility</code>) |
|
|
17
|
-
| **category** | One of: clean, typosquat, malicious, cve, obfuscated, exfiltration, dependency_confusion |
|
|
18
|
-
| **metadata** | Package name, version, description, author, license, dependencies, scripts |
|
|
19
|
-
| **versionHistory** | Recent versions with publish dates and change summaries |
|
|
20
|
-
| **sourceFiles** | Path, size, and content of source files |
|
|
21
|
-
| **knownCVEs** | Known advisories (for cve category) |
|
|
22
|
-
| **expected** | risk_level, min_risk_score, max_risk_score, must_flag |
|
|
23
|
-
|
|
24
|
-
## Categories (10 Cases)
|
|
25
|
-
|
|
26
|
-
| Category | Count | Description |
|
|
14
|
+
| Category | Cases | Description |
|
|
27
15
|
|----------|-------|-------------|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
16
|
+
| Clean | 3 | Legitimate packages (string utils, math, validator) |
|
|
17
|
+
| Typosquat | 1 | Lodash typosquat with credential exfil in postinstall |
|
|
18
|
+
| Malicious | 2 | Postinstall shell execution, SSH key exfiltration |
|
|
19
|
+
| CVE | 1 | Known prototype pollution vulnerability |
|
|
20
|
+
| Obfuscated | 1 | Heavily obfuscated reverse shell |
|
|
21
|
+
| Exfiltration | 1 | Env var exfiltration on import |
|
|
22
|
+
| Dependency confusion | 1 | Internal scope shadowing with DNS exfil |
|
|
35
23
|
|
|
36
24
|
## Evaluation
|
|
37
25
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
1. **Score range check**: <code>actualScore</code> must be within <code>[min_risk_score, max_risk_score]</code>
|
|
41
|
-
2. **Risk level ordinal**: For non-LOW cases, <code>actualLevel</code> must be within ±1 of expected ordinal (LOW=0, MEDIUM=1, HIGH=2, CRITICAL=3)
|
|
42
|
-
|
|
43
|
-
A case **PASS**es only if both checks succeed.
|
|
44
|
-
|
|
45
|
-
## ZK Proof Generation
|
|
46
|
-
|
|
47
|
-
The ZK proof proves accuracy **without revealing** test data or individual results:
|
|
48
|
-
|
|
49
|
-
1. **Commitment**: Hash of (salt, expected[0..9]) using Poseidon
|
|
50
|
-
2. **Proof**: Prove that <code>expected[i] == actual[i]</code> for all i, and that the commitment matches
|
|
51
|
-
3. **Output**: <code>proofHash</code> is stored on-chain; test data stays private
|
|
26
|
+
Each case is checked against:
|
|
52
27
|
|
|
53
|
-
|
|
28
|
+
1. **Score range** — `actualScore` within `[min_risk_score, max_risk_score]`
|
|
29
|
+
2. **Risk level** — For non-LOW cases, actual level within ±1 of expected ordinal
|
|
54
30
|
|
|
55
|
-
|
|
31
|
+
A case passes only if both checks succeed.
|
|
56
32
|
|
|
57
|
-
|
|
58
|
-
- **Public input**: commitmentHash (Poseidon hash of salt + expected values)
|
|
59
|
-
- **Public outputs**: passed (1 if all match), proofHash
|
|
33
|
+
## ZK Proof
|
|
60
34
|
|
|
61
|
-
|
|
35
|
+
1. **Commit** — Poseidon hash of (salt, expected[0..9]) → `commitmentHash`
|
|
36
|
+
2. **Prove** — Circuit verifies `expected[i] == actual[i]` for all i, outputs `passed` and `proofHash`
|
|
37
|
+
3. **Store** — `keccak256(proof)` stored on-chain via `registerAgent()`
|
|
62
38
|
|
|
63
|
-
|
|
64
|
-
The circuit is compiled and used for local verification. On-chain registration stores <code>keccak256(proof)</code> as the proof hash; full on-chain ZK verification can be added later.
|
|
65
|
-
</Note>
|
|
39
|
+
Test data stays private — future agents can't game the benchmark.
|