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,878 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/suppression.ts
|
|
31
|
+
var suppression_exports = {};
|
|
32
|
+
__export(suppression_exports, {
|
|
33
|
+
MARKER_SYNTAX: () => MARKER_SYNTAX,
|
|
34
|
+
MAX_BLOCK_LINES: () => MAX_BLOCK_LINES,
|
|
35
|
+
MAX_COUNT: () => MAX_COUNT,
|
|
36
|
+
MAX_IGNORE_BYTES: () => MAX_IGNORE_BYTES,
|
|
37
|
+
MAX_IGNORE_LINES: () => MAX_IGNORE_LINES,
|
|
38
|
+
MAX_IGNORE_LINE_LEN: () => MAX_IGNORE_LINE_LEN,
|
|
39
|
+
MAX_JUSTIFICATION: () => MAX_JUSTIFICATION,
|
|
40
|
+
MAX_SUPPRESSED_LIST: () => MAX_SUPPRESSED_LIST,
|
|
41
|
+
MAX_WARNING_CAP: () => MAX_WARNING_CAP,
|
|
42
|
+
NESTED_IGNORE_WARNING: () => NESTED_IGNORE_WARNING,
|
|
43
|
+
RULE_ID_PATTERN: () => RULE_ID_PATTERN,
|
|
44
|
+
SUPPRESSION_REGEXES: () => SUPPRESSION_REGEXES,
|
|
45
|
+
applySuppressions: () => applySuppressions,
|
|
46
|
+
attachInlineSuppressed: () => attachInlineSuppressed,
|
|
47
|
+
attachScanSuppression: () => attachScanSuppression,
|
|
48
|
+
buildMarkerIndex: () => buildMarkerIndex,
|
|
49
|
+
capWarnings: () => capWarnings,
|
|
50
|
+
clampCount: () => clampCount,
|
|
51
|
+
countPass: () => countPass,
|
|
52
|
+
isBuiltinRuleId: () => isBuiltinRuleId,
|
|
53
|
+
isRootIgnorePath: () => isRootIgnorePath,
|
|
54
|
+
isRuleScopedIgnoreLine: () => isRuleScopedIgnoreLine,
|
|
55
|
+
isUnscopedOverBroadLine: () => isUnscopedOverBroadLine,
|
|
56
|
+
isWellFormedRuleId: () => isWellFormedRuleId,
|
|
57
|
+
markerCoversLine: () => markerCoversLine,
|
|
58
|
+
maskStringLiterals: () => maskStringLiterals,
|
|
59
|
+
matchIgnore: () => matchIgnore,
|
|
60
|
+
parseIgnoreFile: () => parseIgnoreFile,
|
|
61
|
+
parseIgnoreSources: () => parseIgnoreSources,
|
|
62
|
+
parseMarkers: () => parseMarkers,
|
|
63
|
+
publicSuppressedRecord: () => publicSuppressedRecord,
|
|
64
|
+
readInlineSuppressed: () => readInlineSuppressed,
|
|
65
|
+
readScanSuppression: () => readScanSuppression,
|
|
66
|
+
suppressionSummary: () => suppressionSummary,
|
|
67
|
+
utf8ByteLength: () => utf8ByteLength,
|
|
68
|
+
warningForUpload: () => warningForUpload,
|
|
69
|
+
warningLine: () => warningLine
|
|
70
|
+
});
|
|
71
|
+
module.exports = __toCommonJS(suppression_exports);
|
|
72
|
+
var import_ignore = __toESM(require("ignore"), 1);
|
|
73
|
+
var MAX_IGNORE_BYTES = 64 * 1024;
|
|
74
|
+
var MAX_IGNORE_LINES = 2e3;
|
|
75
|
+
var MAX_IGNORE_LINE_LEN = 1024;
|
|
76
|
+
var MAX_JUSTIFICATION = 200;
|
|
77
|
+
var MAX_WARNING_CAP = 20;
|
|
78
|
+
var MAX_SUPPRESSED_LIST = 500;
|
|
79
|
+
var MAX_COUNT = 1e3;
|
|
80
|
+
var MAX_BLOCK_LINES = 20;
|
|
81
|
+
var NESTED_IGNORE_WARNING = "nested .xploitscanignore ignored (only the root file is read here)";
|
|
82
|
+
var MARKER_SYNTAX = "use <ID>-OK inside a comment";
|
|
83
|
+
var RULE_ID_PATTERN = /^(?:[A-Za-z]{2,8}\d{0,4}|GL:[A-Za-z0-9-]{1,64}|scanner)$/i;
|
|
84
|
+
var SUPPRESSION_REGEXES = [RULE_ID_PATTERN];
|
|
85
|
+
var INLINE = /* @__PURE__ */ Symbol.for("xploitscan.inlineSuppressed");
|
|
86
|
+
function utf8ByteLength(text) {
|
|
87
|
+
return new TextEncoder().encode(text).length;
|
|
88
|
+
}
|
|
89
|
+
function isWellFormedRuleId(id) {
|
|
90
|
+
return RULE_ID_PATTERN.test(id);
|
|
91
|
+
}
|
|
92
|
+
function isBuiltinRuleId(id) {
|
|
93
|
+
if (!isWellFormedRuleId(id)) return false;
|
|
94
|
+
const u = id.toUpperCase();
|
|
95
|
+
if (u === "ENTROPY" || u === "SCANNER" || u === "AI") return true;
|
|
96
|
+
if (/^CFG\d{1,4}$/.test(u)) return true;
|
|
97
|
+
if (/^MFA\d{1,4}$/.test(u)) return true;
|
|
98
|
+
if (/^QA\d{1,4}$/.test(u)) return true;
|
|
99
|
+
if (/^GL:/i.test(id)) return true;
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
function clampCount(value, max = MAX_COUNT) {
|
|
103
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
104
|
+
if (!Number.isFinite(n) || n < 0) return 0;
|
|
105
|
+
return Math.min(max, Math.floor(n));
|
|
106
|
+
}
|
|
107
|
+
function capWarnings(warnings, cap = MAX_WARNING_CAP) {
|
|
108
|
+
if (warnings.length <= cap) return { shown: warnings, extra: 0 };
|
|
109
|
+
return { shown: warnings.slice(0, cap), extra: warnings.length - cap };
|
|
110
|
+
}
|
|
111
|
+
function suppressionSummary(inline, ignoreFile) {
|
|
112
|
+
const n = inline + ignoreFile;
|
|
113
|
+
const noun = n === 1 ? "finding" : "findings";
|
|
114
|
+
return `${n} ${noun} suppressed (${inline} inline marker, ${ignoreFile} ignore file)`;
|
|
115
|
+
}
|
|
116
|
+
function warningForUpload(w) {
|
|
117
|
+
return { code: w.code, ruleIds: [...w.ruleIds], count: w.count };
|
|
118
|
+
}
|
|
119
|
+
function warningLine(w) {
|
|
120
|
+
if (w.code === "nested_ignored") return `${w.file} ${NESTED_IGNORE_WARNING}`;
|
|
121
|
+
const where = w.file ? `${w.file}:${w.line}` : `line ${w.line}`;
|
|
122
|
+
const ids = w.ruleIds.length ? ` ${w.ruleIds.join(",")}` : "";
|
|
123
|
+
const syntax = w.code === "unrecognized_marker" || w.code === "space_before_ok" ? ` ${MARKER_SYNTAX}` : "";
|
|
124
|
+
const more = w.code === "over_broad" ? ` suppresses all findings in ${w.count} files` : "";
|
|
125
|
+
return `${where} ${w.code}${ids}${more}${syntax}`;
|
|
126
|
+
}
|
|
127
|
+
function attachInlineSuppressed(findings, suppressed) {
|
|
128
|
+
Object.defineProperty(findings, INLINE, { value: suppressed, enumerable: false });
|
|
129
|
+
return findings;
|
|
130
|
+
}
|
|
131
|
+
function readInlineSuppressed(findings) {
|
|
132
|
+
if (!findings || typeof findings !== "object") return [];
|
|
133
|
+
const value = findings[INLINE];
|
|
134
|
+
return Array.isArray(value) ? value : [];
|
|
135
|
+
}
|
|
136
|
+
function publicSuppressedRecord(finding) {
|
|
137
|
+
const suppression = finding.suppression;
|
|
138
|
+
const info = suppression && typeof suppression === "object" ? {
|
|
139
|
+
kind: suppression.kind,
|
|
140
|
+
source: suppression.source,
|
|
141
|
+
ruleToken: suppression.ruleToken,
|
|
142
|
+
justification: String(suppression.justification ?? "").slice(
|
|
143
|
+
0,
|
|
144
|
+
MAX_JUSTIFICATION
|
|
145
|
+
),
|
|
146
|
+
declaredIn: suppression.declaredIn
|
|
147
|
+
} : void 0;
|
|
148
|
+
return {
|
|
149
|
+
rule: finding.rule,
|
|
150
|
+
file: finding.file,
|
|
151
|
+
line: finding.line,
|
|
152
|
+
severity: finding.severity,
|
|
153
|
+
...info ? { suppression: info } : {}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function warn(file, line, code, ruleIds = [], count = 1) {
|
|
157
|
+
return { code, file, line, ruleIds, count };
|
|
158
|
+
}
|
|
159
|
+
function fateOf(id, opts) {
|
|
160
|
+
if (isBuiltinRuleId(id)) return "ok";
|
|
161
|
+
const upper = id.toUpperCase();
|
|
162
|
+
const pro = opts?.proIds;
|
|
163
|
+
if (pro && (pro.has(upper) || pro.has(id))) {
|
|
164
|
+
return opts?.tier === "pro" ? "ok" : "pro-silent";
|
|
165
|
+
}
|
|
166
|
+
if (!opts?.knownIds) return "ok";
|
|
167
|
+
if (opts.knownIds.has(upper) || opts.knownIds.has(id)) return "ok";
|
|
168
|
+
return "unknown";
|
|
169
|
+
}
|
|
170
|
+
function idEndingAt(text, end) {
|
|
171
|
+
const window = text.slice(Math.max(0, end - 80), end);
|
|
172
|
+
const gl = window.match(/GL:[A-Za-z0-9-]{1,64}$/i);
|
|
173
|
+
if (gl) {
|
|
174
|
+
const id2 = gl[0];
|
|
175
|
+
if (isWellFormedRuleId(id2)) return { id: id2, start: end - id2.length };
|
|
176
|
+
}
|
|
177
|
+
const plain = window.match(/[A-Za-z]{2,8}\d{0,4}$/);
|
|
178
|
+
if (!plain) return null;
|
|
179
|
+
const id = plain[0];
|
|
180
|
+
if (id.toLowerCase() === "ok") return null;
|
|
181
|
+
if (!isWellFormedRuleId(id)) return null;
|
|
182
|
+
return { id, start: end - id.length };
|
|
183
|
+
}
|
|
184
|
+
function idListBefore(text, end) {
|
|
185
|
+
const first = idEndingAt(text, end);
|
|
186
|
+
if (!first) return null;
|
|
187
|
+
const ids = [first.id];
|
|
188
|
+
let cursor = first.start;
|
|
189
|
+
while (cursor > 0) {
|
|
190
|
+
let j = cursor;
|
|
191
|
+
while (j > 0 && (text[j - 1] === " " || text[j - 1] === " ")) j--;
|
|
192
|
+
if (j > 0 && text[j - 1] === ",") {
|
|
193
|
+
j--;
|
|
194
|
+
while (j > 0 && (text[j - 1] === " " || text[j - 1] === " ")) j--;
|
|
195
|
+
} else if (j === cursor) {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
const prev = idEndingAt(text, j);
|
|
199
|
+
if (!prev || prev.start + prev.id.length !== j) break;
|
|
200
|
+
ids.unshift(prev.id);
|
|
201
|
+
cursor = prev.start;
|
|
202
|
+
}
|
|
203
|
+
return { ids, start: cursor };
|
|
204
|
+
}
|
|
205
|
+
function nextMarkerStart(rest) {
|
|
206
|
+
const lower = rest.toLowerCase();
|
|
207
|
+
let from = 0;
|
|
208
|
+
while (from < lower.length) {
|
|
209
|
+
const at = lower.indexOf("-ok", from);
|
|
210
|
+
if (at < 0) return -1;
|
|
211
|
+
const after = at + 3;
|
|
212
|
+
const next = lower[after];
|
|
213
|
+
if (next !== void 0 && /[A-Za-z0-9_]/.test(next)) {
|
|
214
|
+
from = at + 1;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
let i = at - 1;
|
|
218
|
+
while (i >= 0 && /[A-Za-z0-9:-]/.test(lower[i] ?? "")) i--;
|
|
219
|
+
let start = i + 1;
|
|
220
|
+
while (start < at && !/[A-Za-z0-9]/.test(lower[start] ?? "")) start++;
|
|
221
|
+
if (start < at) return start;
|
|
222
|
+
from = at + 1;
|
|
223
|
+
}
|
|
224
|
+
return -1;
|
|
225
|
+
}
|
|
226
|
+
function parseCommentMarkers(comment, file, line, opts) {
|
|
227
|
+
const warnings = [];
|
|
228
|
+
const ids = [];
|
|
229
|
+
let justification = "";
|
|
230
|
+
const lower = comment.toLowerCase();
|
|
231
|
+
if (lower.includes("xploitscan") || lower.includes("ignore-line")) {
|
|
232
|
+
warnings.push(warn(file, line, "unrecognized_marker"));
|
|
233
|
+
}
|
|
234
|
+
let from = 0;
|
|
235
|
+
while (from < comment.length) {
|
|
236
|
+
const okAt = lower.indexOf("-ok", from);
|
|
237
|
+
const typoAt = lower.indexOf("-0k", from);
|
|
238
|
+
if (okAt < 0 && typoAt < 0) break;
|
|
239
|
+
const useTypo = typoAt >= 0 && (okAt < 0 || typoAt < okAt);
|
|
240
|
+
const at = useTypo ? typoAt : okAt;
|
|
241
|
+
const after = at + 3;
|
|
242
|
+
const boundary = after >= comment.length || !/[A-Za-z0-9]/.test(comment[after]);
|
|
243
|
+
if (!boundary) {
|
|
244
|
+
from = at + 1;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (useTypo) {
|
|
248
|
+
const listed2 = idListBefore(comment, at);
|
|
249
|
+
warnings.push(
|
|
250
|
+
warn(
|
|
251
|
+
file,
|
|
252
|
+
line,
|
|
253
|
+
"unrecognized_marker",
|
|
254
|
+
listed2 ? listed2.ids.map((id) => id.toUpperCase()) : []
|
|
255
|
+
)
|
|
256
|
+
);
|
|
257
|
+
from = after;
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const prev = at > 0 ? comment[at - 1] : "";
|
|
261
|
+
if (prev === " " || prev === " ") {
|
|
262
|
+
const listed2 = idListBefore(
|
|
263
|
+
comment.slice(0, at).trimEnd(),
|
|
264
|
+
comment.slice(0, at).trimEnd().length
|
|
265
|
+
);
|
|
266
|
+
warnings.push(
|
|
267
|
+
warn(file, line, "space_before_ok", listed2 ? listed2.ids.map((id) => id.toUpperCase()) : [])
|
|
268
|
+
);
|
|
269
|
+
from = after;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const listed = idListBefore(comment, at);
|
|
273
|
+
if (!listed) {
|
|
274
|
+
warnings.push(warn(file, line, "unrecognized_marker"));
|
|
275
|
+
from = after;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
let just = "";
|
|
279
|
+
if (comment[after] === ":") {
|
|
280
|
+
const rest = comment.slice(after + 1);
|
|
281
|
+
const next = nextMarkerStart(rest);
|
|
282
|
+
just = (next >= 0 ? rest.slice(0, next) : rest).trim().slice(0, MAX_JUSTIFICATION);
|
|
283
|
+
}
|
|
284
|
+
if (!justification && just) justification = just;
|
|
285
|
+
for (const id of listed.ids) {
|
|
286
|
+
const fate = fateOf(id, opts);
|
|
287
|
+
if (fate === "unknown") {
|
|
288
|
+
warnings.push(warn(file, line, "unknown_rule_id", [id.toUpperCase()]));
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (fate === "pro-silent") continue;
|
|
292
|
+
ids.push(id.toUpperCase());
|
|
293
|
+
}
|
|
294
|
+
from = after;
|
|
295
|
+
}
|
|
296
|
+
return { ids, justification, warnings };
|
|
297
|
+
}
|
|
298
|
+
function commentOpenerAt(chars, i) {
|
|
299
|
+
const a = chars[i] ?? "";
|
|
300
|
+
const b = chars[i + 1] ?? "";
|
|
301
|
+
const two = a + b;
|
|
302
|
+
if (two === "//") return { kind: "line", len: 2 };
|
|
303
|
+
if (two === "/*") return { kind: "block", len: 2 };
|
|
304
|
+
if (two + (chars[i + 2] ?? "") + (chars[i + 3] ?? "") === "<!--") return { kind: "html", len: 4 };
|
|
305
|
+
if (a === "#" && (i === 0 || /\s/.test(chars[i - 1] ?? ""))) return { kind: "line", len: 1 };
|
|
306
|
+
if (two === "--" && (i === 0 || /\s/.test(chars[i - 1] ?? ""))) return { kind: "line", len: 2 };
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
function maskStringLiterals(line) {
|
|
310
|
+
const chars = line.split("");
|
|
311
|
+
const n = chars.length;
|
|
312
|
+
let i = 0;
|
|
313
|
+
while (i < n) {
|
|
314
|
+
const opener = commentOpenerAt(chars, i);
|
|
315
|
+
if (opener) {
|
|
316
|
+
if (opener.kind === "line") break;
|
|
317
|
+
if (opener.kind === "block") {
|
|
318
|
+
const end2 = line.indexOf("*/", i + opener.len);
|
|
319
|
+
i = end2 < 0 ? n : end2 + 2;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
const end = line.indexOf("-->", i + opener.len);
|
|
323
|
+
i = end < 0 ? n : end + 3;
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const c = chars[i];
|
|
327
|
+
if (c === '"' || c === "'") {
|
|
328
|
+
const q = c;
|
|
329
|
+
chars[i] = " ";
|
|
330
|
+
i++;
|
|
331
|
+
while (i < n) {
|
|
332
|
+
if (chars[i] === "\\") {
|
|
333
|
+
chars[i] = " ";
|
|
334
|
+
if (i + 1 < n) chars[i + 1] = " ";
|
|
335
|
+
i += 2;
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
if (chars[i] === q) {
|
|
339
|
+
chars[i] = " ";
|
|
340
|
+
i++;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
chars[i] = " ";
|
|
344
|
+
i++;
|
|
345
|
+
}
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (c === "`") {
|
|
349
|
+
chars[i] = " ";
|
|
350
|
+
i++;
|
|
351
|
+
let expr = 0;
|
|
352
|
+
while (i < n) {
|
|
353
|
+
if (expr === 0 && chars[i] === "\\") {
|
|
354
|
+
chars[i] = " ";
|
|
355
|
+
if (i + 1 < n) chars[i + 1] = " ";
|
|
356
|
+
i += 2;
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (expr === 0 && chars[i] === "`") {
|
|
360
|
+
chars[i] = " ";
|
|
361
|
+
i++;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
if (expr === 0 && chars[i] === "$" && chars[i + 1] === "{") {
|
|
365
|
+
chars[i] = " ";
|
|
366
|
+
chars[i + 1] = " ";
|
|
367
|
+
expr = 1;
|
|
368
|
+
i += 2;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (expr > 0 && chars[i] === "{") {
|
|
372
|
+
expr++;
|
|
373
|
+
i++;
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (expr > 0 && chars[i] === "}") {
|
|
377
|
+
expr--;
|
|
378
|
+
if (expr === 0) chars[i] = " ";
|
|
379
|
+
i++;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (expr === 0) chars[i] = " ";
|
|
383
|
+
i++;
|
|
384
|
+
}
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
i++;
|
|
388
|
+
}
|
|
389
|
+
return chars.join("");
|
|
390
|
+
}
|
|
391
|
+
function commentSpans(masked) {
|
|
392
|
+
const spans = [];
|
|
393
|
+
const n = masked.length;
|
|
394
|
+
let i = 0;
|
|
395
|
+
const code = true;
|
|
396
|
+
while (i < n) {
|
|
397
|
+
if (!code) {
|
|
398
|
+
i++;
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
const two = masked.slice(i, i + 2);
|
|
402
|
+
const four = masked.slice(i, i + 4);
|
|
403
|
+
if (four === "<!--") {
|
|
404
|
+
const end = masked.indexOf("-->", i + 4);
|
|
405
|
+
const stop = end < 0 ? n : end + 3;
|
|
406
|
+
spans.push([i, stop]);
|
|
407
|
+
i = stop;
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
if (two === "//") {
|
|
411
|
+
spans.push([i, n]);
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
if (two === "/*") {
|
|
415
|
+
const end = masked.indexOf("*/", i + 2);
|
|
416
|
+
const stop = end < 0 ? n : end + 2;
|
|
417
|
+
spans.push([i, stop]);
|
|
418
|
+
i = stop;
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
if (masked[i] === "#" && (i === 0 || /\s/.test(masked[i - 1]))) {
|
|
422
|
+
spans.push([i, n]);
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
if (two === "--" && (i === 0 || /\s/.test(masked[i - 1]))) {
|
|
426
|
+
spans.push([i, n]);
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
i++;
|
|
430
|
+
}
|
|
431
|
+
const trimmed = masked.trim();
|
|
432
|
+
if (spans.length === 0 && (/^\*/.test(trimmed) || trimmed === "*/" || trimmed === "*/}" || trimmed === "-->")) {
|
|
433
|
+
spans.push([0, n]);
|
|
434
|
+
}
|
|
435
|
+
return spans;
|
|
436
|
+
}
|
|
437
|
+
function isBlankLine(line) {
|
|
438
|
+
return line.trim() === "";
|
|
439
|
+
}
|
|
440
|
+
function isCommentOnly(masked) {
|
|
441
|
+
const spans = commentSpans(masked);
|
|
442
|
+
if (spans.length === 0) return false;
|
|
443
|
+
const chars = masked.split("");
|
|
444
|
+
for (const [start, end] of spans) {
|
|
445
|
+
for (let i = start; i < end; i++) chars[i] = " ";
|
|
446
|
+
}
|
|
447
|
+
return /^[{}()\s]*$/.test(chars.join(""));
|
|
448
|
+
}
|
|
449
|
+
function targetLineFor(lines, maskedLines, markerLine) {
|
|
450
|
+
if (!isCommentOnly(maskedLines[markerLine] ?? "")) return markerLine;
|
|
451
|
+
let blanks = 0;
|
|
452
|
+
let comments = 0;
|
|
453
|
+
for (let i = markerLine + 1; i < lines.length; i++) {
|
|
454
|
+
if (isBlankLine(lines[i] ?? "")) {
|
|
455
|
+
blanks++;
|
|
456
|
+
if (blanks > 1) return null;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (isCommentOnly(maskedLines[i] ?? "")) {
|
|
460
|
+
if (blanks > 0) return null;
|
|
461
|
+
comments++;
|
|
462
|
+
if (comments > MAX_BLOCK_LINES) return null;
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
return i;
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
function parseMarkers(lines, filePath = "", opts) {
|
|
470
|
+
const maskedLines = lines.map((line) => maskStringLiterals(line));
|
|
471
|
+
const markers = [];
|
|
472
|
+
const warnings = [];
|
|
473
|
+
for (let i = 0; i < lines.length; i++) {
|
|
474
|
+
const spans = commentSpans(maskedLines[i] ?? "");
|
|
475
|
+
if (spans.length === 0) continue;
|
|
476
|
+
const pieces = spans.map(([a, b]) => (maskedLines[i] ?? "").slice(a, b));
|
|
477
|
+
const parsed = parseCommentMarkers(pieces.join("\n"), filePath, i + 1, opts);
|
|
478
|
+
warnings.push(...parsed.warnings);
|
|
479
|
+
if (parsed.ids.length === 0) continue;
|
|
480
|
+
const target = targetLineFor(lines, maskedLines, i);
|
|
481
|
+
if (target === null) continue;
|
|
482
|
+
markers.push({
|
|
483
|
+
markerLine: i,
|
|
484
|
+
targetLine: target,
|
|
485
|
+
ruleIds: parsed.ids,
|
|
486
|
+
justification: parsed.justification,
|
|
487
|
+
declaredIn: `${filePath}:${i + 1}`
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
return { markers, warnings };
|
|
491
|
+
}
|
|
492
|
+
function buildMarkerIndex(lines, filePath = "", opts) {
|
|
493
|
+
const { markers, warnings } = parseMarkers(lines, filePath, opts);
|
|
494
|
+
const covers = (lineIdx, ruleId) => {
|
|
495
|
+
const want = ruleId.toUpperCase();
|
|
496
|
+
for (const marker of markers) {
|
|
497
|
+
if (marker.targetLine !== lineIdx) continue;
|
|
498
|
+
if (marker.ruleIds.includes("SCANNER") || marker.ruleIds.includes(want)) return marker;
|
|
499
|
+
}
|
|
500
|
+
return null;
|
|
501
|
+
};
|
|
502
|
+
return {
|
|
503
|
+
markers,
|
|
504
|
+
warnings,
|
|
505
|
+
covers(lineIdx, ruleId) {
|
|
506
|
+
return covers(lineIdx, ruleId) !== null;
|
|
507
|
+
},
|
|
508
|
+
info(lineIdx, ruleId) {
|
|
509
|
+
const hit = covers(lineIdx, ruleId);
|
|
510
|
+
if (!hit) return null;
|
|
511
|
+
const token = hit.ruleIds.includes(ruleId.toUpperCase()) ? ruleId.toUpperCase() : "SCANNER";
|
|
512
|
+
return { ruleToken: token, justification: hit.justification, declaredIn: hit.declaredIn };
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function markerCoversLine(lines, lineIdx, ruleId) {
|
|
517
|
+
return buildMarkerIndex(lines, "").covers(lineIdx, ruleId);
|
|
518
|
+
}
|
|
519
|
+
function posix(p) {
|
|
520
|
+
return p.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
521
|
+
}
|
|
522
|
+
function isRootIgnorePath(filePath) {
|
|
523
|
+
return posix(filePath) === ".xploitscanignore";
|
|
524
|
+
}
|
|
525
|
+
function splitIgnoreLine(line) {
|
|
526
|
+
let i = 0;
|
|
527
|
+
while (i < line.length && (line[i] === " " || line[i] === " ")) i++;
|
|
528
|
+
if (i < line.length && line[i] === "#") {
|
|
529
|
+
return { code: "", comment: line.slice(i + 1).trim(), escaped: false };
|
|
530
|
+
}
|
|
531
|
+
let code = "";
|
|
532
|
+
let escaped = false;
|
|
533
|
+
for (let k = 0; k < line.length; k++) {
|
|
534
|
+
const c = line[k] ?? "";
|
|
535
|
+
if (c === "\\") {
|
|
536
|
+
escaped = true;
|
|
537
|
+
code += c;
|
|
538
|
+
if (k + 1 < line.length) {
|
|
539
|
+
code += line[k + 1] ?? "";
|
|
540
|
+
k++;
|
|
541
|
+
}
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
if (c === "#" && k > 0 && (line[k - 1] === " " || line[k - 1] === " ")) {
|
|
545
|
+
return { code: code.trimEnd(), comment: line.slice(k + 1).trim(), escaped };
|
|
546
|
+
}
|
|
547
|
+
code += c;
|
|
548
|
+
}
|
|
549
|
+
return { code: code.trim(), comment: "", escaped };
|
|
550
|
+
}
|
|
551
|
+
function peelRules(code) {
|
|
552
|
+
const parts = code.split(/[ \t]+/).filter(Boolean);
|
|
553
|
+
const rules = [];
|
|
554
|
+
while (parts.length > 1) {
|
|
555
|
+
const last = parts[parts.length - 1] ?? "";
|
|
556
|
+
const ids = last.split(",").map((s) => s.trim()).filter(Boolean);
|
|
557
|
+
if (ids.length === 0 || !ids.every((id) => isWellFormedRuleId(id))) break;
|
|
558
|
+
rules.unshift(...ids);
|
|
559
|
+
parts.pop();
|
|
560
|
+
}
|
|
561
|
+
const pattern = parts.join(" ");
|
|
562
|
+
const unscoped = rules.length === 0 && /\s/.test(code.trim());
|
|
563
|
+
return { pattern, rules: rules.length ? rules : null, unscoped };
|
|
564
|
+
}
|
|
565
|
+
function patternRejected(pattern) {
|
|
566
|
+
if (pattern.includes("\0")) return true;
|
|
567
|
+
if (/^[A-Za-z]:/.test(pattern)) return true;
|
|
568
|
+
const norm = pattern.replace(/\\/g, "/");
|
|
569
|
+
if (/^[A-Za-z]:/.test(norm)) return true;
|
|
570
|
+
const body = norm.replace(/^!/, "");
|
|
571
|
+
if (body.split("/").includes("..")) return true;
|
|
572
|
+
const bare = body.replace(/^\.\//, "");
|
|
573
|
+
if (/^\/[^/*?\]]+$/.test(bare) && !bare.slice(1).includes("/")) return true;
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
function isOverBroad(pattern, rules) {
|
|
577
|
+
if (pattern.startsWith("!")) return false;
|
|
578
|
+
const body = pattern.replace(/^\.\//, "").replace(/^\//, "");
|
|
579
|
+
const broad = body === "*" || body === "**" || body === "**/*";
|
|
580
|
+
const all = rules === null || rules.some((r) => r.toUpperCase() === "SCANNER");
|
|
581
|
+
return broad && all;
|
|
582
|
+
}
|
|
583
|
+
function compilePattern(pattern) {
|
|
584
|
+
const neg = pattern.startsWith("!");
|
|
585
|
+
const body = (neg ? pattern.slice(1) : pattern).replace(/^\.\//, "");
|
|
586
|
+
return (0, import_ignore.default)().add(body);
|
|
587
|
+
}
|
|
588
|
+
function parseIgnoreFile(text, dirRel = "", opts) {
|
|
589
|
+
const declared = opts?.declaredPath ?? (dirRel ? `${posix(dirRel)}/.xploitscanignore` : ".xploitscanignore");
|
|
590
|
+
const dir = posix(dirRel).replace(/\/$/, "");
|
|
591
|
+
if (text.includes("\0")) {
|
|
592
|
+
return { entries: [], warnings: [warn(declared, 1, "binary")], ignoredWhole: true };
|
|
593
|
+
}
|
|
594
|
+
const bytes = utf8ByteLength(text);
|
|
595
|
+
const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
596
|
+
let rawLines = normalized.split("\n");
|
|
597
|
+
if (rawLines.length > 0 && rawLines[rawLines.length - 1] === "" && normalized.endsWith("\n")) {
|
|
598
|
+
rawLines = rawLines.slice(0, -1);
|
|
599
|
+
}
|
|
600
|
+
if (bytes > MAX_IGNORE_BYTES || rawLines.length > MAX_IGNORE_LINES) {
|
|
601
|
+
return { entries: [], warnings: [warn(declared, 1, "over_cap")], ignoredWhole: true };
|
|
602
|
+
}
|
|
603
|
+
const entries = [];
|
|
604
|
+
const warnings = [];
|
|
605
|
+
rawLines.forEach((raw, idx) => {
|
|
606
|
+
const lineNo = idx + 1;
|
|
607
|
+
if (raw.length > MAX_IGNORE_LINE_LEN) {
|
|
608
|
+
warnings.push(warn(declared, lineNo, "line_too_long"));
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const split = splitIgnoreLine(raw);
|
|
612
|
+
if (split.escaped) {
|
|
613
|
+
warnings.push(warn(declared, lineNo, "path_rejected"));
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
const { code, comment } = split;
|
|
617
|
+
if (!code.trim() || code.trimStart().startsWith("#")) return;
|
|
618
|
+
const peeled = peelRules(code.trim());
|
|
619
|
+
if (!peeled.pattern) {
|
|
620
|
+
warnings.push(warn(declared, lineNo, "unrecognized_marker"));
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
if (patternRejected(peeled.pattern)) {
|
|
624
|
+
warnings.push(warn(declared, lineNo, "path_rejected"));
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (peeled.unscoped) {
|
|
628
|
+
warnings.push(warn(declared, lineNo, "unscoped_whitespace"));
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
const accepted = [];
|
|
632
|
+
for (const id of peeled.rules ?? []) {
|
|
633
|
+
const fate = fateOf(id, opts);
|
|
634
|
+
if (fate === "unknown") {
|
|
635
|
+
warnings.push(warn(declared, lineNo, "unknown_rule_id", [id.toUpperCase()]));
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (fate === "pro-silent") continue;
|
|
639
|
+
accepted.push(id.toUpperCase());
|
|
640
|
+
}
|
|
641
|
+
if (peeled.rules && accepted.length === 0) return;
|
|
642
|
+
const pattern = peeled.pattern.replace(/\\/g, "/");
|
|
643
|
+
let matcher;
|
|
644
|
+
try {
|
|
645
|
+
matcher = compilePattern(pattern);
|
|
646
|
+
} catch {
|
|
647
|
+
warnings.push(warn(declared, lineNo, "path_rejected"));
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
entries.push({
|
|
651
|
+
dirRel: dir,
|
|
652
|
+
pattern,
|
|
653
|
+
negated: pattern.startsWith("!"),
|
|
654
|
+
rules: peeled.rules ? new Set(accepted) : null,
|
|
655
|
+
justification: comment.slice(0, MAX_JUSTIFICATION),
|
|
656
|
+
declaredIn: `${declared}:${lineNo}`,
|
|
657
|
+
line: lineNo,
|
|
658
|
+
overBroad: isOverBroad(pattern, peeled.rules),
|
|
659
|
+
matcher
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
return { entries, warnings, ignoredWhole: false };
|
|
663
|
+
}
|
|
664
|
+
function parseIgnoreSources(sources, mode, opts) {
|
|
665
|
+
const entries = [];
|
|
666
|
+
const warnings = [];
|
|
667
|
+
const ordered = [...sources].sort((a, b) => posix(a.path).length - posix(b.path).length);
|
|
668
|
+
for (const source of ordered) {
|
|
669
|
+
const path = posix(source.path);
|
|
670
|
+
const root = isRootIgnorePath(path);
|
|
671
|
+
if (mode === "root-only" && !root) {
|
|
672
|
+
warnings.push(warn(path, 1, "nested_ignored"));
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
const dir = root ? "" : path.slice(0, Math.max(0, path.lastIndexOf("/")));
|
|
676
|
+
const parsed = parseIgnoreFile(source.text, dir, { ...opts, declaredPath: path });
|
|
677
|
+
entries.push(...parsed.entries);
|
|
678
|
+
warnings.push(...parsed.warnings);
|
|
679
|
+
}
|
|
680
|
+
return { entries, warnings };
|
|
681
|
+
}
|
|
682
|
+
function relativeTo(filePath, dirRel) {
|
|
683
|
+
const path = posix(filePath);
|
|
684
|
+
if (!dirRel) return path;
|
|
685
|
+
if (path === dirRel) return null;
|
|
686
|
+
if (path.startsWith(`${dirRel}/`)) return path.slice(dirRel.length + 1);
|
|
687
|
+
return null;
|
|
688
|
+
}
|
|
689
|
+
function matcherFor(entry) {
|
|
690
|
+
if (entry.matcher) return entry.matcher;
|
|
691
|
+
try {
|
|
692
|
+
entry.matcher = compilePattern(entry.pattern);
|
|
693
|
+
return entry.matcher;
|
|
694
|
+
} catch {
|
|
695
|
+
return null;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function entryMatches(entry, filePath) {
|
|
699
|
+
const rel = relativeTo(filePath, entry.dirRel);
|
|
700
|
+
if (rel === null || rel === "") return false;
|
|
701
|
+
const matcher = matcherFor(entry);
|
|
702
|
+
if (!matcher) return false;
|
|
703
|
+
try {
|
|
704
|
+
return matcher.ignores(rel);
|
|
705
|
+
} catch {
|
|
706
|
+
return false;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
function matchIgnore(entries, filePath, ruleId) {
|
|
710
|
+
const rule = ruleId.toUpperCase();
|
|
711
|
+
let winner = null;
|
|
712
|
+
for (const entry of entries) {
|
|
713
|
+
if (!entryMatches(entry, filePath)) continue;
|
|
714
|
+
const applies = entry.rules === null || entry.rules.has("SCANNER") || entry.rules.has(rule);
|
|
715
|
+
if (!applies) continue;
|
|
716
|
+
winner = entry.negated ? null : entry;
|
|
717
|
+
}
|
|
718
|
+
return winner;
|
|
719
|
+
}
|
|
720
|
+
function filesMap(input) {
|
|
721
|
+
if (input instanceof Map) return input;
|
|
722
|
+
return new Map(Object.entries(input).map(([k, v]) => [posix(k), v]));
|
|
723
|
+
}
|
|
724
|
+
function applySuppressions(findings, input) {
|
|
725
|
+
const files = filesMap(input.filesByPath);
|
|
726
|
+
const opts = { knownIds: input.knownIds, proIds: input.proIds, tier: input.tier };
|
|
727
|
+
const entries = input.ignoreEntries ?? [];
|
|
728
|
+
const warnings = [];
|
|
729
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
730
|
+
const indexFor = (file) => {
|
|
731
|
+
const key = posix(file);
|
|
732
|
+
const cached = indexes.get(key);
|
|
733
|
+
if (cached) return cached;
|
|
734
|
+
const text = files.get(key) ?? "";
|
|
735
|
+
const folded = text.toLowerCase();
|
|
736
|
+
if (!folded.includes("-ok") && !folded.includes("-0k")) {
|
|
737
|
+
const empty = {
|
|
738
|
+
markers: [],
|
|
739
|
+
warnings: [],
|
|
740
|
+
covers: () => false,
|
|
741
|
+
info: () => null
|
|
742
|
+
};
|
|
743
|
+
indexes.set(key, empty);
|
|
744
|
+
return empty;
|
|
745
|
+
}
|
|
746
|
+
const built = buildMarkerIndex(text.split("\n"), key, opts);
|
|
747
|
+
indexes.set(key, built);
|
|
748
|
+
warnings.push(...built.warnings);
|
|
749
|
+
return built;
|
|
750
|
+
};
|
|
751
|
+
const direct = /* @__PURE__ */ new Map();
|
|
752
|
+
for (const finding of findings) {
|
|
753
|
+
const info = indexFor(finding.file).info(finding.line - 1, finding.rule);
|
|
754
|
+
if (!info) continue;
|
|
755
|
+
direct.set(finding, {
|
|
756
|
+
kind: "inSource",
|
|
757
|
+
source: "marker",
|
|
758
|
+
ruleToken: info.ruleToken,
|
|
759
|
+
justification: info.justification,
|
|
760
|
+
declaredIn: info.declaredIn
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
764
|
+
for (const file of files.keys()) seenFiles.add(posix(file));
|
|
765
|
+
for (const finding of findings) seenFiles.add(posix(finding.file));
|
|
766
|
+
for (const entry of entries) {
|
|
767
|
+
if (!entry.overBroad) continue;
|
|
768
|
+
let count = 0;
|
|
769
|
+
for (const file of seenFiles) if (entryMatches(entry, file)) count++;
|
|
770
|
+
if (count > 0)
|
|
771
|
+
warnings.push(
|
|
772
|
+
warn(entry.declaredIn.split(":")[0] ?? "", entry.line, "over_broad", [], count)
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
const kept = [];
|
|
776
|
+
const suppressed = [];
|
|
777
|
+
for (const finding of findings) {
|
|
778
|
+
const marker = direct.get(finding);
|
|
779
|
+
if (marker) {
|
|
780
|
+
suppressed.push({ ...finding, suppression: marker });
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
const hit = matchIgnore(entries, finding.file, finding.rule);
|
|
784
|
+
if (hit) {
|
|
785
|
+
suppressed.push({
|
|
786
|
+
...finding,
|
|
787
|
+
suppression: {
|
|
788
|
+
kind: "external",
|
|
789
|
+
source: "ignore-file",
|
|
790
|
+
ruleToken: finding.rule.toUpperCase(),
|
|
791
|
+
justification: hit.justification,
|
|
792
|
+
declaredIn: hit.declaredIn
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
kept.push(finding);
|
|
798
|
+
}
|
|
799
|
+
return { kept, suppressed, warnings };
|
|
800
|
+
}
|
|
801
|
+
function isRuleScopedIgnoreLine(line) {
|
|
802
|
+
const split = splitIgnoreLine(line.replace(/\r$/, ""));
|
|
803
|
+
if (split.escaped) return false;
|
|
804
|
+
const { code } = split;
|
|
805
|
+
if (!code.trim() || code.trimStart().startsWith("#")) return false;
|
|
806
|
+
const peeled = peelRules(code.trim());
|
|
807
|
+
return peeled.rules !== null && peeled.rules.length > 0 && !patternRejected(peeled.pattern);
|
|
808
|
+
}
|
|
809
|
+
function isUnscopedOverBroadLine(line) {
|
|
810
|
+
const split = splitIgnoreLine(line.replace(/\r$/, ""));
|
|
811
|
+
if (split.escaped) return false;
|
|
812
|
+
const { code } = split;
|
|
813
|
+
if (!code.trim() || code.trimStart().startsWith("#")) return false;
|
|
814
|
+
const peeled = peelRules(code.trim());
|
|
815
|
+
if (peeled.rules && peeled.rules.length > 0) return false;
|
|
816
|
+
return isOverBroad(peeled.pattern, null);
|
|
817
|
+
}
|
|
818
|
+
var SCAN_META = /* @__PURE__ */ Symbol.for("xploitscan.scanSuppression");
|
|
819
|
+
function attachScanSuppression(findings, meta) {
|
|
820
|
+
Object.defineProperty(findings, SCAN_META, { value: meta, enumerable: false });
|
|
821
|
+
return findings;
|
|
822
|
+
}
|
|
823
|
+
function readScanSuppression(findings) {
|
|
824
|
+
if (!findings || typeof findings !== "object") return null;
|
|
825
|
+
const value = findings[SCAN_META];
|
|
826
|
+
if (!value || typeof value !== "object") return null;
|
|
827
|
+
return value;
|
|
828
|
+
}
|
|
829
|
+
function countPass(inlineAlready, suppressed) {
|
|
830
|
+
let ignoreFile = 0;
|
|
831
|
+
let inline = inlineAlready;
|
|
832
|
+
for (const item of suppressed) {
|
|
833
|
+
if (item.suppression.source === "ignore-file") ignoreFile++;
|
|
834
|
+
else inline++;
|
|
835
|
+
}
|
|
836
|
+
return { inline, ignoreFile };
|
|
837
|
+
}
|
|
838
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
839
|
+
0 && (module.exports = {
|
|
840
|
+
MARKER_SYNTAX,
|
|
841
|
+
MAX_BLOCK_LINES,
|
|
842
|
+
MAX_COUNT,
|
|
843
|
+
MAX_IGNORE_BYTES,
|
|
844
|
+
MAX_IGNORE_LINES,
|
|
845
|
+
MAX_IGNORE_LINE_LEN,
|
|
846
|
+
MAX_JUSTIFICATION,
|
|
847
|
+
MAX_SUPPRESSED_LIST,
|
|
848
|
+
MAX_WARNING_CAP,
|
|
849
|
+
NESTED_IGNORE_WARNING,
|
|
850
|
+
RULE_ID_PATTERN,
|
|
851
|
+
SUPPRESSION_REGEXES,
|
|
852
|
+
applySuppressions,
|
|
853
|
+
attachInlineSuppressed,
|
|
854
|
+
attachScanSuppression,
|
|
855
|
+
buildMarkerIndex,
|
|
856
|
+
capWarnings,
|
|
857
|
+
clampCount,
|
|
858
|
+
countPass,
|
|
859
|
+
isBuiltinRuleId,
|
|
860
|
+
isRootIgnorePath,
|
|
861
|
+
isRuleScopedIgnoreLine,
|
|
862
|
+
isUnscopedOverBroadLine,
|
|
863
|
+
isWellFormedRuleId,
|
|
864
|
+
markerCoversLine,
|
|
865
|
+
maskStringLiterals,
|
|
866
|
+
matchIgnore,
|
|
867
|
+
parseIgnoreFile,
|
|
868
|
+
parseIgnoreSources,
|
|
869
|
+
parseMarkers,
|
|
870
|
+
publicSuppressedRecord,
|
|
871
|
+
readInlineSuppressed,
|
|
872
|
+
readScanSuppression,
|
|
873
|
+
suppressionSummary,
|
|
874
|
+
utf8ByteLength,
|
|
875
|
+
warningForUpload,
|
|
876
|
+
warningLine
|
|
877
|
+
});
|
|
878
|
+
//# sourceMappingURL=suppression.cjs.map
|