@arx-hq/collectors-pro 0.0.0-stage → 0.4.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arx Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @arx-hq/collectors-pro
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > Part of the [Arx](https://github.com/mehmetkoyunco/arx) 360-degree deterministic software quality, security, and production-readiness harness.
4
+
5
+ Wave 3 Vibe-Code AST security (`SEC-04/05/07/10`), license & SQL migration ops (`OPS-05/06`), and historical PRI `TELEMETRY` trend collectors.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @arx-hq/collectors-pro
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { createProCollectors } from "@arx-hq/collectors-pro";
17
+ ```
18
+
19
+ ## Documentation & Source
20
+
21
+ - Repository: https://github.com/mehmetkoyunco/arx
22
+ - CLI Quick Start: `npx @arx-hq/cli init --profile saas-web && npx @arx-hq/cli check`
23
+
24
+ ## License
25
+
26
+ MIT © Arx Contributors
@@ -0,0 +1,38 @@
1
+ import { CollectorPlugin, MetricFinding, ScorecardSnapshot } from '@arx-hq/contracts';
2
+
3
+ declare function isRestrictedLicense(licenseExpr: string): boolean;
4
+ declare function createOpsLicenseCollector(): CollectorPlugin;
5
+
6
+ declare function scanDestructiveSqlMigration(relFile: string, content: string): MetricFinding[];
7
+ declare function createOpsMigrationSafetyCollector(): CollectorPlugin;
8
+
9
+ declare function scanPiiLogLeaks(relFile: string, content: string): MetricFinding[];
10
+ declare function createSecPiiLogCollector(): CollectorPlugin;
11
+
12
+ interface SqlMigrationFile {
13
+ readonly file: string;
14
+ readonly content: string;
15
+ }
16
+ declare function scanSqlMigrationsForRls(migrations: readonly SqlMigrationFile[]): MetricFinding[];
17
+ declare function createSecRlsSqlCollector(): CollectorPlugin;
18
+
19
+ declare function scanVibeAuthAst(relFile: string, content: string): MetricFinding[];
20
+ declare function createSecVibeAuthCollector(): CollectorPlugin;
21
+
22
+ declare function scanWebhookSignature(relFile: string, content: string): MetricFinding[];
23
+ declare function createSecWebhookCollector(): CollectorPlugin;
24
+
25
+ interface TelemetrySummary {
26
+ readonly runs: number;
27
+ readonly latestPri: number;
28
+ readonly priDelta: number;
29
+ readonly regressionRatePct: number;
30
+ }
31
+ declare function analyzeScorecardTrend(history: readonly ScorecardSnapshot[]): TelemetrySummary | null;
32
+ declare function createTelemetryTrendCollector(): CollectorPlugin;
33
+
34
+ declare const COLLECTORS_PRO_SCHEMA_VERSION: "1.0.0";
35
+
36
+ declare function createProCollectors(): CollectorPlugin[];
37
+
38
+ export { COLLECTORS_PRO_SCHEMA_VERSION, type SqlMigrationFile, type TelemetrySummary, analyzeScorecardTrend, createOpsLicenseCollector, createOpsMigrationSafetyCollector, createProCollectors, createSecPiiLogCollector, createSecRlsSqlCollector, createSecVibeAuthCollector, createSecWebhookCollector, createTelemetryTrendCollector, isRestrictedLicense, scanDestructiveSqlMigration, scanPiiLogLeaks, scanSqlMigrationsForRls, scanVibeAuthAst, scanWebhookSignature };
package/dist/index.js ADDED
@@ -0,0 +1,970 @@
1
+ // src/index.ts
2
+ import { ARX_SCHEMA_VERSION } from "@arx-hq/contracts";
3
+
4
+ // src/collectors/ops-license.ts
5
+ import path2 from "path";
6
+ import {
7
+ createFindingFingerprint
8
+ } from "@arx-hq/contracts";
9
+
10
+ // src/utils/walk.ts
11
+ import { readdir, readFile } from "fs/promises";
12
+ import path from "path";
13
+ import { parseInlineIgnore } from "@arx-hq/contracts";
14
+ var ALWAYS_IGNORED_DIRS = /* @__PURE__ */ new Set([
15
+ ".git",
16
+ "node_modules",
17
+ "dist",
18
+ ".next",
19
+ "coverage",
20
+ ".arx"
21
+ ]);
22
+ function toPosix(filePath) {
23
+ return filePath.replace(/\\/g, "/");
24
+ }
25
+ function globToRegex(pattern) {
26
+ const normalized = toPosix(pattern).replace(/^\.\//, "");
27
+ let regex = "^";
28
+ for (let i = 0; i < normalized.length; i += 1) {
29
+ const ch = normalized[i];
30
+ const next = normalized[i + 1];
31
+ if (ch === "*" && next === "*") {
32
+ if (normalized[i + 2] === "/") {
33
+ regex += "(?:.*/)?";
34
+ i += 2;
35
+ } else {
36
+ regex += ".*";
37
+ i += 1;
38
+ }
39
+ continue;
40
+ }
41
+ if (ch === "*") {
42
+ regex += "[^/]*";
43
+ continue;
44
+ }
45
+ if (ch === "?") {
46
+ regex += "[^/]";
47
+ continue;
48
+ }
49
+ if (ch && /[.+^${}()|[\]\\]/.test(ch)) {
50
+ regex += `\\${ch}`;
51
+ continue;
52
+ }
53
+ regex += ch ?? "";
54
+ }
55
+ regex += "$";
56
+ return new RegExp(regex);
57
+ }
58
+ async function walkFiles(options) {
59
+ const regexes = options.ignorePaths.map((p) => globToRegex(p));
60
+ const isIgnored = (rel) => {
61
+ const clean = toPosix(rel).replace(/^\.\//, "");
62
+ return regexes.some((rx) => rx.test(clean));
63
+ };
64
+ const results = [];
65
+ async function visit(currentDir) {
66
+ let entries;
67
+ try {
68
+ entries = await readdir(currentDir, { withFileTypes: true });
69
+ } catch {
70
+ return;
71
+ }
72
+ entries.sort((a, b) => a.name.localeCompare(b.name));
73
+ for (const entry of entries) {
74
+ const absPath = path.join(currentDir, entry.name);
75
+ const relPosix = toPosix(path.relative(options.rootDir, absPath));
76
+ if (entry.isDirectory()) {
77
+ if (ALWAYS_IGNORED_DIRS.has(entry.name) || isIgnored(relPosix) || isIgnored(`${relPosix}/`)) {
78
+ continue;
79
+ }
80
+ await visit(absPath);
81
+ continue;
82
+ }
83
+ if (!entry.isFile() || isIgnored(relPosix)) {
84
+ continue;
85
+ }
86
+ if (options.extensions) {
87
+ const ext = path.extname(entry.name).toLowerCase();
88
+ if (!options.extensions.has(ext)) {
89
+ continue;
90
+ }
91
+ }
92
+ results.push(relPosix);
93
+ }
94
+ }
95
+ await visit(options.rootDir);
96
+ return results;
97
+ }
98
+ async function readTextIfExists(absPath) {
99
+ try {
100
+ return await readFile(absPath, "utf8");
101
+ } catch (error) {
102
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
103
+ return null;
104
+ }
105
+ throw error;
106
+ }
107
+ }
108
+ var SQL_IGNORE_REGEX = /--\s*arx-ignore\s+([A-Z]+-\d{2})\s+--reason\s+"([^"]+)"/;
109
+ function isSuppressedAtLine(lines, oneBasedLine, metricId) {
110
+ const candidates = [
111
+ lines[oneBasedLine - 1],
112
+ oneBasedLine > 1 ? lines[oneBasedLine - 2] : void 0,
113
+ lines[0]
114
+ ];
115
+ for (const line of candidates) {
116
+ if (!line) {
117
+ continue;
118
+ }
119
+ const jsDir = parseInlineIgnore(line);
120
+ if (jsDir && jsDir.metricId === metricId) {
121
+ return true;
122
+ }
123
+ const sqlMatch = SQL_IGNORE_REGEX.exec(line);
124
+ if (sqlMatch?.[1] === metricId && sqlMatch[2]?.trim()) {
125
+ return true;
126
+ }
127
+ }
128
+ return false;
129
+ }
130
+ var TS_JS_EXT = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs"]);
131
+ var SQL_EXT = /* @__PURE__ */ new Set([".sql"]);
132
+
133
+ // src/collectors/ops-license.ts
134
+ var RESTRICTED_LICENSE_REGEX = /\b(?:AGPL(?:-\d(?:\.\d)?)?|GPL-2\.0|GPL-3\.0|SSPL(?:-1\.0)?|BUSL|BSL)\b/i;
135
+ function isRestrictedLicense(licenseExpr) {
136
+ if (/\b(?:LGPL|MIT|Apache-2\.0|BSD|ISC|0BSD|MPL-2\.0)\b/i.test(licenseExpr) && /\bOR\b/i.test(licenseExpr)) {
137
+ return false;
138
+ }
139
+ return RESTRICTED_LICENSE_REGEX.test(licenseExpr);
140
+ }
141
+ function parseJsonPkg(raw) {
142
+ try {
143
+ return JSON.parse(raw);
144
+ } catch (error) {
145
+ return error instanceof Error ? null : null;
146
+ }
147
+ }
148
+ function parseLicenseField(pkg) {
149
+ if (typeof pkg.license === "string" && pkg.license.trim()) {
150
+ return pkg.license.trim();
151
+ }
152
+ if (typeof pkg.license === "object" && pkg.license !== null && typeof pkg.license.type === "string") {
153
+ return pkg.license.type.trim();
154
+ }
155
+ return null;
156
+ }
157
+ function createOpsLicenseCollector() {
158
+ return {
159
+ name: "ops-license",
160
+ pillar: "OPS",
161
+ tier: "T3",
162
+ supportedStacks: ["ts-node", "nextjs", "vite", "backend-api", "*"],
163
+ async detect(ctx) {
164
+ return await readTextIfExists(path2.resolve(ctx.rootDir, "package.json")) !== null;
165
+ },
166
+ async run(ctx) {
167
+ const rawRoot = await readTextIfExists(
168
+ path2.resolve(ctx.rootDir, "package.json")
169
+ );
170
+ if (!rawRoot) {
171
+ return [];
172
+ }
173
+ const rootPkg = parseJsonPkg(rawRoot);
174
+ if (!rootPkg) {
175
+ return [];
176
+ }
177
+ const depNames = /* @__PURE__ */ new Set([
178
+ ...Object.keys(rootPkg.dependencies ?? {}),
179
+ ...Object.keys(rootPkg.devDependencies ?? {})
180
+ ]);
181
+ const findings = [];
182
+ for (const depName of depNames) {
183
+ if (depName.startsWith("@arx-hq/")) {
184
+ continue;
185
+ }
186
+ const depPkgPath = path2.resolve(
187
+ ctx.rootDir,
188
+ "node_modules",
189
+ depName,
190
+ "package.json"
191
+ );
192
+ const rawDep = await readTextIfExists(depPkgPath);
193
+ if (!rawDep) {
194
+ continue;
195
+ }
196
+ const depPkg = parseJsonPkg(rawDep);
197
+ if (!depPkg) {
198
+ continue;
199
+ }
200
+ const lic = parseLicenseField(depPkg);
201
+ if (lic && isRestrictedLicense(lic)) {
202
+ findings.push({
203
+ id: "OPS-05",
204
+ fingerprint: createFindingFingerprint({
205
+ id: "OPS-05",
206
+ collector: "ops-license",
207
+ file: "package.json",
208
+ detail: `${depName}:${lic}`
209
+ }),
210
+ pillar: "OPS",
211
+ tier: "T3",
212
+ severity: "high",
213
+ title: `Restricted dependency license (${lic}): ${depName}`,
214
+ plainSummary: `Dependency "${depName}" uses a restrictive copyleft/source-available license (${lic}) requiring legal review.`,
215
+ evidence: {
216
+ file: "package.json",
217
+ snippet: `${depName}: ${lic}`
218
+ },
219
+ autoFixable: false,
220
+ repairHint: `Replace "${depName}" with a permissively licensed alternative (MIT/Apache-2.0/BSD) or record explicit legal approval in docs/DECISIONS.md.`,
221
+ collector: "ops-license"
222
+ });
223
+ }
224
+ }
225
+ return findings;
226
+ }
227
+ };
228
+ }
229
+
230
+ // src/collectors/ops-migration-safety.ts
231
+ import { readFile as readFile2 } from "fs/promises";
232
+ import path3 from "path";
233
+ import {
234
+ createFindingFingerprint as createFindingFingerprint2
235
+ } from "@arx-hq/contracts";
236
+ var DESTRUCTIVE_SQL_PATTERNS = [
237
+ {
238
+ kind: "drop-table",
239
+ label: "DROP TABLE",
240
+ regex: /\bDROP\s+TABLE\b/i
241
+ },
242
+ {
243
+ kind: "drop-column",
244
+ label: "DROP COLUMN",
245
+ regex: /\bDROP\s+COLUMN\b/i
246
+ },
247
+ {
248
+ kind: "truncate-table",
249
+ label: "TRUNCATE TABLE",
250
+ regex: /\bTRUNCATE\s+(?:TABLE\s+)?[a-zA-Z0-9_."]+/i
251
+ },
252
+ {
253
+ kind: "unfiltered-delete",
254
+ label: "DELETE FROM without WHERE",
255
+ regex: /\bDELETE\s+FROM\s+[a-zA-Z0-9_."]+\s*;/i
256
+ }
257
+ ];
258
+ function scanDestructiveSqlMigration(relFile, content) {
259
+ const findings = [];
260
+ const lines = content.replace(/\r\n/g, "\n").split("\n");
261
+ for (let i = 0; i < lines.length; i += 1) {
262
+ const lineNum = i + 1;
263
+ const line = lines[i] ?? "";
264
+ const trimmed = line.trim();
265
+ if (!trimmed || trimmed.startsWith("--")) {
266
+ continue;
267
+ }
268
+ if (isSuppressedAtLine(lines, lineNum, "OPS-06")) {
269
+ continue;
270
+ }
271
+ for (const rule of DESTRUCTIVE_SQL_PATTERNS) {
272
+ if (rule.regex.test(trimmed)) {
273
+ findings.push({
274
+ id: "OPS-06",
275
+ fingerprint: createFindingFingerprint2({
276
+ id: "OPS-06",
277
+ collector: "ops-migration-safety",
278
+ file: relFile,
279
+ line: lineNum,
280
+ detail: rule.kind
281
+ }),
282
+ pillar: "OPS",
283
+ tier: "T2",
284
+ severity: "critical",
285
+ title: `Destructive SQL migration (${rule.label}) in ${relFile}:${lineNum}`,
286
+ plainSummary: `Migration ${relFile} executes "${rule.label}", which can permanently destroy production data.`,
287
+ evidence: {
288
+ file: relFile,
289
+ line: lineNum,
290
+ snippet: trimmed.slice(0, 140)
291
+ },
292
+ autoFixable: false,
293
+ repairHint: `Use an expand-and-contract migration strategy or explicitly approve with \`-- arx-ignore OPS-06 --reason "..."\` after backup verification.`,
294
+ collector: "ops-migration-safety"
295
+ });
296
+ break;
297
+ }
298
+ }
299
+ }
300
+ return findings;
301
+ }
302
+ function createOpsMigrationSafetyCollector() {
303
+ return {
304
+ name: "ops-migration-safety",
305
+ pillar: "OPS",
306
+ tier: "T2",
307
+ supportedStacks: ["*"],
308
+ async detect(ctx) {
309
+ const files = await walkFiles({
310
+ rootDir: ctx.rootDir,
311
+ ignorePaths: ctx.config.ignorePaths,
312
+ extensions: SQL_EXT
313
+ });
314
+ return files.length > 0;
315
+ },
316
+ async run(ctx) {
317
+ const files = await walkFiles({
318
+ rootDir: ctx.rootDir,
319
+ ignorePaths: ctx.config.ignorePaths,
320
+ extensions: SQL_EXT
321
+ });
322
+ const findings = [];
323
+ for (const relFile of files) {
324
+ const content = await readFile2(
325
+ path3.resolve(ctx.rootDir, relFile),
326
+ "utf8"
327
+ );
328
+ findings.push(...scanDestructiveSqlMigration(relFile, content));
329
+ }
330
+ return findings;
331
+ }
332
+ };
333
+ }
334
+
335
+ // src/collectors/sec-pii-log.ts
336
+ import { readFile as readFile3 } from "fs/promises";
337
+ import path4 from "path";
338
+ import {
339
+ createFindingFingerprint as createFindingFingerprint3
340
+ } from "@arx-hq/contracts";
341
+ import ts from "typescript";
342
+ var LOG_OBJECTS = /* @__PURE__ */ new Set(["console", "logger", "log", "pino"]);
343
+ var LOG_METHODS = /* @__PURE__ */ new Set(["log", "info", "warn", "error", "debug", "trace"]);
344
+ var SENSITIVE_FIELD_REGEX = /^(?:password|passwd|secret|clientSecret|apiKey|accessToken|refreshToken|idToken|authToken|privateKey|creditCard|cardNumber|cvv|ssn|tckn|tcKimlik|authorization)$/i;
345
+ function findSensitiveIdentifierInExpr(node) {
346
+ let hit = null;
347
+ function visit(current) {
348
+ if (hit !== null) {
349
+ return;
350
+ }
351
+ if (ts.isIdentifier(current) && SENSITIVE_FIELD_REGEX.test(current.text)) {
352
+ hit = current.text;
353
+ return;
354
+ }
355
+ if (ts.isPropertyAccessExpression(current) && SENSITIVE_FIELD_REGEX.test(current.name.text)) {
356
+ hit = current.name.text;
357
+ return;
358
+ }
359
+ ts.forEachChild(current, visit);
360
+ }
361
+ visit(node);
362
+ return hit;
363
+ }
364
+ function scanPiiLogLeaks(relFile, content) {
365
+ const findings = [];
366
+ const lines = content.replace(/\r\n/g, "\n").split("\n");
367
+ const sourceFile = ts.createSourceFile(
368
+ relFile,
369
+ content,
370
+ ts.ScriptTarget.Latest,
371
+ true,
372
+ relFile.endsWith(".tsx") || relFile.endsWith(".jsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS
373
+ );
374
+ function visit(node) {
375
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && LOG_OBJECTS.has(node.expression.expression.text) && LOG_METHODS.has(node.expression.name.text)) {
376
+ for (const arg of node.arguments) {
377
+ const sensitiveName = findSensitiveIdentifierInExpr(arg);
378
+ if (sensitiveName) {
379
+ const pos = sourceFile.getLineAndCharacterOfPosition(
380
+ node.getStart(sourceFile)
381
+ );
382
+ const line = pos.line + 1;
383
+ if (!isSuppressedAtLine(lines, line, "SEC-10")) {
384
+ findings.push({
385
+ id: "SEC-10",
386
+ fingerprint: createFindingFingerprint3({
387
+ id: "SEC-10",
388
+ collector: "sec-pii-log",
389
+ file: relFile,
390
+ line,
391
+ detail: sensitiveName.toLowerCase()
392
+ }),
393
+ pillar: "SEC",
394
+ tier: "T2",
395
+ severity: "high",
396
+ title: `Sensitive field "${sensitiveName}" logged at ${relFile}:${line}`,
397
+ plainSummary: `Application logs output sensitive credential/PII field "${sensitiveName}" in ${relFile}, risking privacy (KVKK/GDPR) or credential leakage.`,
398
+ evidence: {
399
+ file: relFile,
400
+ line,
401
+ snippet: lines[line - 1]?.trim().slice(0, 140)
402
+ },
403
+ autoFixable: false,
404
+ repairHint: `Redact or omit "${sensitiveName}" from log statements at ${relFile}:${line}.`,
405
+ collector: "sec-pii-log"
406
+ });
407
+ }
408
+ break;
409
+ }
410
+ }
411
+ }
412
+ ts.forEachChild(node, visit);
413
+ }
414
+ visit(sourceFile);
415
+ return findings;
416
+ }
417
+ function createSecPiiLogCollector() {
418
+ return {
419
+ name: "sec-pii-log",
420
+ pillar: "SEC",
421
+ tier: "T2",
422
+ supportedStacks: ["ts-node", "nextjs", "backend-api", "vite", "*"],
423
+ async detect(ctx) {
424
+ const files = await walkFiles({
425
+ rootDir: ctx.rootDir,
426
+ ignorePaths: ctx.config.ignorePaths,
427
+ extensions: TS_JS_EXT
428
+ });
429
+ return files.length > 0;
430
+ },
431
+ async run(ctx) {
432
+ const files = await walkFiles({
433
+ rootDir: ctx.rootDir,
434
+ ignorePaths: ctx.config.ignorePaths,
435
+ extensions: TS_JS_EXT
436
+ });
437
+ const findings = [];
438
+ for (const relFile of files) {
439
+ if (relFile.endsWith(".d.ts") || relFile.includes("/test/") || relFile.includes("/tests/") || /\.test\.[a-z]+$/.test(relFile)) {
440
+ continue;
441
+ }
442
+ const content = await readFile3(
443
+ path4.resolve(ctx.rootDir, relFile),
444
+ "utf8"
445
+ );
446
+ findings.push(...scanPiiLogLeaks(relFile, content));
447
+ }
448
+ return findings;
449
+ }
450
+ };
451
+ }
452
+
453
+ // src/collectors/sec-rls-sql.ts
454
+ import { readFile as readFile4 } from "fs/promises";
455
+ import path5 from "path";
456
+ import {
457
+ createFindingFingerprint as createFindingFingerprint4
458
+ } from "@arx-hq/contracts";
459
+ var CREATE_TABLE_REGEX = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(?:(?:"?[a-zA-Z0-9_]+"?\.)?"?([a-zA-Z0-9_]+)"?)/gi;
460
+ var ENABLE_RLS_REGEX = /ALTER\s+TABLE\s+(?:ONLY\s+)?(?:(?:"?[a-zA-Z0-9_]+"?\.)?"?([a-zA-Z0-9_]+)"?)\s+ENABLE\s+ROW\s+LEVEL\s+SECURITY/gi;
461
+ var CREATE_POLICY_REGEX = /CREATE\s+POLICY\s+[\s\S]*?\bON\s+(?:(?:"?[a-zA-Z0-9_]+"?\.)?"?([a-zA-Z0-9_]+)"?)/gi;
462
+ var MIGRATION_PATH_REGEX = /(?:^|\/)(?:supabase\/migrations|migrations|prisma\/migrations|drizzle|db)\//i;
463
+ function scanSqlMigrationsForRls(migrations) {
464
+ const createdTables = /* @__PURE__ */ new Map();
465
+ const rlsEnabled = /* @__PURE__ */ new Set();
466
+ const hasPolicy = /* @__PURE__ */ new Set();
467
+ for (const mig of migrations) {
468
+ const lines = mig.content.replace(/\r\n/g, "\n").split("\n");
469
+ CREATE_TABLE_REGEX.lastIndex = 0;
470
+ let createMatch = CREATE_TABLE_REGEX.exec(mig.content);
471
+ while (createMatch !== null) {
472
+ const tableName = createMatch[1]?.toLowerCase();
473
+ if (tableName && !tableName.startsWith("_")) {
474
+ const lineNum = mig.content.slice(0, createMatch.index).split(/\r?\n/).length;
475
+ const suppressed = isSuppressedAtLine(lines, lineNum, "SEC-05");
476
+ if (!createdTables.has(tableName)) {
477
+ createdTables.set(tableName, {
478
+ file: mig.file,
479
+ line: lineNum,
480
+ suppressed
481
+ });
482
+ }
483
+ }
484
+ createMatch = CREATE_TABLE_REGEX.exec(mig.content);
485
+ }
486
+ ENABLE_RLS_REGEX.lastIndex = 0;
487
+ let rlsMatch = ENABLE_RLS_REGEX.exec(mig.content);
488
+ while (rlsMatch !== null) {
489
+ const tableName = rlsMatch[1]?.toLowerCase();
490
+ if (tableName) {
491
+ rlsEnabled.add(tableName);
492
+ }
493
+ rlsMatch = ENABLE_RLS_REGEX.exec(mig.content);
494
+ }
495
+ CREATE_POLICY_REGEX.lastIndex = 0;
496
+ let policyMatch = CREATE_POLICY_REGEX.exec(mig.content);
497
+ while (policyMatch !== null) {
498
+ const tableName = policyMatch[1]?.toLowerCase();
499
+ if (tableName) {
500
+ hasPolicy.add(tableName);
501
+ }
502
+ policyMatch = CREATE_POLICY_REGEX.exec(mig.content);
503
+ }
504
+ }
505
+ const findings = [];
506
+ for (const [tableName, meta] of createdTables.entries()) {
507
+ if (meta.suppressed) {
508
+ continue;
509
+ }
510
+ const missingRls = !rlsEnabled.has(tableName);
511
+ const missingPolicy = !hasPolicy.has(tableName);
512
+ if (!missingRls && !missingPolicy) {
513
+ continue;
514
+ }
515
+ const reason = missingRls ? "Row Level Security (RLS) is not enabled" : "RLS is enabled without any CREATE POLICY rule";
516
+ findings.push({
517
+ id: "SEC-05",
518
+ fingerprint: createFindingFingerprint4({
519
+ id: "SEC-05",
520
+ collector: "sec-rls-sql",
521
+ file: meta.file,
522
+ detail: `${tableName}:${missingRls ? "no-rls" : "no-policy"}`
523
+ }),
524
+ pillar: "SEC",
525
+ tier: "T2",
526
+ severity: "critical",
527
+ title: `Database table "${tableName}": ${reason}`,
528
+ plainSummary: `SQL table "${tableName}" defined in ${meta.file} lacks complete Row Level Security protection, risking unauthorized row access.`,
529
+ evidence: {
530
+ file: meta.file,
531
+ line: meta.line,
532
+ snippet: `CREATE TABLE ${tableName}`
533
+ },
534
+ autoFixable: false,
535
+ repairHint: `Add \`ALTER TABLE ${tableName} ENABLE ROW LEVEL SECURITY;\` and least-privilege \`CREATE POLICY\` statements for "${tableName}".`,
536
+ collector: "sec-rls-sql"
537
+ });
538
+ }
539
+ return findings;
540
+ }
541
+ function createSecRlsSqlCollector() {
542
+ return {
543
+ name: "sec-rls-sql",
544
+ pillar: "SEC",
545
+ tier: "T2",
546
+ supportedStacks: ["*"],
547
+ async detect(ctx) {
548
+ const files = await walkFiles({
549
+ rootDir: ctx.rootDir,
550
+ ignorePaths: ctx.config.ignorePaths,
551
+ extensions: SQL_EXT
552
+ });
553
+ return files.some((f) => MIGRATION_PATH_REGEX.test(f));
554
+ },
555
+ async run(ctx) {
556
+ const files = (await walkFiles({
557
+ rootDir: ctx.rootDir,
558
+ ignorePaths: ctx.config.ignorePaths,
559
+ extensions: SQL_EXT
560
+ })).filter((f) => MIGRATION_PATH_REGEX.test(f));
561
+ const migrations = [];
562
+ for (const file of files) {
563
+ const content = await readFile4(path5.resolve(ctx.rootDir, file), "utf8");
564
+ migrations.push({ file, content });
565
+ }
566
+ return scanSqlMigrationsForRls(migrations);
567
+ }
568
+ };
569
+ }
570
+
571
+ // src/collectors/sec-vibe-auth.ts
572
+ import { readFile as readFile5 } from "fs/promises";
573
+ import path6 from "path";
574
+ import {
575
+ createFindingFingerprint as createFindingFingerprint5
576
+ } from "@arx-hq/contracts";
577
+ import ts2 from "typescript";
578
+ var API_ROUTE_PATH_REGEX = /(?:^|\/)(?:app\/api\/.*\/route|pages\/api\/.*|api\/.*\/route)\.[jt]sx?$/;
579
+ var PUBLIC_ROUTE_ALLOWLIST_REGEX = /(?:^|\/)(?:health|healthz|ready|status|public|auth|login|logout|signup|register|webhook|webhooks|og|sitemap|robots)(?:\/|\.)/i;
580
+ var AUTH_SIGNAL_IDENTIFIERS = /* @__PURE__ */ new Set([
581
+ "auth",
582
+ "getAuth",
583
+ "getSession",
584
+ "getServerSession",
585
+ "getUser",
586
+ "currentUser",
587
+ "requireAuth",
588
+ "requireUser",
589
+ "requireSession",
590
+ "verifyAuth",
591
+ "verifyToken",
592
+ "verifyJwt",
593
+ "verifySession",
594
+ "authenticate",
595
+ "authorize",
596
+ "checkRole",
597
+ "assertAuthorized"
598
+ ]);
599
+ var HTTP_HANDLER_EXPORTS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE", "GET"]);
600
+ function hasUseServerDirective(sourceFile) {
601
+ for (const stmt of sourceFile.statements) {
602
+ if (ts2.isExpressionStatement(stmt) && ts2.isStringLiteral(stmt.expression) && stmt.expression.text === "use server") {
603
+ return true;
604
+ }
605
+ break;
606
+ }
607
+ return false;
608
+ }
609
+ function subtreeHasAuthCheck(node) {
610
+ let found = false;
611
+ function visit(current) {
612
+ if (found) {
613
+ return;
614
+ }
615
+ if (ts2.isIdentifier(current) && AUTH_SIGNAL_IDENTIFIERS.has(current.text)) {
616
+ found = true;
617
+ return;
618
+ }
619
+ if (ts2.isStringLiteral(current) && current.text.toLowerCase() === "authorization") {
620
+ found = true;
621
+ return;
622
+ }
623
+ ts2.forEachChild(current, visit);
624
+ }
625
+ visit(node);
626
+ return found;
627
+ }
628
+ function isExported(node) {
629
+ if (!ts2.canHaveModifiers(node)) {
630
+ return false;
631
+ }
632
+ const mods = ts2.getModifiers(node);
633
+ return Boolean(mods?.some((m) => m.kind === ts2.SyntaxKind.ExportKeyword));
634
+ }
635
+ function scanVibeAuthAst(relFile, content) {
636
+ if (PUBLIC_ROUTE_ALLOWLIST_REGEX.test(relFile)) {
637
+ return [];
638
+ }
639
+ const lines = content.replace(/\r\n/g, "\n").split("\n");
640
+ const sourceFile = ts2.createSourceFile(
641
+ relFile,
642
+ content,
643
+ ts2.ScriptTarget.Latest,
644
+ true,
645
+ relFile.endsWith(".tsx") || relFile.endsWith(".jsx") ? ts2.ScriptKind.TSX : ts2.ScriptKind.TS
646
+ );
647
+ const isApiRoute = API_ROUTE_PATH_REGEX.test(relFile);
648
+ const isServerActionFile = hasUseServerDirective(sourceFile);
649
+ if (!isApiRoute && !isServerActionFile) {
650
+ return [];
651
+ }
652
+ if (subtreeHasAuthCheck(sourceFile)) {
653
+ return [];
654
+ }
655
+ const findings = [];
656
+ for (const stmt of sourceFile.statements) {
657
+ let handlerName = null;
658
+ if (ts2.isFunctionDeclaration(stmt) && isExported(stmt) && stmt.name) {
659
+ handlerName = stmt.name.text;
660
+ } else if (ts2.isVariableStatement(stmt) && isExported(stmt)) {
661
+ for (const decl of stmt.declarationList.declarations) {
662
+ if (ts2.isIdentifier(decl.name)) {
663
+ handlerName = decl.name.text;
664
+ }
665
+ }
666
+ }
667
+ if (!handlerName) {
668
+ continue;
669
+ }
670
+ if (isApiRoute && !HTTP_HANDLER_EXPORTS.has(handlerName)) {
671
+ continue;
672
+ }
673
+ const pos = sourceFile.getLineAndCharacterOfPosition(
674
+ stmt.getStart(sourceFile)
675
+ );
676
+ const line = pos.line + 1;
677
+ if (isSuppressedAtLine(lines, line, "SEC-04")) {
678
+ continue;
679
+ }
680
+ const kindLabel = isServerActionFile ? "Server Action" : "API Route";
681
+ findings.push({
682
+ id: "SEC-04",
683
+ fingerprint: createFindingFingerprint5({
684
+ id: "SEC-04",
685
+ collector: "sec-vibe-auth",
686
+ file: relFile,
687
+ line,
688
+ detail: `${kindLabel}:${handlerName}`
689
+ }),
690
+ pillar: "SEC",
691
+ tier: "T2",
692
+ severity: "blocker",
693
+ title: `Unauthenticated ${kindLabel} "${handlerName}" in ${relFile}:${line}`,
694
+ plainSummary: `${kindLabel} "${handlerName}" in ${relFile} has no authentication or session verification check.`,
695
+ evidence: {
696
+ file: relFile,
697
+ line,
698
+ snippet: lines[line - 1]?.trim().slice(0, 140)
699
+ },
700
+ autoFixable: false,
701
+ repairHint: `Verify user session/auth (e.g. getSession/auth/requireAuth) at the start of "${handlerName}" or explicitly mark intentionally public endpoints with arx-ignore.`,
702
+ collector: "sec-vibe-auth"
703
+ });
704
+ }
705
+ return findings;
706
+ }
707
+ function createSecVibeAuthCollector() {
708
+ return {
709
+ name: "sec-vibe-auth",
710
+ pillar: "SEC",
711
+ tier: "T2",
712
+ supportedStacks: ["ts-node", "nextjs", "backend-api", "vite"],
713
+ async detect(ctx) {
714
+ const files = await walkFiles({
715
+ rootDir: ctx.rootDir,
716
+ ignorePaths: ctx.config.ignorePaths,
717
+ extensions: TS_JS_EXT
718
+ });
719
+ return files.length > 0;
720
+ },
721
+ async run(ctx) {
722
+ const files = await walkFiles({
723
+ rootDir: ctx.rootDir,
724
+ ignorePaths: ctx.config.ignorePaths,
725
+ extensions: TS_JS_EXT
726
+ });
727
+ const findings = [];
728
+ for (const relFile of files) {
729
+ if (relFile.includes("/test/") || relFile.includes("/tests/") || /\.test\.[a-z]+$/.test(relFile)) {
730
+ continue;
731
+ }
732
+ const content = await readFile5(
733
+ path6.resolve(ctx.rootDir, relFile),
734
+ "utf8"
735
+ );
736
+ findings.push(...scanVibeAuthAst(relFile, content));
737
+ }
738
+ return findings;
739
+ }
740
+ };
741
+ }
742
+
743
+ // src/collectors/sec-webhook.ts
744
+ import { readFile as readFile6 } from "fs/promises";
745
+ import path7 from "path";
746
+ import {
747
+ createFindingFingerprint as createFindingFingerprint6
748
+ } from "@arx-hq/contracts";
749
+ var WEBHOOK_FILE_REGEX = /(?:^|\/)webhooks?(?:\/|\.|[-_])/i;
750
+ var SIGNATURE_VERIFICATION_REGEX = /\b(?:constructEvent|verifyWebhook|validateEvent|verifySignature|createHmac|timingSafeEqual|Webhook)\b|stripe-signature|webhook-signature|x-signature|svix-signature|polar-signature/i;
751
+ function scanWebhookSignature(relFile, content) {
752
+ if (!WEBHOOK_FILE_REGEX.test(relFile)) {
753
+ return [];
754
+ }
755
+ const lines = content.replace(/\r\n/g, "\n").split("\n");
756
+ if (isSuppressedAtLine(lines, 1, "SEC-07")) {
757
+ return [];
758
+ }
759
+ if (SIGNATURE_VERIFICATION_REGEX.test(content)) {
760
+ return [];
761
+ }
762
+ return [
763
+ {
764
+ id: "SEC-07",
765
+ fingerprint: createFindingFingerprint6({
766
+ id: "SEC-07",
767
+ collector: "sec-webhook",
768
+ file: relFile,
769
+ detail: "missing-webhook-signature"
770
+ }),
771
+ pillar: "SEC",
772
+ tier: "T2",
773
+ severity: "blocker",
774
+ title: `Unsigned webhook handler in ${relFile}`,
775
+ plainSummary: `Webhook endpoint ${relFile} does not verify cryptographic signatures, allowing forged payment or billing events.`,
776
+ evidence: { file: relFile, line: 1 },
777
+ autoFixable: false,
778
+ repairHint: `Verify the raw request body signature (e.g. Stripe constructEvent, Polar validateEvent, or HMAC + timingSafeEqual) before processing events in ${relFile}.`,
779
+ collector: "sec-webhook"
780
+ }
781
+ ];
782
+ }
783
+ function createSecWebhookCollector() {
784
+ return {
785
+ name: "sec-webhook",
786
+ pillar: "SEC",
787
+ tier: "T2",
788
+ supportedStacks: ["ts-node", "nextjs", "backend-api", "vite"],
789
+ async detect(ctx) {
790
+ const files = await walkFiles({
791
+ rootDir: ctx.rootDir,
792
+ ignorePaths: ctx.config.ignorePaths,
793
+ extensions: TS_JS_EXT
794
+ });
795
+ return files.some((f) => WEBHOOK_FILE_REGEX.test(f));
796
+ },
797
+ async run(ctx) {
798
+ const files = (await walkFiles({
799
+ rootDir: ctx.rootDir,
800
+ ignorePaths: ctx.config.ignorePaths,
801
+ extensions: TS_JS_EXT
802
+ })).filter(
803
+ (f) => WEBHOOK_FILE_REGEX.test(f) && !f.includes("/test/") && !f.includes("/tests/") && !/\.test\.[a-z]+$/.test(f)
804
+ );
805
+ const findings = [];
806
+ for (const relFile of files) {
807
+ const content = await readFile6(
808
+ path7.resolve(ctx.rootDir, relFile),
809
+ "utf8"
810
+ );
811
+ findings.push(...scanWebhookSignature(relFile, content));
812
+ }
813
+ return findings;
814
+ }
815
+ };
816
+ }
817
+
818
+ // src/collectors/telemetry-trends.ts
819
+ import path8 from "path";
820
+ import {
821
+ ARX_PATHS,
822
+ createFindingFingerprint as createFindingFingerprint7,
823
+ ScorecardSnapshotSchema
824
+ } from "@arx-hq/contracts";
825
+ function analyzeScorecardTrend(history) {
826
+ if (history.length === 0) {
827
+ return null;
828
+ }
829
+ const latest = history[history.length - 1];
830
+ const previous = history.length >= 2 ? history[history.length - 2] : void 0;
831
+ if (!latest) {
832
+ return null;
833
+ }
834
+ let transitions = 0;
835
+ let regressions = 0;
836
+ for (let i = 1; i < history.length; i += 1) {
837
+ const prev = history[i - 1];
838
+ const curr = history[i];
839
+ if (!prev || !curr) {
840
+ continue;
841
+ }
842
+ transitions += 1;
843
+ if (prev.status === "green" && curr.status !== "green" || curr.overallScore < prev.overallScore - 2) {
844
+ regressions += 1;
845
+ }
846
+ }
847
+ return {
848
+ runs: history.length,
849
+ latestPri: latest.overallScore,
850
+ priDelta: previous !== void 0 ? Math.round((latest.overallScore - previous.overallScore) * 100) / 100 : 0,
851
+ regressionRatePct: transitions > 0 ? Math.round(regressions / transitions * 100) : 0
852
+ };
853
+ }
854
+ function parseSnapshotLine(line) {
855
+ try {
856
+ return ScorecardSnapshotSchema.parse(JSON.parse(line));
857
+ } catch (error) {
858
+ return error instanceof Error ? null : null;
859
+ }
860
+ }
861
+ function createTelemetryTrendCollector() {
862
+ return {
863
+ name: "telemetry-trends",
864
+ pillar: "TELEMETRY",
865
+ tier: "T2",
866
+ supportedStacks: ["*"],
867
+ async detect(ctx) {
868
+ const raw = await readTextIfExists(
869
+ path8.resolve(ctx.rootDir, ARX_PATHS.HISTORY)
870
+ );
871
+ return raw !== null && raw.trim().length > 0;
872
+ },
873
+ async run(ctx) {
874
+ const raw = await readTextIfExists(
875
+ path8.resolve(ctx.rootDir, ARX_PATHS.HISTORY)
876
+ );
877
+ if (!raw) {
878
+ return [];
879
+ }
880
+ const history = [];
881
+ for (const line of raw.split(/\r?\n/)) {
882
+ const trimmed = line.trim();
883
+ if (!trimmed) {
884
+ continue;
885
+ }
886
+ const parsed = parseSnapshotLine(trimmed);
887
+ if (parsed !== null) {
888
+ history.push(parsed);
889
+ }
890
+ }
891
+ const summary = analyzeScorecardTrend(history);
892
+ if (!summary) {
893
+ return [];
894
+ }
895
+ const deltaSign = summary.priDelta >= 0 ? "+" : "";
896
+ const findings = [
897
+ {
898
+ id: "TEL-01",
899
+ fingerprint: createFindingFingerprint7({
900
+ id: "TEL-01",
901
+ collector: "telemetry-trends",
902
+ detail: `runs:${summary.runs}:pri:${summary.latestPri}`
903
+ }),
904
+ pillar: "TELEMETRY",
905
+ tier: "T2",
906
+ severity: "info",
907
+ title: `PRI trend: ${summary.latestPri}/100 (${deltaSign}${summary.priDelta}) across ${summary.runs} run(s)`,
908
+ plainSummary: `Tracked ${summary.runs} verification run(s); latest PRI is ${summary.latestPri}/100 (${deltaSign}${summary.priDelta} vs previous).`,
909
+ evidence: { file: ARX_PATHS.HISTORY },
910
+ autoFixable: false,
911
+ repairHint: "Informational trend metric; review recurring drops early.",
912
+ collector: "telemetry-trends"
913
+ }
914
+ ];
915
+ if (summary.runs >= 2) {
916
+ findings.push({
917
+ id: "TEL-02",
918
+ fingerprint: createFindingFingerprint7({
919
+ id: "TEL-02",
920
+ collector: "telemetry-trends",
921
+ detail: `reg:${summary.regressionRatePct}`
922
+ }),
923
+ pillar: "TELEMETRY",
924
+ tier: "T2",
925
+ severity: "info",
926
+ title: `Regression rate: ${summary.regressionRatePct}%`,
927
+ plainSummary: `${summary.regressionRatePct}% of recorded transitions lowered quality or broke a previously green gate.`,
928
+ evidence: { file: ARX_PATHS.HISTORY },
929
+ autoFixable: false,
930
+ repairHint: "Add regression tests for modules that break repeatedly.",
931
+ collector: "telemetry-trends"
932
+ });
933
+ }
934
+ return findings;
935
+ }
936
+ };
937
+ }
938
+
939
+ // src/index.ts
940
+ var COLLECTORS_PRO_SCHEMA_VERSION = ARX_SCHEMA_VERSION;
941
+ function createProCollectors() {
942
+ return [
943
+ createSecVibeAuthCollector(),
944
+ createSecRlsSqlCollector(),
945
+ createSecWebhookCollector(),
946
+ createSecPiiLogCollector(),
947
+ createOpsLicenseCollector(),
948
+ createOpsMigrationSafetyCollector(),
949
+ createTelemetryTrendCollector()
950
+ ];
951
+ }
952
+ export {
953
+ COLLECTORS_PRO_SCHEMA_VERSION,
954
+ analyzeScorecardTrend,
955
+ createOpsLicenseCollector,
956
+ createOpsMigrationSafetyCollector,
957
+ createProCollectors,
958
+ createSecPiiLogCollector,
959
+ createSecRlsSqlCollector,
960
+ createSecVibeAuthCollector,
961
+ createSecWebhookCollector,
962
+ createTelemetryTrendCollector,
963
+ isRestrictedLicense,
964
+ scanDestructiveSqlMigration,
965
+ scanPiiLogLeaks,
966
+ scanSqlMigrationsForRls,
967
+ scanVibeAuthAst,
968
+ scanWebhookSignature
969
+ };
970
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/collectors/ops-license.ts","../src/utils/walk.ts","../src/collectors/ops-migration-safety.ts","../src/collectors/sec-pii-log.ts","../src/collectors/sec-rls-sql.ts","../src/collectors/sec-vibe-auth.ts","../src/collectors/sec-webhook.ts","../src/collectors/telemetry-trends.ts"],"sourcesContent":["import { ARX_SCHEMA_VERSION, type CollectorPlugin } from \"@arx-hq/contracts\";\nimport { createOpsLicenseCollector } from \"./collectors/ops-license.js\";\nimport { createOpsMigrationSafetyCollector } from \"./collectors/ops-migration-safety.js\";\nimport { createSecPiiLogCollector } from \"./collectors/sec-pii-log.js\";\nimport { createSecRlsSqlCollector } from \"./collectors/sec-rls-sql.js\";\nimport { createSecVibeAuthCollector } from \"./collectors/sec-vibe-auth.js\";\nimport { createSecWebhookCollector } from \"./collectors/sec-webhook.js\";\nimport { createTelemetryTrendCollector } from \"./collectors/telemetry-trends.js\";\n\nexport const COLLECTORS_PRO_SCHEMA_VERSION = ARX_SCHEMA_VERSION;\n\nexport * from \"./collectors/ops-license.js\";\nexport * from \"./collectors/ops-migration-safety.js\";\nexport * from \"./collectors/sec-pii-log.js\";\nexport * from \"./collectors/sec-rls-sql.js\";\nexport * from \"./collectors/sec-vibe-auth.js\";\nexport * from \"./collectors/sec-webhook.js\";\nexport * from \"./collectors/telemetry-trends.js\";\n\nexport function createProCollectors(): CollectorPlugin[] {\n return [\n createSecVibeAuthCollector(),\n createSecRlsSqlCollector(),\n createSecWebhookCollector(),\n createSecPiiLogCollector(),\n createOpsLicenseCollector(),\n createOpsMigrationSafetyCollector(),\n createTelemetryTrendCollector(),\n ];\n}\n","import path from \"node:path\";\nimport {\n type CollectorPlugin,\n createFindingFingerprint,\n type MetricFinding,\n} from \"@arx-hq/contracts\";\nimport { readTextIfExists } from \"../utils/walk.js\";\n\nconst RESTRICTED_LICENSE_REGEX =\n /\\b(?:AGPL(?:-\\d(?:\\.\\d)?)?|GPL-2\\.0|GPL-3\\.0|SSPL(?:-1\\.0)?|BUSL|BSL)\\b/i;\n\nexport function isRestrictedLicense(licenseExpr: string): boolean {\n if (\n /\\b(?:LGPL|MIT|Apache-2\\.0|BSD|ISC|0BSD|MPL-2\\.0)\\b/i.test(licenseExpr) &&\n /\\bOR\\b/i.test(licenseExpr)\n ) {\n return false;\n }\n return RESTRICTED_LICENSE_REGEX.test(licenseExpr);\n}\n\ninterface RawPkg {\n readonly dependencies?: Record<string, string>;\n readonly devDependencies?: Record<string, string>;\n readonly license?: string | { readonly type?: string };\n}\n\nfunction parseJsonPkg(raw: string): RawPkg | null {\n try {\n return JSON.parse(raw) as RawPkg;\n } catch (error) {\n return error instanceof Error ? null : null;\n }\n}\n\nfunction parseLicenseField(pkg: RawPkg): string | null {\n if (typeof pkg.license === \"string\" && pkg.license.trim()) {\n return pkg.license.trim();\n }\n if (\n typeof pkg.license === \"object\" &&\n pkg.license !== null &&\n typeof pkg.license.type === \"string\"\n ) {\n return pkg.license.type.trim();\n }\n return null;\n}\n\nexport function createOpsLicenseCollector(): CollectorPlugin {\n return {\n name: \"ops-license\",\n pillar: \"OPS\",\n tier: \"T3\",\n supportedStacks: [\"ts-node\", \"nextjs\", \"vite\", \"backend-api\", \"*\"],\n async detect(ctx) {\n return (\n (await readTextIfExists(path.resolve(ctx.rootDir, \"package.json\"))) !==\n null\n );\n },\n async run(ctx) {\n const rawRoot = await readTextIfExists(\n path.resolve(ctx.rootDir, \"package.json\"),\n );\n if (!rawRoot) {\n return [];\n }\n\n const rootPkg = parseJsonPkg(rawRoot);\n if (!rootPkg) {\n return [];\n }\n\n const depNames = new Set<string>([\n ...Object.keys(rootPkg.dependencies ?? {}),\n ...Object.keys(rootPkg.devDependencies ?? {}),\n ]);\n\n const findings: MetricFinding[] = [];\n for (const depName of depNames) {\n if (depName.startsWith(\"@arx-hq/\")) {\n continue;\n }\n const depPkgPath = path.resolve(\n ctx.rootDir,\n \"node_modules\",\n depName,\n \"package.json\",\n );\n const rawDep = await readTextIfExists(depPkgPath);\n if (!rawDep) {\n continue;\n }\n const depPkg = parseJsonPkg(rawDep);\n if (!depPkg) {\n continue;\n }\n const lic = parseLicenseField(depPkg);\n if (lic && isRestrictedLicense(lic)) {\n findings.push({\n id: \"OPS-05\",\n fingerprint: createFindingFingerprint({\n id: \"OPS-05\",\n collector: \"ops-license\",\n file: \"package.json\",\n detail: `${depName}:${lic}`,\n }),\n pillar: \"OPS\",\n tier: \"T3\",\n severity: \"high\",\n title: `Restricted dependency license (${lic}): ${depName}`,\n plainSummary: `Dependency \"${depName}\" uses a restrictive copyleft/source-available license (${lic}) requiring legal review.`,\n evidence: {\n file: \"package.json\",\n snippet: `${depName}: ${lic}`,\n },\n autoFixable: false,\n repairHint: `Replace \"${depName}\" with a permissively licensed alternative (MIT/Apache-2.0/BSD) or record explicit legal approval in docs/DECISIONS.md.`,\n collector: \"ops-license\",\n });\n }\n }\n\n return findings;\n },\n };\n}\n","import type { Dirent } from \"node:fs\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { parseInlineIgnore } from \"@arx-hq/contracts\";\n\nconst ALWAYS_IGNORED_DIRS = new Set([\n \".git\",\n \"node_modules\",\n \"dist\",\n \".next\",\n \"coverage\",\n \".arx\",\n]);\n\nexport function toPosix(filePath: string): string {\n return filePath.replace(/\\\\/g, \"/\");\n}\n\nfunction globToRegex(pattern: string): RegExp {\n const normalized = toPosix(pattern).replace(/^\\.\\//, \"\");\n let regex = \"^\";\n for (let i = 0; i < normalized.length; i += 1) {\n const ch = normalized[i];\n const next = normalized[i + 1];\n if (ch === \"*\" && next === \"*\") {\n if (normalized[i + 2] === \"/\") {\n regex += \"(?:.*/)?\";\n i += 2;\n } else {\n regex += \".*\";\n i += 1;\n }\n continue;\n }\n if (ch === \"*\") {\n regex += \"[^/]*\";\n continue;\n }\n if (ch === \"?\") {\n regex += \"[^/]\";\n continue;\n }\n if (ch && /[.+^${}()|[\\]\\\\]/.test(ch)) {\n regex += `\\\\${ch}`;\n continue;\n }\n regex += ch ?? \"\";\n }\n regex += \"$\";\n return new RegExp(regex);\n}\n\nexport async function walkFiles(options: {\n readonly rootDir: string;\n readonly ignorePaths: readonly string[];\n readonly extensions?: ReadonlySet<string>;\n}): Promise<string[]> {\n const regexes = options.ignorePaths.map((p) => globToRegex(p));\n const isIgnored = (rel: string): boolean => {\n const clean = toPosix(rel).replace(/^\\.\\//, \"\");\n return regexes.some((rx) => rx.test(clean));\n };\n\n const results: string[] = [];\n\n async function visit(currentDir: string): Promise<void> {\n let entries: Dirent[];\n try {\n entries = await readdir(currentDir, { withFileTypes: true });\n } catch {\n return;\n }\n entries.sort((a, b) => a.name.localeCompare(b.name));\n\n for (const entry of entries) {\n const absPath = path.join(currentDir, entry.name);\n const relPosix = toPosix(path.relative(options.rootDir, absPath));\n\n if (entry.isDirectory()) {\n if (\n ALWAYS_IGNORED_DIRS.has(entry.name) ||\n isIgnored(relPosix) ||\n isIgnored(`${relPosix}/`)\n ) {\n continue;\n }\n await visit(absPath);\n continue;\n }\n\n if (!entry.isFile() || isIgnored(relPosix)) {\n continue;\n }\n if (options.extensions) {\n const ext = path.extname(entry.name).toLowerCase();\n if (!options.extensions.has(ext)) {\n continue;\n }\n }\n results.push(relPosix);\n }\n }\n\n await visit(options.rootDir);\n return results;\n}\n\nexport async function readTextIfExists(\n absPath: string,\n): Promise<string | null> {\n try {\n return await readFile(absPath, \"utf8\");\n } catch (error) {\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n (error as { code?: unknown }).code === \"ENOENT\"\n ) {\n return null;\n }\n throw error;\n }\n}\n\nconst SQL_IGNORE_REGEX =\n /--\\s*arx-ignore\\s+([A-Z]+-\\d{2})\\s+--reason\\s+\"([^\"]+)\"/;\n\nexport function isSuppressedAtLine(\n lines: readonly string[],\n oneBasedLine: number,\n metricId: string,\n): boolean {\n const candidates = [\n lines[oneBasedLine - 1],\n oneBasedLine > 1 ? lines[oneBasedLine - 2] : undefined,\n lines[0],\n ];\n\n for (const line of candidates) {\n if (!line) {\n continue;\n }\n const jsDir = parseInlineIgnore(line);\n if (jsDir && jsDir.metricId === metricId) {\n return true;\n }\n const sqlMatch = SQL_IGNORE_REGEX.exec(line);\n if (sqlMatch?.[1] === metricId && sqlMatch[2]?.trim()) {\n return true;\n }\n }\n return false;\n}\n\nexport const TS_JS_EXT = new Set([\".ts\", \".tsx\", \".js\", \".jsx\", \".mjs\"]);\nexport const SQL_EXT = new Set([\".sql\"]);\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n type CollectorPlugin,\n createFindingFingerprint,\n type MetricFinding,\n} from \"@arx-hq/contracts\";\nimport { isSuppressedAtLine, SQL_EXT, walkFiles } from \"../utils/walk.js\";\n\nconst DESTRUCTIVE_SQL_PATTERNS: readonly {\n readonly kind: string;\n readonly label: string;\n readonly regex: RegExp;\n}[] = [\n {\n kind: \"drop-table\",\n label: \"DROP TABLE\",\n regex: /\\bDROP\\s+TABLE\\b/i,\n },\n {\n kind: \"drop-column\",\n label: \"DROP COLUMN\",\n regex: /\\bDROP\\s+COLUMN\\b/i,\n },\n {\n kind: \"truncate-table\",\n label: \"TRUNCATE TABLE\",\n regex: /\\bTRUNCATE\\s+(?:TABLE\\s+)?[a-zA-Z0-9_.\"]+/i,\n },\n {\n kind: \"unfiltered-delete\",\n label: \"DELETE FROM without WHERE\",\n regex: /\\bDELETE\\s+FROM\\s+[a-zA-Z0-9_.\"]+\\s*;/i,\n },\n];\n\nexport function scanDestructiveSqlMigration(\n relFile: string,\n content: string,\n): MetricFinding[] {\n const findings: MetricFinding[] = [];\n const lines = content.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n\n for (let i = 0; i < lines.length; i += 1) {\n const lineNum = i + 1;\n const line = lines[i] ?? \"\";\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"--\")) {\n continue;\n }\n if (isSuppressedAtLine(lines, lineNum, \"OPS-06\")) {\n continue;\n }\n\n for (const rule of DESTRUCTIVE_SQL_PATTERNS) {\n if (rule.regex.test(trimmed)) {\n findings.push({\n id: \"OPS-06\",\n fingerprint: createFindingFingerprint({\n id: \"OPS-06\",\n collector: \"ops-migration-safety\",\n file: relFile,\n line: lineNum,\n detail: rule.kind,\n }),\n pillar: \"OPS\",\n tier: \"T2\",\n severity: \"critical\",\n title: `Destructive SQL migration (${rule.label}) in ${relFile}:${lineNum}`,\n plainSummary: `Migration ${relFile} executes \"${rule.label}\", which can permanently destroy production data.`,\n evidence: {\n file: relFile,\n line: lineNum,\n snippet: trimmed.slice(0, 140),\n },\n autoFixable: false,\n repairHint: `Use an expand-and-contract migration strategy or explicitly approve with \\`-- arx-ignore OPS-06 --reason \"...\"\\` after backup verification.`,\n collector: \"ops-migration-safety\",\n });\n break;\n }\n }\n }\n\n return findings;\n}\n\nexport function createOpsMigrationSafetyCollector(): CollectorPlugin {\n return {\n name: \"ops-migration-safety\",\n pillar: \"OPS\",\n tier: \"T2\",\n supportedStacks: [\"*\"],\n async detect(ctx) {\n const files = await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: SQL_EXT,\n });\n return files.length > 0;\n },\n async run(ctx) {\n const files = await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: SQL_EXT,\n });\n const findings: MetricFinding[] = [];\n for (const relFile of files) {\n const content = await readFile(\n path.resolve(ctx.rootDir, relFile),\n \"utf8\",\n );\n findings.push(...scanDestructiveSqlMigration(relFile, content));\n }\n return findings;\n },\n };\n}\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n type CollectorPlugin,\n createFindingFingerprint,\n type MetricFinding,\n} from \"@arx-hq/contracts\";\nimport ts from \"typescript\";\nimport { isSuppressedAtLine, TS_JS_EXT, walkFiles } from \"../utils/walk.js\";\n\nconst LOG_OBJECTS = new Set([\"console\", \"logger\", \"log\", \"pino\"]);\nconst LOG_METHODS = new Set([\"log\", \"info\", \"warn\", \"error\", \"debug\", \"trace\"]);\n\nconst SENSITIVE_FIELD_REGEX =\n /^(?:password|passwd|secret|clientSecret|apiKey|accessToken|refreshToken|idToken|authToken|privateKey|creditCard|cardNumber|cvv|ssn|tckn|tcKimlik|authorization)$/i;\n\nfunction findSensitiveIdentifierInExpr(node: ts.Node): string | null {\n let hit: string | null = null;\n\n function visit(current: ts.Node): void {\n if (hit !== null) {\n return;\n }\n if (ts.isIdentifier(current) && SENSITIVE_FIELD_REGEX.test(current.text)) {\n hit = current.text;\n return;\n }\n if (\n ts.isPropertyAccessExpression(current) &&\n SENSITIVE_FIELD_REGEX.test(current.name.text)\n ) {\n hit = current.name.text;\n return;\n }\n ts.forEachChild(current, visit);\n }\n\n visit(node);\n return hit;\n}\n\nexport function scanPiiLogLeaks(\n relFile: string,\n content: string,\n): MetricFinding[] {\n const findings: MetricFinding[] = [];\n const lines = content.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n const sourceFile = ts.createSourceFile(\n relFile,\n content,\n ts.ScriptTarget.Latest,\n true,\n relFile.endsWith(\".tsx\") || relFile.endsWith(\".jsx\")\n ? ts.ScriptKind.TSX\n : ts.ScriptKind.TS,\n );\n\n function visit(node: ts.Node): void {\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n ts.isIdentifier(node.expression.expression) &&\n LOG_OBJECTS.has(node.expression.expression.text) &&\n LOG_METHODS.has(node.expression.name.text)\n ) {\n for (const arg of node.arguments) {\n const sensitiveName = findSensitiveIdentifierInExpr(arg);\n if (sensitiveName) {\n const pos = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(sourceFile),\n );\n const line = pos.line + 1;\n if (!isSuppressedAtLine(lines, line, \"SEC-10\")) {\n findings.push({\n id: \"SEC-10\",\n fingerprint: createFindingFingerprint({\n id: \"SEC-10\",\n collector: \"sec-pii-log\",\n file: relFile,\n line,\n detail: sensitiveName.toLowerCase(),\n }),\n pillar: \"SEC\",\n tier: \"T2\",\n severity: \"high\",\n title: `Sensitive field \"${sensitiveName}\" logged at ${relFile}:${line}`,\n plainSummary: `Application logs output sensitive credential/PII field \"${sensitiveName}\" in ${relFile}, risking privacy (KVKK/GDPR) or credential leakage.`,\n evidence: {\n file: relFile,\n line,\n snippet: lines[line - 1]?.trim().slice(0, 140),\n },\n autoFixable: false,\n repairHint: `Redact or omit \"${sensitiveName}\" from log statements at ${relFile}:${line}.`,\n collector: \"sec-pii-log\",\n });\n }\n break;\n }\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return findings;\n}\n\nexport function createSecPiiLogCollector(): CollectorPlugin {\n return {\n name: \"sec-pii-log\",\n pillar: \"SEC\",\n tier: \"T2\",\n supportedStacks: [\"ts-node\", \"nextjs\", \"backend-api\", \"vite\", \"*\"],\n async detect(ctx) {\n const files = await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: TS_JS_EXT,\n });\n return files.length > 0;\n },\n async run(ctx) {\n const files = await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: TS_JS_EXT,\n });\n const findings: MetricFinding[] = [];\n for (const relFile of files) {\n if (\n relFile.endsWith(\".d.ts\") ||\n relFile.includes(\"/test/\") ||\n relFile.includes(\"/tests/\") ||\n /\\.test\\.[a-z]+$/.test(relFile)\n ) {\n continue;\n }\n const content = await readFile(\n path.resolve(ctx.rootDir, relFile),\n \"utf8\",\n );\n findings.push(...scanPiiLogLeaks(relFile, content));\n }\n return findings;\n },\n };\n}\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n type CollectorPlugin,\n createFindingFingerprint,\n type MetricFinding,\n} from \"@arx-hq/contracts\";\nimport { isSuppressedAtLine, SQL_EXT, walkFiles } from \"../utils/walk.js\";\n\nconst CREATE_TABLE_REGEX =\n /CREATE\\s+TABLE\\s+(?:IF\\s+NOT\\s+EXISTS\\s+)?(?:(?:\"?[a-zA-Z0-9_]+\"?\\.)?\"?([a-zA-Z0-9_]+)\"?)/gi;\n\nconst ENABLE_RLS_REGEX =\n /ALTER\\s+TABLE\\s+(?:ONLY\\s+)?(?:(?:\"?[a-zA-Z0-9_]+\"?\\.)?\"?([a-zA-Z0-9_]+)\"?)\\s+ENABLE\\s+ROW\\s+LEVEL\\s+SECURITY/gi;\n\nconst CREATE_POLICY_REGEX =\n /CREATE\\s+POLICY\\s+[\\s\\S]*?\\bON\\s+(?:(?:\"?[a-zA-Z0-9_]+\"?\\.)?\"?([a-zA-Z0-9_]+)\"?)/gi;\n\nconst MIGRATION_PATH_REGEX =\n /(?:^|\\/)(?:supabase\\/migrations|migrations|prisma\\/migrations|drizzle|db)\\//i;\n\nexport interface SqlMigrationFile {\n readonly file: string;\n readonly content: string;\n}\n\nexport function scanSqlMigrationsForRls(\n migrations: readonly SqlMigrationFile[],\n): MetricFinding[] {\n const createdTables = new Map<\n string,\n { file: string; line: number; suppressed: boolean }\n >();\n const rlsEnabled = new Set<string>();\n const hasPolicy = new Set<string>();\n\n for (const mig of migrations) {\n const lines = mig.content.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n\n CREATE_TABLE_REGEX.lastIndex = 0;\n let createMatch = CREATE_TABLE_REGEX.exec(mig.content);\n while (createMatch !== null) {\n const tableName = createMatch[1]?.toLowerCase();\n if (tableName && !tableName.startsWith(\"_\")) {\n const lineNum = mig.content\n .slice(0, createMatch.index)\n .split(/\\r?\\n/).length;\n const suppressed = isSuppressedAtLine(lines, lineNum, \"SEC-05\");\n if (!createdTables.has(tableName)) {\n createdTables.set(tableName, {\n file: mig.file,\n line: lineNum,\n suppressed,\n });\n }\n }\n createMatch = CREATE_TABLE_REGEX.exec(mig.content);\n }\n\n ENABLE_RLS_REGEX.lastIndex = 0;\n let rlsMatch = ENABLE_RLS_REGEX.exec(mig.content);\n while (rlsMatch !== null) {\n const tableName = rlsMatch[1]?.toLowerCase();\n if (tableName) {\n rlsEnabled.add(tableName);\n }\n rlsMatch = ENABLE_RLS_REGEX.exec(mig.content);\n }\n\n CREATE_POLICY_REGEX.lastIndex = 0;\n let policyMatch = CREATE_POLICY_REGEX.exec(mig.content);\n while (policyMatch !== null) {\n const tableName = policyMatch[1]?.toLowerCase();\n if (tableName) {\n hasPolicy.add(tableName);\n }\n policyMatch = CREATE_POLICY_REGEX.exec(mig.content);\n }\n }\n\n const findings: MetricFinding[] = [];\n for (const [tableName, meta] of createdTables.entries()) {\n if (meta.suppressed) {\n continue;\n }\n const missingRls = !rlsEnabled.has(tableName);\n const missingPolicy = !hasPolicy.has(tableName);\n if (!missingRls && !missingPolicy) {\n continue;\n }\n\n const reason = missingRls\n ? \"Row Level Security (RLS) is not enabled\"\n : \"RLS is enabled without any CREATE POLICY rule\";\n\n findings.push({\n id: \"SEC-05\",\n fingerprint: createFindingFingerprint({\n id: \"SEC-05\",\n collector: \"sec-rls-sql\",\n file: meta.file,\n detail: `${tableName}:${missingRls ? \"no-rls\" : \"no-policy\"}`,\n }),\n pillar: \"SEC\",\n tier: \"T2\",\n severity: \"critical\",\n title: `Database table \"${tableName}\": ${reason}`,\n plainSummary: `SQL table \"${tableName}\" defined in ${meta.file} lacks complete Row Level Security protection, risking unauthorized row access.`,\n evidence: {\n file: meta.file,\n line: meta.line,\n snippet: `CREATE TABLE ${tableName}`,\n },\n autoFixable: false,\n repairHint: `Add \\`ALTER TABLE ${tableName} ENABLE ROW LEVEL SECURITY;\\` and least-privilege \\`CREATE POLICY\\` statements for \"${tableName}\".`,\n collector: \"sec-rls-sql\",\n });\n }\n\n return findings;\n}\n\nexport function createSecRlsSqlCollector(): CollectorPlugin {\n return {\n name: \"sec-rls-sql\",\n pillar: \"SEC\",\n tier: \"T2\",\n supportedStacks: [\"*\"],\n async detect(ctx) {\n const files = await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: SQL_EXT,\n });\n return files.some((f) => MIGRATION_PATH_REGEX.test(f));\n },\n async run(ctx) {\n const files = (\n await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: SQL_EXT,\n })\n ).filter((f) => MIGRATION_PATH_REGEX.test(f));\n\n const migrations: SqlMigrationFile[] = [];\n for (const file of files) {\n const content = await readFile(path.resolve(ctx.rootDir, file), \"utf8\");\n migrations.push({ file, content });\n }\n return scanSqlMigrationsForRls(migrations);\n },\n };\n}\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n type CollectorPlugin,\n createFindingFingerprint,\n type MetricFinding,\n} from \"@arx-hq/contracts\";\nimport ts from \"typescript\";\nimport { isSuppressedAtLine, TS_JS_EXT, walkFiles } from \"../utils/walk.js\";\n\nconst API_ROUTE_PATH_REGEX =\n /(?:^|\\/)(?:app\\/api\\/.*\\/route|pages\\/api\\/.*|api\\/.*\\/route)\\.[jt]sx?$/;\n\nconst PUBLIC_ROUTE_ALLOWLIST_REGEX =\n /(?:^|\\/)(?:health|healthz|ready|status|public|auth|login|logout|signup|register|webhook|webhooks|og|sitemap|robots)(?:\\/|\\.)/i;\n\nconst AUTH_SIGNAL_IDENTIFIERS = new Set([\n \"auth\",\n \"getAuth\",\n \"getSession\",\n \"getServerSession\",\n \"getUser\",\n \"currentUser\",\n \"requireAuth\",\n \"requireUser\",\n \"requireSession\",\n \"verifyAuth\",\n \"verifyToken\",\n \"verifyJwt\",\n \"verifySession\",\n \"authenticate\",\n \"authorize\",\n \"checkRole\",\n \"assertAuthorized\",\n]);\n\nconst HTTP_HANDLER_EXPORTS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\", \"GET\"]);\n\nfunction hasUseServerDirective(sourceFile: ts.SourceFile): boolean {\n for (const stmt of sourceFile.statements) {\n if (\n ts.isExpressionStatement(stmt) &&\n ts.isStringLiteral(stmt.expression) &&\n stmt.expression.text === \"use server\"\n ) {\n return true;\n }\n break;\n }\n return false;\n}\n\nfunction subtreeHasAuthCheck(node: ts.Node): boolean {\n let found = false;\n\n function visit(current: ts.Node): void {\n if (found) {\n return;\n }\n if (ts.isIdentifier(current) && AUTH_SIGNAL_IDENTIFIERS.has(current.text)) {\n found = true;\n return;\n }\n if (\n ts.isStringLiteral(current) &&\n current.text.toLowerCase() === \"authorization\"\n ) {\n found = true;\n return;\n }\n ts.forEachChild(current, visit);\n }\n\n visit(node);\n return found;\n}\n\nfunction isExported(node: ts.Node): boolean {\n if (!ts.canHaveModifiers(node)) {\n return false;\n }\n const mods = ts.getModifiers(node);\n return Boolean(mods?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword));\n}\n\nexport function scanVibeAuthAst(\n relFile: string,\n content: string,\n): MetricFinding[] {\n if (PUBLIC_ROUTE_ALLOWLIST_REGEX.test(relFile)) {\n return [];\n }\n\n const lines = content.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n const sourceFile = ts.createSourceFile(\n relFile,\n content,\n ts.ScriptTarget.Latest,\n true,\n relFile.endsWith(\".tsx\") || relFile.endsWith(\".jsx\")\n ? ts.ScriptKind.TSX\n : ts.ScriptKind.TS,\n );\n\n const isApiRoute = API_ROUTE_PATH_REGEX.test(relFile);\n const isServerActionFile = hasUseServerDirective(sourceFile);\n if (!isApiRoute && !isServerActionFile) {\n return [];\n }\n\n if (subtreeHasAuthCheck(sourceFile)) {\n return [];\n }\n\n const findings: MetricFinding[] = [];\n\n for (const stmt of sourceFile.statements) {\n let handlerName: string | null = null;\n if (ts.isFunctionDeclaration(stmt) && isExported(stmt) && stmt.name) {\n handlerName = stmt.name.text;\n } else if (ts.isVariableStatement(stmt) && isExported(stmt)) {\n for (const decl of stmt.declarationList.declarations) {\n if (ts.isIdentifier(decl.name)) {\n handlerName = decl.name.text;\n }\n }\n }\n\n if (!handlerName) {\n continue;\n }\n if (isApiRoute && !HTTP_HANDLER_EXPORTS.has(handlerName)) {\n continue;\n }\n\n const pos = sourceFile.getLineAndCharacterOfPosition(\n stmt.getStart(sourceFile),\n );\n const line = pos.line + 1;\n if (isSuppressedAtLine(lines, line, \"SEC-04\")) {\n continue;\n }\n\n const kindLabel = isServerActionFile ? \"Server Action\" : \"API Route\";\n findings.push({\n id: \"SEC-04\",\n fingerprint: createFindingFingerprint({\n id: \"SEC-04\",\n collector: \"sec-vibe-auth\",\n file: relFile,\n line,\n detail: `${kindLabel}:${handlerName}`,\n }),\n pillar: \"SEC\",\n tier: \"T2\",\n severity: \"blocker\",\n title: `Unauthenticated ${kindLabel} \"${handlerName}\" in ${relFile}:${line}`,\n plainSummary: `${kindLabel} \"${handlerName}\" in ${relFile} has no authentication or session verification check.`,\n evidence: {\n file: relFile,\n line,\n snippet: lines[line - 1]?.trim().slice(0, 140),\n },\n autoFixable: false,\n repairHint: `Verify user session/auth (e.g. getSession/auth/requireAuth) at the start of \"${handlerName}\" or explicitly mark intentionally public endpoints with arx-ignore.`,\n collector: \"sec-vibe-auth\",\n });\n }\n\n return findings;\n}\n\nexport function createSecVibeAuthCollector(): CollectorPlugin {\n return {\n name: \"sec-vibe-auth\",\n pillar: \"SEC\",\n tier: \"T2\",\n supportedStacks: [\"ts-node\", \"nextjs\", \"backend-api\", \"vite\"],\n async detect(ctx) {\n const files = await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: TS_JS_EXT,\n });\n return files.length > 0;\n },\n async run(ctx) {\n const files = await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: TS_JS_EXT,\n });\n const findings: MetricFinding[] = [];\n for (const relFile of files) {\n if (\n relFile.includes(\"/test/\") ||\n relFile.includes(\"/tests/\") ||\n /\\.test\\.[a-z]+$/.test(relFile)\n ) {\n continue;\n }\n const content = await readFile(\n path.resolve(ctx.rootDir, relFile),\n \"utf8\",\n );\n findings.push(...scanVibeAuthAst(relFile, content));\n }\n return findings;\n },\n };\n}\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n type CollectorPlugin,\n createFindingFingerprint,\n type MetricFinding,\n} from \"@arx-hq/contracts\";\nimport { isSuppressedAtLine, TS_JS_EXT, walkFiles } from \"../utils/walk.js\";\n\nconst WEBHOOK_FILE_REGEX = /(?:^|\\/)webhooks?(?:\\/|\\.|[-_])/i;\n\nconst SIGNATURE_VERIFICATION_REGEX =\n /\\b(?:constructEvent|verifyWebhook|validateEvent|verifySignature|createHmac|timingSafeEqual|Webhook)\\b|stripe-signature|webhook-signature|x-signature|svix-signature|polar-signature/i;\n\nexport function scanWebhookSignature(\n relFile: string,\n content: string,\n): MetricFinding[] {\n if (!WEBHOOK_FILE_REGEX.test(relFile)) {\n return [];\n }\n const lines = content.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n if (isSuppressedAtLine(lines, 1, \"SEC-07\")) {\n return [];\n }\n if (SIGNATURE_VERIFICATION_REGEX.test(content)) {\n return [];\n }\n\n return [\n {\n id: \"SEC-07\",\n fingerprint: createFindingFingerprint({\n id: \"SEC-07\",\n collector: \"sec-webhook\",\n file: relFile,\n detail: \"missing-webhook-signature\",\n }),\n pillar: \"SEC\",\n tier: \"T2\",\n severity: \"blocker\",\n title: `Unsigned webhook handler in ${relFile}`,\n plainSummary: `Webhook endpoint ${relFile} does not verify cryptographic signatures, allowing forged payment or billing events.`,\n evidence: { file: relFile, line: 1 },\n autoFixable: false,\n repairHint: `Verify the raw request body signature (e.g. Stripe constructEvent, Polar validateEvent, or HMAC + timingSafeEqual) before processing events in ${relFile}.`,\n collector: \"sec-webhook\",\n },\n ];\n}\n\nexport function createSecWebhookCollector(): CollectorPlugin {\n return {\n name: \"sec-webhook\",\n pillar: \"SEC\",\n tier: \"T2\",\n supportedStacks: [\"ts-node\", \"nextjs\", \"backend-api\", \"vite\"],\n async detect(ctx) {\n const files = await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: TS_JS_EXT,\n });\n return files.some((f) => WEBHOOK_FILE_REGEX.test(f));\n },\n async run(ctx) {\n const files = (\n await walkFiles({\n rootDir: ctx.rootDir,\n ignorePaths: ctx.config.ignorePaths,\n extensions: TS_JS_EXT,\n })\n ).filter(\n (f) =>\n WEBHOOK_FILE_REGEX.test(f) &&\n !f.includes(\"/test/\") &&\n !f.includes(\"/tests/\") &&\n !/\\.test\\.[a-z]+$/.test(f),\n );\n\n const findings: MetricFinding[] = [];\n for (const relFile of files) {\n const content = await readFile(\n path.resolve(ctx.rootDir, relFile),\n \"utf8\",\n );\n findings.push(...scanWebhookSignature(relFile, content));\n }\n return findings;\n },\n };\n}\n","import path from \"node:path\";\nimport {\n ARX_PATHS,\n type CollectorPlugin,\n createFindingFingerprint,\n type MetricFinding,\n type ScorecardSnapshot,\n ScorecardSnapshotSchema,\n} from \"@arx-hq/contracts\";\nimport { readTextIfExists } from \"../utils/walk.js\";\n\nexport interface TelemetrySummary {\n readonly runs: number;\n readonly latestPri: number;\n readonly priDelta: number;\n readonly regressionRatePct: number;\n}\n\nexport function analyzeScorecardTrend(\n history: readonly ScorecardSnapshot[],\n): TelemetrySummary | null {\n if (history.length === 0) {\n return null;\n }\n const latest = history[history.length - 1];\n const previous =\n history.length >= 2 ? history[history.length - 2] : undefined;\n if (!latest) {\n return null;\n }\n\n let transitions = 0;\n let regressions = 0;\n for (let i = 1; i < history.length; i += 1) {\n const prev = history[i - 1];\n const curr = history[i];\n if (!prev || !curr) {\n continue;\n }\n transitions += 1;\n if (\n (prev.status === \"green\" && curr.status !== \"green\") ||\n curr.overallScore < prev.overallScore - 2\n ) {\n regressions += 1;\n }\n }\n\n return {\n runs: history.length,\n latestPri: latest.overallScore,\n priDelta:\n previous !== undefined\n ? Math.round((latest.overallScore - previous.overallScore) * 100) / 100\n : 0,\n regressionRatePct:\n transitions > 0 ? Math.round((regressions / transitions) * 100) : 0,\n };\n}\n\nfunction parseSnapshotLine(line: string): ScorecardSnapshot | null {\n try {\n return ScorecardSnapshotSchema.parse(JSON.parse(line));\n } catch (error) {\n return error instanceof Error ? null : null;\n }\n}\n\nexport function createTelemetryTrendCollector(): CollectorPlugin {\n return {\n name: \"telemetry-trends\",\n pillar: \"TELEMETRY\",\n tier: \"T2\",\n supportedStacks: [\"*\"],\n async detect(ctx) {\n const raw = await readTextIfExists(\n path.resolve(ctx.rootDir, ARX_PATHS.HISTORY),\n );\n return raw !== null && raw.trim().length > 0;\n },\n async run(ctx) {\n const raw = await readTextIfExists(\n path.resolve(ctx.rootDir, ARX_PATHS.HISTORY),\n );\n if (!raw) {\n return [];\n }\n\n const history: ScorecardSnapshot[] = [];\n for (const line of raw.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (!trimmed) {\n continue;\n }\n const parsed = parseSnapshotLine(trimmed);\n if (parsed !== null) {\n history.push(parsed);\n }\n }\n\n const summary = analyzeScorecardTrend(history);\n if (!summary) {\n return [];\n }\n\n const deltaSign = summary.priDelta >= 0 ? \"+\" : \"\";\n const findings: MetricFinding[] = [\n {\n id: \"TEL-01\",\n fingerprint: createFindingFingerprint({\n id: \"TEL-01\",\n collector: \"telemetry-trends\",\n detail: `runs:${summary.runs}:pri:${summary.latestPri}`,\n }),\n pillar: \"TELEMETRY\",\n tier: \"T2\",\n severity: \"info\",\n title: `PRI trend: ${summary.latestPri}/100 (${deltaSign}${summary.priDelta}) across ${summary.runs} run(s)`,\n plainSummary: `Tracked ${summary.runs} verification run(s); latest PRI is ${summary.latestPri}/100 (${deltaSign}${summary.priDelta} vs previous).`,\n evidence: { file: ARX_PATHS.HISTORY },\n autoFixable: false,\n repairHint:\n \"Informational trend metric; review recurring drops early.\",\n collector: \"telemetry-trends\",\n },\n ];\n\n if (summary.runs >= 2) {\n findings.push({\n id: \"TEL-02\",\n fingerprint: createFindingFingerprint({\n id: \"TEL-02\",\n collector: \"telemetry-trends\",\n detail: `reg:${summary.regressionRatePct}`,\n }),\n pillar: \"TELEMETRY\",\n tier: \"T2\",\n severity: \"info\",\n title: `Regression rate: ${summary.regressionRatePct}%`,\n plainSummary: `${summary.regressionRatePct}% of recorded transitions lowered quality or broke a previously green gate.`,\n evidence: { file: ARX_PATHS.HISTORY },\n autoFixable: false,\n repairHint: \"Add regression tests for modules that break repeatedly.\",\n collector: \"telemetry-trends\",\n });\n }\n\n return findings;\n },\n };\n}\n"],"mappings":";AAAA,SAAS,0BAAgD;;;ACAzD,OAAOA,WAAU;AACjB;AAAA,EAEE;AAAA,OAEK;;;ACJP,SAAS,SAAS,gBAAgB;AAClC,OAAO,UAAU;AACjB,SAAS,yBAAyB;AAElC,IAAM,sBA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CAAC;AAAA,UACD,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,UAAU;AAAA,UACV,OAAO,cAAc,QAAQ,SAAS,SAAS,SAAS,GAAG,QAAQ,QAAQ,YAAY,QAAQ,IAAI;AAAA,UACnG,cAAc,WAAW,QAAQ,IAAI,uCAAuC,QAAQ,SAAS,SAAS,SAAS,GAAG,QAAQ,QAAQ;AAAA,UAClI,UAAU,EAAE,MAAM,UAAU,QAAQ;AAAA,UACpC,aAAa;AAAA,UACb,YACE;AAAA,UACF,WAAW;AAAA,QACb;AAAA,MACF;AAEA,UAAI,QAAQ,QAAQ,GAAG;AACrB,iBAAS,KAAK;AAAA,UACZ,IAAI;AAAA,UACJ,aAAaA,0BAAyB;AAAA,YACpC,IAAI;AAAA,YACJ,WAAW;AAAA,YACX,QAAQ,OAAO,QAAQ,iBAAiB;AAAA,UAC1C,CAAC;AAAA,UACD,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,UAAU;AAAA,UACV,OAAO,oBAAoB,QAAQ,iBAAiB;AAAA,UACpD,cAAc,GAAG,QAAQ,iBAAiB;AAAA,UAC1C,UAAU,EAAE,MAAM,UAAU,QAAQ;AAAA,UACpC,aAAa;AAAA,UACb,YAAY;AAAA,UACZ,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;AR7IO,IAAM,gCAAgC;AAUtC,SAAS,sBAAyC;AACvD,SAAO;AAAA,IACL,2BAA2B;AAAA,IAC3B,yBAAyB;AAAA,IACzB,0BAA0B;AAAA,IAC1B,yBAAyB;AAAA,IACzB,0BAA0B;AAAA,IAC1B,kCAAkC;AAAA,IAClC,8BAA8B;AAAA,EAChC;AACF;","names":["path","path","readFile","path","createFindingFingerprint","createFindingFingerprint","readFile","path","readFile","path","createFindingFingerprint","createFindingFingerprint","readFile","path","readFile","path","createFindingFingerprint","createFindingFingerprint","readFile","path","readFile","path","createFindingFingerprint","ts","ts","createFindingFingerprint","readFile","path","readFile","path","createFindingFingerprint","createFindingFingerprint","readFile","path","path","createFindingFingerprint","path","createFindingFingerprint"]}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@arx-hq/collectors-pro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.4.0",
4
+ "description": "Wave 3 Vibe-Code AST security (Auth/RLS/Webhook/PII), license/migration ops, and telemetry collectors for Arx",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "engines": {
21
+ "node": ">=20.0.0"
22
+ },
23
+ "dependencies": {
24
+ "@arx-hq/contracts": "0.4.0",
25
+ "typescript": "^5.9.0"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "keywords": [
31
+ "arx",
32
+ "ai-coding",
33
+ "quality-gate",
34
+ "security",
35
+ "mcp",
36
+ "static-analysis"
37
+ ],
38
+ "author": "Arx Contributors",
39
+ "homepage": "https://github.com/mehmetkoyunco/arx#readme",
40
+ "bugs": {
41
+ "url": "https://github.com/mehmetkoyunco/arx/issues"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/mehmetkoyunco/arx.git",
46
+ "directory": "packages/collectors-pro"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "typecheck": "tsc --noEmit"
51
+ }
6
52
  }