xploitscan-shared-rules 2.4.9 → 2.4.11
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 +201 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +200 -40
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -160,7 +160,7 @@ interface CustomRule {
|
|
|
160
160
|
* before a scan can be saved without enough provenance to explain a changed
|
|
161
161
|
* grade.
|
|
162
162
|
*/
|
|
163
|
-
declare const SCANNER_VERSION = "2.4.
|
|
163
|
+
declare const SCANNER_VERSION = "2.4.11";
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
166
|
* Line-oriented helpers shared by every rule. Pure string manipulation — no fs
|
|
@@ -1134,6 +1134,12 @@ declare const exposedEnvFile: CustomRule;
|
|
|
1134
1134
|
* objects are left as they are, which can only suppress a finding.
|
|
1135
1135
|
*/
|
|
1136
1136
|
declare function maskOutboundAuthNoise(code: string): string;
|
|
1137
|
+
/**
|
|
1138
|
+
* Writes that make a `"use server"` export a real mutation. Shared with
|
|
1139
|
+
* VC064, which walks each pattern once per file. No `g` flag: `.test()`
|
|
1140
|
+
* must not advance `lastIndex`.
|
|
1141
|
+
*/
|
|
1142
|
+
declare const SERVER_ACTION_WRITE_RE: RegExp[];
|
|
1137
1143
|
declare const missingAuthMiddleware: CustomRule;
|
|
1138
1144
|
declare const supabaseNoRLS: CustomRule;
|
|
1139
1145
|
declare const stripeWebhookUnprotected: CustomRule;
|
|
@@ -1684,4 +1690,4 @@ input: {
|
|
|
1684
1690
|
content: string;
|
|
1685
1691
|
}[] | QualityContext, rules?: QualityRule[]): Finding[];
|
|
1686
1692
|
|
|
1687
|
-
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, DOTENV_ASSIGN_RE, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, GRADE_FINDINGS_PER_RULE, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, SCANNER_VERSION, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, deduplicateFindings, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
|
|
1693
|
+
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, DOTENV_ASSIGN_RE, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, GRADE_FINDINGS_PER_RULE, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, SCANNER_VERSION, SERVER_ACTION_WRITE_RE, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, deduplicateFindings, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
|
package/dist/index.d.ts
CHANGED
|
@@ -160,7 +160,7 @@ interface CustomRule {
|
|
|
160
160
|
* before a scan can be saved without enough provenance to explain a changed
|
|
161
161
|
* grade.
|
|
162
162
|
*/
|
|
163
|
-
declare const SCANNER_VERSION = "2.4.
|
|
163
|
+
declare const SCANNER_VERSION = "2.4.11";
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
166
|
* Line-oriented helpers shared by every rule. Pure string manipulation — no fs
|
|
@@ -1134,6 +1134,12 @@ declare const exposedEnvFile: CustomRule;
|
|
|
1134
1134
|
* objects are left as they are, which can only suppress a finding.
|
|
1135
1135
|
*/
|
|
1136
1136
|
declare function maskOutboundAuthNoise(code: string): string;
|
|
1137
|
+
/**
|
|
1138
|
+
* Writes that make a `"use server"` export a real mutation. Shared with
|
|
1139
|
+
* VC064, which walks each pattern once per file. No `g` flag: `.test()`
|
|
1140
|
+
* must not advance `lastIndex`.
|
|
1141
|
+
*/
|
|
1142
|
+
declare const SERVER_ACTION_WRITE_RE: RegExp[];
|
|
1137
1143
|
declare const missingAuthMiddleware: CustomRule;
|
|
1138
1144
|
declare const supabaseNoRLS: CustomRule;
|
|
1139
1145
|
declare const stripeWebhookUnprotected: CustomRule;
|
|
@@ -1684,4 +1690,4 @@ input: {
|
|
|
1684
1690
|
content: string;
|
|
1685
1691
|
}[] | QualityContext, rules?: QualityRule[]): Finding[];
|
|
1686
1692
|
|
|
1687
|
-
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, DOTENV_ASSIGN_RE, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, GRADE_FINDINGS_PER_RULE, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, SCANNER_VERSION, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, deduplicateFindings, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
|
|
1693
|
+
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, DOTENV_ASSIGN_RE, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, GRADE_FINDINGS_PER_RULE, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, SCANNER_VERSION, SERVER_ACTION_WRITE_RE, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, deduplicateFindings, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, replaceBlockComments, routeForFile, runCustomRules, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SCANNER_VERSION = "2.4.
|
|
2
|
+
var SCANNER_VERSION = "2.4.11";
|
|
3
3
|
|
|
4
4
|
// src/snippet.ts
|
|
5
5
|
var cacheContent = null;
|
|
@@ -514,7 +514,7 @@ function isTestPath(filePath) {
|
|
|
514
514
|
if (/(?:^|\/)testing(?:\/|$)/i.test(normalized)) return true;
|
|
515
515
|
return false;
|
|
516
516
|
}
|
|
517
|
-
var SBOM_FILE_RE = /(?:^|\/)(?:[^/]*\.spdx(?:\.json)?|[^/]*\.cdx\.json|[^/]*\.cdx\.xml|bom\.json|sbom[^/]*\.json|[^/]*\.sbom\.json|[^/]*cyclonedx[^/]*\.(?:json|xml))$/i;
|
|
517
|
+
var SBOM_FILE_RE = /(?:^|\/)(?:[^/]*\.spdx(?:\.json)?|[^/]*\.cdx\.json|[^/]*\.cdx\.xml|bom\.(?:json|xml)|sbom[^/]*\.json|[^/]*\.sbom\.json|[^/]*cyclonedx[^/]*\.(?:json|xml))$/i;
|
|
518
518
|
function isSbomPath(filePath) {
|
|
519
519
|
return SBOM_FILE_RE.test(normalize(filePath));
|
|
520
520
|
}
|
|
@@ -1852,13 +1852,40 @@ function dbUrlLacksRealCredential(url) {
|
|
|
1852
1852
|
const userinfo = rest.slice(0, at);
|
|
1853
1853
|
const colon = userinfo.indexOf(":");
|
|
1854
1854
|
const user = colon < 0 ? userinfo : userinfo.slice(0, colon);
|
|
1855
|
-
const
|
|
1855
|
+
const rawPass = colon < 0 ? "" : userinfo.slice(colon + 1);
|
|
1856
|
+
const pass = colon < 0 ? "" : decodeURIComponentSafe(rawPass);
|
|
1856
1857
|
if (!pass) return true;
|
|
1858
|
+
const portShaped = /^(\d{1,5})(?:\/[\w.-]{0,64})?[?#"'`][^@]*$/.exec(rawPass);
|
|
1859
|
+
if (portShaped && Number(portShaped[1]) <= 65535) return true;
|
|
1857
1860
|
if (isFormatPlaceholder(pass)) return true;
|
|
1858
1861
|
if (isPlaceholderSecret(pass)) return true;
|
|
1859
1862
|
if (/^(?:u|user|username)$/i.test(user) && /^(?:pass|password|passwd|pwd)$/i.test(pass)) return true;
|
|
1860
1863
|
return false;
|
|
1861
1864
|
}
|
|
1865
|
+
var LOOPBACK_DEV_USER_RE = /^(?:postgres|root|admin|user|test|dev|mysql|mongo|mongodb|redis|sa|guest|app|example)$/i;
|
|
1866
|
+
function isLoopbackDevDefault(url) {
|
|
1867
|
+
const rest = url.replace(/^[a-z0-9+]+:\/\//i, "");
|
|
1868
|
+
const at = rest.lastIndexOf("@");
|
|
1869
|
+
if (at < 0) return false;
|
|
1870
|
+
const userinfo = rest.slice(0, at);
|
|
1871
|
+
const colon = userinfo.indexOf(":");
|
|
1872
|
+
if (colon < 0) return false;
|
|
1873
|
+
const user = userinfo.slice(0, colon);
|
|
1874
|
+
const pass = decodeURIComponentSafe(userinfo.slice(colon + 1));
|
|
1875
|
+
if (user !== pass || !LOOPBACK_DEV_USER_RE.test(user)) return false;
|
|
1876
|
+
let host = rest.slice(at + 1);
|
|
1877
|
+
const cut = host.search(/[/?#]/);
|
|
1878
|
+
if (cut >= 0) host = host.slice(0, cut);
|
|
1879
|
+
if (host.startsWith("[")) {
|
|
1880
|
+
const end = host.indexOf("]");
|
|
1881
|
+
host = end >= 0 ? host.slice(1, end) : host;
|
|
1882
|
+
} else {
|
|
1883
|
+
const port = host.lastIndexOf(":");
|
|
1884
|
+
if (port >= 0) host = host.slice(0, port);
|
|
1885
|
+
}
|
|
1886
|
+
const h = host.toLowerCase();
|
|
1887
|
+
return h === "localhost" || h === "::1" || h === "0.0.0.0" || h === "host.docker.internal" || /^127(?:\.\d{1,3}){0,3}$/.test(h);
|
|
1888
|
+
}
|
|
1862
1889
|
function decodeURIComponentSafe(value) {
|
|
1863
1890
|
try {
|
|
1864
1891
|
return decodeURIComponent(value);
|
|
@@ -1867,10 +1894,12 @@ function decodeURIComponentSafe(value) {
|
|
|
1867
1894
|
}
|
|
1868
1895
|
}
|
|
1869
1896
|
var FORMAT_PLACEHOLDER_MAX = 256;
|
|
1897
|
+
var FORMAT_FIELD_RE = /^\{(?:[a-z_][a-z0-9_]{0,63}|[A-Z_][A-Z0-9_]{0,63})(?:\.(?:[a-z_][a-z0-9_]{0,63}|[A-Z_][A-Z0-9_]{0,63})){0,4}(?:\[[\w'"]{1,64}\])?(?:![rsa])?(?::[<>=^]?\d{0,3}[sd]?)?\}$/;
|
|
1870
1898
|
function isFormatPlaceholder(value) {
|
|
1871
1899
|
const v = value.trim();
|
|
1872
1900
|
if (!v) return true;
|
|
1873
1901
|
if (v.length > FORMAT_PLACEHOLDER_MAX) return false;
|
|
1902
|
+
if (FORMAT_FIELD_RE.test(v)) return true;
|
|
1874
1903
|
if (/^(?:%(?:[%sdifvx]|\([^)]+\))|\{[0-9]*\}|\$\{[^}]*\}|<[^<>]*>|\*+)$/i.test(v)) return true;
|
|
1875
1904
|
if (/%(?:[%sdifvx]|\([^)]+\))|\{[0-9]*\}|\$\{[^}]*\}|<[^<>]*>/.test(v)) return true;
|
|
1876
1905
|
return false;
|
|
@@ -1925,11 +1954,14 @@ var hardcodedSecrets = {
|
|
|
1925
1954
|
/\b(?:password|passwd|pwd)\s*:\s*["'`]([a-zA-Z0-9_\-!@#$%^&*.\/:\-]{8,})["'`]/gi,
|
|
1926
1955
|
// Private keys
|
|
1927
1956
|
/-----BEGIN (?:RSA |EC |DSA )?PRIVATE KEY-----/g,
|
|
1928
|
-
// Database URLs with credentials.
|
|
1929
|
-
//
|
|
1930
|
-
//
|
|
1931
|
-
//
|
|
1932
|
-
|
|
1957
|
+
// Database URLs with credentials. Align with Pro VC049: `postgresql://`
|
|
1958
|
+
// and `postgresql+asyncpg://` (and mysql/mongodb+srv) are what providers
|
|
1959
|
+
// actually hand out — `postgres://` alone missed Supabase/Prisma URLs.
|
|
1960
|
+
// The user and password cannot cross whitespace or a newline, and each
|
|
1961
|
+
// is capped at 1024 characters, so a localhost URL cannot run forward
|
|
1962
|
+
// to a later `@` and a run of `postgres://a:b` with no `@` cannot
|
|
1963
|
+
// backtrack.
|
|
1964
|
+
/(?:postgres(?:ql)?(?:\+[a-z0-9]{1,20})?|mysql|mongodb(?:\+srv)?):\/\/[^:@\s/]{1,1024}:[^@\s]{1,1024}@[^/\s"'`]{1,256}/gi,
|
|
1933
1965
|
// ── [11]–[14] Fixed-prefix AI-provider and payment keys ──
|
|
1934
1966
|
// These match the token itself, so they fire whatever it is bound to:
|
|
1935
1967
|
// `const k = "…"`, a positional `new OpenAI("…")`, an unquoted .env
|
|
@@ -2044,15 +2076,20 @@ var hardcodedSecrets = {
|
|
|
2044
2076
|
}
|
|
2045
2077
|
if (pi === 6) {
|
|
2046
2078
|
const valMatch = lineText.match(/[:=]\s*["'`]([^"'`]+)["'`]/);
|
|
2047
|
-
const nameMatch =
|
|
2079
|
+
const nameMatch = (matchedText[ri] ?? "").match(/^[A-Z][A-Z0-9_]{0,64}_(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD)\b/);
|
|
2048
2080
|
if (valMatch && nameMatch) {
|
|
2049
2081
|
const value = valMatch[1];
|
|
2050
|
-
const isKeySuffix = nameMatch[
|
|
2051
|
-
const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[
|
|
2082
|
+
const isKeySuffix = nameMatch[0].endsWith("_KEY");
|
|
2083
|
+
const isSlotIdentifier = value.length < 40 && (/^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value) || isNamespacedSlotKey(nameMatch[0], value));
|
|
2052
2084
|
if (isKeySuffix && isSlotIdentifier) continue;
|
|
2053
2085
|
}
|
|
2054
2086
|
}
|
|
2055
|
-
if (pi === 10
|
|
2087
|
+
if (pi === 10) {
|
|
2088
|
+
const url = matchedText[ri] ?? "";
|
|
2089
|
+
if (dbUrlLacksRealCredential(url)) continue;
|
|
2090
|
+
matches.push(isLoopbackDevDefault(url) ? { ...rm, severity: "low" } : textHasLiveCredential(url) ? { ...rm, live: true } : rm);
|
|
2091
|
+
continue;
|
|
2092
|
+
}
|
|
2056
2093
|
const matched = matchedText[ri] ?? "";
|
|
2057
2094
|
matches.push(textHasLiveCredential(matched) ? { ...rm, live: true } : rm);
|
|
2058
2095
|
}
|
|
@@ -2473,6 +2510,22 @@ function unauthenticatedTanStackHandlers(masked, filePath) {
|
|
|
2473
2510
|
}
|
|
2474
2511
|
return hits;
|
|
2475
2512
|
}
|
|
2513
|
+
var SERVER_ACTION_WRITE_RE = [
|
|
2514
|
+
/\b(?:kv|redis|cache|upstash)\s*\.\s*(?:set|del|hset|hdel|incr\w{0,4}|decr\w{0,4}|lpush|rpush|sadd|srem|zadd|expire|getdel)\s*\(/,
|
|
2515
|
+
/\b(?:stripe|paypal|braintree|lemonsqueezy|paddle)\s*\.\s*\w{1,40}\s*\.\s*(?:create|update|del|cancel|capture|refund)\w{0,10}\s*\(/,
|
|
2516
|
+
/\bfetch\s*\([^;]{0,400}?\bmethod\s*(?::\s*(?=["'`](?:POST|PUT|PATCH|DELETE)\b|`\$\{|[A-Za-z_$(\[])|(?=[,}]))/i,
|
|
2517
|
+
/\b(?:fs(?:\.promises)?\s*\.\s*)?(?:writeFile|appendFile|unlink|rm|rmdir|rename|copyFile)(?:Sync)?\s*\(/,
|
|
2518
|
+
/\.\s*(?:del|deleteOne|deleteMany|insertOne|insertMany|updateOne|updateMany|replaceOne|bulkWrite|upsert|increment|decrement|destroy|truncate)\s*\(/,
|
|
2519
|
+
/cookies\(\)\)?\s*\.\s*set\(\s*["'`][\w-]*(?:session|token|auth|jwt|sid|role|user|admin)/i,
|
|
2520
|
+
...TANSTACK_MUTATION_RE,
|
|
2521
|
+
/\b(?:prisma|db|tx)\s*\.\s*\w{1,64}\s*\.\s*(?:create|createMany|insert\w{0,10})\s*\(/,
|
|
2522
|
+
/\b(?:db|tx)\s*\.\s*insert\s*\(\s*\w/,
|
|
2523
|
+
/\.from\(\s*["'`][\w.-]{1,64}["'`]\s*\)\s*\.\s*insert\s*\(/,
|
|
2524
|
+
/\bINSERT\s+INTO\b/i,
|
|
2525
|
+
/\.collection\(\s*["'`][\w.-]{1,64}["'`]\s*\)\s*\.\s*(?:insert\w{0,8}|update\w{0,8}|delete\w{0,8}|replaceOne|findOneAndUpdate|findOneAndDelete)\s*\(/,
|
|
2526
|
+
/\b(?!(?:Object|Array|Promise|Reflect|Buffer|Math|JSON|Date|Intl|Symbol|Map|Set|WeakMap|Response|NextResponse|Request|URL|Error)\b)[A-Z]\w{0,40}\.(?:create|insertMany|updateOne|updateMany|deleteOne|deleteMany|findByIdAndUpdate|findByIdAndDelete|findOneAndUpdate|findOneAndDelete|destroy)\s*\(/,
|
|
2527
|
+
/\b(?:delete|remove|update|set|grant|revoke|ban|promote|demote|transfer|refund|cancel|reset|change)\w{0,20}(?:User|Account|Role|Admin|Order|Payment|Subscription|Member|Permission|Password|Email|Org|Organization|Team|Project|Invoice|Profile|Balance|Credits?|Plan|Post|Comment)s?\s*\(/
|
|
2528
|
+
];
|
|
2476
2529
|
var missingAuthMiddleware = {
|
|
2477
2530
|
id: "VC003",
|
|
2478
2531
|
title: "API Route Missing Authentication",
|
|
@@ -2498,8 +2551,9 @@ var missingAuthMiddleware = {
|
|
|
2498
2551
|
/module\.exports\s*=\s*(?:async\s+)?(?:function\b|\()/g
|
|
2499
2552
|
);
|
|
2500
2553
|
}
|
|
2554
|
+
const useServerPatterns = [];
|
|
2501
2555
|
if (USE_SERVER_DIRECTIVE_RE.test(content)) {
|
|
2502
|
-
|
|
2556
|
+
useServerPatterns.push(
|
|
2503
2557
|
/export\s+(?:async\s+)?function\s+\w+\s*\(/g,
|
|
2504
2558
|
/export\s+const\s+\w+\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?\(/g
|
|
2505
2559
|
);
|
|
@@ -2585,24 +2639,33 @@ var missingAuthMiddleware = {
|
|
|
2585
2639
|
);
|
|
2586
2640
|
const maskedForScope = maskOutboundAuthNoise(maskComments(content));
|
|
2587
2641
|
const codeForAuth = maskOutboundAuthNoise(codeOnly);
|
|
2588
|
-
const
|
|
2642
|
+
const scopeCache = /* @__PURE__ */ new Map();
|
|
2643
|
+
const scopeAt = (index) => {
|
|
2644
|
+
const cached = scopeCache.get(index);
|
|
2645
|
+
if (cached !== void 0) return cached;
|
|
2589
2646
|
const bodyStart = maskedForScope.indexOf("{", index);
|
|
2590
2647
|
const probe = bodyStart === -1 ? index : bodyStart + 1;
|
|
2591
2648
|
const scope = enclosingHandler(maskedForScope, probe);
|
|
2649
|
+
scopeCache.set(index, scope);
|
|
2650
|
+
return scope;
|
|
2651
|
+
};
|
|
2652
|
+
const handlerHasAuth = (index) => {
|
|
2653
|
+
const scope = scopeAt(index);
|
|
2592
2654
|
if (scope === null) return handlerAuthPatterns.some((p) => p.test(codeForAuth));
|
|
2593
2655
|
return handlerAuthPatterns.some((p) => p.test(scope));
|
|
2594
2656
|
};
|
|
2595
2657
|
const matches = [];
|
|
2658
|
+
const routeLines = /* @__PURE__ */ new Set();
|
|
2659
|
+
const authFix = "Add authentication middleware to protect this route. Check the user's session/token before processing the request. If the endpoint is public by design (an OG image, an embeddable badge, a health check), add an inline `// VC003-OK: <reason>` comment above the handler to silence.";
|
|
2596
2660
|
for (const pattern of serverSide ? routePatterns : []) {
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
);
|
|
2661
|
+
const found = findMatches(content, pattern, missingAuthMiddleware, filePath, () => authFix);
|
|
2662
|
+
for (const foundMatch of found) routeLines.add(foundMatch.line);
|
|
2663
|
+
matches.push(...found);
|
|
2664
|
+
}
|
|
2665
|
+
if (serverSide) {
|
|
2666
|
+
for (const pattern of useServerPatterns) {
|
|
2667
|
+
matches.push(...findMatches(content, pattern, missingAuthMiddleware, filePath, () => authFix));
|
|
2668
|
+
}
|
|
2606
2669
|
}
|
|
2607
2670
|
if (matches.length === 0 && serverSide && SUPABASE_EDGE_FN_RE.test(filePath) && isDenoEdgeEntry(codeOnly) && !isPublicByDesignEdgePath(filePath)) {
|
|
2608
2671
|
const fnName = supabaseFunctionName(filePath);
|
|
@@ -2631,7 +2694,12 @@ var missingAuthMiddleware = {
|
|
|
2631
2694
|
const isPublicRootGet = (index) => /\.\s*get\s*\(\s*["'`]\/["'`]\s*,/i.test(content.slice(index, index + 240));
|
|
2632
2695
|
const unauthenticated = matches.filter((m) => {
|
|
2633
2696
|
const index = indexOfLine(m.line);
|
|
2634
|
-
|
|
2697
|
+
if (isPublicRootGet(index) || handlerHasAuth(index)) return false;
|
|
2698
|
+
if (useServerPatterns.length > 0 && !routeLines.has(m.line)) {
|
|
2699
|
+
const scope = scopeAt(index);
|
|
2700
|
+
if (scope !== null && !SERVER_ACTION_WRITE_RE.some((re) => re.test(scope))) return false;
|
|
2701
|
+
}
|
|
2702
|
+
return true;
|
|
2635
2703
|
});
|
|
2636
2704
|
if (serverSide || tanstackCandidate) {
|
|
2637
2705
|
for (const idx of unauthenticatedTanStackHandlers(maskedForScope, filePath)) {
|
|
@@ -3031,6 +3099,9 @@ var noRateLimiting = {
|
|
|
3031
3099
|
check(content, filePath) {
|
|
3032
3100
|
const isEntryFile = /(?:server|app|index|main)\.[jt]sx?$/.test(filePath) || filePath.includes("middleware");
|
|
3033
3101
|
if (!isEntryFile) return [];
|
|
3102
|
+
if (/(?:^|\/)(?:lib|libs|utils?|helpers?|components|hooks|shared|types)\/(?:[^/]+\/)*index\.[jt]sx?$/.test(filePath) && !/\.listen\s*\(|\bcreateServer\s*\(|\bexpress\s*\(\s*\)|\bFastify\s*\(|\bnew\s+(?:Koa|Hono)\b/.test(content)) {
|
|
3103
|
+
return [];
|
|
3104
|
+
}
|
|
3034
3105
|
const isServer = /(?:from\s+|require\s*\(\s*)["'`](?:express|hono|fastify|koa|koa-router|@koa\/[\w-]+|@hono\/[\w-]+|next(?:\/server)?|next-auth(?:\/[\w-]+)?|@clerk\/nextjs(?:\/server)?)["'`]/.test(content) || // Case-sensitive framework types — `adNext` and `nextLap` can't match.
|
|
3035
3106
|
/\b(?:NextApiRequest|NextApiResponse|NextRequest|NextResponse)\b/.test(content) || /\b(?:express|fastify|createServer)\s*\(/.test(content) || /\bnew\s+(?:Hono|Koa)\s*\(/.test(content) || /\b(?:Deno|Bun)\.serve\s*\(/.test(content) || /\.listen\s*\(/.test(content);
|
|
3036
3107
|
if (!isServer) return [];
|
|
@@ -3370,6 +3441,28 @@ var unvalidatedRedirect = {
|
|
|
3370
3441
|
var CLIENT_PREFERENCE_COOKIE_NAME_RE = /(?:consent|preferences?|prefs?)/i;
|
|
3371
3442
|
var CLIENT_PREFERENCE_COOKIE_VALUE_RE = /(?:choice|consent|preferences?|prefs?|accepted|essential(?:-only)?|declined|rejected|granted|denied|opt(?:ed)?[-_ ]?(?:in|out))/i;
|
|
3372
3443
|
var SENSITIVE_CLIENT_COOKIE_RE = /(?:auth|session|token|jwt|bearer|credential|password|passwd|secret|csrf|xsrf|refresh)/i;
|
|
3444
|
+
var UI_FLAG_COOKIE_NAME_RE = /^(?:theme|color-?scheme|sidebar|welcome-toast|toast|locale|lang|language|dir|collapsed|expanded|layout|banner|dismissed|density|contrast|font|font-?size|motion|reduced-?motion|color-mode|dark-mode|ui)$/i;
|
|
3445
|
+
var UI_FLAG_COOKIE_ASSIGN_RE = /\b(?:document\s*\.\s*)?cookie\s*=\s*(["'`])([^"'`]*)\1/gi;
|
|
3446
|
+
var UI_FLAG_SENSITIVE_NAME_RE = /(?:sess|sid(?!ebar)|login|user|uid|key|account|admin|role|remember|__host-|__secure-)/i;
|
|
3447
|
+
var UI_FLAG_COOKIE_BODY_RE = /^[A-Za-z0-9_.-]+=[A-Za-z0-9_.-]+(?:\s*;\s*(?:max-age=-?\d{1,10}|path=\/[\w./-]{0,100}|expires=[\w ,:+-]{1,40}|samesite=(?:lax|strict|none)|secure|domain=\.?[\w.-]{1,100})){0,6}\s*;?\s*$/i;
|
|
3448
|
+
function isConstantUiFlagCookieWrite(line, nextLine) {
|
|
3449
|
+
const next = nextLine.trimStart();
|
|
3450
|
+
if (next.startsWith("+") || next.startsWith(".") || next.startsWith("`")) return false;
|
|
3451
|
+
if (/\bset-cookie\b|\bsetCookie\b|res\.cookie\s*\(/i.test(line)) return false;
|
|
3452
|
+
const re = new RegExp(UI_FLAG_COOKIE_ASSIGN_RE.source, "gi");
|
|
3453
|
+
let saw = false;
|
|
3454
|
+
let assignment;
|
|
3455
|
+
while ((assignment = re.exec(line)) !== null) {
|
|
3456
|
+
saw = true;
|
|
3457
|
+
const body = assignment[2];
|
|
3458
|
+
if (!UI_FLAG_COOKIE_BODY_RE.test(body)) return false;
|
|
3459
|
+
if (SENSITIVE_CLIENT_COOKIE_RE.test(body)) return false;
|
|
3460
|
+
const name = body.split("=")[0];
|
|
3461
|
+
if (!UI_FLAG_COOKIE_NAME_RE.test(name)) return false;
|
|
3462
|
+
if (UI_FLAG_SENSITIVE_NAME_RE.test(name)) return false;
|
|
3463
|
+
}
|
|
3464
|
+
return saw;
|
|
3465
|
+
}
|
|
3373
3466
|
function isClearlyNonSensitivePreferenceCookieWrite(content, line) {
|
|
3374
3467
|
const assignment = /\bdocument\s*\.\s*cookie\s*=\s*(.+)$/i.exec(line);
|
|
3375
3468
|
if (!assignment) return false;
|
|
@@ -3401,7 +3494,7 @@ var insecureCookies = {
|
|
|
3401
3494
|
check(content, filePath) {
|
|
3402
3495
|
if (isTestFile(filePath)) return [];
|
|
3403
3496
|
if (!/cookie/i.test(content)) return [];
|
|
3404
|
-
const setCookiePattern = /(
|
|
3497
|
+
const setCookiePattern = /(?:\bset-cookie|\bsetCookie|\bcookie\s*=|res\.cookie\s*\()/i;
|
|
3405
3498
|
if (!setCookiePattern.test(content)) return [];
|
|
3406
3499
|
const hasHttpOnly = /httpOnly\s*:\s*true|httponly/i.test(content);
|
|
3407
3500
|
const hasSecure = /secure\s*:\s*(?!false\b)\S/i.test(content) || /;\s*secure/i.test(content);
|
|
@@ -3420,12 +3513,18 @@ var insecureCookies = {
|
|
|
3420
3513
|
() => `Add missing cookie flags: ${missing.join(", ")}. Example: { httpOnly: true, secure: true, sameSite: 'lax' }`
|
|
3421
3514
|
);
|
|
3422
3515
|
const lines = content.split("\n");
|
|
3516
|
+
const uiFlagMemo = /* @__PURE__ */ new Map();
|
|
3423
3517
|
for (const match of rawMatches) {
|
|
3424
3518
|
const line = lines[match.line - 1] ?? "";
|
|
3425
3519
|
if (!hasHttpOnly && isClearlyNonSensitivePreferenceCookieWrite(content, line)) {
|
|
3426
3520
|
continue;
|
|
3427
3521
|
}
|
|
3428
|
-
|
|
3522
|
+
let info = uiFlagMemo.get(match.line);
|
|
3523
|
+
if (info === void 0) {
|
|
3524
|
+
info = isConstantUiFlagCookieWrite(line, lines[match.line] ?? "");
|
|
3525
|
+
uiFlagMemo.set(match.line, info);
|
|
3526
|
+
}
|
|
3527
|
+
matches.push(info ? { ...match, severity: "info" } : match);
|
|
3429
3528
|
}
|
|
3430
3529
|
}
|
|
3431
3530
|
return matches;
|
|
@@ -3571,19 +3670,49 @@ var missingHTTPS = {
|
|
|
3571
3670
|
const isScriptFile = /\.(?:[cm]?[jt]sx?|vue|svelte)$/i.test(filePath);
|
|
3572
3671
|
if (!isScriptFile && /<!DOCTYPE|xmlns|\.dtd|\.xsd/i.test(content) && !/fetch|axios|request|http\.get/i.test(content)) return [];
|
|
3573
3672
|
const httpPattern = /["'`]http:\/\/(?!localhost|127\.0\.0\.1|0\.0\.0\.0|192\.168\.|10\.|172\.(?:1[6-9]|2\d|3[01])\.|www\.w3\.org|www\.apple\.com\/DTDs|schemas?\.|xml\.org|purl\.org|ns\.adobe|xmlpull\.org|java\.sun\.com)[^"'`\s]+["'`]/g;
|
|
3574
|
-
const
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
() => "Use https:// instead of http:// for all production URLs. Add HSTS header: Strict-Transport-Security: max-age=31536000; includeSubDomains"
|
|
3580
|
-
);
|
|
3673
|
+
const httpIndexes = [];
|
|
3674
|
+
const rawMatches = findMatches(content, httpPattern, missingHTTPS, filePath, (m) => {
|
|
3675
|
+
httpIndexes.push(m.index);
|
|
3676
|
+
return "Use https:// instead of http:// for all production URLs. Add HSTS header: Strict-Transport-Security: max-age=31536000; includeSubDomains";
|
|
3677
|
+
});
|
|
3581
3678
|
const lines = rawMatches.length > 0 ? content.split("\n") : [];
|
|
3582
|
-
|
|
3679
|
+
const lineStarts = [];
|
|
3680
|
+
if (rawMatches.length > 0) {
|
|
3681
|
+
let acc = 0;
|
|
3682
|
+
for (const line of lines) {
|
|
3683
|
+
lineStarts.push(acc);
|
|
3684
|
+
acc += line.length + 1;
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
const schemaKeyOnLine = /* @__PURE__ */ new Map();
|
|
3688
|
+
const tsaOnLine = /* @__PURE__ */ new Map();
|
|
3689
|
+
const firstSchemaKey = (line, lineNo) => {
|
|
3690
|
+
const cached = schemaKeyOnLine.get(lineNo);
|
|
3691
|
+
if (cached !== void 0) return cached;
|
|
3692
|
+
const key = /(?<![\w$])["']?\$(?:schema|id|ref)["']?\s*:/.exec(line);
|
|
3693
|
+
const at = key ? key.index : -1;
|
|
3694
|
+
schemaKeyOnLine.set(lineNo, at);
|
|
3695
|
+
return at;
|
|
3696
|
+
};
|
|
3697
|
+
for (let i = 0; i < rawMatches.length; i++) {
|
|
3698
|
+
const rm = rawMatches[i];
|
|
3583
3699
|
const matchText = lines[rm.line - 1] ?? "";
|
|
3584
3700
|
if (/DTD|DOCTYPE|w3\.org|apple\.com\/DTDs|\bxmlns[\w:-]*\s*=/i.test(matchText)) continue;
|
|
3585
|
-
if (
|
|
3586
|
-
|
|
3701
|
+
if (firstSchemaKey(matchText, rm.line) >= 0) {
|
|
3702
|
+
const col = httpIndexes[i] - (lineStarts[rm.line - 1] ?? 0);
|
|
3703
|
+
const lookback = matchText.slice(Math.max(0, col - 48), col);
|
|
3704
|
+
if (/(?<![\w$])["']?\$(?:schema|id)["']?\s*:\s*["']?\s*$/.test(lookback)) continue;
|
|
3705
|
+
if (/(?<![\w$])["']?\$ref["']?\s*:\s*["']?\s*$/.test(lookback)) {
|
|
3706
|
+
const host = (/https?:\/\/([^/"'\s:?#]+)/i.exec(matchText.slice(col, col + 300))?.[1] ?? "").toLowerCase();
|
|
3707
|
+
if (host === "json-schema.org" || host.endsWith(".json-schema.org")) continue;
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
let tsa = tsaOnLine.get(rm.line);
|
|
3711
|
+
if (tsa === void 0) {
|
|
3712
|
+
tsa = /--\s*tsaurl\b|\btsaurl\b|timestamp\.(?:digicert|sectigo|comodoca|globalsign|entrust|geotrust|verisign|apple)\.|timestamp\.acs\.microsoft\.com|freetsa\.org/i.test(matchText);
|
|
3713
|
+
tsaOnLine.set(rm.line, tsa);
|
|
3714
|
+
}
|
|
3715
|
+
if (tsa) continue;
|
|
3587
3716
|
matches.push(rm);
|
|
3588
3717
|
}
|
|
3589
3718
|
return matches;
|
|
@@ -4513,12 +4642,13 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
4513
4642
|
}
|
|
4514
4643
|
if (maxLineLen > 5e4) return findings;
|
|
4515
4644
|
if (/demo-data|example-vulnerable|code-sample/i.test(filePath)) return findings;
|
|
4516
|
-
|
|
4645
|
+
const sbomFile = isSbomPath(filePath);
|
|
4517
4646
|
const vendoredFile = isVendoredPath(filePath);
|
|
4518
4647
|
const ruleset = tier === "pro" && extraRules.length > 0 ? [...freeRules, ...extraRules] : freeRules;
|
|
4519
4648
|
const silenceableLines = /-OK\b/i.test(content) ? content.split("\n") : null;
|
|
4520
4649
|
for (const rule of ruleset) {
|
|
4521
4650
|
if (disabledRules.includes(rule.id)) continue;
|
|
4651
|
+
if (sbomFile && rule.category !== "Secrets") continue;
|
|
4522
4652
|
const matches = rule.check(content, filePath, project);
|
|
4523
4653
|
const compliance = complianceMap[rule.id];
|
|
4524
4654
|
const vendored = vendoredFile && isVendoredFinding({ file: filePath, rule: rule.id, category: rule.category });
|
|
@@ -4931,6 +5061,30 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
|
|
|
4931
5061
|
}
|
|
4932
5062
|
|
|
4933
5063
|
// src/entropy-scanner.ts
|
|
5064
|
+
function orderedAlphabetRatio(value) {
|
|
5065
|
+
if (value.length === 0) return 0;
|
|
5066
|
+
let ordered = 0;
|
|
5067
|
+
let run = 1;
|
|
5068
|
+
const cls = (c) => {
|
|
5069
|
+
if (c >= 48 && c <= 57) return 1;
|
|
5070
|
+
if (c >= 65 && c <= 90) return 2;
|
|
5071
|
+
if (c >= 97 && c <= 122) return 3;
|
|
5072
|
+
return 0;
|
|
5073
|
+
};
|
|
5074
|
+
for (let i = 1; i < value.length; i++) {
|
|
5075
|
+
const a = value.charCodeAt(i - 1);
|
|
5076
|
+
const b = value.charCodeAt(i);
|
|
5077
|
+
const ca = cls(a);
|
|
5078
|
+
if (ca !== 0 && ca === cls(b) && b === a + 1) {
|
|
5079
|
+
run++;
|
|
5080
|
+
if (run === 4) ordered += 4;
|
|
5081
|
+
else if (run > 4) ordered++;
|
|
5082
|
+
} else {
|
|
5083
|
+
run = 1;
|
|
5084
|
+
}
|
|
5085
|
+
}
|
|
5086
|
+
return ordered / value.length;
|
|
5087
|
+
}
|
|
4934
5088
|
function shannonEntropy(str) {
|
|
4935
5089
|
const freq = {};
|
|
4936
5090
|
for (const ch of str) {
|
|
@@ -5170,6 +5324,7 @@ function scanEntropy(files) {
|
|
|
5170
5324
|
const stringPattern = /(?:[:=]\s*)(["'`])([^"'`\n]{20,256})\1/g;
|
|
5171
5325
|
let match;
|
|
5172
5326
|
while ((match = stringPattern.exec(line)) !== null) {
|
|
5327
|
+
if (match[1] === "`" && /(?:^|[\s(]):[a-z][\w-]{0,20}:$/.test(line.slice(Math.max(0, match.index - 23), match.index + 1))) continue;
|
|
5173
5328
|
let beforeAssign = line.substring(0, match.index);
|
|
5174
5329
|
if (structured) beforeAssign = beforeAssign.slice(Math.max(beforeAssign.lastIndexOf(","), beforeAssign.lastIndexOf("{")) + 1);
|
|
5175
5330
|
candidates.push({ value: match[2], beforeAssign });
|
|
@@ -5182,7 +5337,10 @@ function scanEntropy(files) {
|
|
|
5182
5337
|
if (value.includes("${")) continue;
|
|
5183
5338
|
if (value.includes("\\(")) continue;
|
|
5184
5339
|
if (value.includes("#{") || value.includes("{{")) continue;
|
|
5185
|
-
if (
|
|
5340
|
+
if (/^(?:\$\w{1,64}|\$env\{\w{1,64}\}|%\w{1,64}%|~|\.{1,2})?[\/\\](?:[\w.@ -]{1,64}[\/\\]){1,20}[\w@ -][\w.@ -]{0,63}\.[A-Za-z0-9]{1,8}$/.test(value) && !/[A-Za-z0-9+]{24,}/.test(value)) continue;
|
|
5341
|
+
if (orderedAlphabetRatio(value) >= 0.9) continue;
|
|
5342
|
+
const isUuidShape = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
5343
|
+
if (!isUuidShape && SAFE_PATTERNS.some((p) => p.test(value))) continue;
|
|
5186
5344
|
if (HASH_PREFIX_RE.test(value)) continue;
|
|
5187
5345
|
if (SAFE_VAR_NAMES.test(beforeAssign)) continue;
|
|
5188
5346
|
if (/^https?:\/\/[^:@]*$/.test(value)) continue;
|
|
@@ -5193,9 +5351,10 @@ function scanEntropy(files) {
|
|
|
5193
5351
|
if (isHex) threshold = 3;
|
|
5194
5352
|
else if (isBase64) threshold = 4.5;
|
|
5195
5353
|
if (value.length < 20) continue;
|
|
5196
|
-
const entropy = shannonEntropy(value);
|
|
5197
|
-
if (entropy < threshold) continue;
|
|
5198
5354
|
const varName = variableName || dotenvName || beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
|
|
5355
|
+
if (isUuidShape && !isSecretVariableName(varName)) continue;
|
|
5356
|
+
const entropy = shannonEntropy(value);
|
|
5357
|
+
if (entropy < threshold && !(isUuidShape && isSecretVariableName(varName))) continue;
|
|
5199
5358
|
if (HUMAN_READABLE_ENV_REFERENCE_RE.test(value) && !isSecretVariableName(varName)) {
|
|
5200
5359
|
continue;
|
|
5201
5360
|
}
|
|
@@ -9711,6 +9870,7 @@ export {
|
|
|
9711
9870
|
QUALITY_EXAMPLES,
|
|
9712
9871
|
RULE_IMPACTS,
|
|
9713
9872
|
SCANNER_VERSION,
|
|
9873
|
+
SERVER_ACTION_WRITE_RE,
|
|
9714
9874
|
TEST_FILE_PATTERN,
|
|
9715
9875
|
TOTAL_RULE_COUNT,
|
|
9716
9876
|
allRules,
|