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.

test(crackme): import lib.mjs with relative specifier for paths with spaces (#58)

Dery Ferdika91548db60399
diff --git a/scripts/crackme/lib.mjs b/scripts/crackme/lib.mjs
index 067745d..6756424 100644
--- a/scripts/crackme/lib.mjs
+++ b/scripts/crackme/lib.mjs
@@ -19,7 +19,7 @@ import {
} from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
-import { fileURLToPath, pathToFileURL } from "node:url";
+import { fileURLToPath } from "node:url";
import { gunzipSync, gzipSync } from "node:zlib";
export const ROOT = resolve(fileURLToPath(new URL("../..", import.meta.url)));
@@ -140,8 +140,11 @@ export function ensureDistBuilt() {
*/
export async function hardenChallenge({ key, flag, outDir, seed = SEED }) {
ensureDistBuilt();
- const { hardenProject } = await import(pathToFileURL(join(ROOT, "dist", "engine", "harden.js")).href);
- const { BLA_IDENTITY } = await import(pathToFileURL(join(ROOT, "dist", "identity.js")).href);
+ // Relative specifier (not file:// URL): Vite/vitest cannot resolve
+ // percent-encoded URLs when the workspace path contains spaces; Node ESM
+ // resolves `import.meta.url`-relative specifiers correctly either way.
+ const { hardenProject } = await import("../../dist/engine/harden.js");
+ const { BLA_IDENTITY } = await import("../../dist/identity.js");
const work = mkdtempSync(join(tmpdir(), "bla-crackme-v6-"));
try {
const stage = join(work, "app");
diff --git a/tests/crackme-v6.test.ts b/tests/crackme-v6.test.ts
index aecbe86..4873bf8 100644
--- a/tests/crackme-v6.test.ts
+++ b/tests/crackme-v6.test.ts
@@ -9,7 +9,6 @@ import { createHash } from "node:crypto";
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
-import { pathToFileURL } from "node:url";
import { gunzipSync } from "node:zlib";
import { assertNoForbiddenMarkers } from "../src/core/identifiers.js";
import { inspectWasmBinary } from "../src/shields/formats/wasm.js";
@@ -17,8 +16,11 @@ import { inspectWasmBinary } from "../src/shields/formats/wasm.js";
const ROOT = resolve(process.cwd());
const V6 = join(ROOT, "challenge", "v6");
const HARDENED = join(V6, "hardened");
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-const libP: Promise<any> = import(pathToFileURL(join(ROOT, "scripts", "crackme", "lib.mjs")).href);
+ // Relative specifier, not a file:// URL: Vite/vitest cannot resolve
+ // percent-encoded file URLs when the workspace path contains spaces.
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ // @ts-expect-error lib.mjs ships no type declarations; typed by its runtime shape.
+ const libP: Promise<any> = import("../scripts/crackme/lib.mjs");
const seal = JSON.parse(readFileSync(join(V6, "SEAL.json"), "utf8"));
// eslint-disable-next-line @typescript-eslint/no-explicit-any