mirror of
https://github.com/qybaihe/bla.git
synced 2026-11-20 08:20:59 +08:00
Merge pull request #234 from DeryFerd/fix/protect-manifest-flags
This commit is contained in:
+14
-3
@@ -101,9 +101,9 @@ Options:
|
||||
--intensity <preset> stealth | balanced | maximum | bankrupt
|
||||
(harden/defend default: bankrupt; protect default: balanced)
|
||||
--seed <seed> Deterministic PRNG seed (default: per-project random in .blarc)
|
||||
--manifest Emit .bla-manifest.json next to protected artifacts (opt-in; unsigned by default)
|
||||
--sign-manifest Ed25519-sign the emitted manifest (implies --manifest; requires --manifest-key)
|
||||
--manifest-key <path> Ed25519 private key PEM file used by --sign-manifest
|
||||
--manifest Emit .bla-manifest.json next to protected artifacts (harden/defend; opt-in)
|
||||
--sign-manifest Ed25519-sign the emitted manifest (harden/defend; implies --manifest)
|
||||
--manifest-key <path> Ed25519 private key PEM file used by --sign-manifest (harden/defend)
|
||||
--public-key <path> Trusted ed25519 public key PEM for verify-manifest
|
||||
--require-pinned-key verify-manifest: exit 2 unless --public-key authenticated the manifest
|
||||
--require-artifact verify-manifest: exit 2 unless the protected artifact's SHA-256 was verified
|
||||
@@ -454,6 +454,17 @@ export function parseCliArgs(argv: readonly string[]): ParsedCliArgs {
|
||||
}
|
||||
}
|
||||
|
||||
// protect has no manifest stage: ProtectionOptions carries no manifest field,
|
||||
// so accepting the flags here would silently produce nothing.
|
||||
if (
|
||||
command === "protect" &&
|
||||
(manifest || signManifest || manifestKey !== undefined)
|
||||
) {
|
||||
argErrors.push(
|
||||
"--manifest / --sign-manifest / --manifest-key are not supported by the protect command; use harden or defend",
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
command,
|
||||
positionals,
|
||||
|
||||
@@ -61,6 +61,23 @@ describe("CLI flag validation", () => {
|
||||
await expect(runCli(["--version", "--bogus"])).resolves.toBe(0);
|
||||
});
|
||||
|
||||
it("rejects manifest flags on protect instead of silently ignoring them", async () => {
|
||||
for (const argv of [
|
||||
["protect", "x.js", "--manifest"],
|
||||
["protect", "x.js", "--sign-manifest"],
|
||||
["protect", "x.js", "--manifest-key", "k.pem"],
|
||||
]) {
|
||||
expect(parseCliArgs(argv).argErrors.join(" ")).toMatch(
|
||||
/not supported by the protect command/,
|
||||
);
|
||||
}
|
||||
await expect(runCli(["protect", "x.js", "--manifest"])).resolves.toBe(1);
|
||||
|
||||
// harden and defend do implement the manifest stage.
|
||||
expect(parseCliArgs(["harden", "./dist", "--manifest"]).argErrors).toEqual([]);
|
||||
expect(parseCliArgs(["defend", "./dist", "--manifest"]).argErrors).toEqual([]);
|
||||
});
|
||||
|
||||
it("accepts --flag=value spellings for every value flag", () => {
|
||||
const parsed = parseCliArgs([
|
||||
"defend",
|
||||
|
||||
Reference in New Issue
Block a user