@lintsure/core 0.3.10 → 0.3.12

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.
@@ -12,7 +12,8 @@ export * from "./guidance.js";
12
12
  export { toAssessmentHtml } from "./assessment.js";
13
13
  export * from "./knowledge/index.js";
14
14
  export { loadPacks, registerPack, type Pack } from "./packs.js";
15
- export declare const RULES_VERSION = "0.3.10";
15
+ export { checksFor } from "./plan.js";
16
+ export declare const RULES_VERSION = "0.3.12";
16
17
  /** Shown with every result, in every interface. Lintsure prepares; people decide. */
17
18
  export declare const DISCLAIMER: string;
18
19
  /** What a report must never be read as. Used in the report and by the MCP server. */
@@ -35,6 +36,7 @@ export interface Config {
35
36
  skipped: string[];
36
37
  ignore: string[];
37
38
  packsMissing?: string[];
39
+ packs?: string[];
38
40
  /** Per-rule settings: "off" stops a rule; "low" | "medium" | "high" changes its risk level. */
39
41
  rules: Record<string, "off" | Severity>;
40
42
  /** "all" also shows medium-confidence findings. */
@@ -57,6 +59,10 @@ export declare const NON_SHIPPING: RegExp;
57
59
  export declare function isNonShipping(file: string): boolean;
58
60
  /** The JSON object key that opens the block a line sits in, e.g. "peerDependencies". Pure. */
59
61
  export declare function enclosingKey(lines: string[], i: number): string;
62
+ export declare function exampleLines(lines: string[], ext: string): boolean[];
63
+ export declare function taintedNames(lines: string[]): Map<string, number>;
64
+ export declare function hopLine(lines: string[], i: number, names: Map<string, number>): string | null;
65
+ export declare const blankStrings: (l: string) => string;
60
66
  export interface Statement {
61
67
  start: number;
62
68
  end: number;
@@ -77,6 +83,35 @@ export interface ScanOptions extends RecordOptions {
77
83
  base: string;
78
84
  lines: Record<string, number[]>;
79
85
  };
86
+ /** Workspace rules from a Lintsure account, handed in by the caller (the plugin downloads them with an API key).
87
+ * The scan never fetches anything; it only hashes what it is given into the policy fingerprint. */
88
+ workspaceRules?: unknown;
80
89
  }
90
+ /** The repo's .lintsure/rules.yml (the Drift Guard's rules), normalized: comments, blank lines and trailing spaces dropped.
91
+ * null when the file isn't there. */
92
+ /** A YAML line without its comment: a # at the start or after a space, outside quotes ("rm # a" keeps its #). Pure. */
93
+ export declare function stripYamlComment(l: string): string;
94
+ /** The policy a scan ran under, as one short code. Same rules and settings give the same code on any machine;
95
+ * any change (a rule switched off or re-rated, a framework, an ignore path, show: all, a new rules version) gives a new one.
96
+ * `fingerprint` is the first 8 hex digits of `sha256`, shown as XXXX-XXXX. It names the policy; it doesn't sign anything. */
97
+ export declare function policyFingerprint(p: {
98
+ frameworks: string[];
99
+ rules: {
100
+ id: string;
101
+ severity: string;
102
+ }[];
103
+ rulesOff: string[];
104
+ ignore: string[];
105
+ show?: string;
106
+ repoRules?: string | null;
107
+ workspaceRules?: unknown;
108
+ packs?: string[];
109
+ }): {
110
+ fingerprint: string;
111
+ sha256: string;
112
+ rulesActive: number;
113
+ repoRules: boolean;
114
+ workspaceRules: boolean;
115
+ };
81
116
  export declare function scan(root: string, frameworks?: FrameworkId[], opts?: ScanOptions): Promise<Report>;
82
117
  export declare function toMarkdown(r: Report): string;
package/dist/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // Scout (file walk) + Checker (rules) + Auditor (dedupe, sort) + Officer (outside code).
2
2
  // No network calls anywhere in this package: a test enforces it.
3
- import { readdir, readFile } from "node:fs/promises";
3
+ import { createHash } from "node:crypto";
4
+ import { readdir, readFile, stat } from "node:fs/promises";
4
5
  import { basename, extname, join, relative, sep } from "node:path";
5
6
  import { outsideFor } from "./knowledge/index.js";
6
7
  import { rules } from "./rules/index.js";
@@ -18,8 +19,10 @@ export * from "./guidance.js";
18
19
  export { toAssessmentHtml } from "./assessment.js";
19
20
  export * from "./knowledge/index.js";
20
21
  export { loadPacks, registerPack } from "./packs.js";
21
- import { loadPacks } from "./packs.js";
22
- export const RULES_VERSION = "0.3.10";
22
+ export { checksFor } from "./plan.js";
23
+ import { configPacks, loadPacks, packFrameworks, packsLoaded } from "./packs.js";
24
+ import { buildGraph, declaredEntries, reachOf } from "./reach.js";
25
+ export const RULES_VERSION = "0.3.12";
23
26
  /** Shown with every result, in every interface. Lintsure prepares; people decide. */
24
27
  export const DISCLAIMER = "Lintsure is a readiness tool, not an audit, a certification or legal advice. " +
25
28
  "Its rules reflect our reading of the publicly available text of each framework, and they check code only. " +
@@ -110,7 +113,7 @@ export async function readConfig(root) {
110
113
  for (const id of Object.keys(ruleSet))
111
114
  if (!ruleIds.has(id))
112
115
  problems.push(`rules: no rule called "${id}"`);
113
- const base = { ignore, packsMissing, rules: ruleSet, show, problems };
116
+ const base = { ignore, packsMissing, packs: lists.packs, rules: ruleSet, show, problems };
114
117
  if (emptyFw)
115
118
  return { frameworks: [], skipped: [], ...base };
116
119
  const ids = lists.frameworks;
@@ -121,6 +124,16 @@ export async function readConfig(root) {
121
124
  }
122
125
  // Dependencies, build output and caches: generated code, not code you wrote.
123
126
  // Also other people's code copied in (vendor, third_party): not code you wrote (field test, 139 repos).
127
+ /** The exact change for a finding, when its rule knows one. Pure. */
128
+ function patchFor(r, line, old) {
129
+ if (r.insert)
130
+ return { patch: { line, old: null, text: r.insert } };
131
+ const text = r.patch?.(old);
132
+ return text != null && text !== old ? { patch: { line, old, text } } : {};
133
+ }
134
+ // What a Partial finding can't show. Rules read lines and statements, not how data moves through the program.
135
+ const UNSEEN = "Lintsure reads this code on its own. It can't see where the values come from or whether they're checked elsewhere, so a person needs to look.";
136
+ const UNSEEN_TESTS = "This is in a test, fixture or example file. Lintsure can't tell whether it ships or is a throwaway value.";
124
137
  export const SKIP_DIRS = ["node_modules", ".git", "dist", "build", "out", ".output", ".next", ".nuxt", ".svelte-kit", ".astro", ".vercel", ".netlify", ".wrangler", ".turbo", ".cache", "venv", ".venv", "__pycache__", "coverage", "vendor", "third_party", "bower_components"];
125
138
  const SKIP = new Set(SKIP_DIRS);
126
139
  // Bundled builds of libraries checked into a repo, e.g. vue.global.js (field test, 139 repos).
@@ -190,6 +203,8 @@ export function isNonShipping(file) {
190
203
  }
191
204
  // Rules that also read test files. Not auth.hardcoded-password: test logins are fake by design (field test, 50 repos).
192
205
  const SECRET_RULES = new Set(["secret.in-source"]); // not config.default-secret-key: a test secret is a test value (review P19)
206
+ // Rules that read agent tooling folders on purpose: an agent hook in .claude/ runs on real machines.
207
+ const TOOLING_RULES = new Set(["agent.config-runs-remote-code", "agent.instructions-unsafe", "agent.permissions-allow-all"]);
193
208
  // Lines a person already reviewed. lintsure-ignore and the secret allowlist pragma count only in a comment and apply
194
209
  // to every rule. Other linters' markers (noqa, nosec, NOSONAR) don't hide secrets: `# noqa: E501` is about line length.
195
210
  const REVIEWED = /(#|\/\/|\/\*|--)\s*(lintsure-ignore|pragma:\s*allowlist secret)\b/;
@@ -207,6 +222,64 @@ export function enclosingKey(lines, i) {
207
222
  }
208
223
  return "";
209
224
  }
225
+ // Example code that shows a pattern instead of running it (benchmark "fp" cases, self-scan 2026-11-19): a fenced block
226
+ // in a doc, a value under an example-style key in JSON data. Only secret rules still look, and only for a real-looking key.
227
+ const EXAMPLE_KEY = /^(?:examples?|code|snippets?|samples?|bad|good|before|after|demo|patch|diff|dont|do)$/i;
228
+ const EXAMPLE_KEY_ON_LINE = /"(?:examples?|code|snippets?|samples?|bad|good|before|after|demo|patch|diff|dont|do)"\s*:/i;
229
+ export function exampleLines(lines, ext) {
230
+ if (ext === ".md" || ext === ".mdx") {
231
+ let fence = false;
232
+ return lines.map((l) => { if (/^\s*(```|~~~)/.test(l)) {
233
+ fence = !fence;
234
+ return true;
235
+ } return fence; });
236
+ }
237
+ if (ext === ".json")
238
+ return lines.map((l, i) => EXAMPLE_KEY_ON_LINE.test(l) || EXAMPLE_KEY.test(enclosingKey(lines, i)));
239
+ return lines.map(() => false);
240
+ }
241
+ // Call-sink rules whose match must come from code, not from text inside a '...' or "..." string (a demo diff stored as
242
+ // data). Template literals are left alone: `exec(\`zip ${req.body.f}\`)` is real code.
243
+ // One hop of request data (benchmark "hop" cases): a request value saved in `target`, then `target` passed to a URL call. Variables assigned from
244
+ // the request are found per file, and a later line is reread with the request value written in place. A variable that is
245
+ // checked before use (startsWith, includes, a comparison, a test) is left alone. Hits are Partial: the hop is a guess.
246
+ // shortcut: one assignment hop inside one file, no reassignment or function-argument flow; upgrade to a real data-flow pass if recall stays low.
247
+ const HOP_RULES = new Set(["ssrf.user-url", "redirect.open", "path.user-input"]);
248
+ const REQ_VALUE = /\b(?:req\.(?:body|query|params|headers|cookies)|request\.(?:args|form|json|data|GET|POST|query_params|files)|ctx\.query|event\.(?:body|queryStringParameters)|searchParams\.get)\b/;
249
+ export function taintedNames(lines) {
250
+ const out = new Map();
251
+ lines.forEach((l, i) => {
252
+ if (!REQ_VALUE.test(l) && ![...out.keys()].some((n) => new RegExp(`\\b${n}\\b`).test(l.split("=").slice(1).join("="))))
253
+ return;
254
+ const m = l.match(/^\s*(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::[^=]+)?=(?!=)/) ?? l.match(/^\s*(\w+)\s*=(?!=)/);
255
+ const d = l.match(/^\s*(?:const|let|var)\s*\{([^}]+)\}\s*=/);
256
+ if (m)
257
+ out.set(m[1], i);
258
+ if (d)
259
+ for (const n of d[1].split(",")) {
260
+ const k = n.split(":").pop().split("=")[0].trim();
261
+ if (/^\w+$/.test(k))
262
+ out.set(k, i);
263
+ }
264
+ });
265
+ return out;
266
+ }
267
+ export function hopLine(lines, i, names) {
268
+ let t = lines[i], changed = false;
269
+ for (const [n, at] of names) {
270
+ if (at >= i || !new RegExp(`\\b${n}\\b`).test(t))
271
+ continue;
272
+ const checked = lines.slice(at + 1, i).some((l) => new RegExp(`\\b${n}\\s*(?:\\.(?:startsWith|endsWith|includes|match|test)\\(|[!=]==?)|\\b(?:allow\\w*|isValid\\w*|is_safe\\w*|validate\\w*)\\(\\s*${n}\\b|\\.(?:has|includes|test)\\(\\s*${n}\\b`).test(l));
273
+ if (checked)
274
+ continue;
275
+ t = t.replace(new RegExp(`(?<![.\\w])${n}\\b`, "g"), "req.query." + n);
276
+ changed = true;
277
+ }
278
+ return changed ? t : null;
279
+ }
280
+ const PROMPT_DOC = /(^|\/)(?:prompts?|personas?|instructions?|system)(?:\/|[._-])|(^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL|SYSTEM|PROMPT)\.mdx?$|\.prompt\.mdx?$|(^|\/)\.(?:github|cursor|claude)\//i;
281
+ const SINK_RULES = new Set(["path.user-input", "ssrf.user-url", "redirect.open", "code.eval", "cmd.shell-built", "deserialize.unsafe"]);
282
+ export const blankStrings = (l) => l.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, (m) => m[0] + m[0]);
210
283
  const HASH_COMMENTS = new Set([".py", ".rb", ".sh", ".yml", ".yaml", ".toml", ".env"]);
211
284
  const C_LIKE = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".java", ".kt", ".swift", ".go", ".css", ".scss"]);
212
285
  // Statement window (review step A): formatters split one call over several lines, and a rule that reads one line
@@ -219,7 +292,9 @@ const JOIN_RULES = new Set(["pii.logged", "pii.to-analytics", "log.injection", "
219
292
  "ssrf.user-url", "path.user-input", "redirect.open", "nosql.operator-input", "template.user-string", "error.stack-to-client",
220
293
  // Narrow call-plus-value patterns, where unrelated parts of a statement rarely complete a match.
221
294
  "transport.plain-http", "transport.tls-verify-off", "jwt.unverified", "crypto.weak-cipher", "fs.world-writable",
222
- "mobile.token-in-plain-storage", "config.debug-on", "cookie.trusted-role"]);
295
+ "mobile.token-in-plain-storage", "config.debug-on", "cookie.trusted-role", "code.eval",
296
+ // Added with rules/more.ts: call-plus-argument shapes, measured on the robustness check only (not yet on the 139 repos).
297
+ "authz.no-owner-check", "jwt.weak-secret", "jwt.no-algorithm-pin", "proto.pollution"]);
223
298
  const MAX_JOIN_LINES = 25, MAX_JOIN_CHARS = 2000;
224
299
  /** Groups lines into statements: lines join while a ( or [ or a template literal is open. Joining stops at a function
225
300
  * body (`=> {`, `) {`), so a handler passed as an argument stays line by line. `prose` marks a multi-line template
@@ -319,9 +394,66 @@ export function commentLines(lines, ext) {
319
394
  return t.startsWith("//") || (C_LIKE.has(ext) && t.startsWith("*")) || t.startsWith("<!--") || (hash && t.startsWith("#")) || (sql && t.startsWith("--"));
320
395
  });
321
396
  }
397
+ /** The repo's .lintsure/rules.yml (the Drift Guard's rules), normalized: comments, blank lines and trailing spaces dropped.
398
+ * null when the file isn't there. */
399
+ /** A YAML line without its comment: a # at the start or after a space, outside quotes ("rm # a" keeps its #). Pure. */
400
+ export function stripYamlComment(l) {
401
+ let q = "";
402
+ for (let i = 0; i < l.length; i++) {
403
+ const c = l[i];
404
+ if (q) {
405
+ if (c === q)
406
+ q = "";
407
+ continue;
408
+ }
409
+ if (c === '"' || c === "'")
410
+ q = c;
411
+ else if (c === "#" && (i === 0 || /\s/.test(l[i - 1])))
412
+ return l.slice(0, i);
413
+ }
414
+ return l;
415
+ }
416
+ async function readRepoRules(root) {
417
+ try {
418
+ const text = await readFile(join(root, ".lintsure", "rules.yml"), "utf8");
419
+ return text.split(/\r?\n/).map((l) => stripYamlComment(l).trimEnd()).filter((l) => l.trim()).join("\n");
420
+ }
421
+ catch {
422
+ return null;
423
+ }
424
+ }
425
+ /** JSON with object keys sorted at every level, so the same data always hashes the same. */
426
+ const stable = (v) => Array.isArray(v) ? `[${v.map(stable).join(",")}]`
427
+ : v && typeof v === "object" ? `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${stable(v[k])}`).join(",")}}`
428
+ : JSON.stringify(v ?? null);
429
+ /** The policy a scan ran under, as one short code. Same rules and settings give the same code on any machine;
430
+ * any change (a rule switched off or re-rated, a framework, an ignore path, show: all, a new rules version) gives a new one.
431
+ * `fingerprint` is the first 8 hex digits of `sha256`, shown as XXXX-XXXX. It names the policy; it doesn't sign anything. */
432
+ export function policyFingerprint(p) {
433
+ const canon = JSON.stringify({
434
+ rulesVersion: RULES_VERSION,
435
+ frameworks: [...p.frameworks].sort(),
436
+ rules: [...p.rules].sort((a, b) => a.id.localeCompare(b.id)).map((r) => `${r.id}:${r.severity}`),
437
+ rulesOff: [...p.rulesOff].sort(),
438
+ ignore: [...p.ignore].sort(),
439
+ show: p.show ?? "default",
440
+ // Installed rule packs and their versions. Left out when none, so codes from before packs existed stay the same.
441
+ ...(p.packs?.length ? { packs: [...p.packs].sort() } : {}),
442
+ // The Drift Guard's .lintsure/rules.yml, comments and blank lines dropped, so only a real rule change moves the code.
443
+ repoRules: p.repoRules ?? null,
444
+ // Account (workspace) rules, when the caller passed them: key order doesn't matter, content does.
445
+ workspaceRules: p.workspaceRules == null ? null : stable(p.workspaceRules),
446
+ });
447
+ const sha256 = createHash("sha256").update(canon).digest("hex");
448
+ return { fingerprint: `${sha256.slice(0, 4)}-${sha256.slice(4, 8)}`.toUpperCase(), sha256, rulesActive: p.rules.length, repoRules: p.repoRules != null, workspaceRules: p.workspaceRules != null };
449
+ }
322
450
  export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
323
451
  const config = await readConfig(root);
324
452
  const { ignore } = config;
453
+ // Packs are registered for the whole process; this scan uses only the ones its own config lists.
454
+ const ownPacks = new Set(config.packs ?? []);
455
+ const usable = (packId) => !configPacks.has(packId) || ownPacks.has(packId);
456
+ frameworks = frameworks.filter((f) => !packFrameworks.has(f) || usable(packFrameworks.get(f)));
325
457
  const rulesOff = Object.keys(config.rules).filter((id) => config.rules[id] === "off");
326
458
  const active = rules.filter((r) => r.controls.some((c) => frameworks.includes(c.framework)) && !rulesOff.includes(r.id));
327
459
  const findings = [];
@@ -338,8 +470,29 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
338
470
  continue;
339
471
  const controls = r.controls.filter((c) => frameworks.includes(c.framework));
340
472
  findings.push({ id: "", ruleId: r.id, file, line: 1, status: r.status, severity: r.severity, title: r.title, controls, fix: r.fix, note: r.note,
341
- proposal: proposalFor({ file, line: 1, title: r.title, fix: r.fix, note: r.note, controls }), fingerprint: fingerprint(r.id, file, "") });
473
+ proposal: proposalFor({ file, line: 1, title: r.title, fix: r.fix, note: r.note, controls }), fingerprint: fingerprint(r.id, file, ""),
474
+ ...(r.status === "partial" ? { unseen: r.unseen ?? UNSEEN } : {}) });
342
475
  }
476
+ // Every file is read once per scan, with one size and binary guard for every reader (code review: files were read up
477
+ // to four times, one at a time). Reads run 32 at a time; null means too big, binary or unreadable.
478
+ const cache = new Map();
479
+ const textOf = (abs) => {
480
+ let t = cache.get(abs);
481
+ if (!t) {
482
+ t = stat(abs).then(async (st) => { if (st.size > MAX_BYTES)
483
+ return null; const b = await readFile(abs); return b.includes(0) ? null : b.toString("utf8"); }).catch(() => null);
484
+ cache.set(abs, t);
485
+ }
486
+ return t;
487
+ };
488
+ // Prefetch only files some reader needs: a rule that applies to it, a shared-file rule, or reachability.
489
+ const needed = all.filter((abs, k) => {
490
+ const ext = extOf(abs), name = basename(abs), file = paths[k];
491
+ return /\.(m|c)?[jt]sx?$|\.html?$|(^|\/)(package|tsconfig)\.json$/.test(file) || active.some((r) => r.sharedFiles?.test(file)
492
+ || (r.extensions.includes(ext) && (!r.fileName || r.fileName.test(name)) && (!r.pathMatch || r.pathMatch.test(file)) && !r.unlessPath?.test(file)));
493
+ });
494
+ for (let i = 0; i < needed.length; i += 32)
495
+ await Promise.all(needed.slice(i, i + 32).map(textOf));
343
496
  // Rules that look across files get the joined text of every file they read, read once up front.
344
497
  const shared = new Map();
345
498
  for (const r of active.filter((x) => x.sharedContext)) {
@@ -348,7 +501,7 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
348
501
  const ext = extOf(abs), file = paths[k];
349
502
  if (!r.extensions.includes(ext) || (r.fileName && !r.fileName.test(basename(abs))) || (r.pathMatch && !r.pathMatch.test(file)) || r.unlessPath?.test(file))
350
503
  continue;
351
- const text = await readFile(abs, "utf8").catch(() => "");
504
+ const text = (await textOf(abs)) ?? "";
352
505
  // Commented-out lines don't count: "-- alter table x enable row level security" switches nothing on.
353
506
  const comment = commentLines(text.split(/\r?\n/), ext);
354
507
  texts.push(text.split(/\r?\n/).filter((_, i) => !comment[i]).join("\n"));
@@ -361,7 +514,7 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
361
514
  const files = {};
362
515
  for (const [k, abs] of all.entries())
363
516
  if (r.sharedFiles.test(paths[k]))
364
- files[paths[k]] = await readFile(abs, "utf8").catch(() => "");
517
+ files[paths[k]] = (await textOf(abs)) ?? "";
365
518
  sharedFiles.set(r.id, files);
366
519
  }
367
520
  for (const abs of all) {
@@ -371,10 +524,10 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
371
524
  const relevant = active.filter((r) => r.extensions.includes(ext) && (!r.fileName || r.fileName.test(name)) && (!r.pathMatch || r.pathMatch.test(file)) && !r.unlessPath?.test(file));
372
525
  if (!relevant.length)
373
526
  continue;
374
- const buf = await readFile(abs);
375
- if (buf.length > MAX_BYTES || buf.includes(0))
376
- continue; // skip big or binary files
377
- const raw = buf.toString("utf8").split(/\r?\n/);
527
+ const whole = await textOf(abs);
528
+ if (whole === null)
529
+ continue; // big, binary or unreadable
530
+ const raw = whole.split(/\r?\n/);
378
531
  if (isMinified(raw))
379
532
  continue; // minified or generated
380
533
  // A single very long line (a data URL, a long prompt) is ignored on its own; the rest of the file is still read.
@@ -386,6 +539,8 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
386
539
  id: "", ruleId: r.id, file, line, status, severity: r.severity, title: r.title, controls, fix: r.fix, note: r.note,
387
540
  proposal: proposalFor({ file, line, title: r.title, fix: r.fix, note: r.note, controls }),
388
541
  fingerprint: fingerprint(r.id, file, lines[line - 1] ?? ""),
542
+ ...(status === "partial" ? { unseen: inTests && !TOOLING_RULES.has(r.id) ? UNSEEN_TESTS : r.unseen ?? UNSEEN } : {}),
543
+ ...patchFor(r, line, lines[line - 1] ?? ""),
389
544
  });
390
545
  };
391
546
  // Tests, fixtures, examples and docs are full of fake tokens and planted examples: only secret rules look at them,
@@ -393,7 +548,8 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
393
548
  const inTests = isNonShipping(file);
394
549
  if (inTests)
395
550
  nonShipping++;
396
- const comment = commentLines(lines, ext);
551
+ const comment = commentLines(lines, ext), example = exampleLines(lines, ext);
552
+ let tainted;
397
553
  // Statements are worked out once per file, on lines with comments blanked.
398
554
  const stmts = JOINABLE.has(ext) ? statements(lines.map((l, i) => (comment[i] ? "" : l)), ext === ".py") : [];
399
555
  const multi = stmts.filter((s) => s.end > s.start);
@@ -403,8 +559,11 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
403
559
  for (let i = s.start; i <= s.end; i++)
404
560
  prose[i] = true;
405
561
  for (const r of relevant) {
562
+ // A markdown page that explains the rule quotes the bad prompt; only prompt files hold real prompts.
563
+ if (r.id === "ai.hides-being-ai" && (ext === ".md" || ext === ".mdx") && !PROMPT_DOC.test(file))
564
+ continue;
406
565
  const secret = SECRET_RULES.has(r.id);
407
- if (inTests && !secret)
566
+ if (inTests && !secret && !TOOLING_RULES.has(r.id))
408
567
  continue;
409
568
  // Count only what actually ran: a file skipped as a test is not a check point (review P1).
410
569
  ran++;
@@ -420,19 +579,30 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
420
579
  lines.forEach((text, i) => {
421
580
  if (skip?.[i] || (prose[i] && !readsText))
422
581
  return;
423
- const hit = r.test(text);
582
+ if (example[i] && !(secret && !PLACEHOLDER.test(text)))
583
+ return;
584
+ let hit = r.test(text), probe = text;
585
+ if (!hit && HOP_RULES.has(r.id)) {
586
+ const h = hopLine(lines, i, (tainted ??= taintedNames(lines)));
587
+ if (h && r.test(h)) {
588
+ hit = "partial";
589
+ probe = h;
590
+ }
591
+ }
592
+ if (hit && SINK_RULES.has(r.id) && !r.test(blankStrings(probe)))
593
+ return;
424
594
  if (!hit || (r.unlessNear && lines.slice(Math.max(0, i - 8), i + 4).some((l) => r.unlessNear.test(l))))
425
595
  return;
426
596
  if (r.unlessInKey && r.unlessInKey.test(enclosingKey(lines, i)))
427
597
  return;
428
- if (inTests && PLACEHOLDER.test(text))
598
+ if (inTests && secret && PLACEHOLDER.test(text))
429
599
  return; // password="test_password", token="xoxb-test-..."
430
600
  if (inTests && /PRIVATE KEY/.test(text))
431
601
  return; // test keys and certificates are fixtures by design (review P24)
432
602
  if (REVIEWED.test(text) || (!secret && OTHER_LINTER.test(text)))
433
603
  return; // someone already looked at this line and marked it
434
604
  hitLines.add(i);
435
- add(r, i + 1, hit === "partial" || inTests ? "partial" : r.status);
605
+ add(r, i + 1, hit === "partial" || (inTests && !TOOLING_RULES.has(r.id)) ? "partial" : r.status);
436
606
  });
437
607
  // A statement spread over several lines: test it as one, and report it only when no single line already did,
438
608
  // so line-by-line results never shrink (review step A).
@@ -455,7 +625,7 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
455
625
  continue;
456
626
  if (lines.slice(s.start, s.end + 1).some((l) => REVIEWED.test(l) || OTHER_LINTER.test(l)))
457
627
  continue;
458
- add(r, s.start + 1, hit === "partial" || inTests ? "partial" : r.status);
628
+ add(r, s.start + 1, hit === "partial" || (inTests && !TOOLING_RULES.has(r.id)) ? "partial" : r.status);
459
629
  }
460
630
  // File rules see comment lines as blank, so "<img> in a comment" or a commented-out call doesn't count (field test).
461
631
  if (r.fileTest)
@@ -469,6 +639,39 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
469
639
  const seen = new Set();
470
640
  const unique = findings.filter((f) => { const k = `${f.ruleId}|${f.file}|${f.line}`; return seen.has(k) ? false : (seen.add(k), true); })
471
641
  .sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.ruleId.localeCompare(b.ruleId));
642
+ // Reachability for findings in JS/TS: read the project's own JS/TS files once (skipping very large ones) and follow
643
+ // imports back to entry points. It adds context; it doesn't change any status.
644
+ const JSTS = /\.(m|c)?[jt]sx?$/;
645
+ if (unique.some((f) => JSTS.test(f.file))) {
646
+ const code = {};
647
+ for (const [k, abs] of all.entries())
648
+ if (JSTS.test(paths[k]) && !/\.d\.ts$/.test(paths[k])) {
649
+ const t = (await textOf(abs)) ?? "";
650
+ if (t.length < 500_000)
651
+ code[paths[k]] = t;
652
+ }
653
+ const dirOf = (p) => (p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : "");
654
+ const tsconfigs = {};
655
+ for (const [k, abs] of all.entries())
656
+ if (/(^|\/)tsconfig\.json$/.test(paths[k]))
657
+ tsconfigs[dirOf(paths[k])] = (await textOf(abs)) ?? "";
658
+ const pkgDirs = paths.filter((p) => /(^|\/)package\.json$/.test(p)).map(dirOf);
659
+ // Entry points no code imports: package.json main/bin/exports and <script src> in HTML pages.
660
+ const pkgs = {}, html = {};
661
+ for (const [k, abs] of all.entries()) {
662
+ if (/(^|\/)package\.json$/.test(paths[k]))
663
+ pkgs[paths[k]] = (await textOf(abs)) ?? "";
664
+ else if (/\.html?$/.test(paths[k])) {
665
+ const t = (await textOf(abs)) ?? "";
666
+ if (t.length < 500_000)
667
+ html[paths[k]] = t;
668
+ }
669
+ }
670
+ const graph = buildGraph(code, tsconfigs, pkgDirs.length ? pkgDirs : [""], declaredEntries(pkgs, html, new Set(Object.keys(code))));
671
+ for (const f of unique)
672
+ if (JSTS.test(f.file))
673
+ f.reach = reachOf(graph, f.file);
674
+ }
472
675
  // A rule that fired still counts as checked (not Met) even when its findings are held back or outside the diff.
473
676
  const hit = new Set(unique.map((f) => f.ruleId));
474
677
  for (const f of unique) {
@@ -489,6 +692,11 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
489
692
  const report = await applyReview({
490
693
  rulesVersion: RULES_VERSION,
491
694
  frameworks: [...frameworks].sort(),
695
+ policy: policyFingerprint({
696
+ frameworks, rulesOff, ignore, show: opts.all ? "all" : config.show, repoRules: await readRepoRules(root), workspaceRules: opts.workspaceRules,
697
+ packs: packsLoaded.filter((p) => usable(p.slice(0, p.lastIndexOf("@")))),
698
+ rules: active.map((r) => ({ id: r.id, severity: (config.rules[r.id] && config.rules[r.id] !== "off" ? config.rules[r.id] : r.severity) })),
699
+ }),
492
700
  findings: deduped,
493
701
  // Only the Checker sets Met: a rule that read at least one file and found nothing. A rule with nothing to read
494
702
  // (mobile rules in a web app) is not Met: nothing was checked.
@@ -504,7 +712,7 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
504
712
  ...(held ? [`${held} medium-confidence finding${held === 1 ? " was" : "s were"} held back. Run with --all to see ${held === 1 ? "it" : "them"}.`] : []),
505
713
  ...(rulesOff.length ? [`Switched off in lintsure.config.yaml: ${rulesOff.join(", ")}.`] : []),
506
714
  ...(ignore.length ? [`Ignored by config: ${ignore.join(", ")}.`] : []),
507
- ...(nonShipping ? [`${nonShipping} test, fixture or tooling file${nonShipping === 1 ? " was" : "s were"} checked for secrets only.`] : []),
715
+ ...(nonShipping ? [`${nonShipping} test, fixture or tooling file${nonShipping === 1 ? " was" : "s were"} checked only for secrets and agent hooks.`] : []),
508
716
  "Each rule reads one file at a time. Data that flows between files, and how the app behaves when it runs, are not checked.",
509
717
  "Languages beyond JavaScript, TypeScript and Python get secret and config checks only.",
510
718
  ],
@@ -545,7 +753,7 @@ function recordLines(r) {
545
753
  export function toMarkdown(r) {
546
754
  const lines = [
547
755
  "# Lintsure report", "",
548
- `Frameworks: ${r.frameworks.join(", ")} · Rules v${r.rulesVersion}`, "",
756
+ `Frameworks: ${r.frameworks.join(", ")} · Rules v${r.rulesVersion}${r.policy ? ` · Policy #${r.policy.fingerprint} (${r.policy.rulesActive} rules active${r.policy.repoRules ? " + .lintsure/rules.yml" : ""}${r.policy.workspaceRules ? " + workspace rules" : ""})` : ""}`, "",
549
757
  `> ${DISCLAIMER}`, "",
550
758
  ...recordLines(r),
551
759
  `## Findings (${r.findings.length})`, "",
