@conarium-ai/core 0.2.10 → 0.2.11
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 +17 -2
- package/LIMITATIONS.md +26 -5
- package/LIMITATIONS.tr.md +26 -5
- package/README.md +11 -8
- package/bin/conarium-doctor.mjs +208 -7
- package/bin/doctor-sql.mjs +47 -0
- package/dist/config.d.ts +14 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +14 -3
- package/dist/console.js.map +1 -1
- package/dist/governance.d.ts +8 -0
- package/dist/governance.d.ts.map +1 -1
- package/dist/governance.js +29 -78
- package/dist/governance.js.map +1 -1
- package/dist/masking-cost.d.ts +16 -0
- package/dist/masking-cost.d.ts.map +1 -0
- package/dist/masking-cost.js +31 -0
- package/dist/masking-cost.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/sql-gate/dispatch.d.ts +17 -0
- package/dist/sql-gate/dispatch.d.ts.map +1 -0
- package/dist/sql-gate/dispatch.js +30 -0
- package/dist/sql-gate/dispatch.js.map +1 -0
- package/dist/sql-gate/mssql.d.ts +11 -0
- package/dist/sql-gate/mssql.d.ts.map +1 -0
- package/dist/sql-gate/mssql.js +287 -0
- package/dist/sql-gate/mssql.js.map +1 -0
- package/dist/sql-gate/oracle.d.ts +11 -0
- package/dist/sql-gate/oracle.d.ts.map +1 -0
- package/dist/sql-gate/oracle.js +227 -0
- package/dist/sql-gate/oracle.js.map +1 -0
- package/dist/sql-gate/postgres.d.ts +12 -0
- package/dist/sql-gate/postgres.d.ts.map +1 -0
- package/dist/sql-gate/postgres.js +64 -0
- package/dist/sql-gate/postgres.js.map +1 -0
- package/dist/sql-gate/rules.d.ts +14 -0
- package/dist/sql-gate/rules.d.ts.map +1 -0
- package/dist/sql-gate/rules.js +73 -0
- package/dist/sql-gate/rules.js.map +1 -0
- package/dist/sql-gate/types.d.ts +31 -0
- package/dist/sql-gate/types.d.ts.map +1 -0
- package/dist/sql-gate/types.js +9 -0
- package/dist/sql-gate/types.js.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/API-STABILITY.md +174 -0
- package/docs/BENCHMARK.md +124 -0
- package/docs/audit/2026-08-14-e2e-health.md +69 -0
- package/docs/audit/2026-08-14-security-scan.md +48 -0
- package/docs/audit/2026-08-14-surface-sync.md +34 -0
- package/docs/benchmarks/latest.json +2310 -0
- package/docs/benchmarks/masking-cost-threshold.json +6 -0
- package/docs/benchmarks/overhead-20260814T1238Z-win32.json +402 -0
- package/docs/benchmarks/overhead-20260814T1346Z-linux.json +2310 -0
- package/docs/benchmarks/overhead-20260814T1644Z-win32.json +2310 -0
- package/docs/releases/v0.2.10.md +24 -0
- package/docs/releases/v0.2.8.md +23 -0
- package/docs/releases/v0.2.9.md +26 -0
- package/docs/security/PENTEST-SCOPE.md +1 -1
- package/docs/security/THREAT-MODEL.md +7 -5
- package/docs/specs/2026-08-14-mssql-bypass-inventory.md +37 -0
- package/docs/specs/2026-08-14-oracle-bypass-inventory.md +28 -0
- package/package.json +5 -2
- package/scripts/benchmark-overhead.mjs +492 -0
- package/test-vectors/README.md +3 -0
- package/test-vectors/sql-gate/LAST-RUN.json +11 -0
- package/test-vectors/sql-gate/README.md +19 -0
- package/test-vectors/sql-gate/vectors.json +331 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- **Postgres overhead measured.** Same SELECT, default `maxRows` 100: about
|
|
6
|
+
5 ms added when email is masked. 500 → ~87 ms. 5 000 → ~22 s. Cost
|
|
7
|
+
follows distinct masked values. Doctor and boot warn above 100; they
|
|
8
|
+
do not reject the query. See `docs/BENCHMARK.md`.
|
|
9
|
+
- **Carry-over corpus lock.** `src/governance.carryover-diff.test.ts`.
|
|
10
|
+
A single-pass rewrite disagreed on sequential longest-first overlap
|
|
11
|
+
and was reverted.
|
|
12
|
+
|
|
13
|
+
- **Overhead benchmark script.** `scripts/benchmark-overhead.mjs` measures
|
|
14
|
+
the same SELECT direct vs through the gate (p50/p95/p99). Without a DSN
|
|
15
|
+
the comparison is recorded as koşulamadı — no invented numbers.
|
|
16
|
+
See `docs/BENCHMARK.md`.
|
|
17
|
+
- **Generated SQL-gate attacks.** `test/property_sql_gate.mjs` (property +
|
|
18
|
+
fuzz). A real bypass stays red and is written under
|
|
19
|
+
`test-vectors/sql-gate/`.
|
|
20
|
+
- **API stability inventory** (draft, not a 1.0): `docs/API-STABILITY.md`.
|
|
21
|
+
|
|
5
22
|
- **Built-in OpenTimestamps client.** Stamp / upgrade / verify no longer
|
|
6
23
|
load `javascript-opentimestamps`. The `web3` / `request` / `bitcore` tree
|
|
7
24
|
is not installed. Old proofs still verify (pending fixture + dogfood
|
|
@@ -14,8 +31,6 @@
|
|
|
14
31
|
- **`test:checks` runs every check even if one fails.** The old `&&` chain
|
|
15
32
|
went silent after the first failure. `test/init.mjs` resolves temp paths
|
|
16
33
|
with `fs.realpathSync` (`/var` vs `/private/var` on macOS).
|
|
17
|
-
- **OpenTimestamps opt-in warning.** Enabling the feature pulls a tree with
|
|
18
|
-
7 critical and 3 high known advisories. Default install still does not.
|
|
19
34
|
|
|
20
35
|
- **c1 launcher sets `CONARIUM_AUDIT_SIGNING_KEY`** from
|
|
21
36
|
`~/.conarium/audit-ed25519.pem` when `receiptSink` is set. Cursor MCP env
|
package/LIMITATIONS.md
CHANGED
|
@@ -10,12 +10,14 @@ No SOC 2. No ISO. No independent penetration test. On the roadmap.
|
|
|
10
10
|
|
|
11
11
|
Version is 0.2.x. The API can break.
|
|
12
12
|
|
|
13
|
-
## SQL is Postgres
|
|
13
|
+
## SQL is Postgres, Microsoft SQL Server, and Oracle
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
A
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
MySQL is not implemented.
|
|
16
|
+
A dialect is listed here only when the shared SQL-gate vector set is green against that dialect, unparseable input is denied, and a live engine run applied the row cap.
|
|
17
|
+
This is a second parser layer, not a connector. The shipped `query` tool selects the gate from `policy.dialect` (`postgres` when omitted, or `mssql`, or `oracle`). The dialect is the operator's declaration — it is not inferred from the SQL. An unknown dialect rejects the config; it does not fall back to postgres.
|
|
18
|
+
Oracle does not resolve synonyms: an allow-listed name is the name the parser sees, not the base table. Database links (`table@dblink`) are denied. `ROWNUM` is denied (it is not a row cap).
|
|
19
|
+
There is no MSSQL or Oracle connector. The gate rewrites SQL; a connector that can speak that engine is still the operator's.
|
|
20
|
+
Parsers: Postgres `pgsql-ast-parser` · MSSQL `node-sql-parser` (transactsql) · Oracle `@guanmingchiu/sqlparser-ts`.
|
|
19
21
|
|
|
20
22
|
## Names in free text are not guaranteed
|
|
21
23
|
|
|
@@ -41,6 +43,25 @@ An OpenTimestamps stamp can take hours to confirm on Bitcoin. Receipts already s
|
|
|
41
43
|
|
|
42
44
|
The Ed25519 implementation has not had a formal audit.
|
|
43
45
|
|
|
46
|
+
## Masking cost grows with distinct masked values
|
|
47
|
+
|
|
48
|
+
Carry-over builds one matcher per unique value this policy already
|
|
49
|
+
masked. `maxRows` bounds that set. When the policy leaves it unset the code falls
|
|
50
|
+
back to 100; the `conarium.config.json` shipped with the package sets 50, so a
|
|
51
|
+
fresh install runs at 50. The figures below use 100 as the conservative case.
|
|
52
|
+
|
|
53
|
+
Measured (same SELECT, same row count, Postgres 16.14, WSL2, see
|
|
54
|
+
[`docs/BENCHMARK.md`](docs/BENCHMARK.md)):
|
|
55
|
+
|
|
56
|
+
| maxRows | overhead p50 (masked) |
|
|
57
|
+
|---|---|
|
|
58
|
+
| 100 (default) | 5.0 ms |
|
|
59
|
+
| 500 | 87 ms |
|
|
60
|
+
| 5 000 | 22 s |
|
|
61
|
+
|
|
62
|
+
Raising the cap is allowed. The doctor and boot log warn above 100.
|
|
63
|
+
The query is not rejected.
|
|
64
|
+
|
|
44
65
|
## OpenTimestamps client
|
|
45
66
|
|
|
46
67
|
Stamping uses a built-in calendar client (Node `crypto` + HTTPS to the public calendars).
|
package/LIMITATIONS.tr.md
CHANGED
|
@@ -10,12 +10,14 @@ SOC 2 yok. ISO yok. Bağımsız sızma testi yok. Yol haritasında.
|
|
|
10
10
|
|
|
11
11
|
Sürüm 0.2.x. API kırılabilir.
|
|
12
12
|
|
|
13
|
-
## SQL
|
|
13
|
+
## SQL: Postgres, Microsoft SQL Server ve Oracle
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
MySQL yok.
|
|
16
|
+
Bir lehçe ancak paylaşılan SQL-kapısı vektör seti o lehçede yeşilse, ayrıştırılamayan girdi reddediliyorsa ve canlı motorda satır tavanı uygulanıyorsa burada yazılır.
|
|
17
|
+
Bu bir konnektör değil, ikinci ayrıştırıcı katmanı. Dağıtılan `query` aracı kapıyı `policy.dialect` ile seçer (yoksa `postgres`; `mssql`; `oracle`). Lehçe operatörün beyanıdır — SQL’den tahmin edilmez. Bilinmeyen lehçe yapılandırmayı reddeder; sessizce postgres’e düşmez.
|
|
18
|
+
Oracle synonym hedefini çözmez: allow-list’teki ad, parser’ın gördüğü addır, taban tablo değil. Veritabanı bağlantısı (`table@dblink`) reddedilir. `ROWNUM` reddedilir (satır tavanı değildir).
|
|
19
|
+
MSSQL veya Oracle konnektörü yok. Kapı SQL’i yeniden yazar; o motora konuşan konnektör hâlâ operatörün.
|
|
20
|
+
Ayrıştırıcılar: Postgres `pgsql-ast-parser` · MSSQL `node-sql-parser` (transactsql) · Oracle `@guanmingchiu/sqlparser-ts`.
|
|
19
21
|
|
|
20
22
|
## Serbest metinde isim garantisi yok
|
|
21
23
|
|
|
@@ -41,6 +43,25 @@ OpenTimestamps damgasının Bitcoin'de onaylanması saatler sürebilir. Makbuzda
|
|
|
41
43
|
|
|
42
44
|
Ed25519 uygulaması resmî denetimden geçmedi.
|
|
43
45
|
|
|
46
|
+
## Maskeleme maliyeti satırla değil, benzersiz değerle büyür
|
|
47
|
+
|
|
48
|
+
Taşıma eşleştiricisi, politikanın maskelediği her benzersiz değer için
|
|
49
|
+
bir tarama kurar. `maxRows` o kümeyi sınırlar. Politika boş bırakırsa kod 100'e
|
|
50
|
+
düşer; pakette gelen `conarium.config.json` 50 yazar. Taze kurulum 50'de çalışır.
|
|
51
|
+
Aşağıdaki ölçüm ihtiyatlı olsun diye 100 üzerinden.
|
|
52
|
+
|
|
53
|
+
Ölçülmüş (aynı SELECT, aynı satır sayısı, Postgres 16.14, WSL2, bakınız
|
|
54
|
+
[`docs/BENCHMARK.md`](docs/BENCHMARK.md)):
|
|
55
|
+
|
|
56
|
+
| maxRows | ek yük p50 (maskeli) |
|
|
57
|
+
|---|---|
|
|
58
|
+
| 100 (varsayılan) | 5,0 ms |
|
|
59
|
+
| 500 | 87 ms |
|
|
60
|
+
| 5 000 | 22 s |
|
|
61
|
+
|
|
62
|
+
Tavanı yükseltmek serbest. 100'ün üstünde doctor ve boot uyarır.
|
|
63
|
+
Sorgu reddedilmez.
|
|
64
|
+
|
|
44
65
|
## OpenTimestamps istemcisi
|
|
45
66
|
|
|
46
67
|
Damgalama yerleşik takvim istemcisiyle yapılır (Node `crypto` + herkese açık takvimlere HTTPS).
|
package/README.md
CHANGED
|
@@ -329,7 +329,7 @@ Conarium operates on a strict tripartite architecture, balancing power between t
|
|
|
329
329
|
graph LR
|
|
330
330
|
A([AI Assistant\nCursor / Copilot]) -- "MCP Query" --> B{The Gateway\nConarium Proxy};
|
|
331
331
|
B -- "Intercept & Parse" --> C[The Engine\nGovernance & Regex];
|
|
332
|
-
C -- "Execute Query" --> D[(Your Database\nPostgres)];
|
|
332
|
+
C -- "Execute Query" --> D[(Your Database\nPostgres / SQL Server / Oracle)];
|
|
333
333
|
D -- "Raw Data" --> C;
|
|
334
334
|
C -- "Mask & Cap" --> B;
|
|
335
335
|
B -- "Sanitized Data" --> A;
|
|
@@ -472,6 +472,8 @@ Control access using a simple `conarium.json` policy file:
|
|
|
472
472
|
|
|
473
473
|
Anything not in `allowTables` is denied by default; matched `maskColumns` are redacted to `[MASKED_PII]` before the data ever reaches the model.
|
|
474
474
|
|
|
475
|
+
`policy.dialect` selects the SQL gate the `query` tool uses: `postgres` (omitted default), `mssql`, or `oracle`. It is the operator's declaration — Conarium does not guess the dialect from the statement. A typo or `mysql` rejects the config.
|
|
476
|
+
|
|
475
477
|
> **Connectors are fail-closed.** `allowConnectors` is a strict allow-list:
|
|
476
478
|
> if it is missing or empty, **no** connector is permitted (previously an empty
|
|
477
479
|
> list meant "allow all"). If you configure connectors, you must list them here —
|
|
@@ -538,14 +540,13 @@ including labelled names in free text · allow/deny + row caps · per-person mas
|
|
|
538
540
|
profiles · immutable hash-chained audit ledger · Ed25519-signed receipt per access
|
|
539
541
|
with an offline verifier · signed coverage declarations · two-sided reconciliation
|
|
540
542
|
against the database's own counters · OpenTimestamps anchoring and an optional
|
|
541
|
-
anchoring service · conformance vectors · Postgres,
|
|
542
|
-
and
|
|
543
|
-
|
|
543
|
+
anchoring service · conformance vectors · SQL gate: Postgres, Microsoft SQL Server, Oracle
|
|
544
|
+
(MySQL is not implemented; Oracle synonyms and database links are not resolved — see LIMITATIONS) · Postgres, Supabase, docs, OpenAPI, Jira
|
|
545
|
+
and Slack connectors · `conarium-init` / `conarium-doctor` via `npx` (`@conarium-ai/core`).
|
|
544
546
|
|
|
545
547
|
**Next:** consent binding ([spec published](docs/CONSENT-BINDING-SPEC.md), no code —
|
|
546
548
|
patent review first) · a second independent implementation of the receipt format ·
|
|
547
|
-
per-user identity bound to an identity provider rather than an operator token map
|
|
548
|
-
publishing `@conarium-ai/core` to npm so `npx conarium-init` works without a clone.
|
|
549
|
+
per-user identity bound to an identity provider rather than an operator token map.
|
|
549
550
|
|
|
550
551
|
**Deliberately not planned**, so nobody waits for it:
|
|
551
552
|
|
|
@@ -556,8 +557,10 @@ publishing `@conarium-ai/core` to npm so `npx conarium-init` works without a clo
|
|
|
556
557
|
- **SOC 2.** It audits organisations that hold customer data. We never receive
|
|
557
558
|
yours. If that ever stops being true, this line changes first.
|
|
558
559
|
|
|
559
|
-
Known gaps: [LIMITATIONS.md](LIMITATIONS.md), the README above,
|
|
560
|
-
[`docs/RECEIPT-SPEC.md`](docs/RECEIPT-SPEC.md)
|
|
560
|
+
Known gaps: [LIMITATIONS.md](LIMITATIONS.md), the README above,
|
|
561
|
+
[`docs/RECEIPT-SPEC.md`](docs/RECEIPT-SPEC.md),
|
|
562
|
+
[`docs/BENCHMARK.md`](docs/BENCHMARK.md), and
|
|
563
|
+
[`docs/API-STABILITY.md`](docs/API-STABILITY.md).
|
|
561
564
|
|
|
562
565
|
## 📜 License
|
|
563
566
|
|
package/bin/conarium-doctor.mjs
CHANGED
|
@@ -30,9 +30,16 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { existsSync, readFileSync, statSync, accessSync, constants } from 'node:fs'
|
|
32
32
|
import { resolve, dirname, join } from 'node:path'
|
|
33
|
-
import { fileURLToPath } from 'node:url'
|
|
33
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
34
34
|
import net from 'node:net'
|
|
35
35
|
import { createPublicKey, createPrivateKey } from 'node:crypto'
|
|
36
|
+
import {
|
|
37
|
+
dialectAgrees,
|
|
38
|
+
dialectLine,
|
|
39
|
+
familyFromBanner,
|
|
40
|
+
familyFromScheme,
|
|
41
|
+
resolveDoctorDialect,
|
|
42
|
+
} from './doctor-sql.mjs'
|
|
36
43
|
|
|
37
44
|
const ARGS = process.argv.slice(2)
|
|
38
45
|
const has = (f) => ARGS.includes(f)
|
|
@@ -60,6 +67,8 @@ const results = []
|
|
|
60
67
|
const ok = (label, detail) => results.push({ level: 'ok', label, detail })
|
|
61
68
|
const warn = (label, detail, fix) => results.push({ level: 'warn', label, detail, fix })
|
|
62
69
|
const fail = (label, detail, fix) => results.push({ level: 'fail', label, detail, fix })
|
|
70
|
+
/** Could not complete the check. Not a pass. Not a silent skip. */
|
|
71
|
+
const unseen = (label, detail, fix) => results.push({ level: 'unseen', label, detail, fix })
|
|
63
72
|
|
|
64
73
|
/* ---------------------------------------------------------------- helpers */
|
|
65
74
|
|
|
@@ -108,6 +117,28 @@ function tcpProbe(host, port, timeoutMs = 4000) {
|
|
|
108
117
|
})
|
|
109
118
|
}
|
|
110
119
|
|
|
120
|
+
/** Ask a reachable engine who it is. Never log the DSN. */
|
|
121
|
+
async function identifyEngine(t) {
|
|
122
|
+
const schemeFamily = familyFromScheme(t.scheme)
|
|
123
|
+
const looksPostgres = schemeFamily === 'postgres' || t.type === 'postgres' || t.type === 'supabase'
|
|
124
|
+
if (!looksPostgres) return null
|
|
125
|
+
try {
|
|
126
|
+
const postgres = (await import('postgres')).default
|
|
127
|
+
const sql = postgres(t.raw, { max: 1, connect_timeout: 3, idle_timeout: 1 })
|
|
128
|
+
try {
|
|
129
|
+
const rows = await sql`select version() as v`
|
|
130
|
+
const banner = String(rows?.[0]?.v || '')
|
|
131
|
+
const family = familyFromBanner(banner)
|
|
132
|
+
if (!family) return null
|
|
133
|
+
return { family, summary: banner.split(',')[0].replace(/\s+/g, ' ').slice(0, 72) }
|
|
134
|
+
} finally {
|
|
135
|
+
await sql.end({ timeout: 2 })
|
|
136
|
+
}
|
|
137
|
+
} catch {
|
|
138
|
+
return null
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
111
142
|
function envSet(name) {
|
|
112
143
|
const v = process.env[name]
|
|
113
144
|
return typeof v === 'string' && v.trim() !== '' ? v : null
|
|
@@ -254,6 +285,105 @@ if (config) {
|
|
|
254
285
|
ok('Policy surface', [hasAllowTables && 'allowTables', hasDeny && 'denyTables', hasMask && 'maskColumns'].filter(Boolean).join(' + '))
|
|
255
286
|
}
|
|
256
287
|
|
|
288
|
+
// 4b. Raised maxRows — performance warning, not a deny.
|
|
289
|
+
// Threshold is measured (docs/benchmarks/masking-cost-threshold.json).
|
|
290
|
+
// Doctor does not import dist/; the number is read from that file, or 100.
|
|
291
|
+
const thresholdPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'docs', 'benchmarks', 'masking-cost-threshold.json')
|
|
292
|
+
let warnAbove = 100
|
|
293
|
+
try {
|
|
294
|
+
if (existsSync(thresholdPath)) {
|
|
295
|
+
const t = JSON.parse(readFileSync(thresholdPath, 'utf8'))
|
|
296
|
+
if (Number.isFinite(t.warnAbove)) warnAbove = t.warnAbove
|
|
297
|
+
}
|
|
298
|
+
} catch { /* keep 100 */ }
|
|
299
|
+
const maxRows = pol.maxRows
|
|
300
|
+
if (typeof maxRows === 'number' && maxRows > warnAbove) {
|
|
301
|
+
warn(
|
|
302
|
+
'policy.maxRows',
|
|
303
|
+
`maxRows is ${maxRows} (measured warning above ${warnAbove}). Masking cost grows with the number of distinct values this policy already masked, not with table size. The row cap bounds that set. The query is not rejected.`,
|
|
304
|
+
'Leave the default if you do not need more rows. If you raise it, expect carry-over cost to grow with unique masked values.',
|
|
305
|
+
)
|
|
306
|
+
} else if (typeof maxRows === 'number') {
|
|
307
|
+
ok('policy.maxRows', `maxRows is ${maxRows} (at or below the measured threshold ${warnAbove})`)
|
|
308
|
+
} else {
|
|
309
|
+
ok('policy.maxRows', `maxRows is 100 (default — policy.maxRows omitted; threshold ${warnAbove})`)
|
|
310
|
+
}
|
|
311
|
+
for (const [name, profile] of Object.entries(pol.profiles || {})) {
|
|
312
|
+
const pMax = profile && typeof profile === 'object' ? profile.maxRows : undefined
|
|
313
|
+
if (typeof pMax === 'number' && pMax > warnAbove) {
|
|
314
|
+
warn(
|
|
315
|
+
`policy.profiles.${name}.maxRows`,
|
|
316
|
+
`profile maxRows is ${pMax} (measured warning above ${warnAbove}). Same cost: distinct masked values, not table size. Not rejected.`,
|
|
317
|
+
'A profile can only raise the cap for one identified person. The cost still grows with unique masked values.',
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// D2 — which SQL gate the query tool will use. Silence here was the bug.
|
|
323
|
+
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
324
|
+
let dialectInfo = null
|
|
325
|
+
try {
|
|
326
|
+
dialectInfo = resolveDoctorDialect(pol.dialect)
|
|
327
|
+
ok('SQL dialect', dialectLine(dialectInfo.dialect, dialectInfo.source))
|
|
328
|
+
} catch (e) {
|
|
329
|
+
fail('SQL dialect', e.message, 'Set policy.dialect to postgres, mssql, or oracle. A typo does not become postgres.')
|
|
330
|
+
}
|
|
331
|
+
if (dialectInfo) {
|
|
332
|
+
if (dialectInfo.dialect === 'postgres') {
|
|
333
|
+
ok('SQL gate', 'postgres gate is built-in (Governance.guardQuery)')
|
|
334
|
+
} else {
|
|
335
|
+
const gateFile = join(pkgRoot, 'dist', 'sql-gate', `${dialectInfo.dialect}.js`)
|
|
336
|
+
if (!existsSync(gateFile)) {
|
|
337
|
+
fail(
|
|
338
|
+
'SQL gate',
|
|
339
|
+
`${dialectInfo.dialect} gate file is missing (dist/sql-gate/${dialectInfo.dialect}.js)`,
|
|
340
|
+
'Run npm run build in the install. The query tool cannot load this dialect without that file.',
|
|
341
|
+
)
|
|
342
|
+
} else {
|
|
343
|
+
try {
|
|
344
|
+
await import(pathToFileURL(gateFile).href)
|
|
345
|
+
ok('SQL gate', `${dialectInfo.dialect} gate loaded from dist/sql-gate/${dialectInfo.dialect}.js`)
|
|
346
|
+
} catch (e) {
|
|
347
|
+
fail(
|
|
348
|
+
'SQL gate',
|
|
349
|
+
`${dialectInfo.dialect} gate failed to load: ${e.name}`,
|
|
350
|
+
'Rebuild the package. The query tool will fail closed on this dialect until the gate loads.',
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// D3 — custom PII: names only. Pattern text must never reach stdout.
|
|
358
|
+
const patterns = Array.isArray(pol.customPatterns) ? pol.customPatterns : []
|
|
359
|
+
const patternNames = patterns
|
|
360
|
+
.map((p) => (p && typeof p.name === 'string' ? p.name : null))
|
|
361
|
+
.filter(Boolean)
|
|
362
|
+
if (patterns.length === 0) {
|
|
363
|
+
ok('policy.customPatterns', '0 custom patterns')
|
|
364
|
+
} else {
|
|
365
|
+
const compilerPath = join(pkgRoot, 'dist', 'custom_patterns.js')
|
|
366
|
+
if (!existsSync(compilerPath)) {
|
|
367
|
+
unseen(
|
|
368
|
+
'policy.customPatterns',
|
|
369
|
+
`${patterns.length} named: ${patternNames.join(', ') || '(unnamed)'} — compile not checked (dist/custom_patterns.js missing)`,
|
|
370
|
+
'Run npm run build. The gateway rejects a broken pattern at load; the doctor could not confirm that here.',
|
|
371
|
+
)
|
|
372
|
+
} else {
|
|
373
|
+
try {
|
|
374
|
+
const { compileCustomPatterns } = await import(pathToFileURL(compilerPath).href)
|
|
375
|
+
compileCustomPatterns(patterns)
|
|
376
|
+
ok('policy.customPatterns', `${patterns.length} compiled: ${patternNames.join(', ')}`)
|
|
377
|
+
} catch (e) {
|
|
378
|
+
fail(
|
|
379
|
+
'policy.customPatterns',
|
|
380
|
+
`${patterns.length} named: ${patternNames.join(', ') || '(unnamed)'} — compile failed (${e.name})`,
|
|
381
|
+
'The gateway will refuse this config. Fix or remove the broken rule. Pattern text is not printed.',
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
257
387
|
// 5. Per-person profiles need per-user credentials
|
|
258
388
|
const profiles = pol.profiles || pol.actorProfiles
|
|
259
389
|
if (profiles && Object.keys(profiles).length > 0) {
|
|
@@ -414,18 +544,87 @@ if (config) {
|
|
|
414
544
|
} else {
|
|
415
545
|
ok('Connector DSN', `${c.name}: ${d.text}${d.hasPassword ? ' (password set, not shown)' : ''}`)
|
|
416
546
|
}
|
|
417
|
-
if (d.host && d.port) targets.push({ name: c.name, ...d })
|
|
547
|
+
if (d.host && d.port) targets.push({ name: c.name, type: c.type, raw, ...d })
|
|
418
548
|
}
|
|
549
|
+
const reachable = []
|
|
419
550
|
for (const t of SKIP_NET ? [] : targets) {
|
|
420
551
|
const r = await tcpProbe(t.host, t.port)
|
|
421
|
-
if (r.reachable)
|
|
422
|
-
|
|
552
|
+
if (r.reachable) {
|
|
553
|
+
ok('Reachability', `${t.name}: ${t.host}:${t.port} answers`)
|
|
554
|
+
reachable.push(t)
|
|
555
|
+
} else
|
|
423
556
|
fail(
|
|
424
557
|
'Reachability',
|
|
425
558
|
`${t.name}: ${t.host}:${t.port} unreachable (${r.why})`,
|
|
426
559
|
'The gateway logs connector failures and keeps running with zero connectors — it will look healthy and serve nothing.',
|
|
427
560
|
)
|
|
428
561
|
}
|
|
562
|
+
|
|
563
|
+
// D1 — declared dialect vs the engine that actually answers.
|
|
564
|
+
// Silence here meant Oracle rules on a Postgres DSN. Mismatch is FAIL.
|
|
565
|
+
// Cannot ask → unseen. Never "probably matches".
|
|
566
|
+
let dialectForEngine = null
|
|
567
|
+
try {
|
|
568
|
+
dialectForEngine = resolveDoctorDialect(config.policy?.dialect).dialect
|
|
569
|
+
} catch {
|
|
570
|
+
dialectForEngine = null
|
|
571
|
+
}
|
|
572
|
+
if (dialectForEngine) {
|
|
573
|
+
let schemeConflict = false
|
|
574
|
+
for (const t of targets) {
|
|
575
|
+
const fromScheme = familyFromScheme(t.scheme)
|
|
576
|
+
if (fromScheme && !dialectAgrees(dialectForEngine, fromScheme)) {
|
|
577
|
+
schemeConflict = true
|
|
578
|
+
fail(
|
|
579
|
+
'Engine identity',
|
|
580
|
+
`${t.name}: policy.dialect is ${dialectForEngine} but the DSN scheme is ${t.scheme} (${fromScheme})`,
|
|
581
|
+
'The query tool will parse with one grammar and send the SQL to another engine. Point the DSN at the declared dialect, or change policy.dialect.',
|
|
582
|
+
)
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (schemeConflict) {
|
|
586
|
+
// Already FAIL. Do not add a "not checked" line that reads like a second opinion.
|
|
587
|
+
} else if (SKIP_NET) {
|
|
588
|
+
unseen(
|
|
589
|
+
'Engine identity',
|
|
590
|
+
`not checked (--no-net). Declared dialect ${dialectForEngine} was not compared to a live engine.`,
|
|
591
|
+
'Rerun without --no-net when the database is reachable. Do not assume the dialect matches.',
|
|
592
|
+
)
|
|
593
|
+
} else if (targets.length === 0) {
|
|
594
|
+
unseen(
|
|
595
|
+
'Engine identity',
|
|
596
|
+
`not checked (no SQL DSN). Declared dialect ${dialectForEngine}.`,
|
|
597
|
+
'Add a postgres / SQL connector URL, or ignore this if this install has no SQL engine.',
|
|
598
|
+
)
|
|
599
|
+
} else if (reachable.length === 0) {
|
|
600
|
+
unseen(
|
|
601
|
+
'Engine identity',
|
|
602
|
+
`not checked (host unreachable). Declared dialect ${dialectForEngine}.`,
|
|
603
|
+
'Bring the engine up, then rerun. Unreachable is not a match.',
|
|
604
|
+
)
|
|
605
|
+
} else {
|
|
606
|
+
for (const t of reachable) {
|
|
607
|
+
const id = await identifyEngine(t)
|
|
608
|
+
if (!id) {
|
|
609
|
+
unseen(
|
|
610
|
+
'Engine identity',
|
|
611
|
+
`${t.name}: ${t.host}:${t.port} answers TCP but the engine family could not be read. Declared ${dialectForEngine}.`,
|
|
612
|
+
'Doctor asked the engine and got no version banner. Not a pass.',
|
|
613
|
+
)
|
|
614
|
+
continue
|
|
615
|
+
}
|
|
616
|
+
if (!dialectAgrees(dialectForEngine, id.family)) {
|
|
617
|
+
fail(
|
|
618
|
+
'Engine identity',
|
|
619
|
+
`${t.name}: policy.dialect is ${dialectForEngine} but the engine identified as ${id.family} (${id.summary})`,
|
|
620
|
+
'The query tool will enforce the wrong grammar against this engine. Fix policy.dialect or the DSN.',
|
|
621
|
+
)
|
|
622
|
+
} else {
|
|
623
|
+
ok('Engine identity', `${t.name}: engine is ${id.family} — matches policy.dialect ${dialectForEngine}`)
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
429
628
|
}
|
|
430
629
|
|
|
431
630
|
// 12. License pack — offline, never fail-closed. A broken license file must
|
|
@@ -466,7 +665,7 @@ if (config) {
|
|
|
466
665
|
|
|
467
666
|
/* ------------------------------------------------------------------ report */
|
|
468
667
|
|
|
469
|
-
const ICON = { ok: ' ok ', warn: ' warn ', fail: ' FAIL ' }
|
|
668
|
+
const ICON = { ok: ' ok ', warn: ' warn ', fail: ' FAIL ', unseen: 'unseen' }
|
|
470
669
|
console.log('')
|
|
471
670
|
console.log('conarium doctor')
|
|
472
671
|
console.log('─'.repeat(66))
|
|
@@ -476,9 +675,11 @@ for (const r of results) {
|
|
|
476
675
|
}
|
|
477
676
|
const fails = results.filter((r) => r.level === 'fail').length
|
|
478
677
|
const warns = results.filter((r) => r.level === 'warn').length
|
|
678
|
+
const unseenN = results.filter((r) => r.level === 'unseen').length
|
|
479
679
|
console.log('─'.repeat(66))
|
|
480
|
-
console.log(`${results.length} checks · ${fails} failed · ${warns} warning(s)`)
|
|
481
|
-
if (fails === 0 && warns === 0) console.log('This install is ready.')
|
|
680
|
+
console.log(`${results.length} checks · ${fails} failed · ${warns} warning(s) · ${unseenN} unseen`)
|
|
681
|
+
if (fails === 0 && warns === 0 && unseenN === 0) console.log('This install is ready.')
|
|
682
|
+
if (fails === 0 && unseenN > 0) console.log('No failures. Unseen lines were not verified — not a pass.')
|
|
482
683
|
if (fails > 0) console.log('Fix the FAIL lines above; the gateway will not govern correctly until you do.')
|
|
483
684
|
console.log('')
|
|
484
685
|
// Set the code and let the loop drain. process.exit() here raced the closing
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure dialect / engine helpers for conarium-doctor.
|
|
3
|
+
* Kept out of src/ so the doctor still runs when the build is broken.
|
|
4
|
+
* No DSN, no pattern text, no secrets.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const DOCTOR_DIALECTS = ['postgres', 'mssql', 'oracle']
|
|
8
|
+
|
|
9
|
+
/** Missing → postgres (today's path). Typo / mysql → throw. No silent fallback. */
|
|
10
|
+
export function resolveDoctorDialect(value) {
|
|
11
|
+
if (value === undefined) return { dialect: 'postgres', source: 'default' }
|
|
12
|
+
if (value === 'postgres' || value === 'mssql' || value === 'oracle') {
|
|
13
|
+
return { dialect: value, source: 'declared' }
|
|
14
|
+
}
|
|
15
|
+
const shown = typeof value === 'string' ? value : typeof value
|
|
16
|
+
throw new Error(`policy.dialect "${shown}" is not allowed. Use postgres, mssql, or oracle.`)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function familyFromScheme(scheme) {
|
|
20
|
+
const s = String(scheme || '').toLowerCase().replace(/:$/, '')
|
|
21
|
+
if (s === 'postgres' || s === 'postgresql') return 'postgres'
|
|
22
|
+
if (s === 'mssql' || s === 'sqlserver' || s === 'microsoft-sql-server') return 'mssql'
|
|
23
|
+
if (s === 'oracle' || s === 'oracledb') return 'oracle'
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Banner / version() text → family. Unknown stays unknown — never guessed into a match. */
|
|
28
|
+
export function familyFromBanner(text) {
|
|
29
|
+
const t = String(text || '')
|
|
30
|
+
if (/postgresql/i.test(t) || /\bpostgres\b/i.test(t)) return 'postgres'
|
|
31
|
+
if (/microsoft sql server/i.test(t) || /\bsql server\b/i.test(t)) return 'mssql'
|
|
32
|
+
if (/\boracle\b/i.test(t)) return 'oracle'
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function dialectAgrees(dialect, family) {
|
|
37
|
+
if (!family) return false
|
|
38
|
+
return dialect === family
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** One line the operator can paste. Never include a DSN or password. */
|
|
42
|
+
export function dialectLine(dialect, source) {
|
|
43
|
+
if (source === 'default') {
|
|
44
|
+
return `${dialect} (default — policy.dialect omitted)`
|
|
45
|
+
}
|
|
46
|
+
return `${dialect} (declared in policy.dialect)`
|
|
47
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const GovernancePolicySchema: z.ZodObject<{
|
|
|
5
5
|
denyTables: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
6
6
|
maskColumns: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
7
7
|
maxRows: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
dialect: z.ZodOptional<z.ZodEnum<["postgres", "mssql", "oracle"]>>;
|
|
8
9
|
maskLabelledNames: z.ZodOptional<z.ZodBoolean>;
|
|
9
10
|
allowTools: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
10
11
|
denyTools: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
@@ -61,6 +62,7 @@ export declare const GovernancePolicySchema: z.ZodObject<{
|
|
|
61
62
|
denyTools?: string[] | undefined;
|
|
62
63
|
allowConnectors?: string[] | undefined;
|
|
63
64
|
denyConnectors?: string[] | undefined;
|
|
65
|
+
dialect?: "postgres" | "mssql" | "oracle" | undefined;
|
|
64
66
|
profiles?: Record<string, {
|
|
65
67
|
maskColumns?: string[] | undefined;
|
|
66
68
|
maxRows?: number | undefined;
|
|
@@ -88,6 +90,7 @@ export declare const GovernancePolicySchema: z.ZodObject<{
|
|
|
88
90
|
denyTools?: string[] | undefined;
|
|
89
91
|
allowConnectors?: string[] | undefined;
|
|
90
92
|
denyConnectors?: string[] | undefined;
|
|
93
|
+
dialect?: "postgres" | "mssql" | "oracle" | undefined;
|
|
91
94
|
profiles?: Record<string, {
|
|
92
95
|
maskColumns?: string[] | undefined;
|
|
93
96
|
maxRows?: number | undefined;
|
|
@@ -166,13 +169,13 @@ export declare const ConnectorConfigSchema: z.ZodObject<{
|
|
|
166
169
|
description: z.ZodString;
|
|
167
170
|
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
168
171
|
}, "strict", z.ZodTypeAny, {
|
|
169
|
-
name: string;
|
|
170
172
|
type: "postgres" | "supabase" | "supabase-rest" | "openapi" | "files" | "docs" | "slack" | "jira";
|
|
173
|
+
name: string;
|
|
171
174
|
description: string;
|
|
172
175
|
config: Record<string, string>;
|
|
173
176
|
}, {
|
|
174
|
-
name: string;
|
|
175
177
|
type: "postgres" | "supabase" | "supabase-rest" | "openapi" | "files" | "docs" | "slack" | "jira";
|
|
178
|
+
name: string;
|
|
176
179
|
description: string;
|
|
177
180
|
config?: Record<string, string> | undefined;
|
|
178
181
|
}>;
|
|
@@ -183,13 +186,13 @@ export declare const ConariumConfigSchema: z.ZodObject<{
|
|
|
183
186
|
description: z.ZodString;
|
|
184
187
|
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
185
188
|
}, "strict", z.ZodTypeAny, {
|
|
186
|
-
name: string;
|
|
187
189
|
type: "postgres" | "supabase" | "supabase-rest" | "openapi" | "files" | "docs" | "slack" | "jira";
|
|
190
|
+
name: string;
|
|
188
191
|
description: string;
|
|
189
192
|
config: Record<string, string>;
|
|
190
193
|
}, {
|
|
191
|
-
name: string;
|
|
192
194
|
type: "postgres" | "supabase" | "supabase-rest" | "openapi" | "files" | "docs" | "slack" | "jira";
|
|
195
|
+
name: string;
|
|
193
196
|
description: string;
|
|
194
197
|
config?: Record<string, string> | undefined;
|
|
195
198
|
}>, "many">;
|
|
@@ -201,6 +204,7 @@ export declare const ConariumConfigSchema: z.ZodObject<{
|
|
|
201
204
|
denyTables: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
202
205
|
maskColumns: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
203
206
|
maxRows: z.ZodOptional<z.ZodNumber>;
|
|
207
|
+
dialect: z.ZodOptional<z.ZodEnum<["postgres", "mssql", "oracle"]>>;
|
|
204
208
|
maskLabelledNames: z.ZodOptional<z.ZodBoolean>;
|
|
205
209
|
allowTools: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
206
210
|
denyTools: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
@@ -257,6 +261,7 @@ export declare const ConariumConfigSchema: z.ZodObject<{
|
|
|
257
261
|
denyTools?: string[] | undefined;
|
|
258
262
|
allowConnectors?: string[] | undefined;
|
|
259
263
|
denyConnectors?: string[] | undefined;
|
|
264
|
+
dialect?: "postgres" | "mssql" | "oracle" | undefined;
|
|
260
265
|
profiles?: Record<string, {
|
|
261
266
|
maskColumns?: string[] | undefined;
|
|
262
267
|
maxRows?: number | undefined;
|
|
@@ -284,6 +289,7 @@ export declare const ConariumConfigSchema: z.ZodObject<{
|
|
|
284
289
|
denyTools?: string[] | undefined;
|
|
285
290
|
allowConnectors?: string[] | undefined;
|
|
286
291
|
denyConnectors?: string[] | undefined;
|
|
292
|
+
dialect?: "postgres" | "mssql" | "oracle" | undefined;
|
|
287
293
|
profiles?: Record<string, {
|
|
288
294
|
maskColumns?: string[] | undefined;
|
|
289
295
|
maxRows?: number | undefined;
|
|
@@ -358,8 +364,8 @@ export declare const ConariumConfigSchema: z.ZodObject<{
|
|
|
358
364
|
}>>;
|
|
359
365
|
}, "strict", z.ZodTypeAny, {
|
|
360
366
|
connectors: {
|
|
361
|
-
name: string;
|
|
362
367
|
type: "postgres" | "supabase" | "supabase-rest" | "openapi" | "files" | "docs" | "slack" | "jira";
|
|
368
|
+
name: string;
|
|
363
369
|
description: string;
|
|
364
370
|
config: Record<string, string>;
|
|
365
371
|
}[];
|
|
@@ -373,6 +379,7 @@ export declare const ConariumConfigSchema: z.ZodObject<{
|
|
|
373
379
|
denyTools?: string[] | undefined;
|
|
374
380
|
allowConnectors?: string[] | undefined;
|
|
375
381
|
denyConnectors?: string[] | undefined;
|
|
382
|
+
dialect?: "postgres" | "mssql" | "oracle" | undefined;
|
|
376
383
|
profiles?: Record<string, {
|
|
377
384
|
maskColumns?: string[] | undefined;
|
|
378
385
|
maxRows?: number | undefined;
|
|
@@ -410,8 +417,8 @@ export declare const ConariumConfigSchema: z.ZodObject<{
|
|
|
410
417
|
} | undefined;
|
|
411
418
|
}, {
|
|
412
419
|
connectors: {
|
|
413
|
-
name: string;
|
|
414
420
|
type: "postgres" | "supabase" | "supabase-rest" | "openapi" | "files" | "docs" | "slack" | "jira";
|
|
421
|
+
name: string;
|
|
415
422
|
description: string;
|
|
416
423
|
config?: Record<string, string> | undefined;
|
|
417
424
|
}[];
|
|
@@ -425,6 +432,7 @@ export declare const ConariumConfigSchema: z.ZodObject<{
|
|
|
425
432
|
denyTools?: string[] | undefined;
|
|
426
433
|
allowConnectors?: string[] | undefined;
|
|
427
434
|
denyConnectors?: string[] | undefined;
|
|
435
|
+
dialect?: "postgres" | "mssql" | "oracle" | undefined;
|
|
428
436
|
profiles?: Record<string, {
|
|
429
437
|
maskColumns?: string[] | undefined;
|
|
430
438
|
maxRows?: number | undefined;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAqBhD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BxB,CAAA;AAEX,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAanB,CAAA;AAEX,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;EAKvB,CAAA;AAEX,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOtB,CAAA;AAEX,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAqBhE"}
|
package/dist/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { compileCustomPatterns, CustomPatternError } from './custom_patterns.js';
|
|
3
|
+
import { warnIfMaxRowsHigh } from './masking-cost.js';
|
|
3
4
|
const stringArray = z.array(z.string().min(1)).default([]);
|
|
4
5
|
const MaskingProfileSchema = z.object({
|
|
5
6
|
// No .default([]): an omitted maskColumns must stay omitted so the overlay
|
|
@@ -19,6 +20,7 @@ export const GovernancePolicySchema = z.object({
|
|
|
19
20
|
denyTables: stringArray.optional(),
|
|
20
21
|
maskColumns: stringArray.optional(),
|
|
21
22
|
maxRows: z.number().int().positive().max(10000).optional(),
|
|
23
|
+
dialect: z.enum(['postgres', 'mssql', 'oracle']).optional(),
|
|
22
24
|
maskLabelledNames: z.boolean().optional(),
|
|
23
25
|
allowTools: stringArray.optional(),
|
|
24
26
|
denyTools: stringArray.optional(),
|
|
@@ -89,6 +91,10 @@ export function parseConariumConfig(raw) {
|
|
|
89
91
|
throw err;
|
|
90
92
|
throw err;
|
|
91
93
|
}
|
|
94
|
+
warnIfMaxRowsHigh(cfg.policy?.maxRows);
|
|
95
|
+
for (const profile of Object.values(cfg.policy?.profiles ?? {})) {
|
|
96
|
+
warnIfMaxRowsHigh(profile.maxRows);
|
|
97
|
+
}
|
|
92
98
|
return cfg;
|
|
93
99
|
}
|
|
94
100
|
/** Zod's default text can echo the received value. Pattern text must not leak. */
|