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.

fix(python): cover CPython 3.14 pyc magic on Ubuntu 26 runners (#55)

Timo Zhang970813a064c9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 145d989..fd1beaa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,7 +50,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
for containers/CODE; copy shared `co_consts` before mutate) and append unused decoy
`TYPE_CODE` into module + customer `co_consts` (no `FLAG_REF` on decoys; original
`co_code` preserved). Trailer canary/diagnostic honey still applied. Planner maturity
- for `python-pyc` is now `woven`.
+ for `python-pyc` is now `woven`. Magic map covers CPython 3.11–3.14
+ (incl. Ubuntu 26 runners / magic 3627) plus 3.15 headroom.
## [1.6.3] β€” 2026-11-01
diff --git a/src/shields/formats/python-pyc-weave.ts b/src/shields/formats/python-pyc-weave.ts
index 4584494..2553bc2 100644
--- a/src/shields/formats/python-pyc-weave.ts
+++ b/src/shields/formats/python-pyc-weave.ts
@@ -47,12 +47,15 @@ const TYPE_SHORT_ASCII = 0x7a;
const TYPE_SHORT_ASCII_INTERNED = 0x5a;
const MAGIC_LAYOUT: ReadonlyMap<number, PythonPycCodeLayout> = new Map([
+ // CPython marshal CODE layout families (see Include/internal/pycore_magic_number.h).
...range(3390, 3394, "py37"),
...range(3400, 3401, "py37"),
- ...range(3410, 3439, "py38"),
- ...range(3494, 3495, "py311"),
- ...range(3500, 3531, "py311"),
- ...range(3550, 3571, "py311"),
+ ...range(3410, 3439, "py38"), // 3.8–3.10 (posonly + nlocals/varnames)
+ ...range(3450, 3495, "py311"), // 3.11 (localsplus; nlocals dropped)
+ ...range(3500, 3531, "py311"), // 3.12
+ ...range(3550, 3571, "py311"), // 3.13
+ ...range(3600, 3627, "py311"), // 3.14 (Ubuntu 26+ runners)
+ ...range(3650, 3699, "py311"), // 3.15 headroom
]);
function range(
diff --git a/tests/python-pyc-weave.test.ts b/tests/python-pyc-weave.test.ts
index 3c53ae5..f5dd45e 100644
--- a/tests/python-pyc-weave.test.ts
+++ b/tests/python-pyc-weave.test.ts
@@ -101,10 +101,16 @@ print(n)
}
describe("python-pyc-weave", () => {
+ it("maps CPython 3.11–3.14 magic numbers to the py311 CODE layout", () => {
+ for (const magic of [3495, 3531, 3571, 3627]) {
+ expect(layoutForPycMagic(magic)).toBe("py311");
+ }
+ });
+
it("maps current CPython magic to a known layout", () => {
const pyc = compileSamplePyc();
const magic = pyc.readUInt16LE(0);
- expect(layoutForPycMagic(magic)).toBe("py311");
+ expect(layoutForPycMagic(magic)).toBe("py311"); // 3.11+ marshal CODE layout (3.11–3.15 magics)
});
it("weave_decoys:true injects decoy TYPE_CODE into customer co_consts without breaking import", () => {