xploitscan-shared-rules 2.4.20 → 2.4.22
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/ai-status-constants.cjs +99 -0
- package/dist/ai-status-constants.cjs.map +1 -0
- package/dist/ai-status-constants.d.cts +12 -0
- package/dist/ai-status-constants.d.ts +12 -0
- package/dist/ai-status-constants.js +69 -0
- package/dist/ai-status-constants.js.map +1 -0
- package/dist/index.cjs +1320 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +91 -5
- package/dist/index.d.ts +91 -5
- package/dist/index.js +1271 -82
- package/dist/index.js.map +1 -1
- package/dist/suppression.cjs +878 -0
- package/dist/suppression.cjs.map +1 -0
- package/dist/suppression.d.cts +163 -0
- package/dist/suppression.d.ts +163 -0
- package/dist/suppression.js +807 -0
- package/dist/suppression.js.map +1 -0
- package/package.json +13 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/suppression.ts"],"sourcesContent":["/**\n * One suppression pass for every surface.\n *\n * Markers (`<ID>-OK`) and `.xploitscanignore` lines are parsed here and applied\n * once to merged findings. Globs go through the `ignore` package. No hand-built\n * regex is compiled from a user pattern.\n *\n * eslint-style `xploitscan-ignore` forms are not a syntax. They warn and\n * suppress nothing.\n */\nimport ignore from \"ignore\";\n\nexport const MAX_IGNORE_BYTES = 64 * 1024;\nexport const MAX_IGNORE_LINES = 2000;\nexport const MAX_IGNORE_LINE_LEN = 1024;\nexport const MAX_JUSTIFICATION = 200;\nexport const MAX_WARNING_CAP = 20;\nexport const MAX_SUPPRESSED_LIST = 500;\nexport const MAX_COUNT = 1000;\nexport const MAX_BLOCK_LINES = 20;\nexport const NESTED_IGNORE_WARNING =\n \"nested .xploitscanignore ignored (only the root file is read here)\";\nexport const MARKER_SYNTAX = \"use <ID>-OK inside a comment\";\n\n/** Bounded, anchored, no nested quantifiers. Exported for the slow-regex check. */\nexport const RULE_ID_PATTERN = /^(?:[A-Za-z]{2,8}\\d{0,4}|GL:[A-Za-z0-9-]{1,64}|scanner)$/i;\nexport const SUPPRESSION_REGEXES: readonly RegExp[] = [RULE_ID_PATTERN];\n\nconst INLINE = Symbol.for(\"xploitscan.inlineSuppressed\");\n\nexport interface SuppressionInfo {\n kind: \"inSource\" | \"external\";\n source: \"marker\" | \"ignore-file\";\n ruleToken: string;\n justification: string;\n declaredIn: string;\n}\n\nexport interface SuppressionWarning {\n code: string;\n file: string;\n line: number;\n ruleIds: string[];\n count: number;\n}\n\nexport interface MarkerHit {\n markerLine: number;\n targetLine: number;\n ruleIds: string[];\n justification: string;\n declaredIn: string;\n}\n\nexport interface IgnoreEntry {\n dirRel: string;\n pattern: string;\n negated: boolean;\n /** Upper-case ids. Null suppresses every rule. */\n rules: Set<string> | null;\n justification: string;\n declaredIn: string;\n line: number;\n overBroad: boolean;\n /** Compiled once at parse time and reused for every finding. */\n matcher?: IgnoreMatcher;\n}\n\nexport interface IdOptions {\n knownIds?: ReadonlySet<string> | null;\n proIds?: ReadonlySet<string>;\n tier?: \"free\" | \"pro\";\n}\n\nexport interface Suppressible {\n rule: string;\n file: string;\n line: number;\n column?: number;\n endColumn?: number;\n snippet?: string;\n}\n\ntype IdFate = \"ok\" | \"pro-silent\" | \"unknown\";\n\nexport function utf8ByteLength(text: string): number {\n return new TextEncoder().encode(text).length;\n}\n\nexport function isWellFormedRuleId(id: string): boolean {\n return RULE_ID_PATTERN.test(id);\n}\n\nexport function isBuiltinRuleId(id: string): boolean {\n if (!isWellFormedRuleId(id)) return false;\n const u = id.toUpperCase();\n if (u === \"ENTROPY\" || u === \"SCANNER\" || u === \"AI\") return true;\n if (/^CFG\\d{1,4}$/.test(u)) return true;\n if (/^MFA\\d{1,4}$/.test(u)) return true;\n if (/^QA\\d{1,4}$/.test(u)) return true;\n if (/^GL:/i.test(id)) return true;\n return false;\n}\n\nexport function clampCount(value: unknown, max = MAX_COUNT): number {\n const n = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(n) || n < 0) return 0;\n return Math.min(max, Math.floor(n));\n}\n\nexport function capWarnings(\n warnings: SuppressionWarning[],\n cap = MAX_WARNING_CAP,\n): { shown: SuppressionWarning[]; extra: number } {\n if (warnings.length <= cap) return { shown: warnings, extra: 0 };\n return { shown: warnings.slice(0, cap), extra: warnings.length - cap };\n}\n\nexport function suppressionSummary(inline: number, ignoreFile: number): string {\n const n = inline + ignoreFile;\n const noun = n === 1 ? \"finding\" : \"findings\";\n return `${n} ${noun} suppressed (${inline} inline marker, ${ignoreFile} ignore file)`;\n}\n\nexport function warningForUpload(w: SuppressionWarning): {\n code: string;\n ruleIds: string[];\n count: number;\n} {\n return { code: w.code, ruleIds: [...w.ruleIds], count: w.count };\n}\n\nexport function warningLine(w: SuppressionWarning): string {\n if (w.code === \"nested_ignored\") return `${w.file} ${NESTED_IGNORE_WARNING}`;\n const where = w.file ? `${w.file}:${w.line}` : `line ${w.line}`;\n const ids = w.ruleIds.length ? ` ${w.ruleIds.join(\",\")}` : \"\";\n const syntax =\n w.code === \"unrecognized_marker\" || w.code === \"space_before_ok\" ? ` ${MARKER_SYNTAX}` : \"\";\n const more = w.code === \"over_broad\" ? ` suppresses all findings in ${w.count} files` : \"\";\n return `${where} ${w.code}${ids}${more}${syntax}`;\n}\n\nexport function attachInlineSuppressed<T>(findings: T[], suppressed: unknown[]): T[] {\n Object.defineProperty(findings, INLINE, { value: suppressed, enumerable: false });\n return findings;\n}\n\nexport function readInlineSuppressed(findings: unknown): unknown[] {\n if (!findings || typeof findings !== \"object\") return [];\n const value = (findings as Record<symbol, unknown>)[INLINE];\n return Array.isArray(value) ? value : [];\n}\n\nexport function publicSuppressedRecord(finding: Record<string, unknown>): Record<string, unknown> {\n const suppression = finding.suppression;\n const info =\n suppression && typeof suppression === \"object\"\n ? {\n kind: (suppression as SuppressionInfo).kind,\n source: (suppression as SuppressionInfo).source,\n ruleToken: (suppression as SuppressionInfo).ruleToken,\n justification: String((suppression as SuppressionInfo).justification ?? \"\").slice(\n 0,\n MAX_JUSTIFICATION,\n ),\n declaredIn: (suppression as SuppressionInfo).declaredIn,\n }\n : undefined;\n return {\n rule: finding.rule,\n file: finding.file,\n line: finding.line,\n severity: finding.severity,\n ...(info ? { suppression: info } : {}),\n };\n}\n\nfunction warn(\n file: string,\n line: number,\n code: string,\n ruleIds: string[] = [],\n count = 1,\n): SuppressionWarning {\n return { code, file, line, ruleIds, count };\n}\n\nfunction fateOf(id: string, opts: IdOptions | undefined): IdFate {\n if (isBuiltinRuleId(id)) return \"ok\";\n const upper = id.toUpperCase();\n const pro = opts?.proIds;\n if (pro && (pro.has(upper) || pro.has(id))) {\n return opts?.tier === \"pro\" ? \"ok\" : \"pro-silent\";\n }\n if (!opts?.knownIds) return \"ok\";\n if (opts.knownIds.has(upper) || opts.knownIds.has(id)) return \"ok\";\n return \"unknown\";\n}\n\nfunction idEndingAt(text: string, end: number): { id: string; start: number } | null {\n const window = text.slice(Math.max(0, end - 80), end);\n const gl = window.match(/GL:[A-Za-z0-9-]{1,64}$/i);\n if (gl) {\n const id = gl[0];\n if (isWellFormedRuleId(id)) return { id, start: end - id.length };\n }\n const plain = window.match(/[A-Za-z]{2,8}\\d{0,4}$/);\n if (!plain) return null;\n const id = plain[0];\n if (id.toLowerCase() === \"ok\") return null;\n if (!isWellFormedRuleId(id)) return null;\n return { id, start: end - id.length };\n}\n\nfunction idListBefore(text: string, end: number): { ids: string[]; start: number } | null {\n const first = idEndingAt(text, end);\n if (!first) return null;\n const ids = [first.id];\n let cursor = first.start;\n while (cursor > 0) {\n let j = cursor;\n while (j > 0 && (text[j - 1] === \" \" || text[j - 1] === \"\\t\")) j--;\n if (j > 0 && text[j - 1] === \",\") {\n j--;\n while (j > 0 && (text[j - 1] === \" \" || text[j - 1] === \"\\t\")) j--;\n } else if (j === cursor) {\n break;\n }\n const prev = idEndingAt(text, j);\n if (!prev || prev.start + prev.id.length !== j) break;\n ids.unshift(prev.id);\n cursor = prev.start;\n }\n return { ids, start: cursor };\n}\n\n/**\n * Leftmost start of the next `<id>-ok` token. Linear: indexOf plus a bounded\n * class walk. The old `/[A-Za-z0-9][A-Za-z0-9:-]*-ok\\b/` search was quadratic\n * on the text after `-OK:`.\n */\nfunction nextMarkerStart(rest: string): number {\n const lower = rest.toLowerCase();\n let from = 0;\n while (from < lower.length) {\n const at = lower.indexOf(\"-ok\", from);\n if (at < 0) return -1;\n const after = at + 3;\n const next = lower[after];\n if (next !== undefined && /[A-Za-z0-9_]/.test(next)) {\n from = at + 1;\n continue;\n }\n let i = at - 1;\n while (i >= 0 && /[A-Za-z0-9:-]/.test(lower[i] ?? \"\")) i--;\n let start = i + 1;\n while (start < at && !/[A-Za-z0-9]/.test(lower[start] ?? \"\")) start++;\n if (start < at) return start;\n from = at + 1;\n }\n return -1;\n}\n\ninterface CommentParse {\n ids: string[];\n justification: string;\n warnings: SuppressionWarning[];\n}\n\nfunction parseCommentMarkers(\n comment: string,\n file: string,\n line: number,\n opts?: IdOptions,\n): CommentParse {\n const warnings: SuppressionWarning[] = [];\n const ids: string[] = [];\n let justification = \"\";\n const lower = comment.toLowerCase();\n if (lower.includes(\"xploitscan\") || lower.includes(\"ignore-line\")) {\n warnings.push(warn(file, line, \"unrecognized_marker\"));\n }\n let from = 0;\n while (from < comment.length) {\n const okAt = lower.indexOf(\"-ok\", from);\n const typoAt = lower.indexOf(\"-0k\", from);\n if (okAt < 0 && typoAt < 0) break;\n const useTypo = typoAt >= 0 && (okAt < 0 || typoAt < okAt);\n const at = useTypo ? typoAt : okAt;\n const after = at + 3;\n const boundary = after >= comment.length || !/[A-Za-z0-9]/.test(comment[after]);\n if (!boundary) {\n from = at + 1;\n continue;\n }\n if (useTypo) {\n const listed = idListBefore(comment, at);\n warnings.push(\n warn(\n file,\n line,\n \"unrecognized_marker\",\n listed ? listed.ids.map((id) => id.toUpperCase()) : [],\n ),\n );\n from = after;\n continue;\n }\n const prev = at > 0 ? comment[at - 1] : \"\";\n if (prev === \" \" || prev === \"\\t\") {\n const listed = idListBefore(\n comment.slice(0, at).trimEnd(),\n comment.slice(0, at).trimEnd().length,\n );\n warnings.push(\n warn(file, line, \"space_before_ok\", listed ? listed.ids.map((id) => id.toUpperCase()) : []),\n );\n from = after;\n continue;\n }\n const listed = idListBefore(comment, at);\n if (!listed) {\n warnings.push(warn(file, line, \"unrecognized_marker\"));\n from = after;\n continue;\n }\n let just = \"\";\n if (comment[after] === \":\") {\n const rest = comment.slice(after + 1);\n const next = nextMarkerStart(rest);\n just = (next >= 0 ? rest.slice(0, next) : rest).trim().slice(0, MAX_JUSTIFICATION);\n }\n if (!justification && just) justification = just;\n for (const id of listed.ids) {\n const fate = fateOf(id, opts);\n if (fate === \"unknown\") {\n warnings.push(warn(file, line, \"unknown_rule_id\", [id.toUpperCase()]));\n continue;\n }\n if (fate === \"pro-silent\") continue;\n ids.push(id.toUpperCase());\n }\n from = after;\n }\n return { ids, justification, warnings };\n}\n\nfunction commentOpenerAt(chars: string[], i: number): { kind: \"line\" | \"block\" | \"html\"; len: number } | null {\n const a = chars[i] ?? \"\";\n const b = chars[i + 1] ?? \"\";\n const two = a + b;\n if (two === \"//\") return { kind: \"line\", len: 2 };\n if (two === \"/*\") return { kind: \"block\", len: 2 };\n if (two + (chars[i + 2] ?? \"\") + (chars[i + 3] ?? \"\") === \"<!--\") return { kind: \"html\", len: 4 };\n if (a === \"#\" && (i === 0 || /\\s/.test(chars[i - 1] ?? \"\"))) return { kind: \"line\", len: 1 };\n if (two === \"--\" && (i === 0 || /\\s/.test(chars[i - 1] ?? \"\"))) return { kind: \"line\", len: 2 };\n return null;\n}\n\n/** Replace string and template contents with spaces. Stops at a comment so a quote inside it cannot mask a marker. Line-local, linear. */\nexport function maskStringLiterals(line: string): string {\n const chars = line.split(\"\");\n const n = chars.length;\n let i = 0;\n while (i < n) {\n const opener = commentOpenerAt(chars, i);\n if (opener) {\n if (opener.kind === \"line\") break;\n if (opener.kind === \"block\") {\n const end = line.indexOf(\"*/\", i + opener.len);\n i = end < 0 ? n : end + 2;\n continue;\n }\n const end = line.indexOf(\"-->\", i + opener.len);\n i = end < 0 ? n : end + 3;\n continue;\n }\n const c = chars[i];\n if (c === '\"' || c === \"'\") {\n const q = c;\n chars[i] = \" \";\n i++;\n while (i < n) {\n if (chars[i] === \"\\\\\") {\n chars[i] = \" \";\n if (i + 1 < n) chars[i + 1] = \" \";\n i += 2;\n continue;\n }\n if (chars[i] === q) {\n chars[i] = \" \";\n i++;\n break;\n }\n chars[i] = \" \";\n i++;\n }\n continue;\n }\n if (c === \"`\") {\n chars[i] = \" \";\n i++;\n let expr = 0;\n while (i < n) {\n if (expr === 0 && chars[i] === \"\\\\\") {\n chars[i] = \" \";\n if (i + 1 < n) chars[i + 1] = \" \";\n i += 2;\n continue;\n }\n if (expr === 0 && chars[i] === \"`\") {\n chars[i] = \" \";\n i++;\n break;\n }\n if (expr === 0 && chars[i] === \"$\" && chars[i + 1] === \"{\") {\n chars[i] = \" \";\n chars[i + 1] = \" \";\n expr = 1;\n i += 2;\n continue;\n }\n if (expr > 0 && chars[i] === \"{\") {\n expr++;\n i++;\n continue;\n }\n if (expr > 0 && chars[i] === \"}\") {\n expr--;\n if (expr === 0) chars[i] = \" \";\n i++;\n continue;\n }\n if (expr === 0) chars[i] = \" \";\n i++;\n }\n continue;\n }\n i++;\n }\n return chars.join(\"\");\n}\n\nfunction commentSpans(masked: string): Array<[number, number]> {\n const spans: Array<[number, number]> = [];\n const n = masked.length;\n let i = 0;\n const code = true;\n while (i < n) {\n if (!code) {\n i++;\n continue;\n }\n const two = masked.slice(i, i + 2);\n const four = masked.slice(i, i + 4);\n if (four === \"<!--\") {\n const end = masked.indexOf(\"-->\", i + 4);\n const stop = end < 0 ? n : end + 3;\n spans.push([i, stop]);\n i = stop;\n continue;\n }\n if (two === \"//\") {\n spans.push([i, n]);\n break;\n }\n if (two === \"/*\") {\n const end = masked.indexOf(\"*/\", i + 2);\n const stop = end < 0 ? n : end + 2;\n spans.push([i, stop]);\n i = stop;\n continue;\n }\n if (masked[i] === \"#\" && (i === 0 || /\\s/.test(masked[i - 1]))) {\n spans.push([i, n]);\n break;\n }\n if (two === \"--\" && (i === 0 || /\\s/.test(masked[i - 1]))) {\n spans.push([i, n]);\n break;\n }\n i++;\n }\n const trimmed = masked.trim();\n if (\n spans.length === 0 &&\n (/^\\*/.test(trimmed) || trimmed === \"*/\" || trimmed === \"*/}\" || trimmed === \"-->\")\n ) {\n spans.push([0, n]);\n }\n return spans;\n}\n\nfunction isBlankLine(line: string): boolean {\n return line.trim() === \"\";\n}\n\nfunction isCommentOnly(masked: string): boolean {\n const spans = commentSpans(masked);\n if (spans.length === 0) return false;\n const chars = masked.split(\"\");\n for (const [start, end] of spans) {\n for (let i = start; i < end; i++) chars[i] = \" \";\n }\n return /^[{}()\\s]*$/.test(chars.join(\"\"));\n}\n\nfunction targetLineFor(lines: string[], maskedLines: string[], markerLine: number): number | null {\n if (!isCommentOnly(maskedLines[markerLine] ?? \"\")) return markerLine;\n let blanks = 0;\n let comments = 0;\n for (let i = markerLine + 1; i < lines.length; i++) {\n if (isBlankLine(lines[i] ?? \"\")) {\n blanks++;\n if (blanks > 1) return null;\n continue;\n }\n if (isCommentOnly(maskedLines[i] ?? \"\")) {\n if (blanks > 0) return null;\n comments++;\n if (comments > MAX_BLOCK_LINES) return null;\n continue;\n }\n return i;\n }\n return null;\n}\n\nexport function parseMarkers(\n lines: string[],\n filePath = \"\",\n opts?: IdOptions,\n): { markers: MarkerHit[]; warnings: SuppressionWarning[] } {\n const maskedLines = lines.map((line) => maskStringLiterals(line));\n const markers: MarkerHit[] = [];\n const warnings: SuppressionWarning[] = [];\n for (let i = 0; i < lines.length; i++) {\n const spans = commentSpans(maskedLines[i] ?? \"\");\n if (spans.length === 0) continue;\n const pieces = spans.map(([a, b]) => (maskedLines[i] ?? \"\").slice(a, b));\n const parsed = parseCommentMarkers(pieces.join(\"\\n\"), filePath, i + 1, opts);\n warnings.push(...parsed.warnings);\n if (parsed.ids.length === 0) continue;\n const target = targetLineFor(lines, maskedLines, i);\n if (target === null) continue;\n markers.push({\n markerLine: i,\n targetLine: target,\n ruleIds: parsed.ids,\n justification: parsed.justification,\n declaredIn: `${filePath}:${i + 1}`,\n });\n }\n return { markers, warnings };\n}\n\nexport interface MarkerIndex {\n covers(lineIdx: number, ruleId: string): boolean;\n info(\n lineIdx: number,\n ruleId: string,\n ): { ruleToken: string; justification: string; declaredIn: string } | null;\n warnings: SuppressionWarning[];\n markers: MarkerHit[];\n}\n\nexport function buildMarkerIndex(lines: string[], filePath = \"\", opts?: IdOptions): MarkerIndex {\n const { markers, warnings } = parseMarkers(lines, filePath, opts);\n const covers = (lineIdx: number, ruleId: string): MarkerHit | null => {\n const want = ruleId.toUpperCase();\n for (const marker of markers) {\n if (marker.targetLine !== lineIdx) continue;\n if (marker.ruleIds.includes(\"SCANNER\") || marker.ruleIds.includes(want)) return marker;\n }\n return null;\n };\n return {\n markers,\n warnings,\n covers(lineIdx, ruleId) {\n return covers(lineIdx, ruleId) !== null;\n },\n info(lineIdx, ruleId) {\n const hit = covers(lineIdx, ruleId);\n if (!hit) return null;\n const token = hit.ruleIds.includes(ruleId.toUpperCase()) ? ruleId.toUpperCase() : \"SCANNER\";\n return { ruleToken: token, justification: hit.justification, declaredIn: hit.declaredIn };\n },\n };\n}\n\nexport function markerCoversLine(lines: string[], lineIdx: number, ruleId: string): boolean {\n return buildMarkerIndex(lines, \"\").covers(lineIdx, ruleId);\n}\n\nfunction posix(p: string): string {\n return p.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n}\n\nexport function isRootIgnorePath(filePath: string): boolean {\n return posix(filePath) === \".xploitscanignore\";\n}\n\n/**\n * A comment is a leading `#`, or `#` after whitespace. A `#` inside a path\n * stays in the pattern. A backslash is recorded and not consumed, so an\n * escape cannot change what the pattern matches.\n */\nfunction splitIgnoreLine(line: string): { code: string; comment: string; escaped: boolean } {\n let i = 0;\n while (i < line.length && (line[i] === \" \" || line[i] === \"\\t\")) i++;\n if (i < line.length && line[i] === \"#\") {\n return { code: \"\", comment: line.slice(i + 1).trim(), escaped: false };\n }\n let code = \"\";\n let escaped = false;\n for (let k = 0; k < line.length; k++) {\n const c = line[k] ?? \"\";\n if (c === \"\\\\\") {\n escaped = true;\n code += c;\n if (k + 1 < line.length) {\n code += line[k + 1] ?? \"\";\n k++;\n }\n continue;\n }\n if (c === \"#\" && k > 0 && (line[k - 1] === \" \" || line[k - 1] === \"\\t\")) {\n return { code: code.trimEnd(), comment: line.slice(k + 1).trim(), escaped };\n }\n code += c;\n }\n return { code: code.trim(), comment: \"\", escaped };\n}\n\nfunction peelRules(code: string): { pattern: string; rules: string[] | null; unscoped: boolean } {\n const parts = code.split(/[ \\t]+/).filter(Boolean);\n const rules: string[] = [];\n while (parts.length > 1) {\n const last = parts[parts.length - 1] ?? \"\";\n const ids = last\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean);\n if (ids.length === 0 || !ids.every((id) => isWellFormedRuleId(id))) break;\n rules.unshift(...ids);\n parts.pop();\n }\n const pattern = parts.join(\" \");\n const unscoped = rules.length === 0 && /\\s/.test(code.trim());\n return { pattern, rules: rules.length ? rules : null, unscoped };\n}\n\nfunction patternRejected(pattern: string): boolean {\n if (pattern.includes(\"\\0\")) return true;\n if (/^[A-Za-z]:/.test(pattern)) return true;\n const norm = pattern.replace(/\\\\/g, \"/\");\n if (/^[A-Za-z]:/.test(norm)) return true;\n const body = norm.replace(/^!/, \"\");\n if (body.split(\"/\").includes(\"..\")) return true;\n const bare = body.replace(/^\\.\\//, \"\");\n if (/^\\/[^/*?\\]]+$/.test(bare) && !bare.slice(1).includes(\"/\")) return true;\n return false;\n}\n\nfunction isOverBroad(pattern: string, rules: string[] | null): boolean {\n if (pattern.startsWith(\"!\")) return false;\n const body = pattern.replace(/^\\.\\//, \"\").replace(/^\\//, \"\");\n const broad = body === \"*\" || body === \"**\" || body === \"**/*\";\n const all = rules === null || rules.some((r) => r.toUpperCase() === \"SCANNER\");\n return broad && all;\n}\n\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\nfunction compilePattern(pattern: string): IgnoreMatcher {\n const neg = pattern.startsWith(\"!\");\n const body = (neg ? pattern.slice(1) : pattern).replace(/^\\.\\//, \"\");\n return ignore().add(body);\n}\n\nexport function parseIgnoreFile(\n text: string,\n dirRel = \"\",\n opts?: IdOptions & { declaredPath?: string },\n): { entries: IgnoreEntry[]; warnings: SuppressionWarning[]; ignoredWhole: boolean } {\n const declared =\n opts?.declaredPath ?? (dirRel ? `${posix(dirRel)}/.xploitscanignore` : \".xploitscanignore\");\n const dir = posix(dirRel).replace(/\\/$/, \"\");\n if (text.includes(\"\\0\")) {\n return { entries: [], warnings: [warn(declared, 1, \"binary\")], ignoredWhole: true };\n }\n const bytes = utf8ByteLength(text);\n const normalized = text.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n let rawLines = normalized.split(\"\\n\");\n if (rawLines.length > 0 && rawLines[rawLines.length - 1] === \"\" && normalized.endsWith(\"\\n\")) {\n rawLines = rawLines.slice(0, -1);\n }\n if (bytes > MAX_IGNORE_BYTES || rawLines.length > MAX_IGNORE_LINES) {\n return { entries: [], warnings: [warn(declared, 1, \"over_cap\")], ignoredWhole: true };\n }\n const entries: IgnoreEntry[] = [];\n const warnings: SuppressionWarning[] = [];\n rawLines.forEach((raw, idx) => {\n const lineNo = idx + 1;\n if (raw.length > MAX_IGNORE_LINE_LEN) {\n warnings.push(warn(declared, lineNo, \"line_too_long\"));\n return;\n }\n const split = splitIgnoreLine(raw);\n if (split.escaped) {\n warnings.push(warn(declared, lineNo, \"path_rejected\"));\n return;\n }\n const { code, comment } = split;\n if (!code.trim() || code.trimStart().startsWith(\"#\")) return;\n const peeled = peelRules(code.trim());\n if (!peeled.pattern) {\n warnings.push(warn(declared, lineNo, \"unrecognized_marker\"));\n return;\n }\n if (patternRejected(peeled.pattern)) {\n warnings.push(warn(declared, lineNo, \"path_rejected\"));\n return;\n }\n if (peeled.unscoped) {\n warnings.push(warn(declared, lineNo, \"unscoped_whitespace\"));\n return;\n }\n const accepted: string[] = [];\n for (const id of peeled.rules ?? []) {\n const fate = fateOf(id, opts);\n if (fate === \"unknown\") {\n warnings.push(warn(declared, lineNo, \"unknown_rule_id\", [id.toUpperCase()]));\n continue;\n }\n if (fate === \"pro-silent\") continue;\n accepted.push(id.toUpperCase());\n }\n if (peeled.rules && accepted.length === 0) return;\n const pattern = peeled.pattern.replace(/\\\\/g, \"/\");\n let matcher: IgnoreMatcher;\n try {\n matcher = compilePattern(pattern);\n } catch {\n warnings.push(warn(declared, lineNo, \"path_rejected\"));\n return;\n }\n entries.push({\n dirRel: dir,\n pattern,\n negated: pattern.startsWith(\"!\"),\n rules: peeled.rules ? new Set(accepted) : null,\n justification: comment.slice(0, MAX_JUSTIFICATION),\n declaredIn: `${declared}:${lineNo}`,\n line: lineNo,\n overBroad: isOverBroad(pattern, peeled.rules),\n matcher,\n });\n });\n return { entries, warnings, ignoredWhole: false };\n}\n\nexport interface IgnoreSource {\n path: string;\n text: string;\n}\n\nexport function parseIgnoreSources(\n sources: IgnoreSource[],\n mode: \"nested\" | \"root-only\",\n opts?: IdOptions,\n): { entries: IgnoreEntry[]; warnings: SuppressionWarning[] } {\n const entries: IgnoreEntry[] = [];\n const warnings: SuppressionWarning[] = [];\n const ordered = [...sources].sort((a, b) => posix(a.path).length - posix(b.path).length);\n for (const source of ordered) {\n const path = posix(source.path);\n const root = isRootIgnorePath(path);\n if (mode === \"root-only\" && !root) {\n warnings.push(warn(path, 1, \"nested_ignored\"));\n continue;\n }\n const dir = root ? \"\" : path.slice(0, Math.max(0, path.lastIndexOf(\"/\")));\n const parsed = parseIgnoreFile(source.text, dir, { ...opts, declaredPath: path });\n entries.push(...parsed.entries);\n warnings.push(...parsed.warnings);\n }\n return { entries, warnings };\n}\n\nfunction relativeTo(filePath: string, dirRel: string): string | null {\n const path = posix(filePath);\n if (!dirRel) return path;\n if (path === dirRel) return null;\n if (path.startsWith(`${dirRel}/`)) return path.slice(dirRel.length + 1);\n return null;\n}\n\nfunction matcherFor(entry: IgnoreEntry): IgnoreMatcher | null {\n if (entry.matcher) return entry.matcher;\n try {\n entry.matcher = compilePattern(entry.pattern);\n return entry.matcher;\n } catch {\n return null;\n }\n}\n\nfunction entryMatches(entry: IgnoreEntry, filePath: string): boolean {\n const rel = relativeTo(filePath, entry.dirRel);\n if (rel === null || rel === \"\") return false;\n const matcher = matcherFor(entry);\n if (!matcher) return false;\n try {\n return matcher.ignores(rel);\n } catch {\n return false;\n }\n}\n\nexport function matchIgnore(\n entries: IgnoreEntry[],\n filePath: string,\n ruleId: string,\n): IgnoreEntry | null {\n const rule = ruleId.toUpperCase();\n let winner: IgnoreEntry | null = null;\n for (const entry of entries) {\n if (!entryMatches(entry, filePath)) continue;\n const applies = entry.rules === null || entry.rules.has(\"SCANNER\") || entry.rules.has(rule);\n if (!applies) continue;\n winner = entry.negated ? null : entry;\n }\n return winner;\n}\n\nfunction filesMap(\n input: ReadonlyMap<string, string> | Record<string, string>,\n): Map<string, string> {\n if (input instanceof Map) return input;\n return new Map(Object.entries(input).map(([k, v]) => [posix(k), v]));\n}\n\nexport interface ApplyInput {\n filesByPath: ReadonlyMap<string, string> | Record<string, string>;\n ignoreEntries?: IgnoreEntry[];\n knownIds?: ReadonlySet<string> | null;\n proIds?: ReadonlySet<string>;\n tier?: \"free\" | \"pro\";\n overlapFrom?: readonly Suppressible[];\n}\n\nexport function applySuppressions<T extends Suppressible>(\n findings: readonly T[],\n input: ApplyInput,\n): {\n kept: T[];\n suppressed: Array<T & { suppression: SuppressionInfo }>;\n warnings: SuppressionWarning[];\n} {\n const files = filesMap(input.filesByPath);\n const opts: IdOptions = { knownIds: input.knownIds, proIds: input.proIds, tier: input.tier };\n const entries = input.ignoreEntries ?? [];\n const warnings: SuppressionWarning[] = [];\n const indexes = new Map<string, MarkerIndex>();\n const indexFor = (file: string): MarkerIndex => {\n const key = posix(file);\n const cached = indexes.get(key);\n if (cached) return cached;\n const text = files.get(key) ?? \"\";\n const folded = text.toLowerCase();\n if (!folded.includes(\"-ok\") && !folded.includes(\"-0k\")) {\n const empty: MarkerIndex = {\n markers: [],\n warnings: [],\n covers: () => false,\n info: () => null,\n };\n indexes.set(key, empty);\n return empty;\n }\n const built = buildMarkerIndex(text.split(\"\\n\"), key, opts);\n indexes.set(key, built);\n warnings.push(...built.warnings);\n return built;\n };\n\n const direct = new Map<T, SuppressionInfo>();\n for (const finding of findings) {\n const info = indexFor(finding.file).info(finding.line - 1, finding.rule);\n if (!info) continue;\n direct.set(finding, {\n kind: \"inSource\",\n source: \"marker\",\n ruleToken: info.ruleToken,\n justification: info.justification,\n declaredIn: info.declaredIn,\n });\n }\n\n const seenFiles = new Set<string>();\n for (const file of files.keys()) seenFiles.add(posix(file));\n for (const finding of findings) seenFiles.add(posix(finding.file));\n for (const entry of entries) {\n if (!entry.overBroad) continue;\n let count = 0;\n for (const file of seenFiles) if (entryMatches(entry, file)) count++;\n if (count > 0)\n warnings.push(\n warn(entry.declaredIn.split(\":\")[0] ?? \"\", entry.line, \"over_broad\", [], count),\n );\n }\n\n const kept: T[] = [];\n const suppressed: Array<T & { suppression: SuppressionInfo }> = [];\n for (const finding of findings) {\n const marker = direct.get(finding);\n if (marker) {\n suppressed.push({ ...finding, suppression: marker });\n continue;\n }\n const hit = matchIgnore(entries, finding.file, finding.rule);\n if (hit) {\n suppressed.push({\n ...finding,\n suppression: {\n kind: \"external\",\n source: \"ignore-file\",\n ruleToken: finding.rule.toUpperCase(),\n justification: hit.justification,\n declaredIn: hit.declaredIn,\n },\n });\n continue;\n }\n kept.push(finding);\n }\n return { kept, suppressed, warnings };\n}\n\n/** Rule-scoped line, including space-separated ids. Plain paths are not. */\nexport function isRuleScopedIgnoreLine(line: string): boolean {\n const split = splitIgnoreLine(line.replace(/\\r$/, \"\"));\n if (split.escaped) return false;\n const { code } = split;\n if (!code.trim() || code.trimStart().startsWith(\"#\")) return false;\n const peeled = peelRules(code.trim());\n return peeled.rules !== null && peeled.rules.length > 0 && !patternRejected(peeled.pattern);\n}\n\n/** Unscoped star, double-star, or slash-double-star. The file is still scanned. */\nexport function isUnscopedOverBroadLine(line: string): boolean {\n const split = splitIgnoreLine(line.replace(/\\r$/, \"\"));\n if (split.escaped) return false;\n const { code } = split;\n if (!code.trim() || code.trimStart().startsWith(\"#\")) return false;\n const peeled = peelRules(code.trim());\n if (peeled.rules && peeled.rules.length > 0) return false;\n return isOverBroad(peeled.pattern, null);\n}\n\nconst SCAN_META = Symbol.for(\"xploitscan.scanSuppression\");\n\nexport interface ScanSuppressionMeta {\n preCount: number;\n inline: number;\n ignoreFile: number;\n warnings: SuppressionWarning[];\n suppressed: Array<Record<string, unknown>>;\n}\n\nexport function attachScanSuppression<T>(findings: T[], meta: ScanSuppressionMeta): T[] {\n Object.defineProperty(findings, SCAN_META, { value: meta, enumerable: false });\n return findings;\n}\n\nexport function readScanSuppression(findings: unknown): ScanSuppressionMeta | null {\n if (!findings || typeof findings !== \"object\") return null;\n const value = (findings as Record<symbol, unknown>)[SCAN_META];\n if (!value || typeof value !== \"object\") return null;\n return value as ScanSuppressionMeta;\n}\n\nexport function countPass(\n inlineAlready: number,\n suppressed: ReadonlyArray<{ suppression: SuppressionInfo }>,\n): { inline: number; ignoreFile: number } {\n let ignoreFile = 0;\n let inline = inlineAlready;\n for (const item of suppressed) {\n if (item.suppression.source === \"ignore-file\") ignoreFile++;\n else inline++;\n }\n return { inline, ignoreFile };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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Y;AAC7B,QAAI,KAAK,YAAY,WAAW,cAAe;AAAA,QAC1C;AAAA,EACP;AACA,SAAO,EAAE,QAAQ,WAAW;AAC9B;","names":["id","listed","end","ignore"]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import ignore from 'ignore';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One suppression pass for every surface.
|
|
5
|
+
*
|
|
6
|
+
* Markers (`<ID>-OK`) and `.xploitscanignore` lines are parsed here and applied
|
|
7
|
+
* once to merged findings. Globs go through the `ignore` package. No hand-built
|
|
8
|
+
* regex is compiled from a user pattern.
|
|
9
|
+
*
|
|
10
|
+
* eslint-style `xploitscan-ignore` forms are not a syntax. They warn and
|
|
11
|
+
* suppress nothing.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare const MAX_IGNORE_BYTES: number;
|
|
15
|
+
declare const MAX_IGNORE_LINES = 2000;
|
|
16
|
+
declare const MAX_IGNORE_LINE_LEN = 1024;
|
|
17
|
+
declare const MAX_JUSTIFICATION = 200;
|
|
18
|
+
declare const MAX_WARNING_CAP = 20;
|
|
19
|
+
declare const MAX_SUPPRESSED_LIST = 500;
|
|
20
|
+
declare const MAX_COUNT = 1000;
|
|
21
|
+
declare const MAX_BLOCK_LINES = 20;
|
|
22
|
+
declare const NESTED_IGNORE_WARNING = "nested .xploitscanignore ignored (only the root file is read here)";
|
|
23
|
+
declare const MARKER_SYNTAX = "use <ID>-OK inside a comment";
|
|
24
|
+
/** Bounded, anchored, no nested quantifiers. Exported for the slow-regex check. */
|
|
25
|
+
declare const RULE_ID_PATTERN: RegExp;
|
|
26
|
+
declare const SUPPRESSION_REGEXES: readonly RegExp[];
|
|
27
|
+
interface SuppressionInfo {
|
|
28
|
+
kind: "inSource" | "external";
|
|
29
|
+
source: "marker" | "ignore-file";
|
|
30
|
+
ruleToken: string;
|
|
31
|
+
justification: string;
|
|
32
|
+
declaredIn: string;
|
|
33
|
+
}
|
|
34
|
+
interface SuppressionWarning {
|
|
35
|
+
code: string;
|
|
36
|
+
file: string;
|
|
37
|
+
line: number;
|
|
38
|
+
ruleIds: string[];
|
|
39
|
+
count: number;
|
|
40
|
+
}
|
|
41
|
+
interface MarkerHit {
|
|
42
|
+
markerLine: number;
|
|
43
|
+
targetLine: number;
|
|
44
|
+
ruleIds: string[];
|
|
45
|
+
justification: string;
|
|
46
|
+
declaredIn: string;
|
|
47
|
+
}
|
|
48
|
+
interface IgnoreEntry {
|
|
49
|
+
dirRel: string;
|
|
50
|
+
pattern: string;
|
|
51
|
+
negated: boolean;
|
|
52
|
+
/** Upper-case ids. Null suppresses every rule. */
|
|
53
|
+
rules: Set<string> | null;
|
|
54
|
+
justification: string;
|
|
55
|
+
declaredIn: string;
|
|
56
|
+
line: number;
|
|
57
|
+
overBroad: boolean;
|
|
58
|
+
/** Compiled once at parse time and reused for every finding. */
|
|
59
|
+
matcher?: IgnoreMatcher;
|
|
60
|
+
}
|
|
61
|
+
interface IdOptions {
|
|
62
|
+
knownIds?: ReadonlySet<string> | null;
|
|
63
|
+
proIds?: ReadonlySet<string>;
|
|
64
|
+
tier?: "free" | "pro";
|
|
65
|
+
}
|
|
66
|
+
interface Suppressible {
|
|
67
|
+
rule: string;
|
|
68
|
+
file: string;
|
|
69
|
+
line: number;
|
|
70
|
+
column?: number;
|
|
71
|
+
endColumn?: number;
|
|
72
|
+
snippet?: string;
|
|
73
|
+
}
|
|
74
|
+
declare function utf8ByteLength(text: string): number;
|
|
75
|
+
declare function isWellFormedRuleId(id: string): boolean;
|
|
76
|
+
declare function isBuiltinRuleId(id: string): boolean;
|
|
77
|
+
declare function clampCount(value: unknown, max?: number): number;
|
|
78
|
+
declare function capWarnings(warnings: SuppressionWarning[], cap?: number): {
|
|
79
|
+
shown: SuppressionWarning[];
|
|
80
|
+
extra: number;
|
|
81
|
+
};
|
|
82
|
+
declare function suppressionSummary(inline: number, ignoreFile: number): string;
|
|
83
|
+
declare function warningForUpload(w: SuppressionWarning): {
|
|
84
|
+
code: string;
|
|
85
|
+
ruleIds: string[];
|
|
86
|
+
count: number;
|
|
87
|
+
};
|
|
88
|
+
declare function warningLine(w: SuppressionWarning): string;
|
|
89
|
+
declare function attachInlineSuppressed<T>(findings: T[], suppressed: unknown[]): T[];
|
|
90
|
+
declare function readInlineSuppressed(findings: unknown): unknown[];
|
|
91
|
+
declare function publicSuppressedRecord(finding: Record<string, unknown>): Record<string, unknown>;
|
|
92
|
+
/** Replace string and template contents with spaces. Stops at a comment so a quote inside it cannot mask a marker. Line-local, linear. */
|
|
93
|
+
declare function maskStringLiterals(line: string): string;
|
|
94
|
+
declare function parseMarkers(lines: string[], filePath?: string, opts?: IdOptions): {
|
|
95
|
+
markers: MarkerHit[];
|
|
96
|
+
warnings: SuppressionWarning[];
|
|
97
|
+
};
|
|
98
|
+
interface MarkerIndex {
|
|
99
|
+
covers(lineIdx: number, ruleId: string): boolean;
|
|
100
|
+
info(lineIdx: number, ruleId: string): {
|
|
101
|
+
ruleToken: string;
|
|
102
|
+
justification: string;
|
|
103
|
+
declaredIn: string;
|
|
104
|
+
} | null;
|
|
105
|
+
warnings: SuppressionWarning[];
|
|
106
|
+
markers: MarkerHit[];
|
|
107
|
+
}
|
|
108
|
+
declare function buildMarkerIndex(lines: string[], filePath?: string, opts?: IdOptions): MarkerIndex;
|
|
109
|
+
declare function markerCoversLine(lines: string[], lineIdx: number, ruleId: string): boolean;
|
|
110
|
+
declare function isRootIgnorePath(filePath: string): boolean;
|
|
111
|
+
type IgnoreMatcher = ReturnType<typeof ignore>;
|
|
112
|
+
declare function parseIgnoreFile(text: string, dirRel?: string, opts?: IdOptions & {
|
|
113
|
+
declaredPath?: string;
|
|
114
|
+
}): {
|
|
115
|
+
entries: IgnoreEntry[];
|
|
116
|
+
warnings: SuppressionWarning[];
|
|
117
|
+
ignoredWhole: boolean;
|
|
118
|
+
};
|
|
119
|
+
interface IgnoreSource {
|
|
120
|
+
path: string;
|
|
121
|
+
text: string;
|
|
122
|
+
}
|
|
123
|
+
declare function parseIgnoreSources(sources: IgnoreSource[], mode: "nested" | "root-only", opts?: IdOptions): {
|
|
124
|
+
entries: IgnoreEntry[];
|
|
125
|
+
warnings: SuppressionWarning[];
|
|
126
|
+
};
|
|
127
|
+
declare function matchIgnore(entries: IgnoreEntry[], filePath: string, ruleId: string): IgnoreEntry | null;
|
|
128
|
+
interface ApplyInput {
|
|
129
|
+
filesByPath: ReadonlyMap<string, string> | Record<string, string>;
|
|
130
|
+
ignoreEntries?: IgnoreEntry[];
|
|
131
|
+
knownIds?: ReadonlySet<string> | null;
|
|
132
|
+
proIds?: ReadonlySet<string>;
|
|
133
|
+
tier?: "free" | "pro";
|
|
134
|
+
overlapFrom?: readonly Suppressible[];
|
|
135
|
+
}
|
|
136
|
+
declare function applySuppressions<T extends Suppressible>(findings: readonly T[], input: ApplyInput): {
|
|
137
|
+
kept: T[];
|
|
138
|
+
suppressed: Array<T & {
|
|
139
|
+
suppression: SuppressionInfo;
|
|
140
|
+
}>;
|
|
141
|
+
warnings: SuppressionWarning[];
|
|
142
|
+
};
|
|
143
|
+
/** Rule-scoped line, including space-separated ids. Plain paths are not. */
|
|
144
|
+
declare function isRuleScopedIgnoreLine(line: string): boolean;
|
|
145
|
+
/** Unscoped star, double-star, or slash-double-star. The file is still scanned. */
|
|
146
|
+
declare function isUnscopedOverBroadLine(line: string): boolean;
|
|
147
|
+
interface ScanSuppressionMeta {
|
|
148
|
+
preCount: number;
|
|
149
|
+
inline: number;
|
|
150
|
+
ignoreFile: number;
|
|
151
|
+
warnings: SuppressionWarning[];
|
|
152
|
+
suppressed: Array<Record<string, unknown>>;
|
|
153
|
+
}
|
|
154
|
+
declare function attachScanSuppression<T>(findings: T[], meta: ScanSuppressionMeta): T[];
|
|
155
|
+
declare function readScanSuppression(findings: unknown): ScanSuppressionMeta | null;
|
|
156
|
+
declare function countPass(inlineAlready: number, suppressed: ReadonlyArray<{
|
|
157
|
+
suppression: SuppressionInfo;
|
|
158
|
+
}>): {
|
|
159
|
+
inline: number;
|
|
160
|
+
ignoreFile: number;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export { type ApplyInput, type IdOptions, type IgnoreEntry, type IgnoreSource, MARKER_SYNTAX, MAX_BLOCK_LINES, MAX_COUNT, MAX_IGNORE_BYTES, MAX_IGNORE_LINES, MAX_IGNORE_LINE_LEN, MAX_JUSTIFICATION, MAX_SUPPRESSED_LIST, MAX_WARNING_CAP, type MarkerHit, type MarkerIndex, NESTED_IGNORE_WARNING, RULE_ID_PATTERN, SUPPRESSION_REGEXES, type ScanSuppressionMeta, type Suppressible, type SuppressionInfo, type SuppressionWarning, applySuppressions, attachInlineSuppressed, attachScanSuppression, buildMarkerIndex, capWarnings, clampCount, countPass, isBuiltinRuleId, isRootIgnorePath, isRuleScopedIgnoreLine, isUnscopedOverBroadLine, isWellFormedRuleId, markerCoversLine, maskStringLiterals, matchIgnore, parseIgnoreFile, parseIgnoreSources, parseMarkers, publicSuppressedRecord, readInlineSuppressed, readScanSuppression, suppressionSummary, utf8ByteLength, warningForUpload, warningLine };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import ignore from 'ignore';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One suppression pass for every surface.
|
|
5
|
+
*
|
|
6
|
+
* Markers (`<ID>-OK`) and `.xploitscanignore` lines are parsed here and applied
|
|
7
|
+
* once to merged findings. Globs go through the `ignore` package. No hand-built
|
|
8
|
+
* regex is compiled from a user pattern.
|
|
9
|
+
*
|
|
10
|
+
* eslint-style `xploitscan-ignore` forms are not a syntax. They warn and
|
|
11
|
+
* suppress nothing.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare const MAX_IGNORE_BYTES: number;
|
|
15
|
+
declare const MAX_IGNORE_LINES = 2000;
|
|
16
|
+
declare const MAX_IGNORE_LINE_LEN = 1024;
|
|
17
|
+
declare const MAX_JUSTIFICATION = 200;
|
|
18
|
+
declare const MAX_WARNING_CAP = 20;
|
|
19
|
+
declare const MAX_SUPPRESSED_LIST = 500;
|
|
20
|
+
declare const MAX_COUNT = 1000;
|
|
21
|
+
declare const MAX_BLOCK_LINES = 20;
|
|
22
|
+
declare const NESTED_IGNORE_WARNING = "nested .xploitscanignore ignored (only the root file is read here)";
|
|
23
|
+
declare const MARKER_SYNTAX = "use <ID>-OK inside a comment";
|
|
24
|
+
/** Bounded, anchored, no nested quantifiers. Exported for the slow-regex check. */
|
|
25
|
+
declare const RULE_ID_PATTERN: RegExp;
|
|
26
|
+
declare const SUPPRESSION_REGEXES: readonly RegExp[];
|
|
27
|
+
interface SuppressionInfo {
|
|
28
|
+
kind: "inSource" | "external";
|
|
29
|
+
source: "marker" | "ignore-file";
|
|
30
|
+
ruleToken: string;
|
|
31
|
+
justification: string;
|
|
32
|
+
declaredIn: string;
|
|
33
|
+
}
|
|
34
|
+
interface SuppressionWarning {
|
|
35
|
+
code: string;
|
|
36
|
+
file: string;
|
|
37
|
+
line: number;
|
|
38
|
+
ruleIds: string[];
|
|
39
|
+
count: number;
|
|
40
|
+
}
|
|
41
|
+
interface MarkerHit {
|
|
42
|
+
markerLine: number;
|
|
43
|
+
targetLine: number;
|
|
44
|
+
ruleIds: string[];
|
|
45
|
+
justification: string;
|
|
46
|
+
declaredIn: string;
|
|
47
|
+
}
|
|
48
|
+
interface IgnoreEntry {
|
|
49
|
+
dirRel: string;
|
|
50
|
+
pattern: string;
|
|
51
|
+
negated: boolean;
|
|
52
|
+
/** Upper-case ids. Null suppresses every rule. */
|
|
53
|
+
rules: Set<string> | null;
|
|
54
|
+
justification: string;
|
|
55
|
+
declaredIn: string;
|
|
56
|
+
line: number;
|
|
57
|
+
overBroad: boolean;
|
|
58
|
+
/** Compiled once at parse time and reused for every finding. */
|
|
59
|
+
matcher?: IgnoreMatcher;
|
|
60
|
+
}
|
|
61
|
+
interface IdOptions {
|
|
62
|
+
knownIds?: ReadonlySet<string> | null;
|
|
63
|
+
proIds?: ReadonlySet<string>;
|
|
64
|
+
tier?: "free" | "pro";
|
|
65
|
+
}
|
|
66
|
+
interface Suppressible {
|
|
67
|
+
rule: string;
|
|
68
|
+
file: string;
|
|
69
|
+
line: number;
|
|
70
|
+
column?: number;
|
|
71
|
+
endColumn?: number;
|
|
72
|
+
snippet?: string;
|
|
73
|
+
}
|
|
74
|
+
declare function utf8ByteLength(text: string): number;
|
|
75
|
+
declare function isWellFormedRuleId(id: string): boolean;
|
|
76
|
+
declare function isBuiltinRuleId(id: string): boolean;
|
|
77
|
+
declare function clampCount(value: unknown, max?: number): number;
|
|
78
|
+
declare function capWarnings(warnings: SuppressionWarning[], cap?: number): {
|
|
79
|
+
shown: SuppressionWarning[];
|
|
80
|
+
extra: number;
|
|
81
|
+
};
|
|
82
|
+
declare function suppressionSummary(inline: number, ignoreFile: number): string;
|
|
83
|
+
declare function warningForUpload(w: SuppressionWarning): {
|
|
84
|
+
code: string;
|
|
85
|
+
ruleIds: string[];
|
|
86
|
+
count: number;
|
|
87
|
+
};
|
|
88
|
+
declare function warningLine(w: SuppressionWarning): string;
|
|
89
|
+
declare function attachInlineSuppressed<T>(findings: T[], suppressed: unknown[]): T[];
|
|
90
|
+
declare function readInlineSuppressed(findings: unknown): unknown[];
|
|
91
|
+
declare function publicSuppressedRecord(finding: Record<string, unknown>): Record<string, unknown>;
|
|
92
|
+
/** Replace string and template contents with spaces. Stops at a comment so a quote inside it cannot mask a marker. Line-local, linear. */
|
|
93
|
+
declare function maskStringLiterals(line: string): string;
|
|
94
|
+
declare function parseMarkers(lines: string[], filePath?: string, opts?: IdOptions): {
|
|
95
|
+
markers: MarkerHit[];
|
|
96
|
+
warnings: SuppressionWarning[];
|
|
97
|
+
};
|
|
98
|
+
interface MarkerIndex {
|
|
99
|
+
covers(lineIdx: number, ruleId: string): boolean;
|
|
100
|
+
info(lineIdx: number, ruleId: string): {
|
|
101
|
+
ruleToken: string;
|
|
102
|
+
justification: string;
|
|
103
|
+
declaredIn: string;
|
|
104
|
+
} | null;
|
|
105
|
+
warnings: SuppressionWarning[];
|
|
106
|
+
markers: MarkerHit[];
|
|
107
|
+
}
|
|
108
|
+
declare function buildMarkerIndex(lines: string[], filePath?: string, opts?: IdOptions): MarkerIndex;
|
|
109
|
+
declare function markerCoversLine(lines: string[], lineIdx: number, ruleId: string): boolean;
|
|
110
|
+
declare function isRootIgnorePath(filePath: string): boolean;
|
|
111
|
+
type IgnoreMatcher = ReturnType<typeof ignore>;
|
|
112
|
+
declare function parseIgnoreFile(text: string, dirRel?: string, opts?: IdOptions & {
|
|
113
|
+
declaredPath?: string;
|
|
114
|
+
}): {
|
|
115
|
+
entries: IgnoreEntry[];
|
|
116
|
+
warnings: SuppressionWarning[];
|
|
117
|
+
ignoredWhole: boolean;
|
|
118
|
+
};
|
|
119
|
+
interface IgnoreSource {
|
|
120
|
+
path: string;
|
|
121
|
+
text: string;
|
|
122
|
+
}
|
|
123
|
+
declare function parseIgnoreSources(sources: IgnoreSource[], mode: "nested" | "root-only", opts?: IdOptions): {
|
|
124
|
+
entries: IgnoreEntry[];
|
|
125
|
+
warnings: SuppressionWarning[];
|
|
126
|
+
};
|
|
127
|
+
declare function matchIgnore(entries: IgnoreEntry[], filePath: string, ruleId: string): IgnoreEntry | null;
|
|
128
|
+
interface ApplyInput {
|
|
129
|
+
filesByPath: ReadonlyMap<string, string> | Record<string, string>;
|
|
130
|
+
ignoreEntries?: IgnoreEntry[];
|
|
131
|
+
knownIds?: ReadonlySet<string> | null;
|
|
132
|
+
proIds?: ReadonlySet<string>;
|
|
133
|
+
tier?: "free" | "pro";
|
|
134
|
+
overlapFrom?: readonly Suppressible[];
|
|
135
|
+
}
|
|
136
|
+
declare function applySuppressions<T extends Suppressible>(findings: readonly T[], input: ApplyInput): {
|
|
137
|
+
kept: T[];
|
|
138
|
+
suppressed: Array<T & {
|
|
139
|
+
suppression: SuppressionInfo;
|
|
140
|
+
}>;
|
|
141
|
+
warnings: SuppressionWarning[];
|
|
142
|
+
};
|
|
143
|
+
/** Rule-scoped line, including space-separated ids. Plain paths are not. */
|
|
144
|
+
declare function isRuleScopedIgnoreLine(line: string): boolean;
|
|
145
|
+
/** Unscoped star, double-star, or slash-double-star. The file is still scanned. */
|
|
146
|
+
declare function isUnscopedOverBroadLine(line: string): boolean;
|
|
147
|
+
interface ScanSuppressionMeta {
|
|
148
|
+
preCount: number;
|
|
149
|
+
inline: number;
|
|
150
|
+
ignoreFile: number;
|
|
151
|
+
warnings: SuppressionWarning[];
|
|
152
|
+
suppressed: Array<Record<string, unknown>>;
|
|
153
|
+
}
|
|
154
|
+
declare function attachScanSuppression<T>(findings: T[], meta: ScanSuppressionMeta): T[];
|
|
155
|
+
declare function readScanSuppression(findings: unknown): ScanSuppressionMeta | null;
|
|
156
|
+
declare function countPass(inlineAlready: number, suppressed: ReadonlyArray<{
|
|
157
|
+
suppression: SuppressionInfo;
|
|
158
|
+
}>): {
|
|
159
|
+
inline: number;
|
|
160
|
+
ignoreFile: number;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export { type ApplyInput, type IdOptions, type IgnoreEntry, type IgnoreSource, MARKER_SYNTAX, MAX_BLOCK_LINES, MAX_COUNT, MAX_IGNORE_BYTES, MAX_IGNORE_LINES, MAX_IGNORE_LINE_LEN, MAX_JUSTIFICATION, MAX_SUPPRESSED_LIST, MAX_WARNING_CAP, type MarkerHit, type MarkerIndex, NESTED_IGNORE_WARNING, RULE_ID_PATTERN, SUPPRESSION_REGEXES, type ScanSuppressionMeta, type Suppressible, type SuppressionInfo, type SuppressionWarning, applySuppressions, attachInlineSuppressed, attachScanSuppression, buildMarkerIndex, capWarnings, clampCount, countPass, isBuiltinRuleId, isRootIgnorePath, isRuleScopedIgnoreLine, isUnscopedOverBroadLine, isWellFormedRuleId, markerCoversLine, maskStringLiterals, matchIgnore, parseIgnoreFile, parseIgnoreSources, parseMarkers, publicSuppressedRecord, readInlineSuppressed, readScanSuppression, suppressionSummary, utf8ByteLength, warningForUpload, warningLine };
|