@@ -557,7 +765,8 @@ export function toMarkdown(r) {
557
765
  // Fix first: Gaps before Partials, then by severity; file order within each group.
558
766
  const rank = (f) => (f.status === "gap" ? 0 : 3) + { high: 0, medium: 1, low: 2 }[f.severity];
559
767
  for (const f of [...r.findings].sort((a, b) => rank(a) - rank(b)))
560
- lines.push(`### ${f.id} · ${f.status === "gap" ? "Finding" : "Observation"} (${LABEL[f.status]}) · \`${f.file}:${f.line}\`${f.change === "new" ? " · New since baseline" : ""}`, `**${f.title}** · Risk level: ${f.severity}`, "", ...(f.accepted ? [acceptedLine(f.accepted), ""] : []), `- Rules: ${ctl(f.controls)}`, `- Auditor note: ${f.note}`, "", `**${PROPOSAL_HEADING}**`, "", `- Where: \`${f.proposal.where}\``, `- What: ${f.proposal.what}`, `- Why: ${f.proposal.why}`, `- Benefit: ${f.proposal.benefit}`, "");
768
+ lines.push(`### ${f.id} · ${f.status === "gap" ? "Finding" : "Observation"} (${LABEL[f.status]}) · \`${f.file}:${f.line}\`${f.change === "new" ? " · New since baseline" : ""}`, `**${f.title}** · Risk level: ${f.severity}`, "", ...(f.accepted ? [acceptedLine(f.accepted), ""] : []), `- Rules: ${ctl(f.controls)}`, `- Auditor note: ${f.note}`, ...(f.unseen ? [`- What Lintsure couldn't see: ${f.unseen}`] : []), ...(rules.find((x) => x.id === f.ruleId)?.seenIn ?? []).map((s) => `- Seen in a real incident: ${s.title} (${s.url})`), ...(f.reach ? [`- Reached from: ${f.reach.status === "entry" ? "this file is an entry point (route, handler or function)" : f.reach.status === "reachable" ? f.reach.via.join(" → ") : f.reach.status === "unknown" ? "unknown (an import Lintsure couldn't resolve may lead here)" : "not reached from any entry point Lintsure recognises (it may be loaded some other way, or be unused)"}`] : []), "", `**${PROPOSAL_HEADING}**`, "", `- Where: \`${f.proposal.where}\``, `- What: ${f.proposal.what}`, `- Why: ${f.proposal.why}`, `- Benefit: ${f.proposal.benefit}`, "", ...(f.patch ? [`Exact change (still needs your approval), line ${f.patch.line}:`, "", "```diff",
769
+ ...(f.patch.old != null ? [`- ${f.patch.old}`] : []), ...f.patch.text.replace(/\n$/, "").split("\n").map((t) => `+ ${t}`), "```", ""] : []));
561
770
  if (r.baseline?.fixed.length)
562
771
  lines.push(`## Fixed since baseline (${r.baseline.fixed.length})`, "", ...r.baseline.fixed.map((x) => `- ${x.ruleId} in \`${x.file}\``), "");
563
772
  lines.push(`## Met (${r.met.length})`, "", ...r.met.map((m) => `- ${m.title} · ${ctl(m.controls)}`), "");
@@ -17,7 +17,7 @@ export const cra = {
17
17
  ],
18
18
  obligations: [
19
19
  { ref: "Annex I Part I (2)(b)", title: "Secure by default configuration", inCode: "partly",
20
- rules: ["config.debug-on", "config.allowed-hosts-any", "config.default-secret-key", "cors.any-origin", "build.sourcemaps-public", "csrf.disabled", "session.cookie-insecure"],
20
+ rules: ["config.debug-on", "config.allowed-hosts-any", "config.default-secret-key", "cors.any-origin", "build.sourcemaps-public", "release.env-not-ignored", "csrf.disabled", "session.cookie-insecure"],
21
21
  plain: "The product ships with safe settings switched on: debug off, real host names, strong secrets, secure cookies, nothing left open that the user has to close.",
22
22
  evidence: "Production configuration and the default settings a new install starts with." },
23
23
  { ref: "Annex I Part I (2)(d)", title: "Protection from unauthorised access", inCode: "partly",
@@ -10,22 +10,22 @@ export const owaspLlm = {
10
10
  return null;
11
11
  },
12
12
  obligations: [
13
- { ref: "LLM01:2026", title: "Prompt Injection", inCode: "partly", rules: ["llm.user-input-in-system-prompt"],
13
+ { ref: "LLM01:2026", title: "Prompt Injection", inCode: "partly", rules: ["llm.user-input-in-system-prompt", "agent.instructions-unsafe", "llm.client-controls-system"],
14
14
  plain: "User text, web pages or files can carry instructions that change what the model does. Keep instructions and user content apart, and limit what the model can do.",
15
15
  evidence: "How prompts are built, and tests with hostile input." },
16
16
  { ref: "LLM02:2026", title: "Sensitive Information Disclosure", inCode: "partly", rules: ["secret.in-source", "secret.public-env", "pii.logged", "log.secret"],
17
17
  plain: "Keys, personal data and internal details must not reach the model, its logs or its answers unless they're meant to.",
18
18
  evidence: "What data is sent to the model provider, and the provider's data retention terms." },
19
- { ref: "LLM03:2026", title: "Excessive Agency", inCode: "no",
19
+ { ref: "LLM03:2026", title: "Excessive Agency", inCode: "partly", rules: ["agent.permissions-allow-all"],
20
20
  plain: "Tools and permissions given to an agent should be the minimum it needs, with a person approving anything risky.",
21
21
  evidence: "A list of the tools each agent can call and which need approval." },
22
- { ref: "LLM04:2026", title: "Supply Chain", inCode: "partly", rules: ["deps.unpinned-version", "deps.install-script"],
22
+ { ref: "LLM04:2026", title: "Supply Chain", inCode: "partly", rules: ["deps.unpinned-version", "deps.install-script", "agent.config-runs-remote-code"],
23
23
  plain: "Models, datasets, plugins and packages come from others. Pin and check them like any dependency.",
24
24
  evidence: "Where each model and dataset comes from, and its licence." },
25
25
  { ref: "LLM05:2026", title: "Data and Model Poisoning", inCode: "no",
26
26
  plain: "Training, fine-tuning or retrieval data can be tampered with to change the model's behaviour.",
27
27
  evidence: "Data sources, who can change them, and checks on new data." },
28
- { ref: "LLM06:2026", title: "Unbounded Consumption", inCode: "partly", rules: ["llm.no-output-limit", "ai.call-not-logged"],
28
+ { ref: "LLM06:2026", title: "Unbounded Consumption", inCode: "partly", rules: ["llm.no-output-limit", "ai.call-not-logged", "llm.unbounded-agent-loop"],
29
29
  plain: "Limit output size, request rate and cost per user, so one person can't run up a bill or take the service down.",
30
30
  evidence: "Rate limits, spending alerts and usage monitoring." },
31
31
  { ref: "LLM07:2026", title: "Misinformation", inCode: "no",
@@ -56,7 +56,7 @@ export const cweTop25 = {
56
56
  { ref: "CWE-22, CWE-434", title: "Path traversal and dangerous uploads", inCode: "yes", rules: ["path.user-input", "upload.unrestricted"], plain: "File paths and uploads are limited to what's expected." },
57
57
  { ref: "CWE-502, CWE-20", title: "Unsafe deserialization and input validation", inCode: "partly", rules: ["deserialize.unsafe", "nosql.operator-input", "mass-assignment"], plain: "Untrusted data is validated and never turned back into objects unsafely." },
58
58
  { ref: "CWE-918", title: "Server-side request forgery", inCode: "yes", rules: ["ssrf.user-url"], plain: "The server doesn't fetch any address a user picks." },
59
- { ref: "CWE-200", title: "Exposure of sensitive information", inCode: "partly", rules: ["pii.logged", "pii.in-url", "log.secret", "error.stack-to-client", "build.sourcemaps-public", "secret.public-env"], plain: "Personal data, secrets and internals don't leak into logs, URLs, errors or the browser." },
59
+ { ref: "CWE-200", title: "Exposure of sensitive information", inCode: "partly", rules: ["pii.logged", "pii.in-url", "log.secret", "error.stack-to-client", "build.sourcemaps-public", "secret.public-env", "release.env-not-ignored"], plain: "Personal data, secrets and internals don't leak into logs, URLs, errors or the browser." },
60
60
  { ref: "CWE-770", title: "Resources without limits", inCode: "partly", rules: ["llm.no-output-limit"], plain: "Expensive work, including AI calls, has limits.", evidence: "Rate limits and quotas." },
61
61
  { ref: "CWE-306", title: "Missing authentication for a critical function", inCode: "no", plain: "Every sensitive endpoint requires a signed-in user. Needs a route-by-route review.", evidence: "A list of endpoints and their authentication." },
62
62
  { ref: "CWE-787, 416, 125, 120, 476, 121, 122", title: "Memory safety", inCode: "no", plain: "Buffer and pointer errors in C and C++. Lintsure doesn't check these languages; use a memory-safe language or a dedicated tool.", evidence: "Results from a C/C++ analyser or fuzzing." },
@@ -16,28 +16,28 @@ export const owaspTop10 = {
16
16
  },
17
17
  obligations: [
18
18
  { ref: "A01:2025", title: "Broken Access Control", inCode: "partly",
19
- rules: ["path.user-input", "redirect.open", "ssrf.user-url", "csrf.disabled", "fs.world-writable", "cors.any-origin", "cookie.trusted-role", "supabase.rls-disabled", "supabase.policy-allows-all", "supabase.service-key-in-client", "supabase.function-no-auth"],
19
+ rules: ["path.user-input", "redirect.open", "ssrf.user-url", "csrf.disabled", "fs.world-writable", "cors.any-origin", "cookie.trusted-role", "supabase.rls-disabled", "supabase.policy-allows-all", "supabase.service-key-in-client", "supabase.function-no-auth", "authz.no-owner-check", "ws.no-origin-check", "cloud.public-bucket"],
20
20
  plain: "People must only reach the data and actions meant for them. This covers file paths, redirects, requests your server makes on a user's behalf (SSRF), forged requests from other sites, and permissions kept where users can change them.",
21
21
  evidence: "A list of roles and what each may do, and tests showing one user can't read or change another user's data." },
22
22
  { ref: "A01:2025 (ownership checks)", title: "Every record is checked against the signed-in user", inCode: "no",
23
23
  plain: "Whether each endpoint checks that the record belongs to the person asking (often called IDOR). A line-by-line code check can't tell; it needs design review and testing with two accounts.",
24
24
  evidence: "Access control tests per role, or a penetration test report." },
25
25
  { ref: "A02:2025", title: "Security Misconfiguration", inCode: "partly",
26
- rules: ["config.debug-on", "config.allowed-hosts-any", "config.default-secret-key", "xml.external-entities", "cors.any-origin", "session.cookie-insecure", "error.stack-to-client", "build.sourcemaps-public"],
26
+ rules: ["config.debug-on", "agent.permissions-allow-all", "config.allowed-hosts-any", "config.default-secret-key", "xml.external-entities", "cors.any-origin", "session.cookie-insecure", "error.stack-to-client", "build.sourcemaps-public", "release.env-not-ignored", "k8s.privileged", "graphql.introspection"],
27
27
  plain: "Safe settings by default: debug off, real host names, strong secret keys, cookies marked secure, XML parsers that don't load outside files, and errors that don't reveal internals.",
28
28
  evidence: "Production configuration and a hardening checklist." },
29
29
  { ref: "A02:2025 (deployed settings)", title: "Server, cloud and header configuration in production", inCode: "no",
30
30
  plain: "What is actually running: server and cloud settings, open ports, default accounts, security headers on real responses. These need a scan of the deployed system.",
31
31
  evidence: "Infrastructure configuration, a header scan and a cloud configuration review." },
32
32
  { ref: "A03:2025", title: "Software Supply Chain Failures", inCode: "partly",
33
- rules: ["deps.unpinned-version", "deps.install-script", "ci.action-unpinned", "ci.prt-checkout-head", "ci.write-all-permissions", "ci.script-injection", "update.unverified-download"],
33
+ rules: ["deps.unpinned-version", "deps.install-script", "agent.config-runs-remote-code", "agent.instructions-unsafe", "ci.action-unpinned", "ci.prt-checkout-head", "ci.write-all-permissions", "ci.script-injection", "update.unverified-download"],
34
34
  plain: "The code you didn't write: dependencies, build tools and CI. Versions should be pinned, install scripts shouldn't fetch code, CI actions should be pinned, untrusted pull requests must not run with your secrets, and text from issues or pull requests must never become part of a CI command.",
35
35
  evidence: "Lockfiles, CI workflow files and the dependency update process." },
36
36
  { ref: "A03:2025 (known vulnerabilities)", title: "Dependencies with known vulnerabilities", inCode: "no",
37
37
  plain: "Whether any dependency version has a published vulnerability, and whether it's maintained. This needs vulnerability advisory data, which Lintsure doesn't download, so use a dependency scanner alongside it.",
38
38
  evidence: "Dependency scanner results (for example npm audit, OSV-Scanner or Dependabot) and how alerts are handled." },
39
39
  { ref: "A04:2025", title: "Cryptographic Failures", inCode: "yes",
40
- rules: ["crypto.weak-password-hash", "crypto.weak-random-token", "crypto.weak-cipher", "jwt.unverified", "transport.plain-http", "transport.tls-verify-off", "secret.in-source", "secret.public-env", "mobile.token-in-plain-storage", "mobile.cleartext-traffic"],
40
+ rules: ["crypto.weak-password-hash", "crypto.weak-random-token", "crypto.weak-cipher", "jwt.unverified", "transport.plain-http", "transport.tls-verify-off", "secret.in-source", "secret.public-env", "mobile.token-in-plain-storage", "mobile.cleartext-traffic", "jwt.weak-secret", "crypto.unsafe-compare"],
41
41
  plain: "Protect data with sound cryptography: HTTPS everywhere, certificate checks on, strong password hashing, modern ciphers, unpredictable tokens, signed tokens that are verified, and no keys in code.",
42
42
  evidence: "Where data is encrypted in transit and at rest, and how keys are stored and rotated." },
43
43
  { ref: "A04:2025 (key management)", title: "Key management and encryption at rest", inCode: "no",
@@ -48,21 +48,21 @@ export const owaspTop10 = {
48
48
  plain: "Keep data and code apart, so input can't become part of a SQL query, a shell command, a template, HTML on the page or code that gets run.",
49
49
  evidence: "Use of parameterised queries, output escaping, and code review practice." },
50
50
  { ref: "A06:2025", title: "Insecure Design", inCode: "partly",
51
- rules: ["upload.unrestricted", "mass-assignment", "pii.in-url", "mobile.webview-any-origin"],
51
+ rules: ["upload.unrestricted", "mass-assignment", "pii.in-url", "mobile.webview-any-origin", "html.tabnabbing"],
52
52
  plain: "Security planned in from the start: limits on uploads, only the fields users may change, sensitive data kept out of URLs. Most of this category is about design, not individual lines.",
53
53
  evidence: "Design notes for sensitive features." },
54
54
  { ref: "A06:2025 (threat modelling)", title: "Threat modelling and abuse cases", inCode: "no",
55
55
  plain: "Thinking through how a feature could be misused before building it: rate limits, business rule abuse, trust boundaries. Code checks can't show whether this happened.",
56
56
  evidence: "Threat models or security design reviews for key features." },
57
57
  { ref: "A07:2025", title: "Authentication Failures", inCode: "partly",
58
- rules: ["auth.hardcoded-password", "jwt.no-expiry", "jwt.unverified", "config.default-secret-key", "session.cookie-insecure", "secret.in-source", "transport.tls-verify-off"],
58
+ rules: ["auth.hardcoded-password", "jwt.no-expiry", "jwt.unverified", "config.default-secret-key", "session.cookie-insecure", "secret.in-source", "transport.tls-verify-off", "auth.no-rate-limit", "jwt.no-algorithm-pin", "jwt.weak-secret"],
59
59
  plain: "Logins and sessions that hold up: no passwords in code, strong secrets, tokens that expire and are verified, and session cookies protected from scripts and plain HTTP.",
60
60
  evidence: "Login, session and token settings." },
61
61
  { ref: "A07:2025 (login protections)", title: "Brute-force protection, MFA and account recovery", inCode: "no",
62
62
  plain: "Rate limiting and lockout on login, multi-factor authentication, and safe password reset flows. These need testing against the running app.",
63
63
  evidence: "Login rate limit settings, MFA options, and password reset flow tests." },
64
64
  { ref: "A08:2025", title: "Software or Data Integrity Failures", inCode: "partly",
65
- rules: ["deserialize.unsafe", "html.script-no-sri", "mass-assignment", "cookie.trusted-role", "ci.prt-checkout-head"],
65
+ rules: ["deserialize.unsafe", "html.script-no-sri", "mass-assignment", "cookie.trusted-role", "ci.prt-checkout-head", "proto.pollution"],
66
66
  plain: "Don't trust code or data you haven't checked: no unsafe deserialisation, integrity checks on third-party scripts, and no trust in values users can change.",
67
67
  evidence: "How third-party scripts are loaded and how incoming data is parsed." },
68
68
  { ref: "A08:2025 (signed releases)", title: "Signed builds and updates", inCode: "no",
@@ -3,11 +3,19 @@ import type { Control, Rule } from "./types.js";
3
3
  export interface Pack {
4
4
  /** Package name, for example "@lintsure/pack-pci-dss". */
5
5
  id: string;
6
+ /** Pack version. Goes into the policy fingerprint, so a pack update gives a new code. */
7
+ version?: string;
6
8
  rules: Rule[];
7
9
  knowledge: FrameworkKnowledge[];
8
10
  /** Controls this pack adds to rules that already exist, by rule id. */
9
11
  forExisting?: Record<string, Control[]>;
10
12
  }
13
+ /** Packs registered in this process, as "id@version", for the policy fingerprint. */
14
+ export declare const packsLoaded: string[];
15
+ /** Which pack added each framework, so a scan only uses the packs its own repo lists (the MCP server scans many repos). */
16
+ export declare const packFrameworks: Map<string, string>;
17
+ /** Packs loaded because some repo's lintsure.config.yaml listed them. Packs registered in code apply to every scan. */
18
+ export declare const configPacks: Set<string>;
11
19
  /** Adds a pack's frameworks, rules and mappings. Loading the same pack twice does nothing. */
12
20
  export declare function registerPack(p: Pack): void;
13
21
  /** Loads packs by name. Returns the names that couldn't be loaded (wrong name or not installed). */