@quatronic/sdk 0.7.0-rc.8 → 0.7.0-test.1a5da40
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/dist/auth/index.js +1 -1
- package/dist/{chunk-2AYDFLKR.js → chunk-F3NHTHFO.js} +6 -104
- package/dist/chunk-F3NHTHFO.js.map +1 -0
- package/dist/{chunk-5MNPBJYS.js → chunk-G7VPNC6M.js} +5 -11
- package/dist/{chunk-5MNPBJYS.js.map → chunk-G7VPNC6M.js.map} +1 -1
- package/dist/{chunk-ZZTO5Z3N.js → chunk-HQT57ITV.js} +2 -2
- package/dist/{chunk-EK6TGWWT.js → chunk-MET4SIMB.js} +2 -8
- package/dist/chunk-MET4SIMB.js.map +1 -0
- package/dist/chunk-P7HNHLW7.js +65 -0
- package/dist/chunk-P7HNHLW7.js.map +1 -0
- package/dist/chunk-QMOZDE3U.js +158 -0
- package/dist/chunk-QMOZDE3U.js.map +1 -0
- package/dist/{chunk-ROHIN74F.js → chunk-TEBDKNUB.js} +2 -2
- package/dist/chunk-TOBGX4CZ.js +109 -0
- package/dist/chunk-TOBGX4CZ.js.map +1 -0
- package/dist/chunk-WU7N4PET.js +20 -0
- package/dist/chunk-WU7N4PET.js.map +1 -0
- package/dist/cli/legacy/qdc-sourcemaps.js +16 -6
- package/dist/cli/skills-postinstall.js +133 -3
- package/dist/cli/skills.js +133 -3
- package/dist/cli/sourcemaps.js +16 -6
- package/dist/eslint/index.js +2 -22
- package/dist/eslint/index.js.map +1 -1
- package/dist/integrations/index.d.ts +3 -75
- package/dist/integrations/index.js +6 -4
- package/dist/mail/index.d.ts +9 -0
- package/dist/mail/index.js +26 -0
- package/dist/mail/index.js.map +1 -0
- package/dist/next/auth/index.d.ts +12 -0
- package/dist/next/auth/index.js +15 -156
- package/dist/next/auth/index.js.map +1 -1
- package/dist/next/better-auth/index.js +1 -1
- package/dist/next/boot/index.d.ts +33 -0
- package/dist/next/boot/index.js +21 -0
- package/dist/next/boot/index.js.map +1 -0
- package/dist/next/connections/index.js +3 -3
- package/dist/next/db/index.d.ts +18 -1
- package/dist/next/db/index.js +25 -0
- package/dist/next/db/index.js.map +1 -1
- package/dist/next/global-error/index.d.ts +9 -0
- package/dist/next/global-error/index.js +17 -0
- package/dist/next/global-error/index.js.map +1 -0
- package/dist/next/integrations/index.d.ts +2 -1
- package/dist/next/integrations/index.js +6 -4
- package/dist/next/platform/index.d.ts +19 -0
- package/dist/next/platform/index.js +44 -0
- package/dist/next/platform/index.js.map +1 -0
- package/dist/next/security/index.d.ts +23 -1
- package/dist/next/security/index.js +41 -58
- package/dist/next/security/index.js.map +1 -1
- package/dist/next/sentry/client.d.ts +0 -1
- package/dist/next/sentry/client.js +2 -2
- package/dist/next/sentry/register.js +6 -14
- package/dist/next/sentry/register.js.map +1 -1
- package/dist/next/users/index.js +7 -4
- package/dist/next/users/index.js.map +1 -1
- package/dist/node/boot/index.d.ts +9 -0
- package/dist/node/boot/index.js +13 -0
- package/dist/node/boot/index.js.map +1 -0
- package/dist/node/connections/index.js +3 -3
- package/dist/node/identity/index.js +2 -2
- package/dist/node/integrations/index.d.ts +2 -1
- package/dist/node/integrations/index.js +6 -4
- package/dist/node/sentry/register.js +2 -2
- package/dist/node-Z7ERWJDZ.js +46 -0
- package/dist/node-Z7ERWJDZ.js.map +1 -0
- package/dist/types-CAwj03sM.d.ts +75 -0
- package/migrations/bootstrap-qore-env/codemod.mjs +77 -0
- package/migrations/bootstrap-qore-env/instructions.md +28 -0
- package/migrations/bootstrap-qore-env/meta.json +7 -0
- package/migrations/global-error/codemod.mjs +28 -0
- package/migrations/global-error/instructions.md +26 -0
- package/migrations/global-error/meta.json +7 -0
- package/migrations/local-db-port/codemod.mjs +61 -0
- package/migrations/local-db-port/instructions.md +35 -0
- package/migrations/local-db-port/meta.json +7 -0
- package/migrations/mail-reexport/codemod.mjs +64 -0
- package/migrations/mail-reexport/instructions.md +27 -0
- package/migrations/mail-reexport/meta.json +7 -0
- package/migrations/platform-routes/codemod.mjs +45 -0
- package/migrations/platform-routes/instructions.md +30 -0
- package/migrations/platform-routes/meta.json +7 -0
- package/migrations/qore-boot/codemod.mjs +261 -0
- package/migrations/qore-boot/instructions.md +74 -0
- package/migrations/qore-boot/meta.json +7 -0
- package/migrations/qore-proxy/codemod.mjs +88 -0
- package/migrations/qore-proxy/instructions.md +56 -0
- package/migrations/qore-proxy/meta.json +7 -0
- package/migrations/run.mjs +322 -0
- package/migrations/sourcemaps-finalize/codemod.mjs +63 -0
- package/migrations/sourcemaps-finalize/instructions.md +56 -0
- package/migrations/sourcemaps-finalize/meta.json +7 -0
- package/package.json +26 -8
- package/skills/qore-enable-auth-method/SKILL.md +4 -3
- package/skills/qore-use-mail-domain/SKILL.next.md +4 -4
- package/workspace-requirements.json +4 -0
- package/dist/chunk-2AYDFLKR.js.map +0 -1
- package/dist/chunk-EK6TGWWT.js.map +0 -1
- package/dist/observability/index.d.ts +0 -10
- package/dist/observability/index.js +0 -7
- package/dist/observability/index.js.map +0 -1
- package/migrations/report-error/codemod.mjs +0 -94
- package/migrations/report-error/instructions.md +0 -46
- package/migrations/report-error/meta.json +0 -6
- /package/dist/{chunk-ZZTO5Z3N.js.map → chunk-HQT57ITV.js.map} +0 -0
- /package/dist/{chunk-ROHIN74F.js.map → chunk-TEBDKNUB.js.map} +0 -0
package/dist/cli/skills.js
CHANGED
|
@@ -171,6 +171,103 @@ off the SDK's lint rules that check the same things.
|
|
|
171
171
|
The \`qore-\` prefix is reserved for managed skills. Sync never touches a skill
|
|
172
172
|
it does not ship, so your own skills are safe under any other name.
|
|
173
173
|
`;
|
|
174
|
+
var APP_README_PATH = "README.md";
|
|
175
|
+
function isLegacyAppReadme(text) {
|
|
176
|
+
const flat = text.replace(/\s+/g, " ");
|
|
177
|
+
return flat.includes("frozen at generation time") && flat.includes("The `quatronic-` prefix is reserved");
|
|
178
|
+
}
|
|
179
|
+
var APP_README_HEAD = `# Claude Code setup for this app
|
|
180
|
+
|
|
181
|
+
This app ships with a Qore Claude Code setup, committed into this repo. The
|
|
182
|
+
\`qore-*\` skills are managed by the SDK; everything else here is yours.
|
|
183
|
+
`;
|
|
184
|
+
var APP_README_CONVENTIONS = `## Conventions
|
|
185
|
+
|
|
186
|
+
- The \`qore-*\` skills are managed by \`@quatronic/sdk\` and stay current with it:
|
|
187
|
+
every SDK upgrade PR re-syncs them. How to turn one off, extend it with your
|
|
188
|
+
own conventions, replace it or keep your own copy is in
|
|
189
|
+
\`qore/README.md\`; editing a managed skill in place does not stick.
|
|
190
|
+
- The \`qore-\` prefix is reserved for managed skills. Name your own skills
|
|
191
|
+
without it (e.g. \`.claude/skills/export-report/SKILL.md\`); sync never touches
|
|
192
|
+
them.
|
|
193
|
+
- \`settings.json\` is yours: it was generated once and nothing re-syncs it.
|
|
194
|
+
`;
|
|
195
|
+
function appReadme(runtime) {
|
|
196
|
+
if (runtime === "next") {
|
|
197
|
+
return `${APP_README_HEAD}
|
|
198
|
+
> New here? Run \`/qore-recommended-tools\` for optional, public skills and
|
|
199
|
+
> plugins (like \`superpowers\` and \`frontend-design\`) that pair well with this app.
|
|
200
|
+
|
|
201
|
+
## What's here
|
|
202
|
+
|
|
203
|
+
- \`settings.json\` \u2014 a safe permission floor: secrets (\`.env\`, \`.env.local\`) can't be read or
|
|
204
|
+
written (\`.env.example\` stays readable), destructive git is blocked, and \`git push\` plus edits to the auth/SDK
|
|
205
|
+
boundary files ask for confirmation.
|
|
206
|
+
- \`skills/qore-*\` \u2014 the managed skills, listed with when to reach for each in
|
|
207
|
+
\`qore/skills.md\` (imported into \`CLAUDE.md\`). Highlights:
|
|
208
|
+
\`/qore-ship-checklist\` (the quality gate to run before every PR),
|
|
209
|
+
\`/qore-author-skill\` to write your own, and \`/qore-recommended-tools\` for
|
|
210
|
+
optional public skills/plugins.
|
|
211
|
+
- \`qore/\` \u2014 \`README.md\` (what you can and can't do with managed skills),
|
|
212
|
+
\`skills.md\` (the index) and \`manifest.json\` (what sync manages).
|
|
213
|
+
- \`../.github/workflows/ci.yml\` \u2014 the PR gate. It calls Quatronic's shared
|
|
214
|
+
pipeline, which runs lint, format-check, typecheck, unit tests,
|
|
215
|
+
integration tests and build on every pull request and on every push to
|
|
216
|
+
\`main\`. Each of those is one of *your* \`package.json\` scripts, so change
|
|
217
|
+
what a check does by changing the script. Add your own jobs to the
|
|
218
|
+
\`verify\` job's \`needs:\` list; leave the shared call alone, as edits to it
|
|
219
|
+
are replaced when the pipeline is upgraded.
|
|
220
|
+
|
|
221
|
+
${APP_README_CONVENTIONS}`;
|
|
222
|
+
}
|
|
223
|
+
return `${APP_README_HEAD}
|
|
224
|
+
## What's here
|
|
225
|
+
|
|
226
|
+
- \`settings.json\` \u2014 a safe permission floor: secrets (\`.env\`, \`.env.local\`) can't be read or
|
|
227
|
+
written, destructive git is blocked, and \`git push\` asks for confirmation.
|
|
228
|
+
- \`skills/qore-*\` \u2014 the managed skills, listed with when to reach for each in
|
|
229
|
+
\`qore/skills.md\` (imported into \`CLAUDE.md\`).
|
|
230
|
+
- \`qore/\` \u2014 \`README.md\` (what you can and can't do with managed skills),
|
|
231
|
+
\`skills.md\` (the index) and \`manifest.json\` (what sync manages).
|
|
232
|
+
- \`../.github/workflows/ci.yml\` \u2014 the PR gate. It calls Quatronic's shared
|
|
233
|
+
pipeline, which runs typecheck, unit tests and build on every pull request
|
|
234
|
+
and on every push to \`main\`. Each of those is one of *your*
|
|
235
|
+
\`package.json\` scripts, so change what a check does by changing the
|
|
236
|
+
script; adding a \`lint\` script is not enough on its own, since the call
|
|
237
|
+
also has to ask for that check. Add your own jobs to the \`verify\` job's
|
|
238
|
+
\`needs:\` list; leave the shared call alone, as edits to it are replaced
|
|
239
|
+
when the pipeline is upgraded.
|
|
240
|
+
|
|
241
|
+
${APP_README_CONVENTIONS}`;
|
|
242
|
+
}
|
|
243
|
+
var TABLE_ROW = /^\s*\|(.*)\|\s*$/;
|
|
244
|
+
var TABLE_RULE = /^\s*\|[\s:|-]+\|\s*$/;
|
|
245
|
+
var firstCell = (line) => TABLE_ROW.exec(line)?.[1].split("|")[0].trim();
|
|
246
|
+
function replaceSkillsTable(md, names) {
|
|
247
|
+
const eol = md.includes("\r\n") ? "\r\n" : "\n";
|
|
248
|
+
const lines = md.split(/\r?\n/);
|
|
249
|
+
for (let i = 0; i + 2 < lines.length; i++) {
|
|
250
|
+
if (!/^skill$/i.test(firstCell(lines[i]) ?? "") || !TABLE_RULE.test(lines[i + 1])) continue;
|
|
251
|
+
let end = i + 2;
|
|
252
|
+
while (end < lines.length && firstCell(lines[end]) !== void 0) end++;
|
|
253
|
+
const rows = lines.slice(i + 2, end);
|
|
254
|
+
const managed = rows.length > 0 && rows.every((r) => {
|
|
255
|
+
const name = /^`\/?([a-z0-9-]+)`$/.exec(firstCell(r))?.[1];
|
|
256
|
+
return name !== void 0 && names.has(name);
|
|
257
|
+
});
|
|
258
|
+
if (!managed) continue;
|
|
259
|
+
const out = [];
|
|
260
|
+
lines.forEach((line, j) => {
|
|
261
|
+
if (j === i) out.push(CLAUDE_MD_IMPORT);
|
|
262
|
+
else if (j > i && j < end) return;
|
|
263
|
+
else if (line.trim() === CLAUDE_MD_IMPORT) {
|
|
264
|
+
if (out.at(-1)?.trim() === "") out.pop();
|
|
265
|
+
} else out.push(line);
|
|
266
|
+
});
|
|
267
|
+
return out.join(eol);
|
|
268
|
+
}
|
|
269
|
+
return void 0;
|
|
270
|
+
}
|
|
174
271
|
function buildTree(catalog, sources, f) {
|
|
175
272
|
const skills = renderSkills(catalog, sources, f);
|
|
176
273
|
for (const entry of catalog.skills) {
|
|
@@ -245,6 +342,7 @@ function planSync(s) {
|
|
|
245
342
|
let claudeMd = s.claudeMd;
|
|
246
343
|
const claudeMdRenamed = [];
|
|
247
344
|
let claudeMdImportAdded = false;
|
|
345
|
+
let claudeMdTableReplaced = false;
|
|
248
346
|
if (claudeMd !== void 0) {
|
|
249
347
|
for (const entry of s.catalog.skills) {
|
|
250
348
|
for (const legacy of entry.legacyNames ?? []) {
|
|
@@ -254,6 +352,11 @@ function planSync(s) {
|
|
|
254
352
|
claudeMdRenamed.push([legacy, entry.name]);
|
|
255
353
|
}
|
|
256
354
|
}
|
|
355
|
+
const withoutTable = replaceSkillsTable(claudeMd, new Set(s.catalog.skills.map((e) => e.name)));
|
|
356
|
+
if (withoutTable !== void 0) {
|
|
357
|
+
claudeMd = withoutTable;
|
|
358
|
+
claudeMdTableReplaced = true;
|
|
359
|
+
}
|
|
257
360
|
if (!claudeMd.split(/\r?\n/).some((l) => l.trim() === CLAUDE_MD_IMPORT)) {
|
|
258
361
|
claudeMd = `${claudeMd.replace(/\s*$/, "")}
|
|
259
362
|
|
|
@@ -262,6 +365,9 @@ ${CLAUDE_MD_IMPORT}
|
|
|
262
365
|
claudeMdImportAdded = true;
|
|
263
366
|
}
|
|
264
367
|
}
|
|
368
|
+
const currentReadme = s.read(APP_README_PATH);
|
|
369
|
+
const appReadmeReplaced = currentReadme !== void 0 && isLegacyAppReadme(currentReadme);
|
|
370
|
+
if (appReadmeReplaced) writes.set(APP_README_PATH, appReadme(s.features.runtime));
|
|
265
371
|
const manifest = {
|
|
266
372
|
schemaVersion: 1,
|
|
267
373
|
sdkVersion: s.sdkVersion,
|
|
@@ -270,6 +376,10 @@ ${CLAUDE_MD_IMPORT}
|
|
|
270
376
|
detached: [...detached].sort(),
|
|
271
377
|
files: Object.fromEntries([...tree].map(([rel, c]) => [rel, hashContent(c)]))
|
|
272
378
|
};
|
|
379
|
+
const skillsIn = (rels) => new Set([...rels].map(skillOf).filter((n) => n !== void 0 && !detached.has(n)));
|
|
380
|
+
const before = skillsIn(Object.keys(known));
|
|
381
|
+
const after = skillsIn(tree.keys());
|
|
382
|
+
const touched = skillsIn([...writes.keys(), ...deletes]);
|
|
273
383
|
const manifestText = renderManifest(manifest);
|
|
274
384
|
if (s.read(MANIFEST_PATH) === void 0 || normalise(s.read(MANIFEST_PATH)) !== manifestText) {
|
|
275
385
|
writes.set(MANIFEST_PATH, manifestText);
|
|
@@ -280,10 +390,15 @@ ${CLAUDE_MD_IMPORT}
|
|
|
280
390
|
edited: edited.sort(),
|
|
281
391
|
adopted: adopted.sort(),
|
|
282
392
|
legacyRemoved: legacyRemoved.sort(),
|
|
393
|
+
skillsAdded: [...after].filter((n) => !before.has(n)).sort(),
|
|
394
|
+
skillsUpdated: [...after].filter((n) => before.has(n) && touched.has(n)).sort(),
|
|
395
|
+
skillsRemoved: [...before].filter((n) => !after.has(n)).sort(),
|
|
283
396
|
manifest,
|
|
284
397
|
claudeMd: claudeMd === s.claudeMd ? void 0 : claudeMd,
|
|
285
398
|
claudeMdRenamed: claudeMdRenamed.sort(([a], [b]) => a.localeCompare(b)),
|
|
286
|
-
claudeMdImportAdded
|
|
399
|
+
claudeMdImportAdded,
|
|
400
|
+
claudeMdTableReplaced,
|
|
401
|
+
appReadmeReplaced
|
|
287
402
|
};
|
|
288
403
|
}
|
|
289
404
|
function planChanges(p) {
|
|
@@ -294,12 +409,18 @@ function renderReport(p, opts) {
|
|
|
294
409
|
const lines = [
|
|
295
410
|
"### Qore skills",
|
|
296
411
|
"",
|
|
297
|
-
`Synced the managed skills for \`@quatronic/sdk@${p.manifest.sdkVersion}\` (runtime \`${f.runtime}\`, auth \`${f.auth}\`, database \`${f.db ? "yes" : "no"}\`${opts.inferred ? ", inferred from the app \u2014 pin with `qore-skills sync --features`" : ", pinned in the manifest"}).`
|
|
412
|
+
`${opts.check ? "Out of date: `qore-skills sync` would update" : "Synced"} the managed skills for \`@quatronic/sdk@${p.manifest.sdkVersion}\` (runtime \`${f.runtime}\`, auth \`${f.auth}\`, database \`${f.db ? "yes" : "no"}\`${opts.inferred ? ", inferred from the app \u2014 pin with `qore-skills sync --features`" : ", pinned in the manifest"}).`
|
|
298
413
|
];
|
|
299
414
|
const managedWrites = [...p.writes.keys()].filter((r) => r !== MANIFEST_PATH);
|
|
300
415
|
if (!managedWrites.length && !p.deletes.length && p.claudeMd === void 0) {
|
|
301
416
|
lines.push("", "No skill content changed.");
|
|
302
417
|
}
|
|
418
|
+
const skills = (title, names) => {
|
|
419
|
+
if (names.length) lines.push("", `**${title}:** ${names.map((n) => `\`${n}\``).join(", ")}`);
|
|
420
|
+
};
|
|
421
|
+
skills("Skills added", p.skillsAdded);
|
|
422
|
+
skills("Skills updated", p.skillsUpdated);
|
|
423
|
+
skills("Skills removed", p.skillsRemoved);
|
|
303
424
|
const section = (title, items, note) => {
|
|
304
425
|
if (!items.length) return;
|
|
305
426
|
lines.push("", `**${title}** ${note}`, "", ...items.map((i) => `- \`.claude/${i}\``));
|
|
@@ -315,9 +436,18 @@ function renderReport(p, opts) {
|
|
|
315
436
|
p.legacyRemoved,
|
|
316
437
|
"(replaced by their `qore-*` names; a local edit to one is in this change's diff):"
|
|
317
438
|
);
|
|
439
|
+
if (p.appReadmeReplaced) {
|
|
440
|
+
lines.push(
|
|
441
|
+
"",
|
|
442
|
+
"**`.claude/README.md`** replaced: the generator's text said this setup is frozen and yours to edit, which the managed skills no longer are. A change of your own to it is in this change's diff."
|
|
443
|
+
);
|
|
444
|
+
}
|
|
318
445
|
if (p.claudeMd !== void 0) {
|
|
319
446
|
lines.push("", "**`CLAUDE.md`:**", "");
|
|
320
447
|
for (const [from, to] of p.claudeMdRenamed) lines.push(`- Renamed \`${from}\` to \`${to}\`.`);
|
|
448
|
+
if (p.claudeMdTableReplaced) {
|
|
449
|
+
lines.push(`- Replaced the generated skills table with \`${CLAUDE_MD_IMPORT}\`, the index of managed skills.`);
|
|
450
|
+
}
|
|
321
451
|
if (p.claudeMdImportAdded) lines.push(`- Imports \`${CLAUDE_MD_IMPORT}\`, the index of managed skills.`);
|
|
322
452
|
}
|
|
323
453
|
return `${lines.join("\n")}
|
|
@@ -450,7 +580,7 @@ function main(argv = process.argv.slice(2)) {
|
|
|
450
580
|
return 0;
|
|
451
581
|
}
|
|
452
582
|
const { plan: p, inferred } = plan(args.cwd, args.features);
|
|
453
|
-
const report = renderReport(p, { inferred });
|
|
583
|
+
const report = renderReport(p, { inferred, check: args.cmd === "check" });
|
|
454
584
|
if (args.cmd === "check") {
|
|
455
585
|
const changed = planChanges(p);
|
|
456
586
|
if (args.json) {
|
package/dist/cli/sourcemaps.js
CHANGED
|
@@ -15,13 +15,14 @@ var BUNDLE = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
|
15
15
|
var SCRIPT = /\.(js|mjs|cjs)$/;
|
|
16
16
|
var MAPPING_URL = /^\/\/# sourceMappingURL=(\S+)[ \t]*$/gm;
|
|
17
17
|
var STANDALONE_SERVER = "standalone/.next/server/";
|
|
18
|
+
var isCommand = (cmd) => cmd === "upload" || cmd === "finalize";
|
|
18
19
|
function parseArgs(argv) {
|
|
19
20
|
const [cmd, dir, ...rest] = argv;
|
|
20
|
-
if (cmd
|
|
21
|
+
if (!isCommand(cmd) || !dir) return { error: "usage: qore-sourcemaps upload|finalize <dir> [--bundle <name>]" };
|
|
21
22
|
let bundle = "app";
|
|
22
23
|
if (rest[0] === "--bundle") bundle = rest[1] ?? "";
|
|
23
24
|
if (!BUNDLE.test(bundle)) return { error: `invalid bundle name: ${bundle}` };
|
|
24
|
-
return { dir, bundle };
|
|
25
|
+
return { cmd, dir, bundle };
|
|
25
26
|
}
|
|
26
27
|
function nextRoots(has) {
|
|
27
28
|
if (!has("BUILD_ID") || !has("server")) return null;
|
|
@@ -114,11 +115,11 @@ async function runCommand(cmd, args) {
|
|
|
114
115
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
|
-
function walkDir(dir, prefix = "") {
|
|
118
|
+
function walkDir(dir, prefix = "", modules = false) {
|
|
118
119
|
const out = [];
|
|
119
120
|
for (const d of readdirSync(join(dir, prefix), { withFileTypes: true })) {
|
|
120
121
|
const rel = prefix ? `${prefix}/${d.name}` : d.name;
|
|
121
|
-
if (d.isDirectory() && d.name !== "node_modules") out.push(...walkDir(dir, rel));
|
|
122
|
+
if (d.isDirectory() && (modules || d.name !== "node_modules")) out.push(...walkDir(dir, rel, modules));
|
|
122
123
|
else if (d.isFile()) out.push(rel);
|
|
123
124
|
}
|
|
124
125
|
return out;
|
|
@@ -126,6 +127,7 @@ function walkDir(dir, prefix = "") {
|
|
|
126
127
|
var defaultIo = () => ({
|
|
127
128
|
env: process.env,
|
|
128
129
|
walk: (dir) => walkDir(dir),
|
|
130
|
+
walkAll: (dir) => walkDir(dir, "", true),
|
|
129
131
|
exists: existsSync,
|
|
130
132
|
readText: (p) => readFileSync(p, "utf8"),
|
|
131
133
|
writeText: (p, t) => writeFileSync(p, t),
|
|
@@ -146,11 +148,18 @@ function tryRemove(io, path) {
|
|
|
146
148
|
} catch {
|
|
147
149
|
}
|
|
148
150
|
}
|
|
151
|
+
function removeAllMaps(io, dir) {
|
|
152
|
+
try {
|
|
153
|
+
for (const p of io.walkAll(dir)) if (p.endsWith(".map")) tryRemove(io, join(dir, p));
|
|
154
|
+
} catch (err) {
|
|
155
|
+
console.warn(`qore-sourcemaps: cleanup skipped: ${describe(err, io.env.QORE_BUILD_UPLOAD_TOKEN)}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
149
158
|
async function main(argv = process.argv.slice(2), io = defaultIo()) {
|
|
150
159
|
const args = parseArgs(argv);
|
|
151
160
|
if ("error" in args) {
|
|
152
161
|
console.warn(`qore-sourcemaps: ${args.error}`);
|
|
153
|
-
const dir2 = argv[0]
|
|
162
|
+
const dir2 = isCommand(argv[0]) ? argv[1] : void 0;
|
|
154
163
|
if (dir2 && !dir2.startsWith("-")) {
|
|
155
164
|
try {
|
|
156
165
|
for (const m of listMaps(io.walk(dir2))) tryRemove(io, join(dir2, m));
|
|
@@ -160,7 +169,7 @@ async function main(argv = process.argv.slice(2), io = defaultIo()) {
|
|
|
160
169
|
}
|
|
161
170
|
return;
|
|
162
171
|
}
|
|
163
|
-
const { dir, bundle } = args;
|
|
172
|
+
const { cmd, dir, bundle } = args;
|
|
164
173
|
const at = (rel) => join(dir, rel);
|
|
165
174
|
let maps = [];
|
|
166
175
|
const scratch = [];
|
|
@@ -214,6 +223,7 @@ async function main(argv = process.argv.slice(2), io = defaultIo()) {
|
|
|
214
223
|
} finally {
|
|
215
224
|
for (const m of maps) tryRemove(io, at(m));
|
|
216
225
|
for (const s of scratch) tryRemove(io, s);
|
|
226
|
+
if (cmd === "finalize") removeAllMaps(io, dir);
|
|
217
227
|
}
|
|
218
228
|
}
|
|
219
229
|
function isMainModule() {
|
package/dist/eslint/index.js
CHANGED
|
@@ -445,24 +445,6 @@ var noSentryInit = {
|
|
|
445
445
|
});
|
|
446
446
|
}
|
|
447
447
|
};
|
|
448
|
-
var useReportError = {
|
|
449
|
-
meta: meta("QDC-OBS-004 - report caught errors with reportError", "suggestion"),
|
|
450
|
-
create(context) {
|
|
451
|
-
const report = reporter(
|
|
452
|
-
context,
|
|
453
|
-
"QDC-OBS-004 - use reportError(err, ctx) from @quatronic/sdk/observability instead of Sentry.captureException; see migration report-error."
|
|
454
|
-
);
|
|
455
|
-
const sentry = trackSentry();
|
|
456
|
-
return listener({
|
|
457
|
-
ImportDeclaration: (node) => sentry.onImport(node),
|
|
458
|
-
CallExpression: (node) => {
|
|
459
|
-
const c = node.callee;
|
|
460
|
-
const name = c?.type === "Identifier" ? sentry.named.get(c.name ?? "") : c?.type === "MemberExpression" && c.object?.type === "Identifier" && sentry.namespaces.has(c.object.name ?? "") ? c.property?.name : void 0;
|
|
461
|
-
if (name === "captureException") report(node);
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
448
|
var observabilityRules = {
|
|
467
449
|
"no-sentry-init": noSentryInit,
|
|
468
450
|
"sentry-attribute-namespace": attributeKeyRule(
|
|
@@ -474,14 +456,12 @@ var observabilityRules = {
|
|
|
474
456
|
"QDC-OBS-003",
|
|
475
457
|
"no personal data in telemetry keys",
|
|
476
458
|
(key) => PII.test(key) ? `'${key}' looks like personal data. Send an id instead; see the qore-observability skill.` : void 0
|
|
477
|
-
)
|
|
478
|
-
"use-report-error": useReportError
|
|
459
|
+
)
|
|
479
460
|
};
|
|
480
461
|
var OBSERVABILITY_RULE_IDS = {
|
|
481
462
|
"no-sentry-init": "QDC-OBS-001",
|
|
482
463
|
"sentry-attribute-namespace": "QDC-OBS-002",
|
|
483
|
-
"no-pii-attributes": "QDC-OBS-003"
|
|
484
|
-
"use-report-error": "QDC-OBS-004"
|
|
464
|
+
"no-pii-attributes": "QDC-OBS-003"
|
|
485
465
|
};
|
|
486
466
|
|
|
487
467
|
// src/eslint/index.ts
|
package/dist/eslint/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/eslint/ast.ts","../../src/eslint/rules.ts","../../src/eslint/observability.ts","../../src/eslint/index.ts"],"sourcesContent":["// A deliberately narrow view of the AST, for rules that are deliberately\n// syntactic.\n//\n// ESLint's own `Rule.Node` is the ESTree union. It does not describe JSX at\n// all, and it forces a narrowing cascade for every property access — in rules\n// whose whole job is to read three or four fields off a node and report it.\n// So these rules declare exactly the fields they read and cast once, at the\n// visitor boundary, rather than per line.\n//\n// Anything that has to follow a value across functions or files is a Semgrep\n// rule instead; that pack ships in `semgrep/` alongside this plugin.\nexport interface AstNode {\n type: string\n /** `Identifier.name` and `MemberExpression.property.name`. Never a JSX name. */\n name?: string\n value?: unknown\n callee?: AstNode\n object?: AstNode\n property?: AstNode\n source?: AstNode\n arguments?: (AstNode | undefined)[]\n expressions?: (AstNode | undefined)[]\n /** `TemplateLiteral.quasis`: the fixed text between the `${}` holes. */\n quasis?: { value?: { cooked?: string | null; raw?: string } }[]\n /** `BinaryExpression.left`; the rule that reads it only follows the left edge. */\n left?: AstNode\n operator?: string\n /** `ImportDeclaration.specifiers`. */\n specifiers?: AstNode[]\n /** `ImportSpecifier.imported` / `.local`. */\n imported?: AstNode\n local?: AstNode\n /** `ObjectExpression.properties`; a `Property` has `key` and `computed`. */\n properties?: AstNode[]\n key?: AstNode\n computed?: boolean\n /** Set by ESLint on every node it visits. */\n parent?: AstNode\n}\n\n/** Calls whose result is a URL this app decided on, not one a caller supplied. */\nexport const VETTED_CALLS = [\"safeRedirect\", \"safeFetch\", \"vetTarget\", \"clone\"]\n\n/** POSIX form of the file being linted, so the checks read the same on Windows. */\nexport function pathOf(filename: string): string {\n return filename.replaceAll(\"\\\\\", \"/\")\n}\n\n/** Is the linted file at, or inside, one of these project paths? */\nexport function isUnder(filename: string, paths: readonly string[]): boolean {\n const file = pathOf(filename)\n return paths.some((path) => file.endsWith(`/${path}`) || file.includes(`/${path}/`))\n}\n\n/** The called name, whether the callee is `f()` or `x.f()`. */\nexport function calleeName(node: AstNode): string {\n const callee = node.callee\n if (!callee) return \"\"\n if (callee.type === \"Identifier\") return callee.name ?? \"\"\n if (callee.type === \"MemberExpression\" && callee.property?.type === \"Identifier\") {\n return callee.property.name ?? \"\"\n }\n return \"\"\n}\n\n/**\n * A target this app wrote down, rather than one that arrived with the request.\n *\n * `allowIdentifier` is the whole difference between the two advisory rules:\n * judging what a bare variable holds takes dataflow, which is what the Semgrep\n * taint rules do. `qdc/safe-redirect` lets a variable through because\n * `NextResponse.redirect(url)` after `req.nextUrl.clone()` is the canonical\n * Next redirect and appears in every generated app; `qdc/safe-fetch` does not.\n */\nexport function isFixedTarget(node: AstNode | undefined, allowIdentifier: boolean): boolean {\n if (!node) return false\n if (node.type === \"Literal\") return typeof node.value === \"string\"\n if (node.type === \"TemplateLiteral\") return (node.expressions?.length ?? 0) === 0\n if (node.type === \"Identifier\") return allowIdentifier\n if (node.type === \"NewExpression\") {\n // `new URL(\"/login\", req.url)` fixes the path; the base only ever\n // contributes this app's own origin.\n return node.callee?.name === \"URL\" && isFixedTarget(node.arguments?.[0], allowIdentifier)\n }\n if (node.type === \"CallExpression\") return VETTED_CALLS.includes(calleeName(node))\n return false\n}\n","import type { Rule } from \"eslint\"\n\nimport { isPlatformManagedHost } from \"../integrations-core/platform-hosts\"\nimport { type AstNode, calleeName, isFixedTarget, isUnder } from \"./ast\"\n\n/**\n * The fourteen QDC security lint rules.\n *\n * One rule per id, rather than fourteen entries in `no-restricted-syntax`, for\n * two reasons that only show up after the fact:\n *\n * - **Severity is per rule.** `no-restricted-syntax` carries one severity for\n * its whole array, and three of these are advisory on purpose — they fire on\n * shapes that are usually fine, and the Semgrep pack does the dataflow they\n * can only approximate.\n * - **Suppression is per rule.** `// eslint-disable-next-line\n * no-restricted-syntax` switches off every selector on that line, so\n * silencing \"no inline styles\" would silently also silence the\n * `dangerouslySetInnerHTML` ban sitting next to it.\n *\n * Suppress one by its own name, and say why:\n *\n * // eslint-disable-next-line qdc/no-dangerous-html -- sanitised in renderPost()\n */\n\n/** Modules that talk to the database directly, and where that is allowed. */\nconst DB_DRIVERS = [\"pg\", \"postgres\", \"mysql2\", \"mysql2/promise\"]\nconst DB_LAYER = [\"src/db\", \"src/lib/db.ts\"]\n\n/** Node's filesystem API, and where a generated app is expected to use it. */\nconst FS_MODULES = [\"fs\", \"node:fs\", \"fs/promises\", \"node:fs/promises\"]\n// `src/lib/migrate.ts` is the migration runner: it reads the migration files\n// off disk at boot, which is the sanctioned use, and it is not reachable from\n// a request. The backend recipes put it there rather than under src/db.\nconst FS_CALLERS = [\"src/scripts\", \"src/db\", \"src/lib/migrate.ts\"]\n\n/** Where a fetch goes out with the server's own network position. */\nconst SERVER_PATHS = [\"src/app/api\", \"src/lib/server\", \"src/proxy.ts\"]\n\n/** One cast, at the boundary, instead of one per `context.report` call. */\nexport function reporter(context: Rule.RuleContext, message: string): (node: AstNode) => void {\n return (node: AstNode) => {\n context.report({ node: node as unknown as Rule.Node, message })\n }\n}\n\nexport function listener(visitor: Record<string, (node: AstNode) => void>): Rule.RuleListener {\n return visitor as unknown as Rule.RuleListener\n}\n\nexport function meta(description: string, type: \"problem\" | \"suggestion\"): Rule.RuleModule[\"meta\"] {\n return { type, docs: { description }, schema: [] }\n}\n\n/** A rule that reports every node matching one of `selectors`. */\nfunction ban(id: string, message: string, selectors: string[]): Rule.RuleModule {\n const text = `${id} - ${message}`\n return {\n meta: meta(text, \"problem\"),\n create(context) {\n const report = reporter(context, text)\n return listener(Object.fromEntries(selectors.map((selector) => [selector, report])))\n },\n }\n}\n\n/** A rule that bans importing any of `modules`, except from `allowed` paths. */\nfunction banImports(\n id: string,\n message: string,\n modules: string[],\n allowed: string[],\n): Rule.RuleModule {\n const text = `${id} - ${message}`\n return {\n meta: meta(text, \"problem\"),\n create(context) {\n if (isUnder(context.filename, allowed)) return {}\n const report = reporter(context, text)\n const flag = (node: AstNode) => {\n const source = node.source\n if (source?.type === \"Literal\" && typeof source.value === \"string\") {\n if (modules.includes(source.value)) report(node)\n }\n }\n return listener({ ImportDeclaration: flag, ImportExpression: flag })\n },\n }\n}\n\nconst noStringEval: Rule.RuleModule = {\n meta: meta(\"QDC-XSS-005 - no code compiled from a string\", \"problem\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-XSS-005 - compiling a string into code runs whatever the string turned out to be. Pass a function.\",\n )\n const isStringy = (node: AstNode | undefined) =>\n node?.type === \"TemplateLiteral\" ||\n node?.type === \"BinaryExpression\" ||\n (node?.type === \"Literal\" && typeof node.value === \"string\")\n return listener({\n \"CallExpression[callee.name='eval']\": report,\n \"CallExpression[callee.name='Function']\": report,\n \"NewExpression[callee.name='Function']\": report,\n \"CallExpression[callee.name=/^set(Timeout|Interval)$/]\": (node) => {\n if (isStringy(node.arguments?.[0])) report(node)\n },\n })\n },\n}\n\nconst safeRedirect: Rule.RuleModule = {\n meta: meta(\"QDC-URL-001 - redirect to a target this app decided on\", \"suggestion\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-URL-001 - redirecting to a value that came with the request is an open redirect. Wrap it in safeRedirect from @quatronic/sdk/next/auth.\",\n )\n return listener({\n \"CallExpression[callee.object.name='NextResponse'][callee.property.name='redirect']\": (\n node,\n ) => {\n if (isFixedTarget(node.arguments?.[0], true)) return\n report(node)\n },\n })\n },\n}\n\nconst safeFetch: Rule.RuleModule = {\n meta: meta(\"QDC-NET-001 - server-side fetch of a caller-supplied URL\", \"suggestion\"),\n create(context) {\n if (!isUnder(context.filename, SERVER_PATHS)) return {}\n const report = reporter(\n context,\n \"QDC-NET-001 - a URL the server did not decide on reaches the private network too. Use safeFetch from @quatronic/sdk/node/net, or connection(alias).fetch for a wired module.\",\n )\n return listener({\n \"CallExpression[callee.name='fetch']\": (node) => {\n if (isFixedTarget(node.arguments?.[0], false)) return\n report(node)\n },\n })\n },\n}\n\n/** Outbound HTTP clients a generated app might reach for. */\nconst HTTP_CLIENTS = [\"fetch\", \"axios\", \"got\", \"ky\"]\nconst HTTP_LIBS = [\"axios\", \"got\", \"ky\"]\nconst HTTP_METHODS = /^(get|post|put|patch|delete|head|request)$/\n\n/** A host that is this cluster or this machine, so not an external API. */\nconst LOCAL_HOST_SUFFIXES = [\".local\", \".internal\", \".svc\", \".cluster.local\"]\nconst ENV_KEY = /^[A-Z][A-Z0-9_]*$/\n\nfunction isLocalHost(host: string): boolean {\n const h = host.toLowerCase()\n if (h === \"localhost\" || h === \"::1\" || h === \"0.0.0.0\" || h.startsWith(\"127.\")) return true\n return LOCAL_HOST_SUFFIXES.some((suffix) => h.endsWith(suffix))\n}\n\n/** The host of an `http(s)://` string, or null when it has none or a `${}` hole cuts it off. */\nfunction hostOf(text: string): string | null {\n const m = /^https?:\\/\\/(?:[^@/?#]*@)?(\\[[^\\]]*\\]|[^/?#:]+)/i.exec(text)\n if (!m?.[1]) return null\n return m[1].replace(/^\\[|\\]$/g, \"\")\n}\n\n/** `process.env.X`, `env.X`, `serverEnv().X` — the env key, when `X` looks like one. */\nfunction envKeyOf(node: AstNode | undefined): string | null {\n if (node?.type !== \"MemberExpression\" || node.property?.type !== \"Identifier\") return null\n const key = node.property.name ?? \"\"\n if (!ENV_KEY.test(key)) return null\n const object = node.object\n if (!object) return null\n if (object.type === \"Identifier\") return object.name === \"env\" ? key : null\n if (object.type === \"MemberExpression\") {\n const isProcessEnv =\n object.object?.type === \"Identifier\" &&\n object.object.name === \"process\" &&\n object.property?.name === \"env\"\n return isProcessEnv ? key : null\n }\n if (object.type === \"CallExpression\") {\n const name = calleeName(object)\n return name === \"env\" || name.endsWith(\"Env\") ? key : null\n }\n return null\n}\n\ntype ExternalTarget = { host: string } | { envKey: string } | null\n\n/**\n * Where a call is going, read off its first argument: a host when the code\n * spells the URL out, an env key when the base comes from the environment,\n * null when the shape says nothing (a bare variable, a relative path).\n */\nfunction externalTargetOf(node: AstNode | undefined): ExternalTarget {\n if (!node) return null\n if (node.type === \"Literal\" && typeof node.value === \"string\") {\n const host = hostOf(node.value)\n return host ? { host } : null\n }\n if (node.type === \"TemplateLiteral\") {\n const head = node.quasis?.[0]?.value?.cooked ?? node.quasis?.[0]?.value?.raw ?? \"\"\n const host = hostOf(head)\n if (host) return { host }\n // `${process.env.SAP_BASE_URL}/path` — the base is the first hole.\n if (head === \"\") {\n const key = envKeyOf(node.expressions?.[0])\n if (key) return { envKey: key }\n }\n return null\n }\n if (node.type === \"BinaryExpression\" && node.operator === \"+\") return externalTargetOf(node.left)\n if (node.type === \"MemberExpression\") {\n const key = envKeyOf(node)\n return key ? { envKey: key } : null\n }\n if (node.type === \"NewExpression\" && node.callee?.name === \"URL\") {\n // new URL(path, base): the base decides the host; new URL(absolute) has no base.\n const args = node.arguments ?? []\n return externalTargetOf(args[1]) ?? externalTargetOf(args[0])\n }\n return null\n}\n\nfunction isHttpClientCall(node: AstNode): boolean {\n const callee = node.callee\n if (!callee) return false\n if (callee.type === \"Identifier\") return HTTP_CLIENTS.includes(callee.name ?? \"\")\n if (callee.type === \"MemberExpression\") {\n return (\n callee.object?.type === \"Identifier\" &&\n HTTP_LIBS.includes(callee.object.name ?? \"\") &&\n callee.property?.type === \"Identifier\" &&\n HTTP_METHODS.test(callee.property.name ?? \"\")\n )\n }\n return false\n}\n\n/**\n * An outbound call to a host this app has not declared. Advisory: the rule\n * reads one argument, so it sees a spelled-out host or an env-backed base and\n * nothing more. The manifest extractor does the same classification at deploy\n * time and the portal shows the result; this is the editor-time echo of it.\n */\nconst noUndeclaredExternalCall: Rule.RuleModule = {\n meta: meta(\"QDC-NET-002 - outbound call to an external API this app has not declared\", \"suggestion\"),\n create(context) {\n return listener({\n CallExpression: (node) => {\n if (!isHttpClientCall(node)) return\n const target = externalTargetOf(node.arguments?.[0])\n if (!target) return\n let label: string\n if (\"host\" in target) {\n if (isLocalHost(target.host) || isPlatformManagedHost(target.host)) return\n label = target.host\n } else {\n // CONN_* is a wired module connection: the portal already knows the other end.\n if (target.envKey.startsWith(\"CONN_\")) return\n label = `$${target.envKey}`\n }\n context.report({\n node: node as unknown as Rule.Node,\n message: `QDC-NET-002 - ${label} is an external API this app has not declared. Declare it in src/config/integrations.ts and call integration(alias).get/post, so the portal can see and manage it.`,\n })\n },\n })\n },\n}\n\n/** The calls on an integration handle that send a request, and where their path sits. */\nconst INTEGRATION_PATH_ARG: Record<string, number> = { get: 0, post: 0, put: 0, patch: 0, delete: 0, request: 1 }\n/** Reads off a handle that send nothing, so taking them through a variable hides no endpoint. */\nconst INTEGRATION_READS = [\"config\", \"alias\", \"definition\"]\n\nconst isStringLiteral = (node: AstNode | undefined): boolean =>\n node?.type === \"Literal\" && typeof node.value === \"string\"\n\n/**\n * An integration call the portal cannot read. The manifest extractor reads\n * exactly `integration(\"alias\").get(\"/path\")`, alias and path written at the\n * call site, because it reads source, not values. A path passed in through a\n * helper, an alias held in a variable, or a handle stored and called later all\n * reach the API fine and leave the portal's Integrations tab short of that\n * endpoint, with nothing failing to say so. Advisory, like QDC-NET-002.\n */\nconst integrationStaticCall: Rule.RuleModule = {\n meta: meta(\"QDC-NET-003 - an integration call whose alias or path the portal cannot read\", \"suggestion\"),\n create(context) {\n const report = (node: AstNode, message: string) => {\n context.report({ node: node as unknown as Rule.Node, message: `QDC-NET-003 - ${message}` })\n }\n return listener({\n CallExpression: (node) => {\n if (node.callee?.type !== \"Identifier\" || node.callee.name !== \"integration\") return\n if (!isStringLiteral(node.arguments?.[0])) {\n report(\n node,\n 'the alias is not a string literal, so the portal cannot tell which integration this calls. Write integration(\"alias\") here.',\n )\n return\n }\n const member = node.parent\n const method =\n member?.type === \"MemberExpression\" && member.object === node && member.property?.type === \"Identifier\"\n ? (member.property.name ?? \"\")\n : \"\"\n if (INTEGRATION_READS.includes(method)) return\n const call = member?.parent\n const index = INTEGRATION_PATH_ARG[method]\n if (index === undefined || call?.type !== \"CallExpression\" || call.callee !== member) {\n report(\n node,\n 'the integration handle is stored or passed on instead of called here, so the portal cannot see the endpoints called through it. Write integration(\"alias\").get(\"/path\") at each call site.',\n )\n return\n }\n const path = call.arguments?.[index]\n if (path === undefined || isStringLiteral(path) || path.type === \"TemplateLiteral\") return\n report(\n path,\n \"the path is not written at the call site, so the portal cannot list this endpoint. Write it as a string or template literal here, e.g. `/orders/${id}`. A helper may share options, never the path.\",\n )\n },\n })\n },\n}\n\nexport const rules: Record<string, Rule.RuleModule> = {\n \"no-dangerous-html\": ban(\n \"QDC-XSS-001\",\n \"dangerouslySetInnerHTML renders unescaped markup. Render text, or sanitise it first.\",\n [\"JSXAttribute[name.name='dangerouslySetInnerHTML']\"],\n ),\n \"no-inner-html\": ban(\n \"QDC-XSS-002\",\n \"Assigning innerHTML parses the string as markup. Use textContent.\",\n [\n \"AssignmentExpression[left.type='MemberExpression'][left.property.name=/^(innerHTML|outerHTML)$/]\",\n ],\n ),\n \"no-insert-adjacent-html\": ban(\n \"QDC-XSS-003\",\n \"insertAdjacentHTML parses its argument as markup. Build the nodes instead.\",\n [\"CallExpression[callee.property.name='insertAdjacentHTML']\"],\n ),\n \"no-document-write\": ban(\n \"QDC-XSS-004\",\n \"document.write parses its argument as markup and blocks the parser. Render it in React.\",\n [\"CallExpression[callee.object.name='document'][callee.property.name=/^write(ln)?$/]\"],\n ),\n \"no-string-eval\": noStringEval,\n \"no-raw-script-tag\": ban(\n \"QDC-CSP-001\",\n \"A hand-written <script> gets no nonce, and this app's CSP uses 'strict-dynamic', so it will not run. Use next/script.\",\n [\"JSXElement[openingElement.name.name='script']\"],\n ),\n \"no-sql-interpolation\": ban(\n \"QDC-SQL-001\",\n \"An interpolated string reaching .execute() is the injection. Use the sql tag, which parameterises.\",\n [\n \"CallExpression[callee.property.name='execute'] > TemplateLiteral[expressions.length>0]\",\n \"CallExpression[callee.property.name='execute'] > BinaryExpression[operator='+']\",\n ],\n ),\n \"no-sql-raw\": ban(\n \"QDC-SQL-002\",\n \"sql.raw() puts its argument into the query verbatim and sanitises nothing. Interpolate through the sql tag.\",\n [\"MemberExpression[object.name='sql'][property.name='raw']\"],\n ),\n \"no-driver-import\": banImports(\n \"QDC-SQL-003\",\n \"The database driver belongs in the db layer. Everywhere else, go through Drizzle.\",\n DB_DRIVERS,\n DB_LAYER,\n ),\n \"no-fs-import\": banImports(\n \"QDC-FS-001\",\n \"Request handlers should not reach the filesystem. If one must, use safeJoin from @quatronic/sdk/node/fspath.\",\n FS_MODULES,\n FS_CALLERS,\n ),\n \"safe-redirect\": safeRedirect,\n \"safe-fetch\": safeFetch,\n \"no-undeclared-external-call\": noUndeclaredExternalCall,\n \"integration-static-call\": integrationStaticCall,\n}\n\n/**\n * Rule name to QDC id, for docs and for anything that wants to assert the set\n * without re-deriving it from the messages.\n */\nexport const RULE_IDS: Record<string, string> = {\n \"no-dangerous-html\": \"QDC-XSS-001\",\n \"no-inner-html\": \"QDC-XSS-002\",\n \"no-insert-adjacent-html\": \"QDC-XSS-003\",\n \"no-document-write\": \"QDC-XSS-004\",\n \"no-string-eval\": \"QDC-XSS-005\",\n \"no-raw-script-tag\": \"QDC-CSP-001\",\n \"no-sql-interpolation\": \"QDC-SQL-001\",\n \"no-sql-raw\": \"QDC-SQL-002\",\n \"no-driver-import\": \"QDC-SQL-003\",\n \"no-fs-import\": \"QDC-FS-001\",\n \"safe-redirect\": \"QDC-URL-001\",\n \"safe-fetch\": \"QDC-NET-001\",\n \"no-undeclared-external-call\": \"QDC-NET-002\",\n \"integration-static-call\": \"QDC-NET-003\",\n}\n","import type { Rule } from \"eslint\"\n\nimport type { AstNode } from \"./ast\"\nimport { listener, meta, reporter } from \"./rules\"\n\nconst SENTRY_MODULE = /^@sentry\\//\nconst BANNED = new Set([\"init\", \"withSentryConfig\"])\nconst SPAN_STARTERS = new Set([\"startSpan\", \"startSpanManual\", \"startInactiveSpan\"])\nconst CAPTURES = new Set([\"captureException\", \"captureMessage\"])\nconst LOG_LEVELS = new Set([\"trace\", \"debug\", \"info\", \"warn\", \"error\", \"fatal\"])\nconst KEY_SETTERS = new Set([\"setAttribute\", \"setTag\"])\nconst OBJECT_SETTERS = new Set([\"setAttributes\", \"setTags\"])\nconst SPAN_RECEIVER = /^(span|\\w*Span)$/\nconst SCOPE_RECEIVER = /^(scope|\\w*Scope)$/\nconst SPAN_GETTERS = new Set([\"getActiveSpan\", \"getRootSpan\"])\nconst SCOPE_GETTERS = new Set([\"getCurrentScope\", \"getIsolationScope\"])\nconst PII =\n /(^|[._-])(e-?mail|phone|password|passwd|token|secret|iban|bsn|ssn|ip_?address|first_?name|last_?name|full_?name|username)($|[._-])/i\n\n/** Local names bound to `@sentry/*` (namespace, default, or a named export). */\nfunction trackSentry() {\n const namespaces = new Set<string>()\n const named = new Map<string, string>()\n return {\n namespaces,\n named,\n onImport(node: AstNode, onBanned?: (n: AstNode) => void) {\n const src = node.source?.value\n if (typeof src !== \"string\" || !SENTRY_MODULE.test(src)) return\n for (const s of node.specifiers ?? []) {\n const local = s.local?.name ?? \"\"\n if (s.type === \"ImportNamespaceSpecifier\" || s.type === \"ImportDefaultSpecifier\") namespaces.add(local)\n else if (s.type === \"ImportSpecifier\") {\n const imported = s.imported?.name ?? \"\"\n named.set(local, imported)\n if (BANNED.has(imported)) onBanned?.(s)\n }\n }\n },\n }\n}\n\nconst keyOf = (prop: AstNode): string | undefined => {\n if (prop.type !== \"Property\" || prop.computed) return undefined\n if (prop.key?.type === \"Identifier\") return prop.key.name\n return typeof prop.key?.value === \"string\" ? prop.key.value : undefined\n}\n\nconst objectKeys = (node: AstNode | undefined): [string, AstNode][] =>\n node?.type === \"ObjectExpression\"\n ? (node.properties ?? []).flatMap((p) => {\n const k = keyOf(p)\n return k === undefined ? [] : [[k, p] as [string, AstNode]]\n })\n : []\n\nconst propertyNamed = (node: AstNode | undefined, name: string): AstNode | undefined =>\n node?.type === \"ObjectExpression\"\n ? ((node.properties ?? []).find((p) => keyOf(p) === name)?.value as AstNode | undefined)\n : undefined\n\n/** Reports every attribute, tag or log-field key the app hands Sentry. */\nfunction attributeKeyRule(\n id: string,\n description: string,\n check: (key: string) => string | undefined,\n): Rule.RuleModule {\n return {\n meta: meta(`${id} - ${description}`, \"suggestion\"),\n create(context) {\n const sentry = trackSentry()\n const flag = (key: string, node: AstNode) => {\n const problem = check(key)\n if (problem) reporter(context, `${id} - ${problem}`)(node)\n }\n return listener({\n ImportDeclaration: (node) => sentry.onImport(node),\n CallExpression: (node) => {\n const callee = node.callee\n const args = node.arguments ?? []\n let name: string | undefined\n let viaSentry = false\n if (callee?.type === \"Identifier\") {\n name = sentry.named.get(callee.name ?? \"\")\n viaSentry = name !== undefined\n } else if (callee?.type === \"MemberExpression\") {\n name = callee.property?.name\n const obj = callee.object\n viaSentry =\n (obj?.type === \"Identifier\" && sentry.namespaces.has(obj.name ?? \"\")) ||\n (obj?.type === \"MemberExpression\" &&\n obj.property?.name === \"logger\" &&\n obj.object?.type === \"Identifier\" &&\n sentry.namespaces.has(obj.object.name ?? \"\")) ||\n (obj?.type === \"Identifier\" && sentry.named.get(obj.name ?? \"\") === \"logger\")\n }\n if (!name) return\n const obj = callee?.type === \"MemberExpression\" ? callee.object : undefined\n const sentryCall = (names: Set<string>) =>\n obj?.type === \"CallExpression\" &&\n ((obj.callee?.type === \"Identifier\" && names.has(sentry.named.get(obj.callee.name ?? \"\") ?? \"\")) ||\n (obj.callee?.type === \"MemberExpression\" &&\n obj.callee.object?.type === \"Identifier\" &&\n sentry.namespaces.has(obj.callee.object.name ?? \"\") &&\n names.has(obj.callee.property?.name ?? \"\")))\n const recv = obj?.type === \"Identifier\" ? (obj.name ?? \"\") : \"\"\n const spanRecv = SPAN_RECEIVER.test(recv) || sentryCall(SPAN_GETTERS)\n const tagRecv = viaSentry || SCOPE_RECEIVER.test(recv) || sentryCall(SCOPE_GETTERS)\n const keys: [string, AstNode][] = []\n if (\n KEY_SETTERS.has(name) &&\n (name === \"setAttribute\" ? spanRecv : tagRecv) &&\n args[0]?.type === \"Literal\" &&\n typeof args[0].value === \"string\"\n ) {\n keys.push([args[0].value, args[0]])\n } else if (OBJECT_SETTERS.has(name) && (name === \"setAttributes\" ? spanRecv : tagRecv)) {\n keys.push(...objectKeys(args[0]))\n } else if (viaSentry && SPAN_STARTERS.has(name)) {\n keys.push(...objectKeys(propertyNamed(args[0], \"attributes\")))\n } else if (viaSentry && CAPTURES.has(name)) {\n keys.push(...objectKeys(propertyNamed(args[1], \"tags\")))\n } else if (viaSentry && LOG_LEVELS.has(name) && callee?.type === \"MemberExpression\") {\n keys.push(...objectKeys(args[1]))\n }\n for (const [key, at] of keys) flag(key, at)\n },\n })\n },\n }\n}\n\nconst noSentryInit: Rule.RuleModule = {\n meta: meta(\"QDC-OBS-001 - the SDK owns Sentry.init and withSentryConfig\", \"problem\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-OBS-001 - @quatronic/sdk owns Sentry.init and withSentryConfig. Use Sentry.* directly; see the qore-observability skill.\",\n )\n const sentry = trackSentry()\n return listener({\n ImportDeclaration: (node) => sentry.onImport(node, report),\n CallExpression: (node) => {\n const c = node.callee\n if (\n c?.type === \"MemberExpression\" &&\n c.object?.type === \"Identifier\" &&\n sentry.namespaces.has(c.object.name ?? \"\") &&\n BANNED.has(c.property?.name ?? \"\")\n ) {\n report(node)\n }\n },\n })\n },\n}\n\n/**\n * App code reports a caught error through the SDK, not through Sentry, so the\n * tracker behind it can change in one place. Spans, the logger and tags stay\n * `Sentry.*`; only the capture call moves.\n */\nconst useReportError: Rule.RuleModule = {\n meta: meta(\"QDC-OBS-004 - report caught errors with reportError\", \"suggestion\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-OBS-004 - use reportError(err, ctx) from @quatronic/sdk/observability instead of Sentry.captureException; see migration report-error.\",\n )\n const sentry = trackSentry()\n return listener({\n ImportDeclaration: (node) => sentry.onImport(node),\n CallExpression: (node) => {\n const c = node.callee\n const name =\n c?.type === \"Identifier\"\n ? sentry.named.get(c.name ?? \"\")\n : c?.type === \"MemberExpression\" &&\n c.object?.type === \"Identifier\" &&\n sentry.namespaces.has(c.object.name ?? \"\")\n ? c.property?.name\n : undefined\n if (name === \"captureException\") report(node)\n },\n })\n },\n}\n\nexport const observabilityRules: Record<string, Rule.RuleModule> = {\n \"no-sentry-init\": noSentryInit,\n \"sentry-attribute-namespace\": attributeKeyRule(\n \"QDC-OBS-002\",\n \"custom attribute, tag and log keys are qore.<area>.<name>\",\n (key) =>\n key.startsWith(\"qore.\") ? undefined : `'${key}' is not namespaced. Use qore.<area>.<name>, e.g. qore.invoice.id.`,\n ),\n \"no-pii-attributes\": attributeKeyRule(\"QDC-OBS-003\", \"no personal data in telemetry keys\", (key) =>\n PII.test(key)\n ? `'${key}' looks like personal data. Send an id instead; see the qore-observability skill.`\n : undefined,\n ),\n \"use-report-error\": useReportError,\n}\n\nexport const OBSERVABILITY_RULE_IDS: Record<string, string> = {\n \"no-sentry-init\": \"QDC-OBS-001\",\n \"sentry-attribute-namespace\": \"QDC-OBS-002\",\n \"no-pii-attributes\": \"QDC-OBS-003\",\n \"use-report-error\": \"QDC-OBS-004\",\n}\n","import type { Linter, Rule } from \"eslint\"\n\nimport { observabilityRules } from \"./observability\"\nimport { RULE_IDS, rules } from \"./rules\"\n\nexport { OBSERVABILITY_RULE_IDS, observabilityRules } from \"./observability\"\nexport { RULE_IDS, rules } from \"./rules\"\n\n/**\n * The QDC security ESLint plugin.\n *\n * It lives here rather than in each generated app because a lint rule is the\n * cheapest security control QDC has, and a rule copied into every app can only\n * be tightened by editing every app. Shipped from the SDK, a corrected rule\n * reaches an app on its next `@quatronic/sdk` bump — the same bump the app\n * pays for everything else in the package.\n *\n * Usage in a generated app's `eslint.config.mjs`:\n *\n * import qdcSecurity from \"@quatronic/sdk/eslint\"\n *\n * export default [\n * ...whatever,\n * ...qdcSecurity.configs.recommended,\n * ]\n *\n * A repository that predates the pack spreads `configs.warn` instead — the\n * same rules and scopes, reporting rather than blocking — and promotes itself\n * to `recommended` once its backlog is clear.\n *\n * The rules are syntactic by design. Anything that has to follow a value\n * across functions and files is a Semgrep rule instead, in this package's\n * `semgrep/` directory, run by the same CI job.\n */\nconst plugin = {\n meta: { name: \"@quatronic/sdk/eslint\" },\n rules: { ...rules, ...observabilityRules },\n}\n\n/** Where a generated app keeps the code these rules are about. */\nconst SRC_FILES = [\"src/**/*.{ts,tsx}\"]\nconst TEST_FILES = [\"**/*.test.{ts,tsx}\", \"**/*.spec.{ts,tsx}\"]\n\nexport interface QdcSecurityConfigs {\n recommended: Linter.Config[]\n /**\n * The same rules, in the same scopes, with every enabled one demoted to\n * \"warn\".\n *\n * For a codebase that predates the pack. Adopting fourteen rules at \"error\"\n * into an existing tree means either a red build on day one or a hand-copied\n * override block in that repo — and a hand-copied block stops covering the\n * pack the moment a fifteenth rule ships, while still reporting green. So\n * the demotion lives here, next to the list it demotes.\n *\n * It is a starting position, not a destination: a pack that warns forever is\n * not a control. Promote the repo to `recommended` once its backlog is clear.\n */\n warn: Linter.Config[]\n /**\n * Telemetry rules for apps whose runtime code logs through Sentry only.\n * Separate from `recommended` so a bump does not turn an older app's lint red.\n */\n observability: Linter.Config[]\n}\n\n/**\n * The plugin object, typed explicitly: an inferred type here reaches into\n * `@eslint/core` and TypeScript refuses to name it in a `.d.ts`.\n */\nexport interface QdcSecurityPlugin {\n meta: { name: string }\n rules: Record<string, Rule.RuleModule>\n configs: QdcSecurityConfigs\n RULE_IDS: Record<string, string>\n}\n\n/**\n * Two blocks, spread into a flat config in this order.\n *\n * The second one is not decoration: a test that proves escaping works has to\n * build the markup it escapes, so the XSS bans are off there. It is a separate\n * block because flat-config rule options **replace** rather than merge — a\n * later block naming a rule wins outright — so the exemption has to come after\n * the block that switches the rules on, and has to name only what it exempts.\n */\nconst recommended: Linter.Config[] = [\n {\n files: SRC_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-dangerous-html\": \"error\",\n \"qdc/no-inner-html\": \"error\",\n \"qdc/no-insert-adjacent-html\": \"error\",\n \"qdc/no-document-write\": \"error\",\n \"qdc/no-string-eval\": \"error\",\n \"qdc/no-raw-script-tag\": \"error\",\n \"qdc/no-sql-interpolation\": \"error\",\n \"qdc/no-sql-raw\": \"error\",\n \"qdc/no-driver-import\": \"error\",\n \"qdc/no-fs-import\": \"error\",\n // Advisory, and `eslint .` does not fail on warnings. All three fire on\n // shapes that are often fine, so they prompt a look rather than block a\n // merge; qdc.redirect.tainted and qdc.ssrf.tainted-fetch in the Semgrep\n // pack follow the value and are what actually decide, and the manifest\n // extractor classifies the same hosts at deploy time for the portal.\n \"qdc/safe-redirect\": \"warn\",\n \"qdc/safe-fetch\": \"warn\",\n \"qdc/no-undeclared-external-call\": \"warn\",\n // Advisory too: the call works either way, the portal just cannot list it.\n \"qdc/integration-static-call\": \"warn\",\n },\n },\n {\n // Tests build markup on purpose, to prove the escaping works.\n files: TEST_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-dangerous-html\": \"off\",\n \"qdc/no-inner-html\": \"off\",\n \"qdc/no-insert-adjacent-html\": \"off\",\n \"qdc/no-document-write\": \"off\",\n \"qdc/no-raw-script-tag\": \"off\",\n // The two location bans are off here for a different reason than the\n // XSS ones above. They do not say \"this is dangerous\"; they say \"this\n // capability belongs in `src/db` or `src/scripts`, not scattered through\n // the app\", and that argument is about the shape of the *application*. A\n // test reads a fixture off disk and an integration test opens a real\n // connection; neither ships, and neither can be reached by a request, so\n // neither is the traversal or injection surface the ban exists for.\n //\n // Found by running the pack over five live tenant repositories before it\n // started blocking merges: `no-fs-import` fired six times in one repo and\n // every hit was a test reading its own fixture.\n \"qdc/no-fs-import\": \"off\",\n \"qdc/no-driver-import\": \"off\",\n // A test that stubs fetch names the host it stubs; nothing leaves the\n // process, and the portal is told about deploys, not test runs.\n \"qdc/no-undeclared-external-call\": \"off\",\n // A test calls a handle it built itself; no deploy reads it.\n \"qdc/integration-static-call\": \"off\",\n },\n },\n]\n\n/**\n * \"off\" is an exemption, not a severity. Demoting it to \"warn\" would switch a\n * rule back on in the scope that deliberately turned it off — the test-file\n * block below being the whole reason that distinction matters.\n */\nconst demote = (config: Linter.Config): Linter.Config => ({\n ...config,\n rules: Object.fromEntries(\n Object.entries(config.rules ?? {}).map(([id, level]) => [\n id,\n level === \"off\" ? \"off\" : \"warn\",\n ]),\n ),\n})\n\nconst warn: Linter.Config[] = recommended.map(demote)\n\nconst observability: Linter.Config[] = [\n {\n files: SRC_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-sentry-init\": \"error\",\n \"no-console\": \"error\",\n \"qdc/sentry-attribute-namespace\": \"warn\",\n \"qdc/no-pii-attributes\": \"warn\",\n },\n },\n {\n // CLI tools and tests print on purpose.\n files: [\"**/seed.ts\", \"src/scripts/**\", ...TEST_FILES],\n rules: { \"no-console\": \"off\" },\n },\n]\n\nexport const configs: QdcSecurityConfigs = { recommended, warn, observability }\n\nconst qdcSecurity: QdcSecurityPlugin = { ...plugin, configs, RULE_IDS }\n\nexport default qdcSecurity\n"],"mappings":";;;;;AAyCO,IAAM,eAAe,CAAC,gBAAgB,aAAa,aAAa,OAAO;AAGvE,SAAS,OAAO,UAA0B;AAC/C,SAAO,SAAS,WAAW,MAAM,GAAG;AACtC;AAGO,SAAS,QAAQ,UAAkB,OAAmC;AAC3E,QAAM,OAAO,OAAO,QAAQ;AAC5B,SAAO,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,EAAE,KAAK,KAAK,SAAS,IAAI,IAAI,GAAG,CAAC;AACrF;AAGO,SAAS,WAAW,MAAuB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AyB;AAAA,MACzB,qBAAqB;AAAA,MACrB,+BAA+B;AAAA,MAC/B,yBAAyB;AAAA,MACzB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAYzB,oBAAoB;AAAA,MACpB,wBAAwB;AAAA;AAAA;AAAA,MAGxB,mCAAmC;AAAA;AAAA,MAEnC,+BAA+B;AAAA,IACjC;AAAA,EACF;AACF;AAOA,IAAM,SAAS,CAAC,YAA0C;AAAA,EACxD,GAAG;AAAA,EACH,OAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,OAAO,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;AAAA,MACtD;AAAA,MACA,UAAU,QAAQ,QAAQ;AAAA,IAC5B,CAAC;AAAA,EACH;AACF;AAEA,IAAM,OAAwB,YAAY,IAAI,MAAM;AAEpD,IAAM,gBAAiC;AAAA,EACrC;AAAA,IACE,OAAO;AAAA,IACP,SAAS,EAAE,KAAK,OAAO;AAAA,IACvB,OAAO;AAAA,MACL,sBAAsB;AAAA,MACtB,cAAc;AAAA,MACd,kCAAkC;AAAA,MAClC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA;AAAA;AAAA,IAEE,OAAO,CAAC,cAAc,kBAAkB,GAAG,UAAU;AAAA,IACrD,OAAO,EAAE,cAAc,MAAM;AAAA,EAC/B;AACF;AAEO,IAAM,UAA8B,EAAE,aAAa,MAAM,cAAc;AAE9E,IAAM,cAAiC,EAAE,GAAG,QAAQ,SAAS,SAAS;AAEtE,IAAO,iBAAQ;","names":["obj"]}
|
|
1
|
+
{"version":3,"sources":["../../src/eslint/ast.ts","../../src/eslint/rules.ts","../../src/eslint/observability.ts","../../src/eslint/index.ts"],"sourcesContent":["// A deliberately narrow view of the AST, for rules that are deliberately\n// syntactic.\n//\n// ESLint's own `Rule.Node` is the ESTree union. It does not describe JSX at\n// all, and it forces a narrowing cascade for every property access — in rules\n// whose whole job is to read three or four fields off a node and report it.\n// So these rules declare exactly the fields they read and cast once, at the\n// visitor boundary, rather than per line.\n//\n// Anything that has to follow a value across functions or files is a Semgrep\n// rule instead; that pack ships in `semgrep/` alongside this plugin.\nexport interface AstNode {\n type: string\n /** `Identifier.name` and `MemberExpression.property.name`. Never a JSX name. */\n name?: string\n value?: unknown\n callee?: AstNode\n object?: AstNode\n property?: AstNode\n source?: AstNode\n arguments?: (AstNode | undefined)[]\n expressions?: (AstNode | undefined)[]\n /** `TemplateLiteral.quasis`: the fixed text between the `${}` holes. */\n quasis?: { value?: { cooked?: string | null; raw?: string } }[]\n /** `BinaryExpression.left`; the rule that reads it only follows the left edge. */\n left?: AstNode\n operator?: string\n /** `ImportDeclaration.specifiers`. */\n specifiers?: AstNode[]\n /** `ImportSpecifier.imported` / `.local`. */\n imported?: AstNode\n local?: AstNode\n /** `ObjectExpression.properties`; a `Property` has `key` and `computed`. */\n properties?: AstNode[]\n key?: AstNode\n computed?: boolean\n /** Set by ESLint on every node it visits. */\n parent?: AstNode\n}\n\n/** Calls whose result is a URL this app decided on, not one a caller supplied. */\nexport const VETTED_CALLS = [\"safeRedirect\", \"safeFetch\", \"vetTarget\", \"clone\"]\n\n/** POSIX form of the file being linted, so the checks read the same on Windows. */\nexport function pathOf(filename: string): string {\n return filename.replaceAll(\"\\\\\", \"/\")\n}\n\n/** Is the linted file at, or inside, one of these project paths? */\nexport function isUnder(filename: string, paths: readonly string[]): boolean {\n const file = pathOf(filename)\n return paths.some((path) => file.endsWith(`/${path}`) || file.includes(`/${path}/`))\n}\n\n/** The called name, whether the callee is `f()` or `x.f()`. */\nexport function calleeName(node: AstNode): string {\n const callee = node.callee\n if (!callee) return \"\"\n if (callee.type === \"Identifier\") return callee.name ?? \"\"\n if (callee.type === \"MemberExpression\" && callee.property?.type === \"Identifier\") {\n return callee.property.name ?? \"\"\n }\n return \"\"\n}\n\n/**\n * A target this app wrote down, rather than one that arrived with the request.\n *\n * `allowIdentifier` is the whole difference between the two advisory rules:\n * judging what a bare variable holds takes dataflow, which is what the Semgrep\n * taint rules do. `qdc/safe-redirect` lets a variable through because\n * `NextResponse.redirect(url)` after `req.nextUrl.clone()` is the canonical\n * Next redirect and appears in every generated app; `qdc/safe-fetch` does not.\n */\nexport function isFixedTarget(node: AstNode | undefined, allowIdentifier: boolean): boolean {\n if (!node) return false\n if (node.type === \"Literal\") return typeof node.value === \"string\"\n if (node.type === \"TemplateLiteral\") return (node.expressions?.length ?? 0) === 0\n if (node.type === \"Identifier\") return allowIdentifier\n if (node.type === \"NewExpression\") {\n // `new URL(\"/login\", req.url)` fixes the path; the base only ever\n // contributes this app's own origin.\n return node.callee?.name === \"URL\" && isFixedTarget(node.arguments?.[0], allowIdentifier)\n }\n if (node.type === \"CallExpression\") return VETTED_CALLS.includes(calleeName(node))\n return false\n}\n","import type { Rule } from \"eslint\"\n\nimport { isPlatformManagedHost } from \"../integrations-core/platform-hosts\"\nimport { type AstNode, calleeName, isFixedTarget, isUnder } from \"./ast\"\n\n/**\n * The fourteen QDC security lint rules.\n *\n * One rule per id, rather than fourteen entries in `no-restricted-syntax`, for\n * two reasons that only show up after the fact:\n *\n * - **Severity is per rule.** `no-restricted-syntax` carries one severity for\n * its whole array, and three of these are advisory on purpose — they fire on\n * shapes that are usually fine, and the Semgrep pack does the dataflow they\n * can only approximate.\n * - **Suppression is per rule.** `// eslint-disable-next-line\n * no-restricted-syntax` switches off every selector on that line, so\n * silencing \"no inline styles\" would silently also silence the\n * `dangerouslySetInnerHTML` ban sitting next to it.\n *\n * Suppress one by its own name, and say why:\n *\n * // eslint-disable-next-line qdc/no-dangerous-html -- sanitised in renderPost()\n */\n\n/** Modules that talk to the database directly, and where that is allowed. */\nconst DB_DRIVERS = [\"pg\", \"postgres\", \"mysql2\", \"mysql2/promise\"]\nconst DB_LAYER = [\"src/db\", \"src/lib/db.ts\"]\n\n/** Node's filesystem API, and where a generated app is expected to use it. */\nconst FS_MODULES = [\"fs\", \"node:fs\", \"fs/promises\", \"node:fs/promises\"]\n// `src/lib/migrate.ts` is the migration runner: it reads the migration files\n// off disk at boot, which is the sanctioned use, and it is not reachable from\n// a request. The backend recipes put it there rather than under src/db.\nconst FS_CALLERS = [\"src/scripts\", \"src/db\", \"src/lib/migrate.ts\"]\n\n/** Where a fetch goes out with the server's own network position. */\nconst SERVER_PATHS = [\"src/app/api\", \"src/lib/server\", \"src/proxy.ts\"]\n\n/** One cast, at the boundary, instead of one per `context.report` call. */\nexport function reporter(context: Rule.RuleContext, message: string): (node: AstNode) => void {\n return (node: AstNode) => {\n context.report({ node: node as unknown as Rule.Node, message })\n }\n}\n\nexport function listener(visitor: Record<string, (node: AstNode) => void>): Rule.RuleListener {\n return visitor as unknown as Rule.RuleListener\n}\n\nexport function meta(description: string, type: \"problem\" | \"suggestion\"): Rule.RuleModule[\"meta\"] {\n return { type, docs: { description }, schema: [] }\n}\n\n/** A rule that reports every node matching one of `selectors`. */\nfunction ban(id: string, message: string, selectors: string[]): Rule.RuleModule {\n const text = `${id} - ${message}`\n return {\n meta: meta(text, \"problem\"),\n create(context) {\n const report = reporter(context, text)\n return listener(Object.fromEntries(selectors.map((selector) => [selector, report])))\n },\n }\n}\n\n/** A rule that bans importing any of `modules`, except from `allowed` paths. */\nfunction banImports(\n id: string,\n message: string,\n modules: string[],\n allowed: string[],\n): Rule.RuleModule {\n const text = `${id} - ${message}`\n return {\n meta: meta(text, \"problem\"),\n create(context) {\n if (isUnder(context.filename, allowed)) return {}\n const report = reporter(context, text)\n const flag = (node: AstNode) => {\n const source = node.source\n if (source?.type === \"Literal\" && typeof source.value === \"string\") {\n if (modules.includes(source.value)) report(node)\n }\n }\n return listener({ ImportDeclaration: flag, ImportExpression: flag })\n },\n }\n}\n\nconst noStringEval: Rule.RuleModule = {\n meta: meta(\"QDC-XSS-005 - no code compiled from a string\", \"problem\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-XSS-005 - compiling a string into code runs whatever the string turned out to be. Pass a function.\",\n )\n const isStringy = (node: AstNode | undefined) =>\n node?.type === \"TemplateLiteral\" ||\n node?.type === \"BinaryExpression\" ||\n (node?.type === \"Literal\" && typeof node.value === \"string\")\n return listener({\n \"CallExpression[callee.name='eval']\": report,\n \"CallExpression[callee.name='Function']\": report,\n \"NewExpression[callee.name='Function']\": report,\n \"CallExpression[callee.name=/^set(Timeout|Interval)$/]\": (node) => {\n if (isStringy(node.arguments?.[0])) report(node)\n },\n })\n },\n}\n\nconst safeRedirect: Rule.RuleModule = {\n meta: meta(\"QDC-URL-001 - redirect to a target this app decided on\", \"suggestion\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-URL-001 - redirecting to a value that came with the request is an open redirect. Wrap it in safeRedirect from @quatronic/sdk/next/auth.\",\n )\n return listener({\n \"CallExpression[callee.object.name='NextResponse'][callee.property.name='redirect']\": (\n node,\n ) => {\n if (isFixedTarget(node.arguments?.[0], true)) return\n report(node)\n },\n })\n },\n}\n\nconst safeFetch: Rule.RuleModule = {\n meta: meta(\"QDC-NET-001 - server-side fetch of a caller-supplied URL\", \"suggestion\"),\n create(context) {\n if (!isUnder(context.filename, SERVER_PATHS)) return {}\n const report = reporter(\n context,\n \"QDC-NET-001 - a URL the server did not decide on reaches the private network too. Use safeFetch from @quatronic/sdk/node/net, or connection(alias).fetch for a wired module.\",\n )\n return listener({\n \"CallExpression[callee.name='fetch']\": (node) => {\n if (isFixedTarget(node.arguments?.[0], false)) return\n report(node)\n },\n })\n },\n}\n\n/** Outbound HTTP clients a generated app might reach for. */\nconst HTTP_CLIENTS = [\"fetch\", \"axios\", \"got\", \"ky\"]\nconst HTTP_LIBS = [\"axios\", \"got\", \"ky\"]\nconst HTTP_METHODS = /^(get|post|put|patch|delete|head|request)$/\n\n/** A host that is this cluster or this machine, so not an external API. */\nconst LOCAL_HOST_SUFFIXES = [\".local\", \".internal\", \".svc\", \".cluster.local\"]\nconst ENV_KEY = /^[A-Z][A-Z0-9_]*$/\n\nfunction isLocalHost(host: string): boolean {\n const h = host.toLowerCase()\n if (h === \"localhost\" || h === \"::1\" || h === \"0.0.0.0\" || h.startsWith(\"127.\")) return true\n return LOCAL_HOST_SUFFIXES.some((suffix) => h.endsWith(suffix))\n}\n\n/** The host of an `http(s)://` string, or null when it has none or a `${}` hole cuts it off. */\nfunction hostOf(text: string): string | null {\n const m = /^https?:\\/\\/(?:[^@/?#]*@)?(\\[[^\\]]*\\]|[^/?#:]+)/i.exec(text)\n if (!m?.[1]) return null\n return m[1].replace(/^\\[|\\]$/g, \"\")\n}\n\n/** `process.env.X`, `env.X`, `serverEnv().X` — the env key, when `X` looks like one. */\nfunction envKeyOf(node: AstNode | undefined): string | null {\n if (node?.type !== \"MemberExpression\" || node.property?.type !== \"Identifier\") return null\n const key = node.property.name ?? \"\"\n if (!ENV_KEY.test(key)) return null\n const object = node.object\n if (!object) return null\n if (object.type === \"Identifier\") return object.name === \"env\" ? key : null\n if (object.type === \"MemberExpression\") {\n const isProcessEnv =\n object.object?.type === \"Identifier\" &&\n object.object.name === \"process\" &&\n object.property?.name === \"env\"\n return isProcessEnv ? key : null\n }\n if (object.type === \"CallExpression\") {\n const name = calleeName(object)\n return name === \"env\" || name.endsWith(\"Env\") ? key : null\n }\n return null\n}\n\ntype ExternalTarget = { host: string } | { envKey: string } | null\n\n/**\n * Where a call is going, read off its first argument: a host when the code\n * spells the URL out, an env key when the base comes from the environment,\n * null when the shape says nothing (a bare variable, a relative path).\n */\nfunction externalTargetOf(node: AstNode | undefined): ExternalTarget {\n if (!node) return null\n if (node.type === \"Literal\" && typeof node.value === \"string\") {\n const host = hostOf(node.value)\n return host ? { host } : null\n }\n if (node.type === \"TemplateLiteral\") {\n const head = node.quasis?.[0]?.value?.cooked ?? node.quasis?.[0]?.value?.raw ?? \"\"\n const host = hostOf(head)\n if (host) return { host }\n // `${process.env.SAP_BASE_URL}/path` — the base is the first hole.\n if (head === \"\") {\n const key = envKeyOf(node.expressions?.[0])\n if (key) return { envKey: key }\n }\n return null\n }\n if (node.type === \"BinaryExpression\" && node.operator === \"+\") return externalTargetOf(node.left)\n if (node.type === \"MemberExpression\") {\n const key = envKeyOf(node)\n return key ? { envKey: key } : null\n }\n if (node.type === \"NewExpression\" && node.callee?.name === \"URL\") {\n // new URL(path, base): the base decides the host; new URL(absolute) has no base.\n const args = node.arguments ?? []\n return externalTargetOf(args[1]) ?? externalTargetOf(args[0])\n }\n return null\n}\n\nfunction isHttpClientCall(node: AstNode): boolean {\n const callee = node.callee\n if (!callee) return false\n if (callee.type === \"Identifier\") return HTTP_CLIENTS.includes(callee.name ?? \"\")\n if (callee.type === \"MemberExpression\") {\n return (\n callee.object?.type === \"Identifier\" &&\n HTTP_LIBS.includes(callee.object.name ?? \"\") &&\n callee.property?.type === \"Identifier\" &&\n HTTP_METHODS.test(callee.property.name ?? \"\")\n )\n }\n return false\n}\n\n/**\n * An outbound call to a host this app has not declared. Advisory: the rule\n * reads one argument, so it sees a spelled-out host or an env-backed base and\n * nothing more. The manifest extractor does the same classification at deploy\n * time and the portal shows the result; this is the editor-time echo of it.\n */\nconst noUndeclaredExternalCall: Rule.RuleModule = {\n meta: meta(\"QDC-NET-002 - outbound call to an external API this app has not declared\", \"suggestion\"),\n create(context) {\n return listener({\n CallExpression: (node) => {\n if (!isHttpClientCall(node)) return\n const target = externalTargetOf(node.arguments?.[0])\n if (!target) return\n let label: string\n if (\"host\" in target) {\n if (isLocalHost(target.host) || isPlatformManagedHost(target.host)) return\n label = target.host\n } else {\n // CONN_* is a wired module connection: the portal already knows the other end.\n if (target.envKey.startsWith(\"CONN_\")) return\n label = `$${target.envKey}`\n }\n context.report({\n node: node as unknown as Rule.Node,\n message: `QDC-NET-002 - ${label} is an external API this app has not declared. Declare it in src/config/integrations.ts and call integration(alias).get/post, so the portal can see and manage it.`,\n })\n },\n })\n },\n}\n\n/** The calls on an integration handle that send a request, and where their path sits. */\nconst INTEGRATION_PATH_ARG: Record<string, number> = { get: 0, post: 0, put: 0, patch: 0, delete: 0, request: 1 }\n/** Reads off a handle that send nothing, so taking them through a variable hides no endpoint. */\nconst INTEGRATION_READS = [\"config\", \"alias\", \"definition\"]\n\nconst isStringLiteral = (node: AstNode | undefined): boolean =>\n node?.type === \"Literal\" && typeof node.value === \"string\"\n\n/**\n * An integration call the portal cannot read. The manifest extractor reads\n * exactly `integration(\"alias\").get(\"/path\")`, alias and path written at the\n * call site, because it reads source, not values. A path passed in through a\n * helper, an alias held in a variable, or a handle stored and called later all\n * reach the API fine and leave the portal's Integrations tab short of that\n * endpoint, with nothing failing to say so. Advisory, like QDC-NET-002.\n */\nconst integrationStaticCall: Rule.RuleModule = {\n meta: meta(\"QDC-NET-003 - an integration call whose alias or path the portal cannot read\", \"suggestion\"),\n create(context) {\n const report = (node: AstNode, message: string) => {\n context.report({ node: node as unknown as Rule.Node, message: `QDC-NET-003 - ${message}` })\n }\n return listener({\n CallExpression: (node) => {\n if (node.callee?.type !== \"Identifier\" || node.callee.name !== \"integration\") return\n if (!isStringLiteral(node.arguments?.[0])) {\n report(\n node,\n 'the alias is not a string literal, so the portal cannot tell which integration this calls. Write integration(\"alias\") here.',\n )\n return\n }\n const member = node.parent\n const method =\n member?.type === \"MemberExpression\" && member.object === node && member.property?.type === \"Identifier\"\n ? (member.property.name ?? \"\")\n : \"\"\n if (INTEGRATION_READS.includes(method)) return\n const call = member?.parent\n const index = INTEGRATION_PATH_ARG[method]\n if (index === undefined || call?.type !== \"CallExpression\" || call.callee !== member) {\n report(\n node,\n 'the integration handle is stored or passed on instead of called here, so the portal cannot see the endpoints called through it. Write integration(\"alias\").get(\"/path\") at each call site.',\n )\n return\n }\n const path = call.arguments?.[index]\n if (path === undefined || isStringLiteral(path) || path.type === \"TemplateLiteral\") return\n report(\n path,\n \"the path is not written at the call site, so the portal cannot list this endpoint. Write it as a string or template literal here, e.g. `/orders/${id}`. A helper may share options, never the path.\",\n )\n },\n })\n },\n}\n\nexport const rules: Record<string, Rule.RuleModule> = {\n \"no-dangerous-html\": ban(\n \"QDC-XSS-001\",\n \"dangerouslySetInnerHTML renders unescaped markup. Render text, or sanitise it first.\",\n [\"JSXAttribute[name.name='dangerouslySetInnerHTML']\"],\n ),\n \"no-inner-html\": ban(\n \"QDC-XSS-002\",\n \"Assigning innerHTML parses the string as markup. Use textContent.\",\n [\n \"AssignmentExpression[left.type='MemberExpression'][left.property.name=/^(innerHTML|outerHTML)$/]\",\n ],\n ),\n \"no-insert-adjacent-html\": ban(\n \"QDC-XSS-003\",\n \"insertAdjacentHTML parses its argument as markup. Build the nodes instead.\",\n [\"CallExpression[callee.property.name='insertAdjacentHTML']\"],\n ),\n \"no-document-write\": ban(\n \"QDC-XSS-004\",\n \"document.write parses its argument as markup and blocks the parser. Render it in React.\",\n [\"CallExpression[callee.object.name='document'][callee.property.name=/^write(ln)?$/]\"],\n ),\n \"no-string-eval\": noStringEval,\n \"no-raw-script-tag\": ban(\n \"QDC-CSP-001\",\n \"A hand-written <script> gets no nonce, and this app's CSP uses 'strict-dynamic', so it will not run. Use next/script.\",\n [\"JSXElement[openingElement.name.name='script']\"],\n ),\n \"no-sql-interpolation\": ban(\n \"QDC-SQL-001\",\n \"An interpolated string reaching .execute() is the injection. Use the sql tag, which parameterises.\",\n [\n \"CallExpression[callee.property.name='execute'] > TemplateLiteral[expressions.length>0]\",\n \"CallExpression[callee.property.name='execute'] > BinaryExpression[operator='+']\",\n ],\n ),\n \"no-sql-raw\": ban(\n \"QDC-SQL-002\",\n \"sql.raw() puts its argument into the query verbatim and sanitises nothing. Interpolate through the sql tag.\",\n [\"MemberExpression[object.name='sql'][property.name='raw']\"],\n ),\n \"no-driver-import\": banImports(\n \"QDC-SQL-003\",\n \"The database driver belongs in the db layer. Everywhere else, go through Drizzle.\",\n DB_DRIVERS,\n DB_LAYER,\n ),\n \"no-fs-import\": banImports(\n \"QDC-FS-001\",\n \"Request handlers should not reach the filesystem. If one must, use safeJoin from @quatronic/sdk/node/fspath.\",\n FS_MODULES,\n FS_CALLERS,\n ),\n \"safe-redirect\": safeRedirect,\n \"safe-fetch\": safeFetch,\n \"no-undeclared-external-call\": noUndeclaredExternalCall,\n \"integration-static-call\": integrationStaticCall,\n}\n\n/**\n * Rule name to QDC id, for docs and for anything that wants to assert the set\n * without re-deriving it from the messages.\n */\nexport const RULE_IDS: Record<string, string> = {\n \"no-dangerous-html\": \"QDC-XSS-001\",\n \"no-inner-html\": \"QDC-XSS-002\",\n \"no-insert-adjacent-html\": \"QDC-XSS-003\",\n \"no-document-write\": \"QDC-XSS-004\",\n \"no-string-eval\": \"QDC-XSS-005\",\n \"no-raw-script-tag\": \"QDC-CSP-001\",\n \"no-sql-interpolation\": \"QDC-SQL-001\",\n \"no-sql-raw\": \"QDC-SQL-002\",\n \"no-driver-import\": \"QDC-SQL-003\",\n \"no-fs-import\": \"QDC-FS-001\",\n \"safe-redirect\": \"QDC-URL-001\",\n \"safe-fetch\": \"QDC-NET-001\",\n \"no-undeclared-external-call\": \"QDC-NET-002\",\n \"integration-static-call\": \"QDC-NET-003\",\n}\n","import type { Rule } from \"eslint\"\n\nimport type { AstNode } from \"./ast\"\nimport { listener, meta, reporter } from \"./rules\"\n\nconst SENTRY_MODULE = /^@sentry\\//\nconst BANNED = new Set([\"init\", \"withSentryConfig\"])\nconst SPAN_STARTERS = new Set([\"startSpan\", \"startSpanManual\", \"startInactiveSpan\"])\nconst CAPTURES = new Set([\"captureException\", \"captureMessage\"])\nconst LOG_LEVELS = new Set([\"trace\", \"debug\", \"info\", \"warn\", \"error\", \"fatal\"])\nconst KEY_SETTERS = new Set([\"setAttribute\", \"setTag\"])\nconst OBJECT_SETTERS = new Set([\"setAttributes\", \"setTags\"])\nconst SPAN_RECEIVER = /^(span|\\w*Span)$/\nconst SCOPE_RECEIVER = /^(scope|\\w*Scope)$/\nconst SPAN_GETTERS = new Set([\"getActiveSpan\", \"getRootSpan\"])\nconst SCOPE_GETTERS = new Set([\"getCurrentScope\", \"getIsolationScope\"])\nconst PII =\n /(^|[._-])(e-?mail|phone|password|passwd|token|secret|iban|bsn|ssn|ip_?address|first_?name|last_?name|full_?name|username)($|[._-])/i\n\n/** Local names bound to `@sentry/*` (namespace, default, or a named export). */\nfunction trackSentry() {\n const namespaces = new Set<string>()\n const named = new Map<string, string>()\n return {\n namespaces,\n named,\n onImport(node: AstNode, onBanned?: (n: AstNode) => void) {\n const src = node.source?.value\n if (typeof src !== \"string\" || !SENTRY_MODULE.test(src)) return\n for (const s of node.specifiers ?? []) {\n const local = s.local?.name ?? \"\"\n if (s.type === \"ImportNamespaceSpecifier\" || s.type === \"ImportDefaultSpecifier\") namespaces.add(local)\n else if (s.type === \"ImportSpecifier\") {\n const imported = s.imported?.name ?? \"\"\n named.set(local, imported)\n if (BANNED.has(imported)) onBanned?.(s)\n }\n }\n },\n }\n}\n\nconst keyOf = (prop: AstNode): string | undefined => {\n if (prop.type !== \"Property\" || prop.computed) return undefined\n if (prop.key?.type === \"Identifier\") return prop.key.name\n return typeof prop.key?.value === \"string\" ? prop.key.value : undefined\n}\n\nconst objectKeys = (node: AstNode | undefined): [string, AstNode][] =>\n node?.type === \"ObjectExpression\"\n ? (node.properties ?? []).flatMap((p) => {\n const k = keyOf(p)\n return k === undefined ? [] : [[k, p] as [string, AstNode]]\n })\n : []\n\nconst propertyNamed = (node: AstNode | undefined, name: string): AstNode | undefined =>\n node?.type === \"ObjectExpression\"\n ? ((node.properties ?? []).find((p) => keyOf(p) === name)?.value as AstNode | undefined)\n : undefined\n\n/** Reports every attribute, tag or log-field key the app hands Sentry. */\nfunction attributeKeyRule(\n id: string,\n description: string,\n check: (key: string) => string | undefined,\n): Rule.RuleModule {\n return {\n meta: meta(`${id} - ${description}`, \"suggestion\"),\n create(context) {\n const sentry = trackSentry()\n const flag = (key: string, node: AstNode) => {\n const problem = check(key)\n if (problem) reporter(context, `${id} - ${problem}`)(node)\n }\n return listener({\n ImportDeclaration: (node) => sentry.onImport(node),\n CallExpression: (node) => {\n const callee = node.callee\n const args = node.arguments ?? []\n let name: string | undefined\n let viaSentry = false\n if (callee?.type === \"Identifier\") {\n name = sentry.named.get(callee.name ?? \"\")\n viaSentry = name !== undefined\n } else if (callee?.type === \"MemberExpression\") {\n name = callee.property?.name\n const obj = callee.object\n viaSentry =\n (obj?.type === \"Identifier\" && sentry.namespaces.has(obj.name ?? \"\")) ||\n (obj?.type === \"MemberExpression\" &&\n obj.property?.name === \"logger\" &&\n obj.object?.type === \"Identifier\" &&\n sentry.namespaces.has(obj.object.name ?? \"\")) ||\n (obj?.type === \"Identifier\" && sentry.named.get(obj.name ?? \"\") === \"logger\")\n }\n if (!name) return\n const obj = callee?.type === \"MemberExpression\" ? callee.object : undefined\n const sentryCall = (names: Set<string>) =>\n obj?.type === \"CallExpression\" &&\n ((obj.callee?.type === \"Identifier\" && names.has(sentry.named.get(obj.callee.name ?? \"\") ?? \"\")) ||\n (obj.callee?.type === \"MemberExpression\" &&\n obj.callee.object?.type === \"Identifier\" &&\n sentry.namespaces.has(obj.callee.object.name ?? \"\") &&\n names.has(obj.callee.property?.name ?? \"\")))\n const recv = obj?.type === \"Identifier\" ? (obj.name ?? \"\") : \"\"\n const spanRecv = SPAN_RECEIVER.test(recv) || sentryCall(SPAN_GETTERS)\n const tagRecv = viaSentry || SCOPE_RECEIVER.test(recv) || sentryCall(SCOPE_GETTERS)\n const keys: [string, AstNode][] = []\n if (\n KEY_SETTERS.has(name) &&\n (name === \"setAttribute\" ? spanRecv : tagRecv) &&\n args[0]?.type === \"Literal\" &&\n typeof args[0].value === \"string\"\n ) {\n keys.push([args[0].value, args[0]])\n } else if (OBJECT_SETTERS.has(name) && (name === \"setAttributes\" ? spanRecv : tagRecv)) {\n keys.push(...objectKeys(args[0]))\n } else if (viaSentry && SPAN_STARTERS.has(name)) {\n keys.push(...objectKeys(propertyNamed(args[0], \"attributes\")))\n } else if (viaSentry && CAPTURES.has(name)) {\n keys.push(...objectKeys(propertyNamed(args[1], \"tags\")))\n } else if (viaSentry && LOG_LEVELS.has(name) && callee?.type === \"MemberExpression\") {\n keys.push(...objectKeys(args[1]))\n }\n for (const [key, at] of keys) flag(key, at)\n },\n })\n },\n }\n}\n\nconst noSentryInit: Rule.RuleModule = {\n meta: meta(\"QDC-OBS-001 - the SDK owns Sentry.init and withSentryConfig\", \"problem\"),\n create(context) {\n const report = reporter(\n context,\n \"QDC-OBS-001 - @quatronic/sdk owns Sentry.init and withSentryConfig. Use Sentry.* directly; see the qore-observability skill.\",\n )\n const sentry = trackSentry()\n return listener({\n ImportDeclaration: (node) => sentry.onImport(node, report),\n CallExpression: (node) => {\n const c = node.callee\n if (\n c?.type === \"MemberExpression\" &&\n c.object?.type === \"Identifier\" &&\n sentry.namespaces.has(c.object.name ?? \"\") &&\n BANNED.has(c.property?.name ?? \"\")\n ) {\n report(node)\n }\n },\n })\n },\n}\n\nexport const observabilityRules: Record<string, Rule.RuleModule> = {\n \"no-sentry-init\": noSentryInit,\n \"sentry-attribute-namespace\": attributeKeyRule(\n \"QDC-OBS-002\",\n \"custom attribute, tag and log keys are qore.<area>.<name>\",\n (key) =>\n key.startsWith(\"qore.\") ? undefined : `'${key}' is not namespaced. Use qore.<area>.<name>, e.g. qore.invoice.id.`,\n ),\n \"no-pii-attributes\": attributeKeyRule(\"QDC-OBS-003\", \"no personal data in telemetry keys\", (key) =>\n PII.test(key)\n ? `'${key}' looks like personal data. Send an id instead; see the qore-observability skill.`\n : undefined,\n ),\n}\n\nexport const OBSERVABILITY_RULE_IDS: Record<string, string> = {\n \"no-sentry-init\": \"QDC-OBS-001\",\n \"sentry-attribute-namespace\": \"QDC-OBS-002\",\n \"no-pii-attributes\": \"QDC-OBS-003\",\n}\n","import type { Linter, Rule } from \"eslint\"\n\nimport { observabilityRules } from \"./observability\"\nimport { RULE_IDS, rules } from \"./rules\"\n\nexport { OBSERVABILITY_RULE_IDS, observabilityRules } from \"./observability\"\nexport { RULE_IDS, rules } from \"./rules\"\n\n/**\n * The QDC security ESLint plugin.\n *\n * It lives here rather than in each generated app because a lint rule is the\n * cheapest security control QDC has, and a rule copied into every app can only\n * be tightened by editing every app. Shipped from the SDK, a corrected rule\n * reaches an app on its next `@quatronic/sdk` bump — the same bump the app\n * pays for everything else in the package.\n *\n * Usage in a generated app's `eslint.config.mjs`:\n *\n * import qdcSecurity from \"@quatronic/sdk/eslint\"\n *\n * export default [\n * ...whatever,\n * ...qdcSecurity.configs.recommended,\n * ]\n *\n * A repository that predates the pack spreads `configs.warn` instead — the\n * same rules and scopes, reporting rather than blocking — and promotes itself\n * to `recommended` once its backlog is clear.\n *\n * The rules are syntactic by design. Anything that has to follow a value\n * across functions and files is a Semgrep rule instead, in this package's\n * `semgrep/` directory, run by the same CI job.\n */\nconst plugin = {\n meta: { name: \"@quatronic/sdk/eslint\" },\n rules: { ...rules, ...observabilityRules },\n}\n\n/** Where a generated app keeps the code these rules are about. */\nconst SRC_FILES = [\"src/**/*.{ts,tsx}\"]\nconst TEST_FILES = [\"**/*.test.{ts,tsx}\", \"**/*.spec.{ts,tsx}\"]\n\nexport interface QdcSecurityConfigs {\n recommended: Linter.Config[]\n /**\n * The same rules, in the same scopes, with every enabled one demoted to\n * \"warn\".\n *\n * For a codebase that predates the pack. Adopting fourteen rules at \"error\"\n * into an existing tree means either a red build on day one or a hand-copied\n * override block in that repo — and a hand-copied block stops covering the\n * pack the moment a fifteenth rule ships, while still reporting green. So\n * the demotion lives here, next to the list it demotes.\n *\n * It is a starting position, not a destination: a pack that warns forever is\n * not a control. Promote the repo to `recommended` once its backlog is clear.\n */\n warn: Linter.Config[]\n /**\n * Telemetry rules for apps whose runtime code logs through Sentry only.\n * Separate from `recommended` so a bump does not turn an older app's lint red.\n */\n observability: Linter.Config[]\n}\n\n/**\n * The plugin object, typed explicitly: an inferred type here reaches into\n * `@eslint/core` and TypeScript refuses to name it in a `.d.ts`.\n */\nexport interface QdcSecurityPlugin {\n meta: { name: string }\n rules: Record<string, Rule.RuleModule>\n configs: QdcSecurityConfigs\n RULE_IDS: Record<string, string>\n}\n\n/**\n * Two blocks, spread into a flat config in this order.\n *\n * The second one is not decoration: a test that proves escaping works has to\n * build the markup it escapes, so the XSS bans are off there. It is a separate\n * block because flat-config rule options **replace** rather than merge — a\n * later block naming a rule wins outright — so the exemption has to come after\n * the block that switches the rules on, and has to name only what it exempts.\n */\nconst recommended: Linter.Config[] = [\n {\n files: SRC_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-dangerous-html\": \"error\",\n \"qdc/no-inner-html\": \"error\",\n \"qdc/no-insert-adjacent-html\": \"error\",\n \"qdc/no-document-write\": \"error\",\n \"qdc/no-string-eval\": \"error\",\n \"qdc/no-raw-script-tag\": \"error\",\n \"qdc/no-sql-interpolation\": \"error\",\n \"qdc/no-sql-raw\": \"error\",\n \"qdc/no-driver-import\": \"error\",\n \"qdc/no-fs-import\": \"error\",\n // Advisory, and `eslint .` does not fail on warnings. All three fire on\n // shapes that are often fine, so they prompt a look rather than block a\n // merge; qdc.redirect.tainted and qdc.ssrf.tainted-fetch in the Semgrep\n // pack follow the value and are what actually decide, and the manifest\n // extractor classifies the same hosts at deploy time for the portal.\n \"qdc/safe-redirect\": \"warn\",\n \"qdc/safe-fetch\": \"warn\",\n \"qdc/no-undeclared-external-call\": \"warn\",\n // Advisory too: the call works either way, the portal just cannot list it.\n \"qdc/integration-static-call\": \"warn\",\n },\n },\n {\n // Tests build markup on purpose, to prove the escaping works.\n files: TEST_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-dangerous-html\": \"off\",\n \"qdc/no-inner-html\": \"off\",\n \"qdc/no-insert-adjacent-html\": \"off\",\n \"qdc/no-document-write\": \"off\",\n \"qdc/no-raw-script-tag\": \"off\",\n // The two location bans are off here for a different reason than the\n // XSS ones above. They do not say \"this is dangerous\"; they say \"this\n // capability belongs in `src/db` or `src/scripts`, not scattered through\n // the app\", and that argument is about the shape of the *application*. A\n // test reads a fixture off disk and an integration test opens a real\n // connection; neither ships, and neither can be reached by a request, so\n // neither is the traversal or injection surface the ban exists for.\n //\n // Found by running the pack over five live tenant repositories before it\n // started blocking merges: `no-fs-import` fired six times in one repo and\n // every hit was a test reading its own fixture.\n \"qdc/no-fs-import\": \"off\",\n \"qdc/no-driver-import\": \"off\",\n // A test that stubs fetch names the host it stubs; nothing leaves the\n // process, and the portal is told about deploys, not test runs.\n \"qdc/no-undeclared-external-call\": \"off\",\n // A test calls a handle it built itself; no deploy reads it.\n \"qdc/integration-static-call\": \"off\",\n },\n },\n]\n\n/**\n * \"off\" is an exemption, not a severity. Demoting it to \"warn\" would switch a\n * rule back on in the scope that deliberately turned it off — the test-file\n * block below being the whole reason that distinction matters.\n */\nconst demote = (config: Linter.Config): Linter.Config => ({\n ...config,\n rules: Object.fromEntries(\n Object.entries(config.rules ?? {}).map(([id, level]) => [\n id,\n level === \"off\" ? \"off\" : \"warn\",\n ]),\n ),\n})\n\nconst warn: Linter.Config[] = recommended.map(demote)\n\nconst observability: Linter.Config[] = [\n {\n files: SRC_FILES,\n plugins: { qdc: plugin },\n rules: {\n \"qdc/no-sentry-init\": \"error\",\n \"no-console\": \"error\",\n \"qdc/sentry-attribute-namespace\": \"warn\",\n \"qdc/no-pii-attributes\": \"warn\",\n },\n },\n {\n // CLI tools and tests print on purpose.\n files: [\"**/seed.ts\", \"src/scripts/**\", ...TEST_FILES],\n rules: { \"no-console\": \"off\" },\n },\n]\n\nexport const configs: QdcSecurityConfigs = { recommended, warn, observability }\n\nconst qdcSecurity: QdcSecurityPlugin = { ...plugin, configs, RULE_IDS }\n\nexport default qdcSecurity\n"],"mappings":";;;;;AAyCO,IAAM,eAAe,CAAC,gBAAgB,aAAa,aAAa,OAAO;AAGvE,SAAS,OAAO,UAA0B;AAC/C,SAAO,SAAS,WAAW,MAAM,GAAG;AACtC;AAGO,SAAS,QAAQ,UAAkB,OAAmC;AAC3E,QAAM,OAAO,OAAO,QAAQ;AAC5B,SAAO,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,EAAE,KAAK,KAAK,SAAS,IAAI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