Skip to content

armgit / bla

Public Imported from GitHub
0

🛡️ 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.

feat(verify): wire honesty soft-caps into verifyTarget report fields

qybaihe5a9a60bd1f26
diff --git a/src/core/types.ts b/src/core/types.ts
index 51bb5b0..7de2152 100644
--- a/src/core/types.ts
+++ b/src/core/types.ts
@@ -207,12 +207,26 @@ export interface VerificationCheck {
readonly details: string;
}
+/** Soft-cap annotation when known product gaps still apply (issue #40.6). */
+export interface DefenseScoreGapAnnotation {
+ readonly id: string;
+ readonly summary: string;
+ readonly scoreCap: number;
+}
+
export interface VerificationReport {
readonly targetPath: string;
readonly originalPath?: string;
readonly detectedFormat: ArtifactFormat;
readonly overallPassed: boolean;
- readonly defenseScore: number; // 0 to 100
+ /** Soft-capped Counter-REA gate score (0–100). Not a preimage-hardness claim. */
+ readonly defenseScore: number;
+ /** Raw gate score before honesty soft-caps (issue #40.6). */
+ readonly defenseScoreRaw?: number;
+ /** Known gaps that annotated / capped the score. */
+ readonly defenseScoreGaps?: readonly DefenseScoreGapAnnotation[];
+ /** Fixed disclaimer: score ≠ preimage hardness. */
+ readonly defenseScoreDisclaimer?: string;
readonly checks: readonly VerificationCheck[];
readonly tokenAmplificationFactor: number;
readonly costAmplificationFactor: number;
diff --git a/src/engine/verifier.ts b/src/engine/verifier.ts
index fd07aa0..ff22e8f 100644
--- a/src/engine/verifier.ts
+++ b/src/engine/verifier.ts
@@ -1,13 +1,25 @@
import { resolve } from "node:path";
import type { VerificationCheck, VerificationReport } from "../core/types.js";
import { auditTarget } from "./auditor.js";
+import {
+ applyDefenseScoreHonesty,
+ DEFENSE_SCORE_DISCLAIMER,
+} from "./defense-score-honesty.js";
+
+export interface VerifyTargetOptions {
+ readonly selfSealEnabled?: boolean;
+ readonly wasmExportRenameApplied?: boolean;
+ readonly numericTemplateLeakKnown?: boolean;
+}
/**
* Verifies a protected artifact against REA's analysis invariants (`bla verify`).
+ * `defenseScore` is soft-capped when known product gaps still apply (issue #40.6).
*/
export function verifyTarget(
targetPath: string,
originalPath?: string,
+ options: VerifyTargetOptions = {},
): VerificationReport {
const absTarget = resolve(targetPath);
const afterAudit = auditTarget(absTarget);
@@ -91,20 +103,34 @@ export function verifyTarget(
});
const passedCount = checks.filter((c) => c.passed).length;
- // defenseScore measures Counter-REA gate pass-rate + exposure drop only.
- // It is NOT a claim of cryptographic preimage hardness: numeric-literal
- // coverage, WASM export rename, opaque-predicate seed strength, and
- // opt-in self-seal helpers are tracked separately (issue #40).
- const defenseScore = Math.round(
- (passedCount / checks.length) * 70 + Math.max(0, (100 - afterAudit.exposureScore) * 0.3),
+ // Raw score = Counter-REA gate pass-rate + exposure drop only.
+ // Soft-capped below when known gaps still apply (issue #40.6).
+ const rawDefenseScore = Math.min(
+ 100,
+ Math.round(
+ (passedCount / checks.length) * 70 + Math.max(0, (100 - afterAudit.exposureScore) * 0.3),
+ ),
);
+ const honesty = applyDefenseScoreHonesty(rawDefenseScore, {
+ detectedFormat: afterAudit.detectedFormat,
+ selfSealEnabled: options.selfSealEnabled === true,
+ wasmExportRenameApplied: options.wasmExportRenameApplied === true,
+ numericTemplateLeakKnown: options.numericTemplateLeakKnown === true,
+ });
return {
targetPath: absTarget,
...(originalPath ? { originalPath: resolve(originalPath) } : {}),
detectedFormat: afterAudit.detectedFormat,
overallPassed: passedCount === checks.length,
- defenseScore: Math.min(100, defenseScore),
+ defenseScore: honesty.cappedScore,
+ defenseScoreRaw: honesty.rawScore,
+ defenseScoreGaps: honesty.gaps.map((g) => ({
+ id: g.id,
+ summary: g.summary,
+ scoreCap: g.scoreCap,
+ })),
+ defenseScoreDisclaimer: DEFENSE_SCORE_DISCLAIMER,
checks,
tokenAmplificationFactor: tokenAmp,
costAmplificationFactor: costAmp,
diff --git a/src/index.ts b/src/index.ts
index e134cad..5e32a7a 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -144,6 +144,19 @@ export {
export { auditTarget } from "./engine/auditor.js";
export { protectTarget } from "./engine/protector.js";
export { verifyTarget } from "./engine/verifier.js";
+export type { VerifyTargetOptions } from "./engine/verifier.js";
+export {
+ applyDefenseScoreHonesty,
+ collectDefenseScoreGaps,
+ DEFENSE_SCORE_DISCLAIMER,
+ formatDefenseScoreGapAnnotation,
+} from "./engine/defense-score-honesty.js";
+export type {
+ DefenseScoreGap,
+ DefenseScoreGapId,
+ DefenseScoreHonesty,
+ DefenseScoreHonestyInput,
+} from "./engine/defense-score-honesty.js";
export {
defendTarget,
type OneClickDefenseOptions,