xploitscan-shared-rules 2.4.22 → 2.4.23
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/index.cjs +29 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -9
- package/dist/index.d.ts +23 -9
- package/dist/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
FREE_RULE_COUNT: () => FREE_RULE_COUNT,
|
|
40
40
|
GRADE_FINDINGS_PER_RULE: () => GRADE_FINDINGS_PER_RULE,
|
|
41
41
|
INTENT_EXPECTATIONS: () => INTENT_EXPECTATIONS,
|
|
42
|
+
KEEP_SEVERITY_IN_TESTS: () => KEEP_SEVERITY_IN_TESTS,
|
|
42
43
|
MAX_IGNORE_BYTES: () => MAX_IGNORE_BYTES,
|
|
43
44
|
MAX_IGNORE_LINES: () => MAX_IGNORE_LINES,
|
|
44
45
|
MAX_SUPPRESSED_LIST: () => MAX_SUPPRESSED_LIST,
|
|
@@ -69,6 +70,7 @@ __export(index_exports, {
|
|
|
69
70
|
aiStatusLine: () => aiStatusLine,
|
|
70
71
|
allRules: () => allRules,
|
|
71
72
|
applySuppressions: () => applySuppressions,
|
|
73
|
+
applyTestPathSeverity: () => applyTestPathSeverity,
|
|
72
74
|
assessHeaders: () => assessHeaders,
|
|
73
75
|
astMatch: () => astMatch,
|
|
74
76
|
attachInlineSuppressed: () => attachInlineSuppressed,
|
|
@@ -194,13 +196,13 @@ __export(index_exports, {
|
|
|
194
196
|
supabaseFunctionName: () => supabaseFunctionName,
|
|
195
197
|
supabaseNoRLS: () => supabaseNoRLS,
|
|
196
198
|
suppressionSummary: () => suppressionSummary,
|
|
199
|
+
testPathHold: () => testPathHold,
|
|
197
200
|
toAiDegraded: () => toAiDegraded,
|
|
198
201
|
todoLeftInCode: () => todoLeftInCode,
|
|
199
202
|
tryParse: () => tryParse,
|
|
200
203
|
unknownAiStatus: () => unknownAiStatus,
|
|
201
204
|
unmeasuredQualityRules: () => unmeasuredQualityRules,
|
|
202
205
|
unvalidatedRedirect: () => unvalidatedRedirect,
|
|
203
|
-
vc001TestFixtureSeverity: () => vc001TestFixtureSeverity,
|
|
204
206
|
vendoredReason: () => vendoredReason,
|
|
205
207
|
visitBinary: () => visitBinary,
|
|
206
208
|
visitCalls: () => visitCalls,
|
|
@@ -212,7 +214,7 @@ __export(index_exports, {
|
|
|
212
214
|
module.exports = __toCommonJS(index_exports);
|
|
213
215
|
|
|
214
216
|
// src/version.ts
|
|
215
|
-
var SCANNER_VERSION = "2.4.
|
|
217
|
+
var SCANNER_VERSION = "2.4.23";
|
|
216
218
|
|
|
217
219
|
// src/snippet.ts
|
|
218
220
|
var cacheContent = null;
|
|
@@ -1607,8 +1609,9 @@ function baseName(normalized) {
|
|
|
1607
1609
|
function isTestPath(filePath) {
|
|
1608
1610
|
const normalized = normalize(filePath);
|
|
1609
1611
|
if (!normalized) return false;
|
|
1612
|
+
if (normalized.split("/").includes("..")) return false;
|
|
1610
1613
|
const base = baseName(normalized);
|
|
1611
|
-
if (/(?:\.test\.|\.spec\.|\.
|
|
1614
|
+
if (/(?:\.test\.|\.spec\.|\.mock\.|\.cy\.|\.e2e\.)/i.test(base)) return true;
|
|
1612
1615
|
if (/^test_.*\.py$/i.test(base) || /_test\.py$/i.test(base)) return true;
|
|
1613
1616
|
if (/^Test[A-Z_]\w*\.py$/.test(base)) return true;
|
|
1614
1617
|
if (/^conftest\.py$/i.test(base)) return true;
|
|
@@ -1616,10 +1619,11 @@ function isTestPath(filePath) {
|
|
|
1616
1619
|
if (/^[A-Z][A-Za-z0-9]*Tests\.cs$/.test(base)) return true;
|
|
1617
1620
|
if (/(?:^|\/)routes\/test\//i.test(normalized)) return false;
|
|
1618
1621
|
if (/(?:^|\/)(?:tests|testdata|spec|__tests__|__mocks__|fixtures?|mocks?)(?:\/|$)/i.test(normalized)) return true;
|
|
1622
|
+
if (/(?:^|\/)e2e(?:\/|$)/i.test(normalized)) return true;
|
|
1619
1623
|
if (/(?:^|\/)test\//i.test(normalized)) return true;
|
|
1620
1624
|
if (/(?:^|\/)[^/]*\.(?:UnitTests|IntegrationTests|Tests)\//i.test(normalized)) return true;
|
|
1621
1625
|
if (/\.cs$/.test(base) && /(?:^|\/)[^/]*Tests\//.test(normalized)) return true;
|
|
1622
|
-
if (/test-utils/i.test(normalized)) return true;
|
|
1626
|
+
if (/(?:^|\/)test-utils(?:\/|$)/i.test(normalized)) return true;
|
|
1623
1627
|
if (/(?:^|\/)testing(?:\/|$)/i.test(normalized)) return true;
|
|
1624
1628
|
return false;
|
|
1625
1629
|
}
|
|
@@ -1686,10 +1690,14 @@ function isUngradedFinding(finding, options = {}) {
|
|
|
1686
1690
|
if (options.gradeVendored) return false;
|
|
1687
1691
|
return isVendoredFinding(finding);
|
|
1688
1692
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1693
|
+
var KEEP_SEVERITY_IN_TESTS = /* @__PURE__ */ new Set(["VC002", "VC014"]);
|
|
1694
|
+
function applyTestPathSeverity(rule, testFile, severity) {
|
|
1695
|
+
if (testFile === true && !KEEP_SEVERITY_IN_TESTS.has(rule ?? "")) return "low";
|
|
1691
1696
|
return severity;
|
|
1692
1697
|
}
|
|
1698
|
+
function testPathHold(finding) {
|
|
1699
|
+
return isTestPath(finding.file ?? "") && !isLive(finding) && !KEEP_SEVERITY_IN_TESTS.has(finding.rule ?? "");
|
|
1700
|
+
}
|
|
1693
1701
|
|
|
1694
1702
|
// src/routes.ts
|
|
1695
1703
|
var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
|
|
@@ -3553,7 +3561,8 @@ var hardcodedSecrets = {
|
|
|
3553
3561
|
continue;
|
|
3554
3562
|
}
|
|
3555
3563
|
const matched = matchedText[ri] ?? "";
|
|
3556
|
-
|
|
3564
|
+
const pemHeader = pi === 9 && isTestPath(filePath);
|
|
3565
|
+
emit(rm, judged, pemHeader || textHasLiveCredential(matched) || matchedLive ? { live: true } : {});
|
|
3557
3566
|
}
|
|
3558
3567
|
}
|
|
3559
3568
|
collectSupabaseCreateClientKeys(content, filePath, matches, hardcodedSecrets, fixMessages[3]);
|
|
@@ -6009,7 +6018,7 @@ var todoLeftInCode = {
|
|
|
6009
6018
|
category: "Code Quality",
|
|
6010
6019
|
description: "TODO, FIXME, HACK, and XXX comments indicate unfinished work that should be resolved before shipping to production.",
|
|
6011
6020
|
check(content, filePath) {
|
|
6012
|
-
if (filePath.
|
|
6021
|
+
if (isTestFile(filePath) || filePath.includes("node_modules")) return [];
|
|
6013
6022
|
if (/\.(?:md|mdx|markdown|txt)$/i.test(filePath)) return [];
|
|
6014
6023
|
const marker = /(?<![`'":])(?:\/\/|\/\*\*?|^[ \t]*\*+)[ \t]*(?:(?:TODO|FIXME|HACK)\b|XXX(?![\w.-])|(?:[Tt]odo|[Ff]ixme)[ \t]*:|@todo\b)/gm;
|
|
6015
6024
|
const matches = [];
|
|
@@ -6051,7 +6060,7 @@ var emptyCatchBlock = {
|
|
|
6051
6060
|
category: "Code Quality",
|
|
6052
6061
|
description: "Empty catch blocks silently swallow errors, making bugs impossible to diagnose. At minimum, log the error.",
|
|
6053
6062
|
check(content, filePath) {
|
|
6054
|
-
if (filePath
|
|
6063
|
+
if (isTestFile(filePath)) return [];
|
|
6055
6064
|
const fix = () => "Handle errors in catch blocks: catch(err) { console.error('Operation failed:', err); } or re-throw if appropriate.";
|
|
6056
6065
|
const blocks = findMatches(content, /catch\s*(?:\([^)]{0,200}\))?\s*\{\s*\}/g, emptyCatchBlock, filePath, fix);
|
|
6057
6066
|
const seen = new Set(blocks.map((m) => m.line));
|
|
@@ -6149,7 +6158,6 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
6149
6158
|
const matches = rule.check(content, filePath, project);
|
|
6150
6159
|
const compliance = complianceMap[rule.id];
|
|
6151
6160
|
const vendored = vendoredFile && isVendoredFinding({ file: filePath, rule: rule.id, category: rule.category });
|
|
6152
|
-
const onTestPath = isTestPath(filePath);
|
|
6153
6161
|
for (const match of matches) {
|
|
6154
6162
|
const live = isLive({
|
|
6155
6163
|
rule: match.rule,
|
|
@@ -6157,14 +6165,20 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
6157
6165
|
live: match.live,
|
|
6158
6166
|
snippet: match.snippet
|
|
6159
6167
|
});
|
|
6160
|
-
const testFixture =
|
|
6168
|
+
const testFixture = testPathHold({
|
|
6169
|
+
rule: match.rule,
|
|
6170
|
+
file: filePath,
|
|
6171
|
+
live: match.live,
|
|
6172
|
+
category: match.category,
|
|
6173
|
+
snippet: match.snippet
|
|
6174
|
+
});
|
|
6161
6175
|
findings.push({
|
|
6162
6176
|
...vendored ? { vendored: true } : {},
|
|
6163
6177
|
...testFixture ? { testFile: true } : {},
|
|
6164
6178
|
...live ? { live: true } : {},
|
|
6165
6179
|
id: `${match.rule}-${match.file}:${match.line}`,
|
|
6166
6180
|
rule: match.rule,
|
|
6167
|
-
severity:
|
|
6181
|
+
severity: applyTestPathSeverity(match.rule, testFixture ? true : void 0, match.severity),
|
|
6168
6182
|
title: match.title,
|
|
6169
6183
|
description: rule.description,
|
|
6170
6184
|
file: match.file,
|
|
@@ -12300,6 +12314,7 @@ function scanQuality(input, rules = qualityRules) {
|
|
|
12300
12314
|
FREE_RULE_COUNT,
|
|
12301
12315
|
GRADE_FINDINGS_PER_RULE,
|
|
12302
12316
|
INTENT_EXPECTATIONS,
|
|
12317
|
+
KEEP_SEVERITY_IN_TESTS,
|
|
12303
12318
|
MAX_IGNORE_BYTES,
|
|
12304
12319
|
MAX_IGNORE_LINES,
|
|
12305
12320
|
MAX_SUPPRESSED_LIST,
|
|
@@ -12330,6 +12345,7 @@ function scanQuality(input, rules = qualityRules) {
|
|
|
12330
12345
|
aiStatusLine,
|
|
12331
12346
|
allRules,
|
|
12332
12347
|
applySuppressions,
|
|
12348
|
+
applyTestPathSeverity,
|
|
12333
12349
|
assessHeaders,
|
|
12334
12350
|
astMatch,
|
|
12335
12351
|
attachInlineSuppressed,
|
|
@@ -12455,13 +12471,13 @@ function scanQuality(input, rules = qualityRules) {
|
|
|
12455
12471
|
supabaseFunctionName,
|
|
12456
12472
|
supabaseNoRLS,
|
|
12457
12473
|
suppressionSummary,
|
|
12474
|
+
testPathHold,
|
|
12458
12475
|
toAiDegraded,
|
|
12459
12476
|
todoLeftInCode,
|
|
12460
12477
|
tryParse,
|
|
12461
12478
|
unknownAiStatus,
|
|
12462
12479
|
unmeasuredQualityRules,
|
|
12463
12480
|
unvalidatedRedirect,
|
|
12464
|
-
vc001TestFixtureSeverity,
|
|
12465
12481
|
vendoredReason,
|
|
12466
12482
|
visitBinary,
|
|
12467
12483
|
visitCalls,
|