npmguard-cli 0.5.6 → 1.0.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 +6 -152
- package/dist/api.js +66 -0
- package/dist/commands/audit.js +195 -0
- package/dist/commands/check.js +69 -118
- package/dist/index.js +16 -26
- package/dist/render.js +47 -0
- package/package.json +14 -21
- package/dist/audit-source.d.ts +0 -12
- package/dist/audit-source.js +0 -1
- package/dist/commands/check.d.ts +0 -2
- package/dist/commands/install.d.ts +0 -2
- package/dist/commands/install.js +0 -424
- package/dist/contract.d.ts +0 -121
- package/dist/contract.js +0 -92
- package/dist/ens-source.d.ts +0 -4
- package/dist/ens-source.js +0 -57
- package/dist/index.d.ts +0 -2
- package/dist/mock-source.d.ts +0 -4
- package/dist/mock-source.js +0 -50
- package/dist/scanner.d.ts +0 -7
- package/dist/scanner.js +0 -35
package/dist/contract.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// NpmGuardAuditRequest contract — deployed on Sepolia + 0G Galileo Testnet
|
|
2
|
-
// Update these addresses after running: cd contracts && npm run deploy
|
|
3
|
-
export const AUDIT_REQUEST_ADDRESS = "0x4bbaf196bde9e02594631e03c28ebe16719214f3"; // Sepolia
|
|
4
|
-
export const AUDIT_REQUEST_ADDRESS_0G = "0x1201448ae5f00e1783036439569e71ab3757d0de"; // 0G Galileo Testnet
|
|
5
|
-
export const AUDIT_REQUEST_ABI = [
|
|
6
|
-
{
|
|
7
|
-
inputs: [{ name: "_auditFee", type: "uint256" }],
|
|
8
|
-
stateMutability: "nonpayable",
|
|
9
|
-
type: "constructor",
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
anonymous: false,
|
|
13
|
-
inputs: [
|
|
14
|
-
{ indexed: false, name: "packageName", type: "string" },
|
|
15
|
-
{ indexed: false, name: "version", type: "string" },
|
|
16
|
-
{ indexed: true, name: "requester", type: "address" },
|
|
17
|
-
],
|
|
18
|
-
name: "AuditRequested",
|
|
19
|
-
type: "event",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
anonymous: false,
|
|
23
|
-
inputs: [
|
|
24
|
-
{ indexed: true, name: "key", type: "bytes32" },
|
|
25
|
-
{ indexed: true, name: "requester", type: "address" },
|
|
26
|
-
],
|
|
27
|
-
name: "AuditRequestedByKey",
|
|
28
|
-
type: "event",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
inputs: [
|
|
32
|
-
{ name: "packageName", type: "string" },
|
|
33
|
-
{ name: "version", type: "string" },
|
|
34
|
-
],
|
|
35
|
-
name: "requestAudit",
|
|
36
|
-
outputs: [],
|
|
37
|
-
stateMutability: "payable",
|
|
38
|
-
type: "function",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
inputs: [{ name: "key", type: "bytes32" }],
|
|
42
|
-
name: "requestAuditByKey",
|
|
43
|
-
outputs: [],
|
|
44
|
-
stateMutability: "payable",
|
|
45
|
-
type: "function",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
inputs: [],
|
|
49
|
-
name: "auditFee",
|
|
50
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
51
|
-
stateMutability: "view",
|
|
52
|
-
type: "function",
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
inputs: [],
|
|
56
|
-
name: "owner",
|
|
57
|
-
outputs: [{ name: "", type: "address" }],
|
|
58
|
-
stateMutability: "view",
|
|
59
|
-
type: "function",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
inputs: [
|
|
63
|
-
{ name: "packageName", type: "string" },
|
|
64
|
-
{ name: "version", type: "string" },
|
|
65
|
-
],
|
|
66
|
-
name: "isRequested",
|
|
67
|
-
outputs: [{ name: "", type: "bool" }],
|
|
68
|
-
stateMutability: "view",
|
|
69
|
-
type: "function",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
inputs: [{ name: "", type: "bytes32" }],
|
|
73
|
-
name: "requested",
|
|
74
|
-
outputs: [{ name: "", type: "bool" }],
|
|
75
|
-
stateMutability: "view",
|
|
76
|
-
type: "function",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
inputs: [{ name: "_fee", type: "uint256" }],
|
|
80
|
-
name: "setFee",
|
|
81
|
-
outputs: [],
|
|
82
|
-
stateMutability: "nonpayable",
|
|
83
|
-
type: "function",
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
inputs: [],
|
|
87
|
-
name: "withdraw",
|
|
88
|
-
outputs: [],
|
|
89
|
-
stateMutability: "nonpayable",
|
|
90
|
-
type: "function",
|
|
91
|
-
},
|
|
92
|
-
];
|
package/dist/ens-source.d.ts
DELETED
package/dist/ens-source.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { createPublicClient, http } from "viem";
|
|
2
|
-
import { sepolia } from "viem/chains";
|
|
3
|
-
const RPC_URLS = process.env.SEPOLIA_RPC_URL
|
|
4
|
-
? [process.env.SEPOLIA_RPC_URL]
|
|
5
|
-
: [
|
|
6
|
-
"https://sepolia.infura.io/v3/c087278b0ced40f5bea26b7536ebe9a1",
|
|
7
|
-
"https://ethereum-sepolia-rpc.publicnode.com",
|
|
8
|
-
"https://sepolia.drpc.org",
|
|
9
|
-
];
|
|
10
|
-
function makeClient(url) {
|
|
11
|
-
return createPublicClient({ chain: sepolia, transport: http(url) });
|
|
12
|
-
}
|
|
13
|
-
async function getText(ensName, key) {
|
|
14
|
-
for (const url of RPC_URLS) {
|
|
15
|
-
try {
|
|
16
|
-
return await makeClient(url).getEnsText({ name: ensName, key });
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
export class ENSAuditSource {
|
|
25
|
-
async getAudit(packageName, version) {
|
|
26
|
-
const versionSlug = version
|
|
27
|
-
.replace(/[^a-z0-9]+/gi, "-")
|
|
28
|
-
.replace(/^-+|-+$/g, "")
|
|
29
|
-
.toLowerCase();
|
|
30
|
-
const ensName = `${versionSlug}.${packageName}.npmguard.eth`;
|
|
31
|
-
try {
|
|
32
|
-
const [verdict, score, capabilities, reportCid, sourceCid] = await Promise.all([
|
|
33
|
-
getText(ensName, "npmguard.verdict"),
|
|
34
|
-
getText(ensName, "npmguard.score"),
|
|
35
|
-
getText(ensName, "npmguard.capabilities"),
|
|
36
|
-
getText(ensName, "npmguard.report_cid"),
|
|
37
|
-
getText(ensName, "npmguard.source_cid"),
|
|
38
|
-
]);
|
|
39
|
-
if (!verdict)
|
|
40
|
-
return null;
|
|
41
|
-
return {
|
|
42
|
-
packageName,
|
|
43
|
-
version,
|
|
44
|
-
verdict: verdict.toUpperCase(),
|
|
45
|
-
score: score ? parseInt(score, 10) : 0,
|
|
46
|
-
capabilities: capabilities
|
|
47
|
-
? capabilities.split(",").map((c) => c.trim()).filter(Boolean)
|
|
48
|
-
: [],
|
|
49
|
-
reportCid: reportCid ?? undefined,
|
|
50
|
-
sourceCid: sourceCid ?? undefined,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
package/dist/index.d.ts
DELETED
package/dist/mock-source.d.ts
DELETED
package/dist/mock-source.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Mock data for demo — simulates what ENS would return
|
|
2
|
-
const MOCK_AUDITS = {
|
|
3
|
-
"axios@1.14.0": {
|
|
4
|
-
packageName: "axios",
|
|
5
|
-
version: "1.14.0",
|
|
6
|
-
verdict: "SAFE",
|
|
7
|
-
score: 92,
|
|
8
|
-
capabilities: ["network"],
|
|
9
|
-
reportCid: "bafkreia3dgrfewkj6q4sdpqrbxcfuxa47d3ku4uzbauqdk4qo7gok3geoi",
|
|
10
|
-
sourceCid: "bafybeif372guv6lwfzdx622uyqmtk3bkxuhsozd6j5bmzxgqohe4ste77q",
|
|
11
|
-
},
|
|
12
|
-
"axios@1.13.0": {
|
|
13
|
-
packageName: "axios",
|
|
14
|
-
version: "1.13.0",
|
|
15
|
-
verdict: "SAFE",
|
|
16
|
-
score: 90,
|
|
17
|
-
capabilities: ["network"],
|
|
18
|
-
reportCid: "bafkreia3dgrfewkj6q4sdpqrbxcfuxa47d3ku4uzbauqdk4qo7gok3geoi",
|
|
19
|
-
},
|
|
20
|
-
"lodash@4.18.1": {
|
|
21
|
-
packageName: "lodash",
|
|
22
|
-
version: "4.18.1",
|
|
23
|
-
verdict: "WARNING",
|
|
24
|
-
score: 65,
|
|
25
|
-
capabilities: ["network", "filesystem"],
|
|
26
|
-
reportCid: "QmT5NvUtoM5nWFfrQdVrFtvGfKFmG7AHE8P34isapyhCxX", // mock
|
|
27
|
-
},
|
|
28
|
-
"express@5.2.1": {
|
|
29
|
-
packageName: "express",
|
|
30
|
-
version: "5.2.1",
|
|
31
|
-
verdict: "CRITICAL",
|
|
32
|
-
score: 12,
|
|
33
|
-
capabilities: ["network", "filesystem", "process_spawn", "binary_download"],
|
|
34
|
-
reportCid: "QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ", // mock
|
|
35
|
-
},
|
|
36
|
-
"chalk@5.6.2": {
|
|
37
|
-
packageName: "chalk",
|
|
38
|
-
version: "5.6.2",
|
|
39
|
-
verdict: "SAFE",
|
|
40
|
-
score: 98,
|
|
41
|
-
capabilities: [],
|
|
42
|
-
reportCid: "QmRf22bZar3WKmojipms22PkXH1MZGmvsqzQtuSvQE3uhm", // mock
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
export class MockAuditSource {
|
|
46
|
-
async getAudit(packageName, version) {
|
|
47
|
-
const key = `${packageName}@${version}`;
|
|
48
|
-
return MOCK_AUDITS[key] ?? null;
|
|
49
|
-
}
|
|
50
|
-
}
|
package/dist/scanner.d.ts
DELETED
package/dist/scanner.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
export async function scanProject(projectPath) {
|
|
4
|
-
const pkgPath = join(projectPath, "package.json");
|
|
5
|
-
const raw = await readFile(pkgPath, "utf-8");
|
|
6
|
-
const pkg = JSON.parse(raw);
|
|
7
|
-
const allDeps = {
|
|
8
|
-
...pkg.dependencies,
|
|
9
|
-
...pkg.devDependencies,
|
|
10
|
-
};
|
|
11
|
-
const results = [];
|
|
12
|
-
for (const [name, versionRange] of Object.entries(allDeps)) {
|
|
13
|
-
// Strip ^, ~, >= etc. to get the installed version
|
|
14
|
-
const installed = versionRange.replace(/^[\^~>=<]*/, "");
|
|
15
|
-
// Fetch latest from npm registry
|
|
16
|
-
let latest = null;
|
|
17
|
-
try {
|
|
18
|
-
const resp = await fetch(`https://registry.npmjs.org/${name}/latest`);
|
|
19
|
-
if (resp.ok) {
|
|
20
|
-
const data = await resp.json();
|
|
21
|
-
latest = data.version;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// Network error — skip
|
|
26
|
-
}
|
|
27
|
-
results.push({
|
|
28
|
-
name,
|
|
29
|
-
installed,
|
|
30
|
-
latest,
|
|
31
|
-
hasUpdate: latest !== null && latest !== installed,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return results;
|
|
35
|
-
}
|