@zksecurity/zkao-cli 0.16.0-next.11 → 0.18.0-next.13
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/dist/index.js +76 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { readFileSync as readFileSync3 } from "fs";
|
|
5
5
|
import { createRequire } from "module";
|
|
6
|
-
import { Command } from "commander";
|
|
6
|
+
import { Command, InvalidArgumentError } from "commander";
|
|
7
7
|
import {
|
|
8
8
|
ZkaoApiError,
|
|
9
9
|
ZkaoClient,
|
|
@@ -772,6 +772,81 @@ areas.command("add <repoId> <name>").description("Add a custom audit area").opti
|
|
|
772
772
|
areas.command("rm <repoId> <areaKey>").description("Delete a custom audit area").action(
|
|
773
773
|
(repoId, areaKey) => run((c) => c.deleteAuditArea(repoId, areaKey))
|
|
774
774
|
);
|
|
775
|
+
var toCredits = (value) => {
|
|
776
|
+
const credits = Number(value);
|
|
777
|
+
if (!Number.isInteger(credits) || credits <= 0) {
|
|
778
|
+
throw new InvalidArgumentError("Expected a whole number of credits.");
|
|
779
|
+
}
|
|
780
|
+
return credits;
|
|
781
|
+
};
|
|
782
|
+
function continuousChanges(opts) {
|
|
783
|
+
if (opts.wholeRepo && opts.area.length > 0) {
|
|
784
|
+
fail("Pass --area or --whole-repo, not both.");
|
|
785
|
+
}
|
|
786
|
+
return {
|
|
787
|
+
...opts.branch === void 0 ? {} : { branch: opts.branch },
|
|
788
|
+
...opts.budget === void 0 ? {} : { monthlyBudgetCredits: opts.budget },
|
|
789
|
+
...opts.wholeRepo ? { areaKeys: [] } : {},
|
|
790
|
+
...opts.area.length > 0 ? { areaKeys: opts.area } : {}
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
var continuous = program.command("continuous").description(
|
|
794
|
+
"Turn Continuous Testing on or off for a repository and set its monthly budget"
|
|
795
|
+
);
|
|
796
|
+
continuous.command("get <repoId>").description(
|
|
797
|
+
"Show the schedule, this month's spend, and the recommended, minimum and maximum monthly budgets"
|
|
798
|
+
).option("--branch <branch>", "the scheduled branch (default: the repository's default branch)").action(
|
|
799
|
+
(repoId, opts) => run(
|
|
800
|
+
(c) => c.getContinuousTesting(repoId, {
|
|
801
|
+
...opts.branch === void 0 ? {} : { branch: opts.branch }
|
|
802
|
+
})
|
|
803
|
+
)
|
|
804
|
+
);
|
|
805
|
+
for (const [name, description, enabled] of [
|
|
806
|
+
[
|
|
807
|
+
"on",
|
|
808
|
+
"Turn it on or resume it. A new schedule starts at the recommended budget unless --budget is given",
|
|
809
|
+
true
|
|
810
|
+
],
|
|
811
|
+
[
|
|
812
|
+
"set",
|
|
813
|
+
"Change the monthly budget or the audit areas without turning it on or off",
|
|
814
|
+
void 0
|
|
815
|
+
]
|
|
816
|
+
]) {
|
|
817
|
+
continuous.command(`${name} <repoId>`).description(description).option("--branch <branch>", "the scheduled branch").option(
|
|
818
|
+
"--budget <credits>",
|
|
819
|
+
"monthly budget in credits; sets the interval from weekly to twice daily",
|
|
820
|
+
toCredits
|
|
821
|
+
).option(
|
|
822
|
+
"--area <key>",
|
|
823
|
+
"audit area to rotate through, one per run (repeatable; see `zkao areas list`)",
|
|
824
|
+
collect,
|
|
825
|
+
[]
|
|
826
|
+
).option("--whole-repo", "scan the whole repository every run").action(
|
|
827
|
+
(repoId, opts) => run(
|
|
828
|
+
(c) => c.setContinuousTesting(repoId, {
|
|
829
|
+
...enabled === void 0 ? {} : { enabled },
|
|
830
|
+
...continuousChanges(opts)
|
|
831
|
+
})
|
|
832
|
+
)
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
continuous.command("off <repoId>").description("Pause it. The schedule and its settings are kept").option("--branch <branch>", "the scheduled branch").action(
|
|
836
|
+
(repoId, opts) => run(
|
|
837
|
+
(c) => c.setContinuousTesting(repoId, {
|
|
838
|
+
enabled: false,
|
|
839
|
+
...opts.branch === void 0 ? {} : { branch: opts.branch }
|
|
840
|
+
})
|
|
841
|
+
)
|
|
842
|
+
);
|
|
843
|
+
continuous.command("rm <repoId>").description("Remove the schedule. Scans it already ran are kept").option("--branch <branch>", "the scheduled branch").action(
|
|
844
|
+
(repoId, opts) => run(
|
|
845
|
+
(c) => c.removeContinuousTesting(repoId, {
|
|
846
|
+
...opts.branch === void 0 ? {} : { branch: opts.branch }
|
|
847
|
+
})
|
|
848
|
+
)
|
|
849
|
+
);
|
|
775
850
|
var scans = program.command("scans").description("Launch, list, and poll scans");
|
|
776
851
|
scans.command("list").option("--page <n>", "page number", toInt).option("--limit <n>", "page size (max 100)", toInt).action(
|
|
777
852
|
(opts) => run((c) => c.listScans({ page: opts.page, limit: opts.limit }))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zksecurity/zkao-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0-next.13",
|
|
4
4
|
"description": "Command-line interface for the zkao Project API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "zkSecurity",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"prepublishOnly": "node -e \"if (!(process.env.npm_config_user_agent || '').includes('bun/')) { console.error('Publish with bun publish: npm ships the literal workspace:* dependency and breaks installs.'); process.exit(1); }\""
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@zksecurity/zkao-sdk": "0.
|
|
42
|
+
"@zksecurity/zkao-sdk": "0.18.0-next.13",
|
|
43
43
|
"commander": "^12.1.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|