From 5a724569b4fbe910c39499cbb8775c3804db6164 Mon Sep 17 00:00:00 2001 From: DeryFerd Date: Sun, 15 Nov 2026 16:50:27 +0700 Subject: [PATCH] fix(cli): reject manifest flags on protect instead of ignoring them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --manifest, --sign-manifest and --manifest-key are accepted by the parser and advertised in --help with no per-command restriction, but only harden and defend consume them. ProtectionOptions has no manifest field, so 'bla protect app.js --manifest' exited 0 and wrote no manifest — an operator would think the artifact had been signed. The flags are now an argument error for protect, and the help text says which commands implement the stage. --- src/cli.ts | 17 ++++++++++++++--- tests/cli-flag-validation.test.ts | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 3869c6b..0dc77b4 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 --llm-directives Opt-in risky LLM directive layers (COPPA/medical bait, dual-use imitation, AI chat markers); OFF by default @@ -449,6 +449,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 4af8c9a..cdcc4cd 100644 --- a/tests/cli-flag-validation.test.ts +++ b/tests/cli-flag-validation.test.ts @@ -38,6 +38,23 @@ describe("CLI flag validation", () => { await expect(runCli(["--help", "--fail-under", "-1"])).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",