@chainpatrol/cli 0.11.0 → 0.12.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/CHANGELOG.md +43 -0
- package/dist/{breakdown-MM5GSZKV.js → breakdown-KCTKQNDY.js} +1 -1
- package/dist/{check-GDKUHVQI.js → check-P5JJJNEX.js} +1 -1
- package/dist/{chunk-37KYJWB3.js → chunk-DJVB73FL.js} +1 -1
- package/dist/{chunk-YXRFUYA6.js → chunk-NQT77IB7.js} +50 -8
- package/dist/{chunk-SX3L6NKR.js → chunk-OSRFCVBT.js} +129 -2
- package/dist/{chunk-EPKNZRX6.js → chunk-W42ITB5J.js} +1 -1
- package/dist/cli.js +395 -76
- package/dist/{completions-62OW3B3Y.js → completions-6C6KG5DH.js} +1 -1
- package/dist/{configs-update-7X7657PB.js → configs-update-3ZVXGADV.js} +1 -1
- package/dist/{create-FL4QQTPN.js → create-DFH2G7RH.js} +1 -1
- package/dist/{drift-JKBHWWFU.js → drift-T74V2C3J.js} +1 -1
- package/dist/{found-3WI4XQG4.js → found-EVXJZGYX.js} +1 -1
- package/dist/{healthcheck-EVQVPGWW.js → healthcheck-HZYEIIOR.js} +1 -1
- package/dist/{list-BLNIE4GL.js → list-23QQYAV5.js} +1 -1
- package/dist/list-EIVPGMWJ.js +82 -0
- package/dist/list-I7SBGA52.js +50 -0
- package/dist/{list-5DN6X3DP.js → list-IYJBKE2F.js} +1 -1
- package/dist/list-PBAXQSL5.js +85 -0
- package/dist/list-QUFY4IP7.js +146 -0
- package/dist/{list-JPG2ZSR4.js → list-WJQT2XLE.js} +7 -1
- package/dist/{list-ULHPOUJV.js → list-WX5G3IOF.js} +2 -2
- package/dist/list-YCT6DYDI.js +89 -0
- package/dist/{list-XDGU6SJQ.js → list-YRJPN4PI.js} +1 -1
- package/dist/{list-E5XNR2YG.js → list-ZFPML3ZR.js} +47 -3
- package/dist/{list-json-R2MIXADX.js → list-json-T2Z7NV7G.js} +1 -1
- package/dist/{organization-MJRKWC4Z.js → organization-IIIOSTHF.js} +1 -1
- package/dist/{run-EUVRC72M.js → run-BHEXWBAS.js} +2 -2
- package/dist/{run-2YZZGZYN.js → run-CJGN6TX4.js} +1 -1
- package/dist/{run-5E5EC3MP.js → run-MSO6IXEV.js} +1 -1
- package/dist/search-WPSKQGUS.js +71 -0
- package/dist/{setup-skill-HAENFIFQ.js → setup-skill-FA4STSGA.js} +2 -2
- package/dist/{snapshot-3FUJICJJ.js → snapshot-ZWAHEG64.js} +1 -1
- package/dist/{summary-RVYQUKWV.js → summary-Y2LG6UJM.js} +1 -1
- package/dist/{validate-UOVKEAJM.js → validate-SM5DD7I2.js} +1 -1
- package/dist/whoami-DH5HVLFN.js +69 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPresetDefinition,
|
|
3
3
|
runPreset
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DJVB73FL.js";
|
|
5
5
|
import {
|
|
6
6
|
CliExitError,
|
|
7
7
|
ExitCode
|
|
8
8
|
} from "./chunk-E2LAMILJ.js";
|
|
9
9
|
import "./chunk-VFT3TD3E.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-OSRFCVBT.js";
|
|
11
11
|
import "./chunk-EGWK6SRQ.js";
|
|
12
12
|
import "./chunk-TFCNKBRC.js";
|
|
13
13
|
import "./chunk-U73SABXK.js";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CliExitError,
|
|
3
|
+
ExitCode
|
|
4
|
+
} from "./chunk-E2LAMILJ.js";
|
|
5
|
+
import {
|
|
6
|
+
printOutput,
|
|
7
|
+
toCsvRows
|
|
8
|
+
} from "./chunk-VFT3TD3E.js";
|
|
9
|
+
import {
|
|
10
|
+
createApiClient
|
|
11
|
+
} from "./chunk-OSRFCVBT.js";
|
|
12
|
+
import "./chunk-EGWK6SRQ.js";
|
|
13
|
+
import "./chunk-TFCNKBRC.js";
|
|
14
|
+
import "./chunk-U73SABXK.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/reports/search.ts
|
|
17
|
+
function toRow(report) {
|
|
18
|
+
return {
|
|
19
|
+
id: report.id,
|
|
20
|
+
status: report.status,
|
|
21
|
+
reportedByCustomer: report.reportedByCustomer,
|
|
22
|
+
assets: report.assets.join("|")
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async function runReportsSearch(options) {
|
|
26
|
+
const outputFormat = options.outputFormat ?? (options.json ? "json" : "human");
|
|
27
|
+
if (options.assetContents.length === 0) {
|
|
28
|
+
throw new CliExitError(
|
|
29
|
+
"reports search requires at least one asset content. Pass --asset <content> (repeatable) or positional arguments.",
|
|
30
|
+
ExitCode.USAGE
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const client = options.apiClient ?? createApiClient();
|
|
34
|
+
const input = {
|
|
35
|
+
assetContents: options.assetContents,
|
|
36
|
+
reportedByCustomer: options.reportedByCustomer
|
|
37
|
+
};
|
|
38
|
+
const result = await client.searchReports(input);
|
|
39
|
+
const rows = result.reports.map(toRow);
|
|
40
|
+
printOutput({
|
|
41
|
+
outputFormat,
|
|
42
|
+
json: result,
|
|
43
|
+
markdown: [
|
|
44
|
+
"# Report search results",
|
|
45
|
+
"",
|
|
46
|
+
`- Searched: ${options.assetContents.length} asset(s)`,
|
|
47
|
+
`- Matched: ${result.reports.length} report(s)`,
|
|
48
|
+
"",
|
|
49
|
+
...rows.map(
|
|
50
|
+
(row) => `- #${row.id} [${row.status}]${row.reportedByCustomer ? " (customer)" : ""} assets=${row.assets}`
|
|
51
|
+
)
|
|
52
|
+
].join("\n"),
|
|
53
|
+
csv: toCsvRows(rows),
|
|
54
|
+
human: () => {
|
|
55
|
+
if (result.reports.length === 0) {
|
|
56
|
+
console.log("No matching reports found.");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
console.log(
|
|
60
|
+
`Matched ${result.reports.length} report(s) for ${options.assetContents.length} asset(s)`
|
|
61
|
+
);
|
|
62
|
+
for (const row of rows) {
|
|
63
|
+
const customerTag = row.reportedByCustomer ? " (customer)" : "";
|
|
64
|
+
console.log(`#${row.id} [${row.status}]${customerTag} assets=${row.assets}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
runReportsSearch
|
|
71
|
+
};
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
readInstalledSkillVersion,
|
|
7
7
|
setupSkill,
|
|
8
8
|
uninstallSkill
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-W42ITB5J.js";
|
|
10
|
+
import "./chunk-NQT77IB7.js";
|
|
11
11
|
export {
|
|
12
12
|
getBundledSkillContent,
|
|
13
13
|
getBundledSkillVersion,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
printOutput
|
|
3
|
+
} from "./chunk-VFT3TD3E.js";
|
|
4
|
+
import {
|
|
5
|
+
createApiClient
|
|
6
|
+
} from "./chunk-OSRFCVBT.js";
|
|
7
|
+
import "./chunk-EGWK6SRQ.js";
|
|
8
|
+
import "./chunk-TFCNKBRC.js";
|
|
9
|
+
import "./chunk-U73SABXK.js";
|
|
10
|
+
|
|
11
|
+
// src/commands/whoami.ts
|
|
12
|
+
function detectAuthKind() {
|
|
13
|
+
const envKey = process.env.CHAINPATROL_API_KEY;
|
|
14
|
+
if (envKey && envKey.trim().length > 0) return "api-key";
|
|
15
|
+
return "bearer";
|
|
16
|
+
}
|
|
17
|
+
async function runWhoami(options) {
|
|
18
|
+
const outputFormat = options.outputFormat ?? (options.json ? "json" : "human");
|
|
19
|
+
const client = options.apiClient ?? createApiClient();
|
|
20
|
+
const authKind = options.authKind ?? detectAuthKind();
|
|
21
|
+
if (authKind === "api-key") {
|
|
22
|
+
const result2 = await client.validateApiKey();
|
|
23
|
+
const payload2 = {
|
|
24
|
+
authKind,
|
|
25
|
+
status: result2.status,
|
|
26
|
+
message: result2.message
|
|
27
|
+
};
|
|
28
|
+
printOutput({
|
|
29
|
+
outputFormat,
|
|
30
|
+
json: payload2,
|
|
31
|
+
markdown: [
|
|
32
|
+
"# whoami",
|
|
33
|
+
"",
|
|
34
|
+
`- Auth: API key`,
|
|
35
|
+
`- Status: ${result2.status}`,
|
|
36
|
+
`- Message: ${result2.message}`
|
|
37
|
+
].join("\n"),
|
|
38
|
+
human: () => {
|
|
39
|
+
console.log(`Auth: API key (CHAINPATROL_API_KEY)`);
|
|
40
|
+
console.log(`Status: ${result2.status}`);
|
|
41
|
+
console.log(`Message: ${result2.message}`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const result = await client.getCurrentUser();
|
|
47
|
+
const payload = { authKind, ...result };
|
|
48
|
+
printOutput({
|
|
49
|
+
outputFormat,
|
|
50
|
+
json: payload,
|
|
51
|
+
markdown: [
|
|
52
|
+
"# whoami",
|
|
53
|
+
"",
|
|
54
|
+
`- Auth: session token`,
|
|
55
|
+
`- User: ${result.user.name} <${result.user.email}>`,
|
|
56
|
+
`- Role: ${result.user.role}`,
|
|
57
|
+
`- ID: ${result.user.id}`
|
|
58
|
+
].join("\n"),
|
|
59
|
+
human: () => {
|
|
60
|
+
console.log(`Auth: session token`);
|
|
61
|
+
console.log(`User: ${result.user.name} <${result.user.email}>`);
|
|
62
|
+
console.log(`Role: ${result.user.role}`);
|
|
63
|
+
console.log(`ID: ${result.user.id}`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
runWhoami
|
|
69
|
+
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@chainpatrol/cli",
|
|
3
3
|
"description": "The official ChainPatrol CLI — terminal interface for threat detection",
|
|
4
4
|
"author": "Umar Ahmed <umar@chainpatrol.io>",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.12.0",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"homepage": "https://chainpatrol.com/docs/cli",
|
|
8
8
|
"keywords": [
|