agents: the hosted witness for agent ledgers (sandbox on testnet 28001), its probe and negative control; crypto-inventory 0.4.1 resolves a minimum TLS version given through a constant or a ternary; proof-kinds and conformance gain the agent-witness-checkpoint kind; the reproduction scripts of the Shield recipes no longer carry a workstation path

This commit is contained in:
Aere Network committed 2026-10-20 01:04:12 +03:00
1 parent 0c8f1de3fd
commit a654c3d522
27 files changed
+4737 -43

No files matched your search

+8 -1
View File
@@ -68,6 +68,13 @@ tool does not guess. At most 64 distinct variables are resolved per file; past t
file are reported as `unknown`, and the file is counted (`files-over-resolution-limit` in the CBOM, a
line in the text summary).
The TLS protocol version of a Node.js option (`minVersion`, `maxVersion`, `tls.DEFAULT_MIN_VERSION`, `tls.DEFAULT_MAX_VERSION`) is
resolved the same way since 0.4.1 (2026-10-19): a constant holding a version string is followed, and a constant assigned a
conditional between two version strings (`const min = strict ? 'TLSv1.3' : 'TLSv1.2'`) is reported with the WEAKER of the two,
since that is the version the code can end up allowing; `resolvedFrom` names the line and says it was a conditional. Any other
expression gives an `unknown` finding. Before 0.4.1 a version given through a variable produced no TLS finding at all, not even an
`unknown` one; it was found on our own TLS gateway, whose upstream minimum had moved into such a constant.
## Cost on hostile input
The scanner reads repositories it did not write, so its cost is kept linear in the size of each file,
@@ -215,7 +222,7 @@ console.log(renderSummary(result));
```
node test/proba.mjs # 68 probes: fixtures per language with the exact expected findings
node test/control-negativ.mjs # breaks the scanner in a copy, one rule at a time (35 mutations), and
node test/control-negativ.mjs # breaks the scanner in a copy, one rule at a time (38 mutations), and
# requires the matching probe to fail while the rest of the suite still runs
node test/proba-timp.mjs # 13 hostile inputs, each at two sizes: the cost must grow linearly
node test/control-negativ-timp.mjs # puts each quadratic form back (and one Swift comment rescan) and requires the cost probe to turn red
+21
View File
@@ -182,6 +182,27 @@ function rezolvaOData(ctx, nume) {
return null;
}
// 0.4.1 (2026-10-19, D-540): un TERNAR intre doua literale, `const X = <conditie> ? 'A' : 'B'`, cu aceleasi conditii ca rezolva()
// (exact o atribuire in fisier, pe randul declaratiei, numele nu e parametru). Intoarce ambele valori: cine il cheama alege ce conteaza
// (pentru o versiune TLS, ramura cea mai slaba). Numai JavaScript/TypeScript; orice alta forma: null.
export function rezolvaTernarJs(ctx, nume) {
if (ctx.limbaj !== 'javascript' || !identificator(nume)) return null;
const c = ctx.code;
const e = escapeRe(nume);
const atribuiri = ctx.potriviri(new RegExp(`(?<![\\w$.])${e}\\s*(?:[-+*/%|&^]|\\?\\?|\\|\\||&&)?(?::=|=)(?![=>])`, 'g'));
// garda proprie, cu alt text decat cea din rezolvaOData: controlul negativ le ancoreaza separat
if (atribuiri.length > 1 || !atribuiri.length) return null;
const k = atribuiri[0].index;
const ls0 = c.lastIndexOf('\n', k) + 1;
const le0 = c.indexOf('\n', k) < 0 ? c.length : c.indexOf('\n', k);
const linie = c.slice(ls0, le0);
const parametru = new RegExp(`(?:function\\b[^(]{0,200}\\(|\\()([^()]{0,2000}(?<![\\w$.])${e}(?![\\w$])[^()]{0,2000})\\)\\s*(?:=>|\\{)`).test(c)
|| new RegExp(`\\bfor\\s*\\(\\s*(?:const|let|var)?\\s*${e}\\s+(?:of|in)\\b`).test(c)
|| new RegExp(`(?<![\\w$.])${e}\\s*=>`).test(c);
const m = new RegExp(`\\b(?:const|let|var)\\s+${e}\\s*=\\s*[^?\\n;]{1,200}\\?\\s*(['"])([^'"\\n$\\\\]*)\\1\\s*:\\s*(['"])([^'"\\n$\\\\]*)\\3\\s*;?\\s*$`).exec(linie);
return !parametru && m ? { valori: [m[2], m[4]], line: ctx.poz(k).line } : null;
}
// valoarea unui argument: literal, variabila rezolvata sau necunoscuta
export function valoareArgument(ctx, arg) {
if (!arg) return { fel: 'lipsa' };
+27 -1
View File
@@ -1,5 +1,5 @@
// Detectorul JavaScript / TypeScript: node:crypto, WebCrypto, optiuni TLS, biblioteci din importuri.
import { argumente, imparteArgumente, valoareArgument, necunoscut, obiectulDin, cifruOpenssl, identificator, rezolva, escapeRe } from './context.mjs';
import { argumente, imparteArgumente, valoareArgument, necunoscut, obiectulDin, cifruOpenssl, identificator, rezolva, rezolvaTernarJs, escapeRe } from './context.mjs';
import { hashCanonic, grupTls, jws, JWS_RE } from './catalog.mjs';
const MODP = { modp1: 768, modp2: 1024, modp5: 1536, modp14: 2048, modp15: 3072, modp16: 4096, modp17: 6144, modp18: 8192 };
@@ -210,6 +210,32 @@ function detecteazaTlsJs(ctx) {
const rol = /min/i.test(m[1]) ? 'min' : 'max';
ctx.adauga(m.index, `tls ${m[1]}`, 'config', { grup: 'TLS', param: TLSV[m[3]], rol }, { bucata: m[0] });
}
// 0.4.1 (2026-10-19, D-540): versiunea data printr-o EXPRESIE, nu printr-un sir. Pana la 0.4.0 o constanta (`minVersion: v`) nu dadea
// nicio gasire TLS, nici macar una necunoscuta (gasit pe gateway-ul PQ al casei: `const minSus = ... ? 'TLSv1.3' : 'TLSv1.2'`). Acum, ca la
// ecdhCurve: o constanta se rezolva; un ternar intre doua literale de versiune da ramura cea mai SLABA (pentru o minima e podeaua care
// conteaza, pentru o maxima plafonul cel mai jos), spusa in resolvedFrom; orice alta expresie iese "unknown", nu tace. Un nume de tip
// TypeScript (`SecureVersion`, `string`) dupa doua puncte nu e o valoare.
for (const m of ctx.potriviri(/(?<![\w$])(minVersion|maxVersion|DEFAULT_MIN_VERSION|DEFAULT_MAX_VERSION)\s*(?::|=(?![=>]))\s*/g)) {
const baza = m.index + m[0].length;
const expr = expresiePanaLaVirgula(ctx, baza);
if (!expr || /^(['"])/.test(expr) || /^(?:tls\s*\.\s*)?SecureVersion\b|^string\b/.test(expr)) continue;
const rol = /min/i.test(m[1]) ? 'min' : 'max';
const v = valoareExpresie(ctx, expr);
if (v && TLSV[v.valoare]) {
ctx.adauga(m.index, `tls ${m[1]}`, 'config', { grup: 'TLS', param: TLSV[v.valoare], rol }, { bucata: `${m[1]}: ${v.valoare}`, rezolvatDin: v.din });
continue;
}
const id = identificator(expr);
const ter = id && !v ? rezolvaTernarJs(ctx, id) : null;
if (ter && ter.valori.every((x) => TLSV[x])) {
const ORDINE = ['ssl3', '1.0', '1.1', '1.2', '1.3'];
const slaba = ter.valori.slice().sort((a, b) => ORDINE.indexOf(TLSV[a]) - ORDINE.indexOf(TLSV[b]))[0];
ctx.adauga(m.index, `tls ${m[1]}`, 'config', { grup: 'TLS', param: TLSV[slaba], rol },
{ bucata: `${m[1]}: ${slaba}`, rezolvatDin: `${id} (line ${ter.line}, a conditional: ${ter.valori.join(' or ')}; the weaker one)` });
continue;
}
ctx.adauga(m.index, `tls ${m[1]}`, 'config', necunoscut(expr, `tls ${m[1]}`), { bucata: m[0] + expr });
}
for (const m of ctx.potriviri(/(?<![\w$])secureProtocol\s*:\s*(['"])(\w+)\1/g)) {
const map = { SSLv2_method: 'ssl2', SSLv3_method: 'ssl3', TLSv1_method: '1.0', TLSv1_1_method: '1.1', TLSv1_2_method: '1.2', TLS_method: 'negotiated', SSLv23_method: 'negotiated' };
const v = map[m[2].replace(/_(client|server)_method$/, '_method')];
+1 -1
View File
@@ -13,7 +13,7 @@ import { detecteazaKotlin } from './detect-kotlin.mjs';
import { detecteazaPem } from './pem.mjs';
import { citesteManifest, NUME_MANIFEST } from './manifeste.mjs';
export const VERSIUNE = '0.4.0';
export const VERSIUNE = '0.4.1';
export const DOSARE_EXCLUSE_IMPLICIT = ['.git', '.hg', '.svn', 'node_modules', '__pycache__', '.venv', 'venv', '.tox', '.gradle', '.idea', '.mypy_cache', '.pytest_cache', '.claude'];
const LIMBAJ = {
+24
View File
@@ -16,6 +16,30 @@ const SUITA = join(AICI, 'proba.mjs');
const B = 'negativ: fisierul binar e sarit si numarat';
const MUTATII = [
{
nume: 'versiunea TLS data printr-o variabila nu mai e citita (D-540: forma de dinainte de 0.4.1)',
fisier: 'lib/detect-js.mjs',
ancora: "if (!expr || /^(['\"])/.test(expr) || /^(?:tls\\s*\\.\\s*)?SecureVersion\\b|^string\\b/.test(expr)) continue;",
cu: "if (!expr || /^(['\"])/.test(expr) || /^(?:tls\\s*\\.\\s*)?SecureVersion\\b|^string\\b/.test(expr) || Boolean.length > 0) continue;",
tinta: 'pozitiv: js/tls.cjs',
martor: B,
},
{
nume: 'ternarul reasignat e rezolvat la prima lui forma (D-540: garda unei singure atribuiri scoasa din rezolvaTernarJs)',
fisier: 'lib/context.mjs',
ancora: "if (atribuiri.length > 1 || !atribuiri.length) return null;",
cu: "if (!atribuiri.length) return null;",
tinta: 'pozitiv: js/tls.cjs',
martor: B,
},
{
nume: 'ternarul versiunii TLS da ramura cea mai TARE, nu cea mai slaba (D-540)',
fisier: 'lib/detect-js.mjs',
ancora: "const slaba = ter.valori.slice().sort((a, b) => ORDINE.indexOf(TLSV[a]) - ORDINE.indexOf(TLSV[b]))[0];",
cu: "const slaba = ter.valori.slice().sort((a, b) => ORDINE.indexOf(TLSV[b]) - ORDINE.indexOf(TLSV[a]))[0];",
tinta: 'pozitiv: js/tls.cjs',
martor: B,
},
{
nume: 'comentariile bloc Rust nu se mai imbrica (lexerul)',
fisier: 'lib/lexer.mjs',
+5 -1
View File
@@ -64,7 +64,11 @@ try {
// 0.4.0: si regulile JVM adaugate pentru Kotlin, care se aplica si in Java (Android Keystore, Tink, OkHttp, PKIX, puntea libsignal).
const ADAUGIRI = /"api":"(?:(?:ECKeyPair|IdentityKeyPair|ECPrivateKey|PrivateKey|KEMKeyPair)\.generate|Curve\.generateKeyPair|HKDF\.deriveSecrets|new (?:Aes256GcmSiv|Aes256GcmEncryption|Aes256GcmDecryption|Aes256Ctr32|PreKeyBundle|KEMPublicKey|SealedSessionCipher)|import org\.signal\.libsignal|hkdf|Aes256GcmSiv\.new|PreKeyBundle\.new|processPreKeyBundle|import @signalapp\/libsignal-client(?:\/[^"]*)?|Native\.\w+|KeyGenParameterSpec\.Builder|KeyTemplates\.get|\w+KeyTemplates\.\w+|Predefined\w+Parameters\.\w+|\w+Config\.register|import com\.google\.crypto\.tink|ConnectionSpec\.\w+|CertificatePinner\.Builder|(?:CertPathValidator|TrustManagerFactory)\.getInstance|KeyStore\.getInstance\("AndroidCAStore"\)|X509TrustManager|checkServerTrusted)"/;
const doarV = ka.filter((x) => !sb.has(x)), doarN0 = kb.filter((x) => !sa.has(x));
const adaugate = doarN0.filter((x) => ADAUGIRI.test(x)), doarN = doarN0.filter((x) => !ADAUGIRI.test(x));
// 0.4.1 (2026-10-19, D-540): versiunea TLS data printr-o variabila (rezolvata, sau "unknown"); 0.1.0 nu o vedea deloc. Numai forma noua:
// o gasire a acestei reguli care nu e rezolvata si nu e necunoscuta ar fi forma literala, deci diferenta adevarata.
const ADAUGIRE_TLS = (x) => /"api":"tls (?:minVersion|maxVersion|DEFAULT_MIN_VERSION|DEFAULT_MAX_VERSION)"/.test(x) && (/"resolvedFrom":/.test(x) || /"classification":"unknown"/.test(x));
const eAdaugire = (x) => ADAUGIRI.test(x) || ADAUGIRE_TLS(x);
const adaugate = doarN0.filter(eAdaugire), doarN = doarN0.filter((x) => !eAdaugire(x));
if (adaugate.length) console.log(` (in afara echivalentei: ${adaugate.length} gasiri ale detectoarelor adaugate dupa 0.1.0, API-ul libsignal Java/Node si regulile JVM din 0.4.0)`);
const ok = !doarV.length && !doarN.length && ka.length + adaugate.length === kb.length && JSON.stringify(a.libraries) === JSON.stringify(b.libraries);
comparate += ka.length;
+14 -1
View File
@@ -15,4 +15,17 @@ const a2 = tls.connect({ ecdhCurve: PQ }); // EXPECT: X25519MLKEM768 | quantum-s
const a3 = tls.connect({ ecdhCurve: `${PQ}:X25519` }); // EXPECT: X25519MLKEM768 | quantum-safe ; X25519 | quantum-vulnerable
const a4 = tls.connect({ ecdhCurve: GRUPURI[process.env.MOD] }); // EXPECT: tls ecdhCurve | unknown
module.exports = { server, agent, a2, a3, a4 };
// 0.4.1 (2026-10-19, D-540): versiunea data printr-o variabila. Pana la 0.4.0 niciuna din cele patru nu dadea vreo gasire TLS.
const MIN_TLS = 'TLSv1.2';
const a5 = tls.connect({ minVersion: MIN_TLS }); // EXPECT: TLSv1.2 | quantum-vulnerable
const modSus = process.env.MOD_SUS;
const minSus = modSus === 'hybrid-only' ? 'TLSv1.3' : 'TLSv1.2';
const a6 = tls.connect({ minVersion: minSus }); // EXPECT: TLSv1.2 | quantum-vulnerable
const a7 = tls.connect({ minVersion: process.env.TLS_MIN }); // EXPECT: tls minVersion | unknown
function a8(v) { return tls.connect({ minVersion: v }); } // EXPECT: tls minVersion | unknown
let minVar = modSus === 'x' ? 'TLSv1.3' : 'TLSv1.1';
minVar = 'TLSv1.3';
const a9 = tls.connect({ minVersion: minVar }); // EXPECT: tls minVersion | unknown
module.exports = { server, agent, a2, a3, a4, a5, a6, a7, a8, a9 };
+2 -1
View File
@@ -19,7 +19,8 @@ const CA_JSON = process.argv.includes('--json');
// numarul total de marcaje EXPECT scrise de mana in fixturi; o schimbare aici se face constient
// (0.4.0, 2026-10-18: 158 + 111 din fixturile Swift si Kotlin, numarate de compara-fixturi inainte de a fi scrise aici)
const MARCAJE_ASTEPTATE = 269;
// 0.4.1 (2026-10-19, D-540): + 5 in js/tls.cjs (versiunea TLS printr-o constanta, un ternar, o expresie, un parametru, un ternar reasignat)
const MARCAJE_ASTEPTATE = 274;
const FISIERE_CU_MARCAJE = ['js/node-crypto.mjs', 'js/webcrypto.js', 'js/biblioteci.ts', 'js/tls.cjs', 'js/libsignal-client.ts', 'js/libsignal-client-import.ts', 'python/crypto_py.py', 'java/Crypto.java', 'java/Libsignal.java', 'java/LibsignalImport.java', 'go/crypto.go', 'rust/cripto.rs', 'rust/ambiguu.rs', 'rust/glob.rs', 'rust/libsignal.rs', 'negative/variabile.js',
'swift/libsignal.swift', 'swift/libsignal-import.swift', 'swift/cryptokit.swift', 'swift/securitate.swift', 'swift/biblioteci.swift', 'kotlin/Libsignal.kt', 'kotlin/Android.kt'];
// fixturile negative: fiecare fisier de aici e un fisier de cod citit si analizat, cu zero gasiri (in afara de variabile.js, care are marcaje)