@lintsure/core 0.3.14 → 0.3.16

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/src/index.js CHANGED
@@ -4,10 +4,11 @@ import { createHash } from "node:crypto";
4
4
  import { readdir, readFile, stat } from "node:fs/promises";
5
5
  import { basename, extname, join, relative, sep } from "node:path";
6
6
  import { outsideFor } from "./knowledge/index.js";
7
- import { rules } from "./rules/index.js";
7
+ import { MASKED, rules } from "./rules/index.js";
8
8
  import { proposalFor } from "./guidance.js";
9
9
  import { applyReview, fingerprint, isOpen } from "./review.js";
10
10
  export * from "./review.js";
11
+ export * from "./verify.js";
11
12
  export { toSarif } from "./sarif.js";
12
13
  import { buildRecord } from "./record.js";
13
14
  export * from "./record.js";
@@ -22,7 +23,7 @@ export { loadPacks, registerPack } from "./packs.js";
22
23
  export { checksFor } from "./plan.js";
23
24
  import { configPacks, loadPacks, packFrameworks, packsLoaded } from "./packs.js";
24
25
  import { buildGraph, declaredEntries, reachOf } from "./reach.js";
25
- export const RULES_VERSION = "0.3.14";
26
+ export const RULES_VERSION = "0.3.16";
26
27
  /** Shown with every result, in every interface. Lintsure prepares; people decide. */
27
28
  export const DISCLAIMER = "Lintsure is a readiness tool, not an audit, a certification or legal advice. " +
28
29
  "Its rules reflect our reading of the publicly available text of each framework, and they check code only. " +
@@ -37,15 +38,22 @@ export function nextSteps(r) {
37
38
  const gaps = open.filter((f) => f.status === "gap").length;
38
39
  const partial = open.filter((f) => f.status === "partial").length;
39
40
  const expired = r.findings.filter((f) => f.accepted?.expired).length;
41
+ // The same rule accepted again and again is a setting waiting to be written down.
42
+ const perRule = new Map();
43
+ for (const f of r.findings)
44
+ if (f.accepted && !f.accepted.expired)
45
+ perRule.set(f.ruleId, (perRule.get(f.ruleId) ?? 0) + 1);
46
+ const repeats = [...perRule].filter(([, n]) => n >= 3);
40
47
  return [
41
48
  gaps ? `Review the ${gaps} gap${gaps === 1 ? "" : "s"} and decide how to fix each one. Approve any change before it is made.` : "No gaps were found by the current rules. Keep checking as the code changes.",
42
49
  partial ? `Check the ${partial} partial finding${partial === 1 ? "" : "s"}: each depends on context only you can confirm.` : "",
43
50
  `Work through the ${r.outside.length} item${r.outside.length === 1 ? "" : "s"} that live outside code. Code checks alone are not enough for a full review.`,
51
+ ...repeats.map(([rule, n]) => `You have accepted ${rule} ${n} times. If it never applies to this project, say so once in lintsure.config.yaml (under rules, or an ignore path) and keep the reason there.`),
44
52
  expired ? `${expired} accepted finding${expired === 1 ? " is" : "s are"} past the review date. Look again, then renew the acceptance or fix it.` : "",
45
53
  "Ask a qualified compliance professional to review the results before you rely on them.",
46
54
  ].filter(Boolean);
47
55
  }
48
- export const ALL_FRAMEWORKS = ["gdpr", "eu-ai-act", "owasp-top10", "cra", "owasp-llm", "cwe-top25"];
56
+ export const ALL_FRAMEWORKS = ["gdpr", "eu-ai-act", "owasp-top10", "cra", "owasp-llm", "cwe-top25", "owasp-ast", "owasp-api"];
49
57
  const KEYS = new Set(["frameworks", "ignore", "packs", "rules", "show"]);
50
58
  const RULE_SETTINGS = new Set(["off", "low", "medium", "high"]);
