@conarium-ai/core 0.2.37 → 0.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +6 -5
- package/bin/conarium-coverage.mjs +20 -19
- package/bin/conarium-init.mjs +10 -9
- package/bin/conarium-reconcile.mjs +6 -6
- package/bin/conarium-verify.mjs +37 -33
- package/dist/audit-hash.d.ts +1 -1
- package/dist/audit-hash.d.ts.map +1 -1
- package/dist/audit-hash.js +1 -1
- package/dist/audit-hash.js.map +1 -1
- package/dist/audit.d.ts +22 -21
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +104 -88
- package/dist/audit.js.map +1 -1
- package/dist/config.d.ts +69 -433
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -4
- package/dist/config.js.map +1 -1
- package/dist/connectors/supabase_rest.d.ts +2 -2
- package/dist/connectors/supabase_rest.d.ts.map +1 -1
- package/dist/connectors/supabase_rest.js +7 -5
- package/dist/connectors/supabase_rest.js.map +1 -1
- package/dist/console-receipts.d.ts +2 -2
- package/dist/console-receipts.d.ts.map +1 -1
- package/dist/console-receipts.js +2 -2
- package/dist/console-receipts.js.map +1 -1
- package/dist/console.d.ts +6 -22
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +13 -12
- package/dist/console.js.map +1 -1
- package/dist/coverage.d.ts +32 -30
- package/dist/coverage.d.ts.map +1 -1
- package/dist/coverage.js +39 -36
- package/dist/coverage.js.map +1 -1
- package/dist/governance.d.ts +14 -13
- package/dist/governance.d.ts.map +1 -1
- package/dist/governance.js +52 -48
- package/dist/governance.js.map +1 -1
- package/dist/http.d.ts +6 -5
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +45 -41
- package/dist/http.js.map +1 -1
- package/dist/iban.d.ts.map +1 -1
- package/dist/iban.js +13 -12
- package/dist/iban.js.map +1 -1
- package/dist/llm-gate.d.ts +6 -6
- package/dist/llm-gate.js +6 -6
- package/dist/pseudonymize.d.ts +8 -8
- package/dist/pseudonymize.d.ts.map +1 -1
- package/dist/pseudonymize.js +7 -7
- package/dist/pseudonymize.js.map +1 -1
- package/dist/receipt-view.d.ts +1 -1
- package/dist/receipt-view.d.ts.map +1 -1
- package/dist/receipt-view.js +52 -51
- package/dist/receipt-view.js.map +1 -1
- package/dist/receipt.d.ts +32 -28
- package/dist/receipt.d.ts.map +1 -1
- package/dist/receipt.js +23 -20
- package/dist/receipt.js.map +1 -1
- package/dist/scripts/discover_schema.js +14 -12
- package/dist/scripts/discover_schema.js.map +1 -1
- package/dist/scripts/dogfood_prove.js +16 -16
- package/dist/scripts/dogfood_prove.js.map +1 -1
- package/dist/server.d.ts +5 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +44 -34
- package/dist/server.js.map +1 -1
- package/dist/sql-gate/rules.d.ts +8 -7
- package/dist/sql-gate/rules.d.ts.map +1 -1
- package/dist/sql-gate/rules.js +11 -9
- package/dist/sql-gate/rules.js.map +1 -1
- package/dist/tokens.d.ts +3 -3
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +18 -18
- package/dist/tokens.js.map +1 -1
- package/docs/RECEIPT-SPEC.md +188 -1
- package/docs/claims/reviews/0.2.38.md +58 -0
- package/docs/claims/reviews/0.2.39.md +90 -0
- package/docs/security/THREAT-MODEL.md +6 -1
- package/package.json +6 -4
- package/public/app.js +6 -6
- package/public/index.html +7 -7
- package/public/receipts-panel.js +7 -7
- package/scripts/audit-chain-check.mjs +6 -6
- package/scripts/benchmark-overhead.mjs +4 -4
- package/scripts/conarium_sabah_brief.mjs +11 -11
- package/test-vectors/README.md +15 -0
package/dist/coverage.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Conarium Coverage Declaration v0.1 —
|
|
2
|
+
* Conarium Coverage Declaration v0.1 — coverage-proof producer + verifier.
|
|
3
3
|
*
|
|
4
4
|
* Spec: docs/superpowers/specs/2026-08-01-coverage-proof-design.md
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* "
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* RECORDED")
|
|
6
|
+
* CRITICAL HONESTY RULE: this module cannot say "access DID NOT HAPPEN". The only
|
|
7
|
+
* thing it can say is "access was NOT RECORDED". Absence of a record is ambiguous
|
|
8
|
+
* (it may never have been accessed, Conarium may have been bypassed, or logging
|
|
9
|
+
* may have failed). That distinction is carried in the field names (notRecorded /
|
|
10
|
+
* notRecordedObjects) and the message text ("access NOT RECORDED") — in the code,
|
|
11
|
+
* not only in a comment.
|
|
11
12
|
*/
|
|
12
13
|
import { createHash } from 'crypto';
|
|
13
14
|
import { ulid, canonicalize, receiptHash } from './receipt.js';
|
|
14
15
|
import { signHash, verifyHash } from './keys.js';
|
|
15
16
|
export const COVERAGE_VERSION = 'conarium-coverage/0.2';
|
|
16
|
-
/**
|
|
17
|
+
/** Hash the declaration body (excluding sig). */
|
|
17
18
|
export function coverageHash(d) {
|
|
18
19
|
const digest = createHash('sha256').update(canonicalize(d)).digest('hex');
|
|
19
20
|
return `sha256:${digest}`;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
23
|
+
* Compute the seq range and contiguity from receipts.
|
|
24
|
+
* Does every value in 1..N appear exactly once? If there is a gap, gaps is filled.
|
|
24
25
|
*/
|
|
25
26
|
export function computeChain(receipts, opts = {}) {
|
|
26
27
|
if (receipts.length === 0) {
|
|
@@ -36,7 +37,7 @@ export function computeChain(receipts, opts = {}) {
|
|
|
36
37
|
}
|
|
37
38
|
for (let expected = firstSeq; expected < lastSeq; expected++) {
|
|
38
39
|
if (!seqs.includes(expected)) {
|
|
39
|
-
//
|
|
40
|
+
// Find the first real seq after the gap.
|
|
40
41
|
let foundSeq = expected + 1;
|
|
41
42
|
while (foundSeq <= lastSeq && !seqs.includes(foundSeq))
|
|
42
43
|
foundSeq++;
|
|
@@ -54,7 +55,7 @@ export function computeChain(receipts, opts = {}) {
|
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
|
-
*
|
|
58
|
+
* Compute the decision breakdown from receipts (allow/partial/deny).
|
|
58
59
|
*/
|
|
59
60
|
export function computeDecisions(receipts) {
|
|
60
61
|
const out = { allow: 0, partial: 0, deny: 0 };
|
|
@@ -66,29 +67,30 @@ export function computeDecisions(receipts) {
|
|
|
66
67
|
out.partial++;
|
|
67
68
|
else if (d === 'deny')
|
|
68
69
|
out.deny++;
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
// fail-closed
|
|
70
|
+
// An unknown decision is not silently skipped — honesty: ignoring the unknown
|
|
71
|
+
// would mis-state the breakdown. The schema is limited to allow/partial/deny;
|
|
72
|
+
// still, to stay fail-closed, throw if an unknown decision appears.
|
|
72
73
|
else
|
|
73
74
|
throw new Error(`coverage: unknown policy decision "${d}" in receipt ${r.id}`);
|
|
74
75
|
}
|
|
75
76
|
return out;
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
|
-
* declaredScope ∩
|
|
79
|
-
* notRecorded = declaredScope
|
|
80
|
-
*
|
|
79
|
+
* declaredScope ∩ receipt objects — coverage summary.
|
|
80
|
+
* notRecorded = objects that are in declaredScope and NEVER appear in receipts.
|
|
81
|
+
* Meaning is "access was NOT RECORDED" — not "was not accessed".
|
|
81
82
|
*
|
|
82
|
-
*
|
|
83
|
-
* 1. dataRefs[].object (query/search
|
|
84
|
-
* 2. request.target —
|
|
85
|
-
* (describe_table).
|
|
86
|
-
*
|
|
83
|
+
* An object's "recorded access" can be derived from TWO sources:
|
|
84
|
+
* 1. dataRefs[].object (query/search result, describe_table target)
|
|
85
|
+
* 2. request.target — only on tools where the target IS the object itself
|
|
86
|
+
* (describe_table). Depending on a single source invites the fault of
|
|
87
|
+
* counting access as "not recorded" when a tool left dataRefs empty.
|
|
87
88
|
*
|
|
88
|
-
* "
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
89
|
+
* Do not silently count "UNKNOWN" as "ABSENT": a receipt with empty dataRefs AND
|
|
90
|
+
* a target that is not an object AND a data-access tool (query/search) has an
|
|
91
|
+
* indeterminate object. That cannot be read as "those objects were not accessed"
|
|
92
|
+
* — it is counted separately via unassignedReceiptCount. list_tables is not data
|
|
93
|
+
* access (schema listing) and is not counted.
|
|
92
94
|
*/
|
|
93
95
|
export function computeCoverage(receipts, declaredScope) {
|
|
94
96
|
const recorded = new Set();
|
|
@@ -99,12 +101,12 @@ export function computeCoverage(receipts, declaredScope) {
|
|
|
99
101
|
recorded.add(ref.object);
|
|
100
102
|
hasObject = true;
|
|
101
103
|
}
|
|
102
|
-
//
|
|
104
|
+
// Second evidence source: on describe_table the target already IS the object itself.
|
|
103
105
|
if (r.request.tool === 'describe_table' && r.request.target) {
|
|
104
106
|
recorded.add(r.request.target);
|
|
105
107
|
hasObject = true;
|
|
106
108
|
}
|
|
107
|
-
//
|
|
109
|
+
// Data-access receipt whose object cannot be determined → ambiguity counter.
|
|
108
110
|
if (!hasObject && (r.request.tool === 'query' || r.request.tool === 'search')) {
|
|
109
111
|
unassignedReceiptCount++;
|
|
110
112
|
}
|
|
@@ -121,8 +123,8 @@ export function computeCoverage(receipts, declaredScope) {
|
|
|
121
123
|
};
|
|
122
124
|
}
|
|
123
125
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
+
* Produce a coverage declaration. Deterministic (depends on receipts + declaredScope;
|
|
127
|
+
* id/ts depend on the moment of production). Signed with Ed25519.
|
|
126
128
|
*/
|
|
127
129
|
export function buildCoverageDeclaration(receipts, declaredScope, key, opts = {}) {
|
|
128
130
|
if (receipts.length === 0) {
|
|
@@ -134,10 +136,11 @@ export function buildCoverageDeclaration(receipts, declaredScope, key, opts = {}
|
|
|
134
136
|
const chain = computeChain(receipts, { seqFrom: opts.seqFrom });
|
|
135
137
|
const decisions = computeDecisions(receipts);
|
|
136
138
|
const coverage = computeCoverage(receipts, declaredScope);
|
|
137
|
-
//
|
|
138
|
-
// (r.ts)
|
|
139
|
-
//
|
|
140
|
-
//
|
|
139
|
+
// The coverage period is computed from the time the receipts COVER — not from
|
|
140
|
+
// the moment they were created (r.ts). A receipt can be created a little AFTER
|
|
141
|
+
// the access; a "I cover this period" claim must rest on the covered time.
|
|
142
|
+
// The smallest start and the largest end are found SEPARATELY (not by sorting
|
|
143
|
+
// a single array and taking first/last).
|
|
141
144
|
let start = receipts[0].period.start;
|
|
142
145
|
let end = receipts[0].period.end;
|
|
143
146
|
for (const r of receipts) {
|
|
@@ -166,8 +169,8 @@ export function buildCoverageDeclaration(receipts, declaredScope, key, opts = {}
|
|
|
166
169
|
return { ...body, sig };
|
|
167
170
|
}
|
|
168
171
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
172
|
+
* Verify the declaration signature. True if valid, false otherwise (fail-closed:
|
|
173
|
+
* never returns true in any case that cannot be confirmed).
|
|
171
174
|
*/
|
|
172
175
|
export function verifyCoverageSignature(d, key) {
|
|
173
176
|
if (d.sig.alg !== 'Ed25519')
|
package/dist/coverage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["../src/coverage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["../src/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAmB,QAAQ,EAAkB,UAAU,EAAE,MAAM,WAAW,CAAA;AAEjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAgC,CAAA;AAgEhE,iDAAiD;AACjD,MAAM,UAAU,YAAY,CAAC,CAAmC;IAC9D,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CA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,IAAI,CAAC,CAAC,CAAC,GAAG;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,CAAA;QACtE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACjC,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAA;QACrF,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YACpC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,CAAA;QAC9D,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAChD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,qCAAqC,EAAE,CAAA;QACpF,CAAC;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;AACrB,CAAC"}
|
package/dist/governance.d.ts
CHANGED
|
@@ -68,21 +68,22 @@ export declare class Governance {
|
|
|
68
68
|
allowsTable(qualified: string): boolean;
|
|
69
69
|
filterTables(tables: SchemaTable[]): SchemaTable[];
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* Tool permission — `allowTools` / `denyTools`.
|
|
72
72
|
*
|
|
73
|
-
* 🔴 2026-08-12:
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* `allowsTable`
|
|
78
|
-
*
|
|
79
|
-
*
|
|
73
|
+
* 🔴 2026-08-12: these fields were editable in the CONSOLE, documented in `types.ts`
|
|
74
|
+
* and had a test, but the check lived only inside `ApiGovernance`, which nothing
|
|
75
|
+
* called — so an operator saying "I turned that tool off" changed nothing.
|
|
76
|
+
* It was not a hole (writes are already refused at the connector; reads go through
|
|
77
|
+
* `allowsTable`), but it was a FALSE CLAIM: the UI promised something the engine
|
|
78
|
+
* did not do. This product's only claim is "actually do what you said", so a dead
|
|
79
|
+
* policy field is more expensive than a working gap.
|
|
80
80
|
*
|
|
81
|
-
* ⚠️
|
|
82
|
-
*
|
|
83
|
-
* fail-closed.
|
|
84
|
-
*
|
|
85
|
-
*
|
|
81
|
+
* ⚠️ Deliberately fail-OPEN — unlike `allowsTable`/`allowsConnector`. If
|
|
82
|
+
* `allowTools` is undefined every tool passes, because the real door is already
|
|
83
|
+
* table policy and that is fail-closed. Making this fail-closed too would silently
|
|
84
|
+
* break every existing install that never wrote `allowTools`; that would be the
|
|
85
|
+
* same class of error we are closing. This field is not a protection layer, it is
|
|
86
|
+
* a NARROWING layer.
|
|
86
87
|
*/
|
|
87
88
|
allowsTool(toolName: string): boolean;
|
|
88
89
|
/**
|
package/dist/governance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../src/governance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAiDjD,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAA;AAG/B,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM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O,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CA8LpH;IAED,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,oBAAoB;IAuB5B,OAAO,CAAC,IAAI;IASZ,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,WAAW;IAoDnB,OAAO,CAAC,aAAa;IAuCrB,OAAO,CAAC,WAAW;IAmEnB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,WAAW;IAiFnB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,0BAA0B;IA8DlC,OAAO,CAAC,mBAAmB;IA2B3B,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,oBAAoB;IAuB5B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;CAGpB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAkB;IAEhC,YAAY,MAAM,GAAE,gBAAqB,EAExC;IAED,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAKpC;IAED,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAS7B;IAED,OAAO,CAAC,OAAO;IAwBf,OAAO,CAAC,eAAe;CAKxB"}
|
package/dist/governance.js
CHANGED
|
@@ -238,10 +238,11 @@ export class Governance {
|
|
|
238
238
|
return false;
|
|
239
239
|
if (denyTables?.some(p => match(p, qualified)))
|
|
240
240
|
return false;
|
|
241
|
-
// 🔒 DEFAULT-DENY (Codex
|
|
242
|
-
//
|
|
243
|
-
// "denied by default"
|
|
244
|
-
//
|
|
241
|
+
// 🔒 DEFAULT-DENY (Codex review 2026-07-06, P1): if allowTables is NOT defined,
|
|
242
|
+
// allow no table. docs.html "Nothing is allowed unless you allow it" + README
|
|
243
|
+
// "denied by default" already promised this; the old code (return true) was THE
|
|
244
|
+
// OPPOSITE = a broken guarantee in a security product. Anyone who wants open mode
|
|
245
|
+
// (playground/demo) must pass explicit allowTables:['*'].
|
|
245
246
|
if (allowTables && allowTables.length > 0) {
|
|
246
247
|
return allowTables.some(p => match(p, qualified));
|
|
247
248
|
}
|
|
@@ -251,21 +252,22 @@ export class Governance {
|
|
|
251
252
|
return tables.filter(t => this.allowsTable(`${t.schema}.${t.name}`));
|
|
252
253
|
}
|
|
253
254
|
/**
|
|
254
|
-
*
|
|
255
|
+
* Tool permission — `allowTools` / `denyTools`.
|
|
255
256
|
*
|
|
256
|
-
* 🔴 2026-08-12:
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* `allowsTable`
|
|
261
|
-
*
|
|
262
|
-
*
|
|
257
|
+
* 🔴 2026-08-12: these fields were editable in the CONSOLE, documented in `types.ts`
|
|
258
|
+
* and had a test, but the check lived only inside `ApiGovernance`, which nothing
|
|
259
|
+
* called — so an operator saying "I turned that tool off" changed nothing.
|
|
260
|
+
* It was not a hole (writes are already refused at the connector; reads go through
|
|
261
|
+
* `allowsTable`), but it was a FALSE CLAIM: the UI promised something the engine
|
|
262
|
+
* did not do. This product's only claim is "actually do what you said", so a dead
|
|
263
|
+
* policy field is more expensive than a working gap.
|
|
263
264
|
*
|
|
264
|
-
* ⚠️
|
|
265
|
-
*
|
|
266
|
-
* fail-closed.
|
|
267
|
-
*
|
|
268
|
-
*
|
|
265
|
+
* ⚠️ Deliberately fail-OPEN — unlike `allowsTable`/`allowsConnector`. If
|
|
266
|
+
* `allowTools` is undefined every tool passes, because the real door is already
|
|
267
|
+
* table policy and that is fail-closed. Making this fail-closed too would silently
|
|
268
|
+
* break every existing install that never wrote `allowTools`; that would be the
|
|
269
|
+
* same class of error we are closing. This field is not a protection layer, it is
|
|
270
|
+
* a NARROWING layer.
|
|
269
271
|
*/
|
|
270
272
|
allowsTool(toolName) {
|
|
271
273
|
const { allowTools, denyTools } = this.policy;
|
|
@@ -324,16 +326,16 @@ export class Governance {
|
|
|
324
326
|
const output = this.analyzeRead(ast[0], state, new Set());
|
|
325
327
|
this.applyRowCap(ast[0]);
|
|
326
328
|
let rewrittenSql = emitPostgresSql(ast[0]);
|
|
327
|
-
//
|
|
328
|
-
// applyRowCap
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
//
|
|
329
|
+
// SET OPERATIONS (UNION / UNION ALL / INTERSECT / EXCEPT) — row-cap gap.
|
|
330
|
+
// applyRowCap can only attach LIMIT to 'select' and 'with' nodes;
|
|
331
|
+
// set operations returned undefined from limitTarget and SILENTLY passed uncapped.
|
|
332
|
+
// That punched the product's "row caps stop bulk extraction" promise: policy and
|
|
333
|
+
// masking still ran, but the row count was unbounded.
|
|
332
334
|
//
|
|
333
|
-
// AST
|
|
334
|
-
//
|
|
335
|
-
//
|
|
336
|
-
//
|
|
335
|
+
// A set node in the AST cannot carry a limit (only type/left/right), and the parser
|
|
336
|
+
// puts a user-written `A UNION ALL B LIMIT 50` onto the right arm, changing the
|
|
337
|
+
// meaning. So the cap is applied by wrapping FROM THE OUTSIDE — the inner SQL
|
|
338
|
+
// already comes from a validated, rewritten AST.
|
|
337
339
|
if (!this.limitTarget(ast[0])) {
|
|
338
340
|
rewrittenSql = `SELECT * FROM (${rewrittenSql}) AS conarium_capped LIMIT ${this.maxRows()}`;
|
|
339
341
|
}
|
|
@@ -442,20 +444,21 @@ export class Governance {
|
|
|
442
444
|
maskPII(obj, ctx) {
|
|
443
445
|
if (!obj)
|
|
444
446
|
return { masked: obj, count: 0, byClass: {} };
|
|
445
|
-
//
|
|
446
|
-
//
|
|
447
|
-
//
|
|
448
|
-
//
|
|
449
|
-
//
|
|
447
|
+
// NUMERIC PII (NEO security scan, 2026-07-31 — experimentally confirmed).
|
|
448
|
+
// Masking only ran on string and object branches; number/bigint returned RAW
|
|
449
|
+
// without any check. Measured result:
|
|
450
|
+
// tckn_text "12345678901" -> [MASKED_PII] · tckn_number 12345678901 -> LEAKED
|
|
451
|
+
// In Turkey, storing TCKN and phone as bigint is common; this is not theoretical.
|
|
450
452
|
//
|
|
451
|
-
//
|
|
452
|
-
//
|
|
453
|
-
//
|
|
454
|
-
//
|
|
455
|
-
//
|
|
453
|
+
// The number is converted to text and run through THE SAME patterns — keeping a
|
|
454
|
+
// separate "which numbers are PII" rule set would create a second source that
|
|
455
|
+
// would go stale. If no pattern matches, the number is returned unchanged WITH
|
|
456
|
+
// ITS TYPE PRESERVED: id/count/price/year stay intact.
|
|
457
|
+
// If 13–16 digits fail Luhn, or the sequence is longer (order number), the
|
|
458
|
+
// content scanner does not touch it — a half-mask plus a lying maskedCount is worse.
|
|
456
459
|
if (typeof obj === 'number' || typeof obj === 'bigint') {
|
|
457
|
-
const
|
|
458
|
-
return
|
|
460
|
+
const result = this.maskPII(String(obj), ctx);
|
|
461
|
+
return result.count > 0 ? result : { masked: obj, count: 0, byClass: {} };
|
|
459
462
|
}
|
|
460
463
|
if (typeof obj === 'string') {
|
|
461
464
|
if (ctx?.column) {
|
|
@@ -501,12 +504,13 @@ export class Governance {
|
|
|
501
504
|
masked = mrzPass.text;
|
|
502
505
|
count += mrzPass.count;
|
|
503
506
|
}
|
|
504
|
-
//
|
|
505
|
-
// response stream"
|
|
506
|
-
// token /
|
|
507
|
-
//
|
|
508
|
-
//
|
|
509
|
-
//
|
|
507
|
+
// Hardening (Codex review 2026-07-06, P1): README says "secrets are redacted in the
|
|
508
|
+
// response stream" but the response path (maskPII) only caught PII — API key /
|
|
509
|
+
// token / password / connection-string credentials went to the MODEL in the clear
|
|
510
|
+
// (e.g. if the api_key column was not in maskColumns). The audit path
|
|
511
|
+
// (audit.ts maskArgs) already caught these; we carried the same detectors onto
|
|
512
|
+
// the response path. The product's security promise = this.
|
|
513
|
+
// sk- family: new OpenAI keys are sk-proj-... (contain hyphens) → allow hyphen/underscore.
|
|
510
514
|
// Secrets and labelled names need letters. A 12k-digit order field
|
|
511
515
|
// otherwise still pays for those unicode regexes.
|
|
512
516
|
if (/[A-Za-z]/.test(masked)) {
|
|
@@ -537,9 +541,9 @@ export class Governance {
|
|
|
537
541
|
return `${label}: [MASKED_PII]`;
|
|
538
542
|
});
|
|
539
543
|
}
|
|
540
|
-
//
|
|
541
|
-
// NEO red-team harness
|
|
542
|
-
//
|
|
544
|
+
// Hardening (Claude, 2026-07-02): also catch PII smuggled via encode(...,'base64').
|
|
545
|
+
// The NEO red-team harness found this hole (pii-base64 BYPASS). If a pure-base64
|
|
546
|
+
// string decodes to email/TCKN, mask it.
|
|
543
547
|
// Length-capped: a 12k-digit field matches `{12,}` and Buffer.from of
|
|
544
548
|
// 12 kB of '1's was the leftover ~80 ms after the email regex was bounded.
|
|
545
549
|
// Encoded TCKN/email/IBAN fit in well under 256 characters.
|
|
@@ -552,7 +556,7 @@ export class Governance {
|
|
|
552
556
|
masked = '[MASKED_PII]';
|
|
553
557
|
}
|
|
554
558
|
}
|
|
555
|
-
catch { /* base64
|
|
559
|
+
catch { /* not base64 */ }
|
|
556
560
|
}
|
|
557
561
|
masked = ibanPass.restore(masked);
|
|
558
562
|
// Backstop: a leftover country-code prefix glued to a mask is a partial
|