π‘οΈ BLA (Blind LLM Agents) β Adversarial defense shield that protects binaries, Electron apps, JS bundles, Python, and WebAssembly against AI reverse-engineering agents like REA. Poison -> Exhaust -> Hallucinate.
JavaScript adversarial-aiclaude-codecursorelectron-securityllm-securitymcpmcp-serverobfuscationreverse-engineeringwebassembly
feat(engine): opt-in ed25519 signing for defense attestation manifests
DeryFerde6a022509513
diff --git a/src/cli.ts b/src/cli.tsindex c286e64..b4e2e59 100644--- a/src/cli.ts+++ b/src/cli.ts@@ -86,7 +86,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 unsigned .bla-manifest.json next to protected artifacts (opt-in)+ --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--llm-directives Opt-in risky LLM directive layers (COPPA/medical bait, dual-use imitation, AI chat markers); OFF by default--weave-decoys Opt-in structural weave decoys (Python customer-def / .pyc co_consts weave; JS AST weave already on); OFF by default--self-seal Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5); OFF by default@@ -117,6 +119,8 @@ interface ParsedCliArgs {readonly intensity: ProtectionIntensity;readonly seed?: string;readonly manifest: boolean;+ readonly signManifest: boolean;+ readonly manifestKey?: string;readonly llmDirectives: boolean;readonly weaveDecoys: boolean;readonly selfSeal: boolean;@@ -152,6 +156,8 @@ export function parseCliArgs(argv: readonly string[]): ParsedCliArgs {let intensity: ProtectionIntensity = "balanced";let seed: string | undefined;let manifest = false;+ let signManifest = false;+ let manifestKey: string | undefined;let llmDirectives = false;let weaveDecoys = false;let selfSeal = false;@@ -199,6 +205,10 @@ export function parseCliArgs(argv: readonly string[]): ParsedCliArgs {honeyMaps = false;} else if (arg === "--manifest") {manifest = true;+ } else if (arg === "--sign-manifest") {+ signManifest = true;+ } else if (arg === "--manifest-key" && i + 1 < argv.length) {+ manifestKey = argv[++i]!;} else if (arg === "--llm-directives") {llmDirectives = true;} else if (arg === "--weave-decoys") {@@ -274,6 +284,8 @@ export function parseCliArgs(argv: readonly string[]): ParsedCliArgs {intensity,...(seed !== undefined ? { seed } : {}),manifest,+ signManifest,+ ...(manifestKey !== undefined ? { manifestKey } : {}),llmDirectives,weaveDecoys,selfSeal,@@ -408,7 +420,10 @@ export async function runCli(argv: readonly string[] = process.argv.slice(2)): Pintensity: explicitIntensity,...(seed !== undefined ? { seed } : {}),dryRun: parsed.dryRun,- emitManifest: parsed.manifest || loaded.config.emitManifest === true,+ emitManifest: parsed.manifest || parsed.signManifest === true || loaded.config.emitManifest === true,+ ...(parsed.signManifest === true+ ? { signManifest: true, manifestSigningKeyPath: parsed.manifestKey ?? "" }+ : {}),llmDirectives: parsed.llmDirectives || loaded.config.llmDirectives === true,weaveDecoys: parsed.weaveDecoys || loaded.config.weaveDecoys === true,selfSeal: parsed.selfSeal || loaded.config.selfSeal === true,@@ -475,7 +490,10 @@ export async function runCli(argv: readonly string[] = process.argv.slice(2)): PinPlace: parsed.inPlace,intensity: explicitIntensity,seed: resolved.seed,- emitManifest: parsed.manifest || loaded.config.emitManifest === true,+ emitManifest: parsed.manifest || parsed.signManifest === true || loaded.config.emitManifest === true,+ ...(parsed.signManifest === true+ ? { signManifest: true, manifestSigningKeyPath: parsed.manifestKey ?? "" }+ : {}),llmDirectives: parsed.llmDirectives || loaded.config.llmDirectives === true,weaveDecoys: parsed.weaveDecoys || loaded.config.weaveDecoys === true,selfSeal: parsed.selfSeal || loaded.config.selfSeal === true,diff --git a/src/core/manifest-signing.ts b/src/core/manifest-signing.tsnew file mode 100644index 0000000..47c50e2--- /dev/null+++ b/src/core/manifest-signing.ts@@ -0,0 +1,110 @@+import {+ createPrivateKey,+ createPublicKey,+ generateKeyPairSync,+ sign as cryptoSign,+ verify as cryptoVerify,+} from "node:crypto";+import { readFileSync } from "node:fs";+import { isAbsolute, resolve } from "node:path";++/**+ * Optional ed25519 signing for `.bla-manifest.json` attestation manifests.+ *+ * The manifest payload itself stays plain JSON; signing is additive so+ * unsigned manifests remain valid. A signed manifest embeds `signature` with+ * the SPKI public key and a base64 ed25519 signature over `JSON.stringify`+ * of the payload WITHOUT the `signature` field (key order preserved).+ *+ * Honesty contract (matches defender.ts `attestationKind`):+ * - `attestationKind: "unsigned"` β no `signature` field, never claim signed.+ * - `attestationKind: "ed25519"` β `signature` present and verifiable.+ */+export interface ManifestSignature {+ readonly algorithm: "ed25519";+ /** SPKI public key (PEM) that verifies `value`. */+ readonly publicKey: string;+ /** base64 ed25519 signature over the canonical payload JSON. */+ readonly value: string;+}++export interface ManifestSigningKeyPair {+ readonly privateKeyPem: string;+ readonly publicKeyPem: string;+}++/** Generate a fresh ed25519 keypair (PKCS8 private + SPKI public, PEM). */+export function generateManifestSigningKeyPair(): ManifestSigningKeyPair {+ const { privateKey, publicKey } = generateKeyPairSync("ed25519");+ return {+ privateKeyPem: privateKey.export({ type: "pkcs8", format: "pem" }).toString("utf8"),+ publicKeyPem: publicKey.export({ type: "spki", format: "pem" }).toString("utf8"),+ };+}++/**+ * Sign a manifest payload. Returns the payload plus an embedded `signature`.+ * The signature covers `JSON.stringify(payload)` exactly as passed (caller+ * controls key insertion order; `signature` is always appended last).+ */+export function signManifestPayload<T extends object>(+ payload: T,+ privateKeyPem: string,+): T & { readonly signature: ManifestSignature } {+ const privateKey = createPrivateKey(privateKeyPem);+ const canonical = JSON.stringify(payload);+ const value = cryptoSign(null, Buffer.from(canonical, "utf8"), privateKey).toString("base64");+ const publicKeyPem = createPublicKey(privateKey)+ .export({ type: "spki", format: "pem" })+ .toString("utf8");+ return {+ ...payload,+ signature: { algorithm: "ed25519", publicKey: publicKeyPem, value },+ };+}++/**+ * Verify a manifest object's embedded ed25519 `signature`.+ * Returns false for unsigned manifests, malformed signatures, or mismatches β+ * never throws.+ */+export function verifyManifestSignature(manifest: Record<string, unknown>): boolean {+ const rawSignature = manifest.signature;+ if (rawSignature === undefined || rawSignature === null || typeof rawSignature !== "object") {+ return false;+ }+ const signature = rawSignature as Partial<ManifestSignature>;+ if (+ signature.algorithm !== "ed25519" ||+ typeof signature.publicKey !== "string" ||+ typeof signature.value !== "string"+ ) {+ return false;+ }+ try {+ const publicKey = createPublicKey(signature.publicKey);+ const { signature: _ignored, ...rest } = manifest;+ const canonical = JSON.stringify(rest);+ return cryptoVerify(null, Buffer.from(canonical, "utf8"), publicKey, Buffer.from(signature.value, "base64"));+ } catch {+ return false;+ }+}++/**+ * Resolve the signing private key PEM from an explicit path (required when+ * signing is requested β fail closed instead of silently emitting unsigned).+ */+export function readManifestSigningKeyOrThrow(keyPath: string): string {+ if (typeof keyPath !== "string" || keyPath.trim().length === 0) {+ throw new Error(+ "Manifest signing requires a private key path (CLI --manifest-key <path>, MCP manifest_key_path).",+ );+ }+ const resolved = isAbsolute(keyPath) ? keyPath : resolve(process.cwd(), keyPath);+ try {+ return readFileSync(resolved, "utf8");+ } catch {+ throw new Error(`Manifest signing key not readable: ${resolved}`);+ }+}diff --git a/src/engine/defender.ts b/src/engine/defender.tsindex 0710a56..6ac515d 100644--- a/src/engine/defender.ts+++ b/src/engine/defender.ts@@ -15,6 +15,10 @@ import { REA_BUDGET_BREAKER_MATRIX } from "../shields/exhaustion/index.js";import { auditTarget } from "./auditor.js";import { protectTarget } from "./protector.js";import { verifyTarget } from "./verifier.js";+import {+ signManifestPayload,+ readManifestSigningKeyOrThrow,+} from "../core/manifest-signing.js";export interface OneClickDefenseOptions {readonly inputPath: string;@@ -23,6 +27,10 @@ export interface OneClickDefenseOptions {readonly intensity?: ProtectionIntensity;readonly seed?: string | number;readonly emitManifest?: boolean;+ /** Opt-in ed25519 signing of the stage-5 manifest. Requires emitManifest. */+ readonly signManifest?: boolean;+ /** Path to an ed25519 private key PEM used when signManifest is true. */+ readonly manifestSigningKeyPath?: string;readonly llmDirectives?: boolean;readonly weaveDecoys?: boolean;/** Opt-in self-seal / sibling-module integrity binding for JS/Node (issue #40.5). */@@ -70,6 +78,8 @@ export interface OneClickDefenseReport {readonly weaveDecoys: boolean;/** True when caller opted into self-seal integrity binding. */readonly selfSeal: boolean;+ /** True when stage 5 emitted an ed25519-signed manifest. */+ readonly manifestSigned?: boolean;readonly overallSuccess: boolean;readonly stages: readonly OneClickDefenseStageSummary[];readonly releaseExposure: ReleaseExposureReport | null;@@ -109,6 +119,17 @@ export function defendTarget(options: OneClickDefenseOptions): OneClickDefenseReconst absInput = resolve(options.inputPath);const intensity: ProtectionIntensity = options.intensity ?? "bankrupt";+ // Fail closed before any pipeline work when signing is requested.+ let manifestSigningKeyPem: string | undefined;+ if (options.signManifest === true) {+ if (options.emitManifest !== true) {+ throw new Error(+ "signManifest requires emitManifest β a manifest must be emitted before it can be signed.",+ );+ }+ manifestSigningKeyPem = readManifestSigningKeyOrThrow(options.manifestSigningKeyPath ?? "");+ }+// Stage 1: Release Exposure Scan (best-effort for local files/directories)let releaseExposure: ReleaseExposureReport | null = null;try {@@ -222,15 +243,18 @@ export function defendTarget(options: OneClickDefenseOptions): OneClickDefenseRe];let manifestPath: string | undefined;+ let manifestSigned = false;if (options.emitManifest) {manifestPath = `${protection.outputPath}.bla-manifest.json`;+ const attestationKind =+ options.signManifest === true ? ("ed25519" as const) : ("unsigned" as const);const manifestPayload = {schema: "https://bla.tools/schemas/defense-manifest-v1.json",blaVersion: BLA_IDENTITY.version,protectedAt: new Date().toISOString(),// Honesty: this JSON is an attestation record, not a cryptographic signature.// Set attestationKind to "ed25519" only when a real signature is attached.- attestationKind: "unsigned",+ attestationKind,inputSha256: protection.originalSha256,protectedSha256: protection.protectedSha256,detectedFormat: protection.detectedFormat,@@ -241,11 +265,22 @@ export function defendTarget(options: OneClickDefenseOptions): OneClickDefenseReexhaustionSummary,deceptionSummary,};- writeFileSync(manifestPath, JSON.stringify(manifestPayload, null, 2) + "\n", "utf8");+ let payloadToWrite: Record<string, unknown> = manifestPayload;+ if (attestationKind === "ed25519") {+ // manifestSigningKeyPem is guaranteed non-undefined by the fail-closed+ // validation at function entry whenever signManifest is true.+ payloadToWrite = signManifestPayload(manifestPayload, manifestSigningKeyPem!);+ manifestSigned = true;+ }+ writeFileSync(manifestPath, JSON.stringify(payloadToWrite, null, 2) + "\n", "utf8");stages.push({stage: "5-defense-attestation-manifest",status: "passed",- headline: `Emitted unsigned Counter-REA attestation manifest (not ed25519-signed) to ${manifestPath}`,+ headline: `Emitted ${+ manifestSigned ? "ed25519-signed" : "unsigned"+ } Counter-REA attestation manifest${+ manifestSigned ? "" : " (not ed25519-signed)"+ } to ${manifestPath}`,});}@@ -263,6 +298,7 @@ export function defendTarget(options: OneClickDefenseOptions): OneClickDefenseReprotection,verification,...(manifestPath !== undefined ? { manifestPath } : {}),+ ...(manifestSigned ? { manifestSigned } : {}),exhaustionSummary,deceptionSummary,};diff --git a/src/engine/harden.ts b/src/engine/harden.tsindex 1c27c35..0fa9542 100644--- a/src/engine/harden.ts+++ b/src/engine/harden.ts@@ -122,6 +122,10 @@ export interface HardenProjectOptions {readonly intensity?: ProtectionIntensity;readonly seed?: string | number;readonly emitManifest?: boolean;+ /** Opt-in ed25519 signing of each emitted manifest. Requires emitManifest. */+ readonly signManifest?: boolean;+ /** Path to an ed25519 private key PEM used when signManifest is true. */+ readonly manifestSigningKeyPath?: string;readonly llmDirectives?: boolean;readonly weaveDecoys?: boolean;/** Opt-in self-seal / sibling-module integrity binding for JS/Node (issue #40.5). */@@ -378,6 +382,9 @@ export function hardenProject(const intensity: ProtectionIntensity = options.intensity ?? "bankrupt";// Manifests are opt-in: do not ship `.bla-manifest.json` next to customer artifacts by default.const emitManifest = options.emitManifest === true;+ if (options.signManifest === true && emitManifest !== true) {+ throw new Error("signManifest requires emitManifest in hardenProject");+ }const maxArtifacts = options.maxArtifacts ?? MAX_DISCOVERED_ARTIFACTS;const dryRun = options.dryRun === true;@@ -659,6 +666,9 @@ export function hardenProject(return list.length > 0 ? { selfSealSiblingPaths: list } : {};})()),emitManifest,+ ...(options.signManifest === true+ ? { signManifest: true, manifestSigningKeyPath: options.manifestSigningKeyPath ?? "" }+ : {}),});summaries.push({inputPath: artifact.path,diff --git a/src/index.ts b/src/index.tsindex cb1f857..c148b3b 100644--- a/src/index.ts+++ b/src/index.ts@@ -264,6 +264,14 @@ export * from "./core/sarif.js";export * from "./core/release-plan.js";export * from "./core/debug-posture.js";export * from "./core/coverage-contract.js";+export {+ generateManifestSigningKeyPair,+ signManifestPayload,+ verifyManifestSignature,+ readManifestSigningKeyOrThrow,+ type ManifestSignature,+ type ManifestSigningKeyPair,+} from "./core/manifest-signing.js";export {resolveSupportedAgentClients,detectInstalledClients,diff --git a/src/mcp/server.ts b/src/mcp/server.tsindex a8c7d3b..8db668d 100644--- a/src/mcp/server.ts+++ b/src/mcp/server.ts@@ -181,7 +181,15 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([},emit_manifest: {type: "boolean",- description: "Opt-in: emit an unsigned .bla-manifest.json attestation (not ed25519-signed) per artifact. Default false.",+ description: "Opt-in: emit a .bla-manifest.json attestation per artifact (unsigned unless sign_manifest is true). Default false.",+ },+ sign_manifest: {+ type: "boolean",+ description: "Opt-in: ed25519-sign each emitted manifest (implies emit_manifest). Requires manifest_key_path. Default false.",+ },+ manifest_key_path: {+ type: "string",+ description: "Path to an ed25519 private key PEM file used when sign_manifest is true.",},llm_directives: {type: "boolean",@@ -316,7 +324,15 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([},emit_manifest: {type: "boolean",- description: "Opt-in: emit an unsigned .bla-manifest.json attestation (not ed25519-signed) next to the hardened artifact. Default false.",+ description: "Opt-in: emit a .bla-manifest.json attestation next to the hardened artifact (unsigned unless sign_manifest is true). Default false.",+ },+ sign_manifest: {+ type: "boolean",+ description: "Opt-in: ed25519-sign the emitted manifest (implies emit_manifest). Requires manifest_key_path. Default false.",+ },+ manifest_key_path: {+ type: "string",+ description: "Path to an ed25519 private key PEM file used when sign_manifest is true.",},llm_directives: {type: "boolean",@@ -1220,7 +1236,14 @@ function runDefend(handlers: McpEngineHandlers, args: Record<string, unknown>):typeof args.intensity === "string"? (args.intensity as ProtectionIntensity): "bankrupt",- emitManifest: Boolean(args.emit_manifest),+ emitManifest: Boolean(args.emit_manifest) || args.sign_manifest === true,+ ...(args.sign_manifest === true+ ? {+ signManifest: true,+ manifestSigningKeyPath:+ typeof args.manifest_key_path === "string" ? args.manifest_key_path : "",+ }+ : {}),llmDirectives: Boolean(args.llm_directives),weaveDecoys: Boolean(args.weave_decoys),selfSeal: Boolean(args.self_seal),@@ -1864,7 +1887,14 @@ export async function handleMcpRequest(typeof args.intensity === "string"? (args.intensity as ProtectionIntensity): "bankrupt",- emitManifest: Boolean(args.emit_manifest),+ emitManifest: Boolean(args.emit_manifest) || args.sign_manifest === true,+ ...(args.sign_manifest === true+ ? {+ signManifest: true,+ manifestSigningKeyPath:+ typeof args.manifest_key_path === "string" ? args.manifest_key_path : "",+ }+ : {}),llmDirectives: Boolean(args.llm_directives),weaveDecoys: Boolean(args.weave_decoys),selfSeal: Boolean(args.self_seal),@@ -1918,7 +1948,8 @@ export async function handleMcpRequest(inPlace,);const planned =- name === "bla_defend" && args.emit_manifest === true+ name === "bla_defend" &&+ (args.emit_manifest === true || args.sign_manifest === true)? [out, `${out}.bla-manifest.json`]: [out];const clobbered = existingPaths(planned);diff --git a/src/ui/reporter.ts b/src/ui/reporter.tsindex c07d7cb..a60b959 100644--- a/src/ui/reporter.ts+++ b/src/ui/reporter.ts@@ -295,7 +295,12 @@ export function formatOneClickDefenseReport(rep: OneClickDefenseReport): stringif (rep.manifestPath) {lines.push("",- ` ${ANSI.bold}Signed Manifest:${ANSI.reset} ${ANSI.green}${rep.manifestPath}${ANSI.reset}`,+ ` ${ANSI.bold}Manifest:${ANSI.reset} ${ANSI.green}${rep.manifestPath}${ANSI.reset}`,+ ...(rep.manifestSigned+ ? [+ ` ${ANSI.bold}Signature:${ANSI.reset} ${ANSI.green}ed25519${ANSI.reset}`,+ ]+ : []),);}diff --git a/tests/manifest-signing.test.ts b/tests/manifest-signing.test.tsnew file mode 100644index 0000000..0ad5499--- /dev/null+++ b/tests/manifest-signing.test.ts@@ -0,0 +1,148 @@+import * as fs from "node:fs";+import * as os from "node:os";+import * as path from "node:path";+import { afterEach, beforeEach, describe, expect, it } from "vitest";+import {+ generateManifestSigningKeyPair,+ readManifestSigningKeyOrThrow,+ signManifestPayload,+ verifyManifestSignature,+} from "../src/core/manifest-signing.js";+import { defendTarget } from "../src/engine/defender.js";++describe("manifest ed25519 signing", () => {+ let dir: string;+ beforeEach(() => {+ dir = fs.mkdtempSync(path.join(os.tmpdir(), "bla-manifest-signing-"));+ });+ afterEach(() => {+ fs.rmSync(dir, { recursive: true, force: true });+ });++ it("generates a usable ed25519 keypair", () => {+ const pair = generateManifestSigningKeyPair();+ expect(pair.privateKeyPem).toContain("PRIVATE KEY");+ expect(pair.publicKeyPem).toContain("PUBLIC KEY");+ });++ it("signs and verifies a round trip, including JSON round trip", () => {+ const pair = generateManifestSigningKeyPair();+ const payload = { schema: "https://bla.tools/schemas/defense-manifest-v1.json", blaVersion: "1.2.3", items: [1, 2, 3] };+ const signed = signManifestPayload(payload, pair.privateKeyPem);+ expect(signed.signature.algorithm).toBe("ed25519");+ expect(signed.signature.publicKey).toContain("PUBLIC KEY");+ expect(verifyManifestSignature({ ...signed })).toBe(true);++ // Writing and re-reading the manifest must still verify (key order preserved).+ const parsed = JSON.parse(JSON.stringify(signed)) as Record<string, unknown>;+ expect(verifyManifestSignature(parsed)).toBe(true);+ });++ it("rejects tampered, unsigned, and forged manifests", () => {+ const pair = generateManifestSigningKeyPair();+ const signed = signManifestPayload({ a: 1 }, pair.privateKeyPem) as Record<string, unknown>;+ const signature = signed.signature as { algorithm: string; publicKey: string; value: string };++ expect(verifyManifestSignature({ ...signed, a: 2 })).toBe(false);+ expect(verifyManifestSignature({ a: 1 })).toBe(false);+ expect(verifyManifestSignature({ ...signed, signature: undefined })).toBe(false);++ const other = generateManifestSigningKeyPair();+ expect(+ verifyManifestSignature({+ ...signed,+ signature: { ...signature, publicKey: other.publicKeyPem },+ }),+ ).toBe(false);+ expect(+ verifyManifestSignature({+ ...signed,+ signature: { ...signature, value: Buffer.from("forged").toString("base64") },+ }),+ ).toBe(false);+ });++ it("reads the signing key from disk and fails closed on missing path", () => {+ const pair = generateManifestSigningKeyPair();+ const keyPath = path.join(dir, "manifest-key.pem");+ fs.writeFileSync(keyPath, pair.privateKeyPem);+ expect(readManifestSigningKeyOrThrow(keyPath)).toBe(pair.privateKeyPem);+ expect(() => readManifestSigningKeyOrThrow("")).toThrow(/private key path/);+ expect(() =>+ readManifestSigningKeyOrThrow(path.join(dir, "missing.pem")),+ ).toThrow(/not readable/);+ });++ it("defendTarget writes an ed25519-signed manifest when opted in", () => {+ const pair = generateManifestSigningKeyPair();+ const keyPath = path.join(dir, "signed-key.pem");+ fs.writeFileSync(keyPath, pair.privateKeyPem);++ const input = path.join(dir, "signed-app.js");+ const output = path.join(dir, "signed-app.shielded.js");+ fs.writeFileSync(input, "export const version = '1.0.0';\n", "utf8");++ const report = defendTarget({+ inputPath: input,+ outputPath: output,+ intensity: "stealth",+ emitManifest: true,+ signManifest: true,+ manifestSigningKeyPath: keyPath,+ });++ expect(report.manifestSigned).toBe(true);+ const manifestPath = `${output}.bla-manifest.json`;+ expect(report.manifestPath).toBe(manifestPath);++ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")) as Record<string, unknown>;+ expect(manifest.attestationKind).toBe("ed25519");+ expect(manifest.signature).toBeDefined();+ expect(verifyManifestSignature(manifest)).toBe(true);+ });++ it("defendTarget emits an unsigned manifest without the signing opt-in", () => {+ const input = path.join(dir, "plain-app.js");+ const output = path.join(dir, "plain-app.shielded.js");+ fs.writeFileSync(input, "export const n = 7;\n", "utf8");++ const report = defendTarget({+ inputPath: input,+ outputPath: output,+ intensity: "stealth",+ emitManifest: true,+ });++ expect(report.manifestSigned).toBeUndefined();+ const manifest = JSON.parse(+ fs.readFileSync(`${output}.bla-manifest.json`, "utf8"),+ ) as Record<string, unknown>;+ expect(manifest.attestationKind).toBe("unsigned");+ expect(manifest.signature).toBeUndefined();+ expect(verifyManifestSignature(manifest)).toBe(false);+ });++ it("fails closed when signing without emitManifest or a key path", () => {+ const pair = generateManifestSigningKeyPair();+ const keyPath = path.join(dir, "fail-key.pem");+ fs.writeFileSync(keyPath, pair.privateKeyPem);+ const input = path.join(dir, "fail-app.js");+ fs.writeFileSync(input, "export const q = 1;\n", "utf8");++ expect(() =>+ defendTarget({ inputPath: input, intensity: "stealth", signManifest: true, manifestSigningKeyPath: keyPath }),+ ).toThrow(/emitManifest/);+ expect(() =>+ defendTarget({ inputPath: input, intensity: "stealth", emitManifest: true, signManifest: true }),+ ).toThrow(/private key path/);+ expect(() =>+ defendTarget({+ inputPath: input,+ intensity: "stealth",+ emitManifest: true,+ signManifest: true,+ manifestSigningKeyPath: path.join(dir, "no-such-key.pem"),+ }),+ ).toThrow(/not readable/);+ });+});