diff --git a/src/cli.ts b/src/cli.ts index 4e2b8e1..2f0e24f 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -101,9 +101,9 @@ Options: --intensity stealth | balanced | maximum | bankrupt (harden/defend default: bankrupt; protect default: balanced) --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 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 Ed25519 private key PEM file used by --sign-manifest (harden/defend) --public-key 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, diff --git a/tests/cli-flag-validation.test.ts b/tests/cli-flag-validation.test.ts index d3526b9..4ba6419 100644 --- a/tests/cli-flag-validation.test.ts +++ b/tests/cli-flag-validation.test.ts @@ -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",