51
59
  export async function readConfig(root) {
@@ -147,8 +155,8 @@ export function extOf(abs) {
147
155
  const name = basename(abs);
148
156
  if (/^\.env(\.[\w.-]+)?$/.test(name))
149
157
  return ".env";
150
- if (/^Dockerfile\b/i.test(name))
151
- return ""; // Dockerfile.prod is still a Dockerfile
158
+ if (/^(Dockerfile|Containerfile)\b|\.Dockerfile$/i.test(name))
159
+ return ""; // Dockerfile.prod, api.Dockerfile and Containerfile are Dockerfiles too
152
160
  const e = extname(abs);
153
161
  return e === ".mts" || e === ".cts" ? ".ts" : e;
154
162
  }
@@ -185,6 +193,11 @@ const NS_FOLDER = /(^|\/)(tests?|__tests__|__mocks__|mocks?|spec|fixtures?|__fix
185
193
  // Dev scripts at the top of a repo (scripts/test-*.mjs, build and seed helpers) and agent tooling (.agents/, .claude/)
186
194
  // don't ship: they were the largest single source of false alarms in the 0.3.9 labelled sample (44 of 242).
187
195
  const TEST_FILE = /(^|\/)__tests__\/|(^|\/)test[-_]?(utils?|helpers?|rig)\/|(^|\/)test-[^/]+\.[cm]?[jt]s$|[._-]tests?\/|\.(test|spec|stories)\.[cm]?[jt]sx?$|(^|\/)test_[^/]+\.py$|_test\.(py|go)$|(^|\/)(conftest\.py|pytest\.ini|tox\.ini)$/i;
196
+ // Files named for what they hold: seed.js, seed-users.ts, demo.ts, mock-data.ts, orders.mock.ts, user.fixture.ts.
197
+ const DEV_FILE = /(^|\/)(seeds?|demo|mocks?)([-_.][\w.-]*)?\.([cm]?[jt]sx?|py)$|\.(mock|fixtures?)\.[cm]?[jt]sx?$/i;
198
+ // Test and fixture folders. Agent-tooling rules read .claude/ and .agents/ on purpose, but a hostile SKILL.md kept as a
199
+ // test fixture is a test input, not an instruction anyone's agent loads.
200
+ const TEST_PATH = /(^|\/)(tests?|__tests__|fixtures?|__fixtures__|e2e|testdata|test-data)\//i;
188
201
  /** True for code that doesn't ship: tests, fixtures, examples, docs, stories and seed data. A folder name only counts
189
202
  * when it comes before any app or route root in the path: examples/site/app/page.tsx is an example, while
190
203
  * app/api/demo/route.ts and src/samples/handler.ts are live code. Pure. */
@@ -192,8 +205,10 @@ export function isNonShipping(file) {
192
205
  if (TEST_FILE.test(file))
193
206
  return true;
194
207
  // Shell scripts in scripts/ are often the installer people run (curl ... | sh): those still count.
195
- if (/\.(sh|bash|zsh|ps1)$/i.test(file) && !/(^|\/)(tests?|__tests__|e2e|fixtures?|examples?|demos?)\//i.test(file))
208
+ if (/\.(sh|bash|zsh|ps1)$/i.test(file) && !/(^|\/)(tests?|__tests__|e2e|fixtures?|examples?|demos?|\.devcontainer)\//i.test(file))
196
209
  return false;
210
+ // In a monorepo, apps/api/ or packages/app/ is a package that happens to share a route folder's name, not a route root.
211
+ file = file.replace(/(^|\/)(apps|packages|services)\/(app|api|pages|routes)\//g, "$1$2/_/");
197
212
  const live = LIVE_ROOT.exec(file), ns = NS_FOLDER.exec(file);
198
213
  if (!live || (ns && ns.index < live.index))
199
214
  return NON_SHIPPING.test(file);
@@ -201,16 +216,105 @@ export function isNonShipping(file) {
201
216
  if (/^(app|pages|api|routes|supabase\/functions)$/.test(live[2]))
202
217
  return false;
203
218
  // Under src/, lib/ or server/, test folders are still tests; example, demo, docs and sample folders are app code.
204
- return /(^|\/)(tests?|__tests__|__mocks__|mocks?|spec|fixtures?|__fixtures__|e2e|seeds?|seeders|factories|stories|storybook)\//i.test(file.slice(live.index));
219
+ // Dev scripts kept inside the app folder (server/scripts/reset_admin_password.py) and files named for seed, demo
220
+ // or mock data don't ship either (0.3.14 review: 3 false alarms, no real finding in such a file).
221
+ const rest = file.slice(live.index);
222
+ return /(^|\/)(tests?|__tests__|__mocks__|mocks?|spec|fixtures?|__fixtures__|e2e|seeds?|seeders|factories|stories|storybook|scripts?)\//i.test(rest) || DEV_FILE.test(rest);
205
223
  }
206
224
  // Rules that also read test files. Not auth.hardcoded-password: test logins are fake by design (field test, 50 repos).
207
225
  const SECRET_RULES = new Set(["secret.in-source"]); // not config.default-secret-key: a test secret is a test value (review P19)
208
226
  // Rules that read agent tooling folders on purpose: an agent hook in .claude/ runs on real machines.
209
- const TOOLING_RULES = new Set(["agent.config-runs-remote-code", "agent.instructions-unsafe", "agent.permissions-allow-all"]);
227
+ // Settings that sit in the branch that only runs outside production (`if IS_PRODUCTION: ... else:`, `if (!isProduction) {`)
228
+ // are dev settings (0.3.14 review: 2 of 2). Only for rules about a setting, where the branch decides what ships.
229
+ // pii.logged too: a sign-in code or an email printed only when a dev flag is set never reaches production logs
230
+ // (workspace scan 2026-11-23: `if (env.APP_DEV === "1") console.log(...)`).
231
+ const DEV_BRANCH_RULES = new Set(["config.allowed-hosts-any", "cors.any-origin", "pii.logged"]);
232
+ // A condition that is only true in development: isDev, DEBUG, NODE_ENV === "development", or a flag such as APP_DEV === "1".
233
+ const DEV_CONDITION = /(?<!!\s*)(?<!\bnot\s)\b(is_?dev\w*|DEBUG)\b|===?\s*["']development["']|\b\w*_DEV(_MODE)?\s*===?\s*["']?(1|true)\b/;
234
+ /** True when line i sits inside a branch taken only outside production. Reads indentation, up to 30 lines back. Pure. */
235
+ export function inDevBranch(lines, i) {
236
+ const indent = (l) => l.search(/\S/);
237
+ const opens = /^\s*(\}\s*else\s+)?(if|elif)\b/;
238
+ const negated = (l) => /!\s*[\w.]*prod|\bnot\s+[\w.]*prod|!==?\s*["']production["']/i.test(l);
239
+ // The whole branch on one line: `if (env.APP_DEV === "1") { console.log(...) }`.
240
+ if (opens.test(lines[i]) && DEV_CONDITION.test(lines[i]))
241
+ return true;
242
+ let level = indent(lines[i]);
243
+ for (let k = i - 1; k >= Math.max(0, i - 30) && level > 0; k--) {
244
+ const at = indent(lines[k]);
245
+ if (at < 0 || at >= level)
246
+ continue;
247
+ level = at;
248
+ if (/^\s*(\}\s*)?else\s*[:{]?\s*$/.test(lines[k])) { // a plain else: its `if` is the nearest opener above at the same indent
249
+ const open = lines.slice(Math.max(0, k - 30), k).reverse().find((x) => indent(x) === at && opens.test(x));
250
+ if (open && /\b(is_?prod(uction)?|production)\b/i.test(open) && !negated(open))
251
+ return true;
252
+ }
253
+ else if (opens.test(lines[k]) && (negated(lines[k]) || DEV_CONDITION.test(lines[k])))
254
+ return true;
255
+ }
256
+ return false;
257
+ }
258
+ /** Names of functions in this file that wrap a masking call: `def _refusal(email): return pseudonym(email)`. A value logged
259
+ * through one is masked too (0.3.14 review). Pure.
260
+ * shortcut: reads the 12 lines after the definition, not the real function body; parse the body if that misleads. */
261
+ export function localMaskers(lines) {
262
+ return lines.flatMap((l, i) => {
263
+ const m = /^\s*(?:export\s+)?(?:async\s+)?(?:def|function)\s+(\w+)\s*\(|^\s*(?:export\s+)?const\s+(\w+)\s*=\s*(?:async\s*)?\(/.exec(l);
264
+ return m && lines.slice(i + 1, i + 13).some((x) => MASKED.test(x)) ? [m[1] ?? m[2]] : [];
265
+ });
266
+ }
267
+ /** The names a file imports, with the project file each comes from: JS/TS `import { a as b } from "./x"` and
268
+ * `const { a } = require("./x")`, Python `from pkg.mod import a as b`. Packages and unresolved paths are left out. Pure.
269
+ * shortcut: relative paths, "@/" as src/ or the root, and Python modules by path ending; tsconfig aliases are not read here. */
270
+ export function importedNames(file, text, files, byEnding) {
271
+ const dir = file.includes("/") ? file.slice(0, file.lastIndexOf("/")) : "";
272
+ const norm = (p) => { const out = []; for (const s of p.split("/")) {
273
+ if (s === "..")
274
+ out.pop();
275
+ else if (s && s !== ".")
276
+ out.push(s);
277
+ } return out.join("/"); };
278
+ const names = (list, sep) => list.split(",").map((x) => x.trim().replace(/^type\s+/, "")).filter(Boolean).map((x) => { const [name, local] = x.split(sep).map((y) => y.trim()); return { name, local: local ?? name }; });
279
+ const out = [];
280
+ if (/\.py$/.test(file)) {
281
+ for (const m of text.matchAll(/^[ \t]*from[ \t]+(\.*)([\w.]*)[ \t]+import[ \t]+(?:\(([^)]*)\)|([^#\n]+))/gm)) {
282
+ const mod = m[2].split(".").filter(Boolean).join("/");
283
+ const base = m[1] ? norm(`${dir}/${"../".repeat(m[1].length - 1)}${mod}`) : mod;
284
+ if (!base)
285
+ continue;
286
+ const ends = [`${base}.py`, `${base}/__init__.py`];
287
+ const find = byEnding ?? ((e) => { for (const f of files)
288
+ if (f === e || f.endsWith("/" + e))
289
+ return f; return undefined; });
290
+ const from = m[1] ? ends.find((e) => files.has(e)) : ends.map(find).find(Boolean);
291
+ if (from)
292
+ for (const n of names(m[3] ?? m[4], /\s+as\s+/))
293
+ out.push({ ...n, from });
294
+ }
295
+ return out;
296
+ }
297
+ const resolve = (spec) => {
298
+ const bases = spec.startsWith(".") ? [norm(`${dir}/${spec}`)] : spec.startsWith("@/") ? [`src/${spec.slice(2)}`, spec.slice(2)] : [];
299
+ for (const b of bases)
300
+ for (const c of [b, b.replace(/\.js$/, ".ts"), ...[".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].flatMap((e) => [b + e, `${b}/index${e}`])])
301
+ if (files.has(c))
302
+ return c;
303
+ return null;
304
+ };
305
+ for (const m of text.matchAll(/\bimport\s*(?:type\s*)?\{([^}]*)\}\s*from\s*["']([^"'\n]+)["']|\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*require\(\s*["']([^"'\n]+)["']\s*\)/g)) {
306
+ const from = resolve(m[2] ?? m[4]);
307
+ if (from)
308
+ for (const n of names(m[1] ?? m[3], m[1] != null ? /\s+as\s+/ : /\s*:\s*/))
309
+ out.push({ ...n, from });
310
+ }
311
+ return out;
312
+ }
313
+ const TOOLING_RULES = new Set(["agent.config-runs-remote-code", "agent.instructions-unsafe", "agent.permissions-allow-all", "skill.fetches-remote-instructions", "skill.writes-agent-memory", "skill.unrestricted-shell"]);
210
314
  // Lines a person already reviewed. lintsure-ignore and the secret allowlist pragma count only in a comment and apply
211
315
  // to every rule. Other linters' markers (noqa, nosec, NOSONAR) don't hide secrets: `# noqa: E501` is about line length.
212
316
  const REVIEWED = /(#|\/\/|\/\*|--)\s*(lintsure-ignore|pragma:\s*allowlist secret)\b/;
213
- const OTHER_LINTER = /#\s*(noqa|nosec)\b|\/\/\s*NOSONAR\b/;
317
+ const OTHER_LINTER = /#\s*(noqa|nosec|nosemgrep|NOSONAR)\b|\/\/\s*(NOSONAR|nosemgrep)\b/i;
214
318
  // Also hand-typed fake keys: alphabet or number runs, words where random text should be, a whole key block on one line.
215
319
  const PLACEHOLDER = /test|fake|dummy|example|sample|placeholder|sanitized|mock|xxx|changeme|localhost|["'](password|pass|secret|elastic|admin)["']|abcdef|123456|\b(xox[baprs]|gh[pousr])[-_][a-z]+(-[a-z]+)*\b|PRIVATE KEY-----.*-----END/i;
216
320
  /** The JSON object key that opens the block a line sits in, e.g. "peerDependencies". Pure. */
@@ -240,8 +344,10 @@ export function enclosingKeys(lines) {
240
344
  }
241
345
  // Example code that shows a pattern instead of running it (benchmark "fp" cases, self-scan 2026-11-19): a fenced block
242
346
  // 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.
243
- const EXAMPLE_KEY = /^(?:examples?|code|snippets?|samples?|bad|good|before|after|demo|patch|diff|dont|do)$/i;
244
- const EXAMPLE_KEY_ON_LINE = /"(?:examples?|code|snippets?|samples?|bad|good|before|after|demo|patch|diff|dont|do)"\s*:/i;
347
+ // Keys that hold quoted material count too (text, context, excerpt, fix, note): a file of stored findings or review
348
+ // notes keeps other people's lines there (workspace scan 2026-11-23: about 110 of 177 findings came from such files).
349
+ const EXAMPLE_KEY = /^(?:examples?|code|snippets?|samples?|bad|good|before|after|demo|patch|diff|dont|do|text|context|excerpt|evidence|quote|fix|note|hint)$/i;
350
+ const EXAMPLE_KEY_ON_LINE = /"(?:examples?|code|snippets?|samples?|bad|good|before|after|demo|patch|diff|dont|do|text|context|excerpt|evidence|quote|fix|note|hint)"\s*:/i;
245
351
  export function exampleLines(lines, ext) {
246
352
  if (ext === ".md" || ext === ".mdx") {
247
353
  let fence = false;
@@ -342,7 +448,13 @@ export function hopLine(lines, i, names) {
342
448
  return changed ? t : null;
343
449
  }
344
450
  const PROMPT_DOC = /(^|\/)(?:prompts?|personas?|instructions?|system)(?:\/|[._-])|(^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL|SYSTEM|PROMPT)\.mdx?$|\.prompt\.mdx?$|(^|\/)\.(?:github|cursor|claude)\//i;
345
- const SINK_RULES = new Set(["path.user-input", "ssrf.user-url", "redirect.open", "code.eval", "cmd.shell-built", "deserialize.unsafe"]);
451
+ // pii.logged is here for the same reason: a log call drawn into an image, a slide or a code sample on a page is text.
452
+ const SINK_RULES = new Set(["path.user-input", "ssrf.user-url", "redirect.open", "code.eval", "cmd.shell-built", "deserialize.unsafe", "pii.logged"]);
453
+ // A Python f-string builds its text from variables, so it is code, not a stored line.
454
+ const BUILDS_TEXT = /\b[fF][rR]?["']/;
455
+ /** A line with its quoted strings and its on-screen text (between a tag and its closing tag) emptied. Pure. */
456
+ // A template literal with no ${...} in it is a plain string as well.
457
+ export const codeOnly = (l) => blankStrings(l).replace(/`[^`$]*`/g, "``").replace(/>[^<>{}]*<\//g, "></");
346
458
  // One pass, no regex: a line with an unclosed quote and many escapes must not cost more than its length (CodeQL js/polynomial-redos).
347
459
  export function blankStrings(l) {
348
460
  let out = "", q = "", start = 0;
@@ -543,6 +655,8 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
543
655
  const rulesOff = Object.keys(config.rules).filter((id) => config.rules[id] === "off");
544
656
  const active = rules.filter((r) => r.controls.some((c) => frameworks.includes(c.framework)) && !rulesOff.includes(r.id));
545
657
  const findings = [];
658
+ // Secrets found in quoted material inside a JSON data file ("file:line"): shown with --all, like secrets in tests.
659
+ const quoted = new Set();
546
660
  let filesChecked = 0, checkPoints = 0, nonShipping = 0;
547
661
  const perRule = {};
548
662
  const all = await listFiles(root, ignore);
@@ -579,6 +693,40 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
579
693
  });
580
694
  for (let i = 0; i < needed.length; i += 32)
581
695
  await Promise.all(needed.slice(i, i + 32).map(textOf));
696
+ // One hop across files for masking helpers: a helper imported from another project file masks if it does so where it
697
+ // is defined (0.3.14 review: logs through an imported pseudonym helper were false alarms).
698
+ const absOf = new Map(paths.map((p, k) => [p, all[k]])), pathSet = new Set(paths);
699
+ const maskersIn = new Map();
700
+ // Every path ending of every Python file, built on first use, so `from a.b import c` is one lookup, not a search.
701
+ let endings;
702
+ const byEnding = (e) => {
703
+ if (!endings) {
704
+ endings = new Map();
705
+ for (const p of paths)
706
+ if (p.endsWith(".py")) {
707
+ const s = p.split("/");
708
+ for (let i = 0; i < s.length; i++) {
709
+ const k = s.slice(i).join("/");
710
+ if (!endings.has(k))
711
+ endings.set(k, p);
712
+ }
713
+ }
714
+ }
715
+ return endings.get(e);
716
+ };
717
+ const importedMaskers = async (file, text) => {
718
+ const got = [];
719
+ for (const im of importedNames(file, text, pathSet, byEnding)) {
720
+ let m = maskersIn.get(im.from);
721
+ if (!m) {
722
+ m = textOf(absOf.get(im.from)).then((t) => (t ? localMaskers(t.split(/\r?\n/)) : []));
723
+ maskersIn.set(im.from, m);
724
+ }
725
+ if ((await m).includes(im.name))
726
+ got.push(im.local);
727
+ }
728
+ return got;
729
+ };
582
730
  // Say what was not read, so "no findings" is never read as "checked everything".
583
731
  let filesSkipped = 0;
584
732
  for (const abs of needed)
@@ -641,6 +789,9 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
641
789
  nonShipping++;
642
790
  const comment = commentLines(lines, ext), example = exampleLines(lines, ext);
643
791
  let tainted;
792
+ let maskers;
793
+ const fromOtherFiles = relevant.some((r) => r.id === "pii.logged") && /e-?mail|phone|passw|\bssn\b|birth|\bdob\b|card|iban|passport/i.test(whole) && /\b(import|require)\b/.test(whole) ? await importedMaskers(file, whole) : [];
794
+ const viaMasker = (text) => (maskers ??= [...localMaskers(lines), ...fromOtherFiles]).some((n) => text.includes(n + "("));
644
795
  // Statements are worked out once per file, on lines with comments blanked.
645
796
  const stmts = JOINABLE.has(ext) ? statements(lines.map((l, i) => (comment[i] ? "" : l)), ext === ".py") : [];
646
797
  const multi = stmts.filter((s) => s.end > s.start);
@@ -654,7 +805,7 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
654
805
  if (r.id === "ai.hides-being-ai" && (ext === ".md" || ext === ".mdx") && !PROMPT_DOC.test(file))
655
806
  continue;
656
807
  const secret = SECRET_RULES.has(r.id);
657
- if (inTests && !secret && !TOOLING_RULES.has(r.id))
808
+ if (inTests && !secret && !(TOOLING_RULES.has(r.id) && !TEST_PATH.test(file) && !TEST_FILE.test(file)))
658
809
  continue;
659
810
  // Count only what actually ran: a file skipped as a test is not a check point (review P1).
660
811
  ran++;
@@ -680,12 +831,16 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
680
831
  probe = h;
681
832
  }
682
833
  }
683
- if (hit && SINK_RULES.has(r.id) && !r.test(blankStrings(probe)))
834
+ if (hit && SINK_RULES.has(r.id) && !BUILDS_TEXT.test(probe) && !r.test(codeOnly(probe)))
684
835
  return;
685
836
  if (!hit || (r.unlessNear && lines.slice(Math.max(0, i - 8), i + 4).some((l) => r.unlessNear.test(l))))
686
837
  return;
687
838
  if (r.unlessInKey && r.unlessInKey.test(enclosingKey(lines, i)))
688
839
  return;
840
+ if (DEV_BRANCH_RULES.has(r.id) && inDevBranch(lines, i))
841
+ return;
842
+ if (r.id === "pii.logged" && viaMasker(probe))
843
+ return;
689
844
  if (inTests && secret && PLACEHOLDER.test(text))
690
845
  return; // password="test_password", token="xoxb-test-..."
691
846
  if (inTests && /PRIVATE KEY/.test(text))
@@ -693,6 +848,8 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
693
848
  if (REVIEWED.test(text) || (!secret && OTHER_LINTER.test(text)))
694
849
  return; // someone already looked at this line and marked it
695
850
  hitLines.add(i);
851
+ if (secret && example[i] && ext === ".json")
852
+ quoted.add(`${file}:${i + 1}`);
696
853
  add(r, i + 1, hit === "partial" || (inTests && !TOOLING_RULES.has(r.id)) ? "partial" : r.status);
697
854
  });
698
855
  // A statement spread over several lines: test it as one, and report it only when no single line already did,
@@ -710,6 +867,10 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
710
867
  if (already)
711
868
  continue;
712
869
  const hit = r.test(s.text);
870
+ if (hit && SINK_RULES.has(r.id) && !BUILDS_TEXT.test(s.text) && !r.test(codeOnly(s.text)))
871
+ continue; // text on a page, as above
872
+ if (hit && r.id === "pii.logged" && viaMasker(s.text))
873
+ continue;
713
874
  if (!hit || (r.unlessNear && lines.slice(Math.max(0, s.start - 8), s.end + 4).some((l) => r.unlessNear.test(l))))
714
875
  continue;
715
876
  if (r.unlessInKey && r.unlessInKey.test(enclosingKey(lines, s.start)))
@@ -719,9 +880,12 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
719
880
  add(r, s.start + 1, hit === "partial" || (inTests && !TOOLING_RULES.has(r.id)) ? "partial" : r.status);
720
881
  }
721
882
  // File rules see comment lines as blank, so "<img> in a comment" or a commented-out call doesn't count (field test).
883
+ // A Python MCP tool's description is its docstring, so this rule reads docstrings too (it drops # and // lines itself).
722
884
  if (r.fileTest)
723
- for (const n of r.fileTest(skip ? lines.map((l, i) => (skip[i] ? "" : l)) : lines, shared.get(r.id), sharedFiles.get(r.id)))
724
- typeof n === "number" ? add(r, n) : add(r, n.line, n.status);
885
+ for (const n of r.fileTest(skip && r.id !== "mcp.tool-description-poisoned" ? lines.map((l, i) => (skip[i] ? "" : l)) : lines, shared.get(r.id), sharedFiles.get(r.id)))
886
+ // A file rule's hit on a quoted line in a JSON data file is a stored line too, as for line rules above.
887
+ if (!(DEV_BRANCH_RULES.has(r.id) && inDevBranch(lines, (typeof n === "number" ? n : n.line) - 1)) && !(ext === ".json" && example[(typeof n === "number" ? n : n.line) - 1]))
888
+ typeof n === "number" ? add(r, n) : add(r, n.line, n.status);
725
889
  }
726
890
  if (ran)
727
891
  filesChecked++;
@@ -776,7 +940,7 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
776
940
  // Request data reaching a query, a shell, eval or a CI script (status Gap) is shown by default even from a held-back
777
941
  // rule: the default run found 61% of the benchmark's real problems, and these were most of the rest (2026-11-20).
778
942
  const reachesSink = (f) => f.status === "gap" && REQUEST_SINK_RULES.has(f.ruleId) && !isNonShipping(f.file);
779
- const isMedium = (f) => (medium.has(f.ruleId) && !reachesSink(f)) || (SECRET_RULES.has(f.ruleId) && isNonShipping(f.file));
943
+ const isMedium = (f) => (medium.has(f.ruleId) && !reachesSink(f)) || (SECRET_RULES.has(f.ruleId) && (isNonShipping(f.file) || quoted.has(`${f.file}:${f.line}`)));
780
944
  const changed = opts.changed && new Map(Object.entries(opts.changed.lines).map(([k, v]) => [k, new Set(v)]));
781
945
  const inDiff = (f) => !changed || changed.get(f.file)?.has(f.line) === true;
782
946
  const held = showAll ? 0 : unique.filter((f) => isMedium(f) && inDiff(f)).length;
@@ -846,22 +1010,32 @@ function recordLines(r) {
846
1010
  ...c.byControl.map((b) => `| ${b.framework} | ${b.control} ${b.title} | ${b.rules.join(", ")} | ${b.checkPoints} | ${RESULT[b.result]} | ${b.findingIds.join(", ") || "-"} |`), "",
847
1011
  ];
848
1012
  }
1013
+ // Housekeeping for the repo, not a flaw in the code. These four were 74% of what the 0.3.14 field test showed, so every
1014
+ // output lists them after the findings in the code. Presentation only: the report data, SARIF and exit code don't change.
1015
+ // The two Dockerfile hardening basics joined the group after their first field scan: 138 findings in 304 projects, true
1016
+ // but routine, and they would bury findings in the code.
1017
+ const HYGIENE_RULES = new Set(["ci.action-unpinned", "repo.no-sbom", "repo.no-security-policy", "repo.no-dependency-updates", "docker.runs-as-root", "docker.image-unpinned", "docker.copies-everything"]);
1018
+ export const isHygiene = (f) => HYGIENE_RULES.has(f.ruleId);
849
1019
  export function toMarkdown(r) {
1020
+ const hygiene = r.findings.filter(isHygiene);
850
1021
  const lines = [
851
1022
  "# Lintsure report", "",
852
1023
  `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" : ""})` : ""}`, "",
853
1024
  `> ${DISCLAIMER}`, "",
854
1025
  ...recordLines(r),
855
- `## Findings (${r.findings.length})`, "",
1026
+ `## Findings (${r.findings.length - hygiene.length})`, "",
856
1027
  ];
857
1028
  if (r.baseline)
858
1029
  lines.splice(lines.length - 2, 0, `Since the baseline of ${r.baseline.created}: ${r.baseline.newCount} new, ${r.baseline.fixed.length} fixed, ${r.baseline.unchangedCount} unchanged.`, "");
859
- if (!r.findings.length)
860
- lines.push("No issues found by the current rules.", "");
1030
+ if (r.findings.length === hygiene.length)
1031
+ lines.push(hygiene.length ? "No findings in the code from the current rules. Repo hygiene items follow." : "No issues found by the current rules.", "");
861
1032
  // Fix first: Gaps before Partials, then by severity; file order within each group.
862
- const rank = (f) => (f.status === "gap" ? 0 : 3) + { high: 0, medium: 1, low: 2 }[f.severity];
863
- for (const f of [...r.findings].sort((a, b) => rank(a) - rank(b)))
864
- 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",
1033
+ // Within the same status and risk level, code that no route, handler or entry point reaches comes after code that is
1034
+ // reached. A tie-break only: reachability misses dynamic imports, so it never hides or demotes a finding across levels.
1035
+ const rank = (f) => (isHygiene(f) ? 6 : 0) + (f.status === "gap" ? 0 : 3) + { high: 0, medium: 1, low: 2 }[f.severity] + (f.reach?.status === "unreachable" ? 0.5 : 0);
1036
+ const sorted = [...r.findings].sort((a, b) => rank(a) - rank(b));
1037
+ for (const f of sorted)
1038
+ lines.push(...(f === sorted[r.findings.length - hygiene.length] ? [`## Repo hygiene (${hygiene.length})`, "", "Housekeeping for the repo, not flaws in the code. Findings in the code come first.", ""] : []), `### ${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), ""] : []), ...(f.confirmed ? [`Confirmed as real by ${f.confirmed.by}${f.confirmed.date ? ` on ${f.confirmed.date}` : ""}, after reading the code.${f.confirmed.note ? ` ${f.confirmed.note}` : ""}`, ""] : []), `- 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",
865
1039
  ...(f.patch.old != null ? [`- ${f.patch.old}`] : []), ...f.patch.text.replace(/\n$/, "").split("\n").map((t) => `+ ${t}`), "```", ""] : []));
866
1040
  if (r.baseline?.fixed.length)
867
1041
  lines.push(`## Fixed since baseline (${r.baseline.fixed.length})`, "", ...r.baseline.fixed.map((x) => `- ${x.ruleId} in \`${x.file}\``), "");
@@ -48,7 +48,7 @@ export const cra = {
48
48
  plain: "Nothing ships with a vulnerability that's already public and exploitable, including in dependencies. This needs advisory data, which Lintsure doesn't download, so use a dependency scanner alongside it.",
49
49
  evidence: "Dependency scanner results at release and how alerts are handled." },
50
50
  { ref: "Annex I Part II (1)", title: "Components identified, including an SBOM", inCode: "partly",
51
- rules: ["repo.no-sbom", "repo.binary-committed", "deps.unpinned-version", "deps.install-script"],
51
+ rules: ["repo.no-sbom", "repo.binary-committed", "deps.unpinned-version", "deps.install-script", "deps.unsafe-source"],
52
52
  plain: "You know what's in your product: pinned dependencies, no unexplained compiled files, and a machine-readable software bill of materials (SBOM) covering at least the top-level components.",
53
53
  evidence: "An SBOM per release in CycloneDX or SPDX format." },
54
54
  { ref: "Annex I Part II (5)", title: "Coordinated vulnerability disclosure policy", inCode: "partly",
@@ -56,7 +56,7 @@ export const cra = {
56
56
  plain: "A published way for anyone to report a vulnerability to you, and a process for handling reports.",
57
57
  evidence: "SECURITY.md or a security page, and records of reports received and handled." },
58
58
  { ref: "Annex I Part II (7)", title: "Updates distributed securely", inCode: "partly",
59
- rules: ["update.unverified-download", "ci.action-unpinned", "ci.prt-checkout-head", "ci.write-all-permissions", "ci.script-injection"],
59
+ rules: ["update.unverified-download", "ci.action-unpinned", "ci.prt-checkout-head", "ci.write-all-permissions", "ci.script-injection", "ci.scan-cannot-fail"],
60
60
  plain: "Builds and updates can't be swapped or tampered with: pinned CI steps, workflow tokens limited to what they need, untrusted pull requests and issue text kept away from secrets and commands, and nothing run straight from a download without a check.",
61
61
  evidence: "Release signing, CI configuration and how users receive updates." },
62
62
  { ref: "Annex I Part II (2)", title: "Vulnerabilities fixed without delay", inCode: "partly",
@@ -25,16 +25,16 @@ export const gdpr = {
25
25
  { ref: "Art. 6", title: "A lawful reason", inCode: "no",
26
26
  plain: "Every use of personal data needs one of six legal bases, such as consent, a contract, or legitimate interests weighed against people's rights.",
27
27
  evidence: "The legal basis recorded for each processing purpose." },
28
- { ref: "Art. 7", title: "Consent done right", inCode: "partly",
28
+ { ref: "Art. 7", title: "Consent done right", inCode: "partly", rules: ["privacy.consent-preticked"],
29
29
  plain: "If you rely on consent, it must be freely given, specific, informed and as easy to withdraw as to give. No pre-ticked boxes.",
30
30
  evidence: "Consent records and the wording users saw." },
31
- { ref: "Art. 9", title: "Sensitive data", inCode: "partly", rules: ["ai.emotion-or-biometric"],
31
+ { ref: "Art. 9", title: "Sensitive data", inCode: "partly", rules: ["ai.emotion-or-biometric", "privacy.special-category-field"],
32
32
  plain: "Health, biometric, ethnic, religious, political, sexual and union data is off-limits unless a specific exception applies.",
33
33
  evidence: "The exception you rely on." },
34
34
  { ref: "Art. 12–15", title: "Transparency and access", inCode: "no",
35
35
  plain: "Tell people clearly what you collect and why, and give them a copy of their data when they ask.",
36
36
  evidence: "Your privacy notice and how access requests are handled." },
37
- { ref: "Art. 17", title: "Right to erasure", inCode: "partly",
37
+ { ref: "Art. 17", title: "Right to erasure", inCode: "partly", rules: ["privacy.memory-no-delete"],
38
38
  plain: "When someone asks, and no exception applies, delete their data everywhere you hold it, including backups on rotation and third-party tools.",
39
39
  evidence: "The deletion path and where it reaches." },
40
40
  { ref: "Art. 22", title: "Automated decisions", inCode: "partly", rules: ["ai.automated-decision"],
@@ -50,7 +50,7 @@ export const gdpr = {
50
50
  plain: "Keep a list of what personal data you process, why, with whom you share it and how long you keep it.",
51
51
  evidence: "The register of processing activities." },
52
52
  { ref: "Art. 32", title: "Security of processing", inCode: "yes",
53
- rules: ["pii.logged", "secret.in-source", "transport.plain-http", "transport.tls-verify-off", "crypto.weak-password-hash", "sql.string-built", "pii.in-url", "supabase.rls-disabled", "supabase.policy-allows-all", "supabase.service-key-in-client", "supabase.function-no-auth", "secret.public-env", "mobile.token-in-plain-storage", "mobile.cleartext-traffic", "mobile.backup-allowed"],
53
+ rules: ["crypto.static-iv", "crypto.weak-parameters", "mobile.debuggable-build", "payment.card-code-stored", "pii.logged", "secret.in-source", "transport.plain-http", "transport.tls-verify-off", "crypto.weak-password-hash", "sql.string-built", "pii.in-url", "supabase.rls-disabled", "supabase.policy-allows-all", "supabase.service-key-in-client", "supabase.function-no-auth", "secret.public-env", "mobile.token-in-plain-storage", "mobile.cleartext-traffic", "mobile.backup-allowed"],
54
54
  plain: "Protect personal data with security that fits the risk: encryption, access control, testing and the ability to recover.",
55
55
  evidence: "Security measures and when they were last tested." },
56
56
  { ref: "Art. 33–34", title: "Breach notification", inCode: "no",
@@ -2,9 +2,9 @@ import { euAiAct } from "./eu-ai-act.js";
2
2
  import { gdpr } from "./gdpr.js";
3
3
  import { owaspTop10 } from "./owasp-top10.js";
4
4
  import { cra } from "./cra.js";
5
- import { cweTop25, owaspLlm } from "./more.js";
5
+ import { cweTop25, owaspApi, owaspAst, owaspLlm } from "./more.js";
6
6
  export * from "./types.js";
7
- export const knowledge = [euAiAct, gdpr, owaspTop10, cra, owaspLlm, cweTop25];
7
+ export const knowledge = [euAiAct, gdpr, owaspTop10, cra, owaspLlm, cweTop25, owaspAst, owaspApi];
8
8
  export const getKnowledge = (id) => knowledge.find((k) => k.id === id);
9
9
  /** Classifier: suggest frameworks with a reason. The user confirms; nothing is auto-applied. */
10
10
  export function classify(p) {
@@ -1,3 +1,5 @@
1
1
  import type { FrameworkKnowledge } from "./types.js";
2
2
  export declare const owaspLlm: FrameworkKnowledge;
3
3
  export declare const cweTop25: FrameworkKnowledge;
4
+ export declare const owaspAst: FrameworkKnowledge;
5
+ export declare const owaspApi: FrameworkKnowledge;
@@ -10,7 +10,7 @@ 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", "agent.instructions-unsafe", "llm.client-controls-system"],
13
+ { ref: "LLM01:2026", title: "Prompt Injection", inCode: "partly", rules: ["llm.user-input-in-system-prompt", "llm.retrieved-text-in-system-prompt", "agent.instructions-unsafe", "llm.client-controls-system", "mcp.tool-description-poisoned"],
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"],
@@ -19,7 +19,7 @@ export const owaspLlm = {
19
19
  { ref: "LLM03:2026", title: "Excessive Agency", inCode: "partly", rules: ["agent.permissions-allow-all", "mcp.tool-runs-shell", "mcp.tool-uses-secret"],
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", "agent.config-runs-remote-code", "ml.unsafe-model-load"],
22
+ { ref: "LLM04:2026", title: "Supply Chain", inCode: "partly", rules: ["deps.unpinned-version", "deps.install-script", "agent.config-runs-remote-code", "ml.unsafe-model-load", "mcp.config-unsafe-server"],
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",
@@ -64,3 +64,89 @@ export const cweTop25 = {
64
64
  watchOut: ["The list ranks weaknesses by data from published vulnerabilities; it changes a little each year.", "Seven of the 25 are memory-safety weaknesses that don't apply to JavaScript, TypeScript or Python code."],
65
65
  checkedOn: "2026-11-09",
66
66
  };
67
+ // The list is an OWASP incubator project, version 1.0 (2026), in public review when this was written. Ids and names only.
68
+ export const owaspAst = {
69
+ id: "owasp-ast", name: "OWASP Agentic Skills Top 10", kind: "standard",
70
+ summary: "Ten risks in the skills, instruction files and tool servers that AI coding agents load: malicious skills, a poisoned supply chain, too many permissions, misleading metadata, instructions fetched at run time, weak isolation, silent updates, weak scanning, no inventory and reuse across platforms. It's a young awareness list, still in public review, not a law or certification.",
71
+ whoItAppliesTo: "Any team whose developers or products use an AI agent that loads skills, instruction files or MCP servers.",
72
+ applies(p) {
73
+ // The profile describes the product, not the team's tools, so this follows the same signal as the LLM list.
74
+ return p.usesAI && (p.generativeAI || p.interactsWithPeople) ? "Agents load skills, instruction files and tool servers as instructions, so what is in them is part of your supply chain." : null;
75
+ },
76
+ obligations: [
77
+ { ref: "AST01", title: "Malicious Skills", inCode: "partly", rules: ["agent.instructions-unsafe", "skill.writes-agent-memory"],
78
+ plain: "A skill can look useful and still tell the agent to hide a step, send secrets out or change its own instructions. Read a skill's text like code before an agent uses it.",
79
+ evidence: "Where each installed skill came from, and who read it before it was added." },
80
+ { ref: "AST02", title: "Supply Chain Compromise", inCode: "partly", rules: ["agent.config-runs-remote-code", "mcp.config-unsafe-server"],
81
+ plain: "Skills, hooks and tool servers come from others. Pin them to a version you have read, and treat config files an agent runs by itself as code.",
82
+ evidence: "A list of installed skills and servers with their versions and sources." },
83
+ { ref: "AST03", title: "Over-Privileged Skills", inCode: "partly", rules: ["agent.permissions-allow-all", "skill.unrestricted-shell"],
84
+ plain: "A skill should get only the tools, files and network access its job needs. Open shell access makes every other limit moot.",
85
+ evidence: "The permissions each skill declares, and why it needs them." },
86
+ { ref: "AST04", title: "Insecure Metadata", inCode: "partly", rules: ["agent.instructions-unsafe"],
87
+ plain: "A skill's description and front matter are read by the agent too. They must match what the skill does and carry no hidden characters.",
88
+ evidence: "A check that each skill's description matches its behaviour." },
89
+ { ref: "AST05", title: "Untrusted External Instructions", inCode: "partly", rules: ["skill.fetches-remote-instructions"],
90
+ plain: "A skill that tells the agent to fetch a page and follow it hands control to whoever owns that page tomorrow. Keep the instructions inside the skill, or pin what is fetched.",
91
+ evidence: "Every outside page or file a skill reads at run time." },
92
+ { ref: "AST06", title: "Weak Isolation", inCode: "partly", rules: ["mcp.server-binds-all-interfaces"],
93
+ plain: "Skills and tool servers should run boxed in: local interfaces only, with sign-in, and limited to the files they declare.",
94
+ evidence: "How each tool server is started, where it listens and who can reach it." },
95
+ { ref: "AST07", title: "Update Drift", inCode: "partly", rules: ["mcp.config-unsafe-server"],
96
+ plain: "A skill or server that updates by itself can change after you approved it. Pin versions and look again on every update.",
97
+ evidence: "How updates to skills and servers are approved." },
98
+ { ref: "AST08", title: "Poor Scanning", inCode: "no",
99
+ plain: "A pattern scanner reads code well and prose badly, and a skill is mostly prose. Use more than one kind of check, and never rely on a scanner that is itself a skill.",
100
+ evidence: "Which checks run on a skill before it is installed, and what they cannot see." },
101
+ { ref: "AST09", title: "No Governance", inCode: "no",
102
+ plain: "Someone should know which skills are installed, who approved each one and how to remove one fast.",
103
+ evidence: "A skill inventory with an owner, an approval and a review date for each entry." },
104
+ { ref: "AST10", title: "Cross-Platform Reuse", inCode: "no",
105
+ plain: "A skill moved from one agent to another can lose its limits on the way, because each agent enforces different things. Check it again on each one.",
106
+ evidence: "For a skill used on several agents, what each agent enforces." },
107
+ ],
108
+ watchOut: ["The list is version 1.0 from an OWASP incubator project and was in public review when we mapped it, so ids and names may change.", "Lintsure reads a skill one line at a time. It can't judge whether a skill's description matches what it does, and it doesn't run the skill."],
109
+ checkedOn: "2026-11-23",
110
+ };
111
+ export const owaspApi = {
112
+ id: "owasp-api", name: "OWASP API Security Top 10 2023", kind: "standard",
113
+ summary: "The ten most serious security risks in APIs: reaching other people's records, weak sign-in, changing fields you shouldn't, no limits on use, calling functions meant for others, abusing business flows, server-side request forgery, misconfiguration, forgotten API versions and trusting other APIs too much. It's an awareness list, not a law or certification.",
114
+ whoItAppliesTo: "Any team whose product has an API: a backend for a web or mobile app, a public API, or endpoints called by other services.",
115
+ applies(p) {
116
+ return p.personalData || p.cardPayments ? "Personal and payment data usually travels through your API, and most API breaches are access-control failures." : null;
117
+ },
118
+ obligations: [
119
+ { ref: "API1:2023", title: "Broken Object Level Authorization", inCode: "partly", rules: ["authz.no-owner-check", "supabase.rls-disabled", "supabase.policy-allows-all"],
120
+ plain: "Every request for a record by id must check that this caller may see that record. A valid sign-in is not enough.",
121
+ evidence: "Tests that sign in as one user and ask for another user's records." },
122
+ { ref: "API2:2023", title: "Broken Authentication", inCode: "partly", rules: ["auth.hardcoded-password", "jwt.unverified", "jwt.no-expiry", "jwt.no-algorithm-pin", "jwt.weak-secret", "crypto.weak-password-hash", "session.cookie-insecure", "auth.no-rate-limit"],
123
+ plain: "Sign-in, tokens and password resets must resist guessing, forgery and theft: verified tokens that expire, strong password hashing and limits on attempts.",
124
+ evidence: "How tokens are issued, checked and revoked, and the limits on sign-in attempts." },
125
+ { ref: "API3:2023", title: "Broken Object Property Level Authorization", inCode: "partly", rules: ["mass-assignment"],
126
+ plain: "A caller should only read and change the fields meant for them. Don't save a whole request body, and don't return whole records.",
127
+ evidence: "For each endpoint, the fields a caller may read and the fields they may change." },
128
+ { ref: "API4:2023", title: "Unrestricted Resource Consumption", inCode: "partly", rules: ["auth.no-rate-limit", "llm.no-output-limit", "llm.unbounded-agent-loop", "upload.unrestricted"],
129
+ plain: "Limit how often, how much and how long: request rates, page sizes, upload sizes, and anything you pay for per call.",
130
+ evidence: "The limits in code and at the gateway, and spending caps with providers." },
131
+ { ref: "API5:2023", title: "Broken Function Level Authorization", inCode: "partly", rules: ["authz.admin-route-no-check", "cookie.trusted-role", "supabase.function-no-auth", "cloud.function-url-no-auth"],
132
+ plain: "Admin and other privileged endpoints must check the caller's role on the server. Hiding the button in the app does not protect the endpoint.",
133
+ evidence: "A list of privileged endpoints and where each one checks the role." },
134
+ { ref: "API6:2023", title: "Unrestricted Access to Sensitive Business Flows", inCode: "no",
135
+ plain: "A flow such as buying, booking or signing up can be abused when it is run at scale by a script, even if every single call is allowed.",
136
+ evidence: "Which flows could hurt the business if automated, and what slows automation down." },
137
+ { ref: "API7:2023", title: "Server Side Request Forgery", inCode: "partly", rules: ["ssrf.user-url"],
138
+ plain: "When the server fetches an address a caller supplied, check it against an allow-list first, or it can be pointed at your own internal systems.",
139
+ evidence: "Every place the server fetches a caller-supplied address, and the allow-list for each." },
140
+ { ref: "API8:2023", title: "Security Misconfiguration", inCode: "partly", rules: ["cors.any-origin", "config.debug-on", "error.stack-to-client", "graphql.introspection", "config.allowed-hosts-any", "transport.tls-verify-off"],
141
+ plain: "Open CORS, debug mode, detailed errors and switched-off checks give attackers a head start. Ship with them closed.",
142
+ evidence: "The production configuration, and who can change it." },
143
+ { ref: "API9:2023", title: "Improper Inventory Management", inCode: "no",
144
+ plain: "Old versions, test hosts and undocumented endpoints stay reachable long after everyone forgot them, usually with weaker protection.",
145
+ evidence: "A current list of API hosts and versions, and when each old one is switched off." },
146
+ { ref: "API10:2023", title: "Unsafe Consumption of APIs", inCode: "partly", rules: ["transport.tls-verify-off", "transport.plain-http"],
147
+ plain: "Data from another company's API is input like any other. Reach it over verified TLS, validate what comes back, and don't follow its redirects blindly.",
148
+ evidence: "The third-party APIs you call, and how each response is validated." },
149
+ ],
150
+ watchOut: ["Most API breaches are logic flaws: the code works as written and still lets the wrong person in. A pattern check sees only part of that.", "Lintsure reads one file at a time, with the project's middleware. A check that lives in a gateway or a shared wrapper may not be seen."],
151
+ checkedOn: "2026-11-23",
152
+ };
@@ -23,7 +23,7 @@ export const owaspTop10 = {
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", "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", "docker.socket-mounted", "graphql.introspection"],
26
+ rules: ["cloud.database-public", "cloud.network-open", "cloud.iam-allow-all", "cloud.function-url-no-auth", "docker.runs-as-root", "docker.image-unpinned", "docker.secret-in-build", "docker.copies-everything", "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", "docker.socket-mounted", "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",