xploitscan-shared-rules 2.4.31 → 2.4.32
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 +204 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -4
- package/dist/index.d.ts +77 -4
- package/dist/index.js +198 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -169,7 +169,7 @@ interface CustomRule {
|
|
|
169
169
|
* before a scan can be saved without enough provenance to explain a changed
|
|
170
170
|
* grade.
|
|
171
171
|
*/
|
|
172
|
-
declare const SCANNER_VERSION = "2.4.
|
|
172
|
+
declare const SCANNER_VERSION = "2.4.32";
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Line-oriented helpers shared by every rule. Pure string manipulation — no fs
|
|
@@ -667,6 +667,24 @@ interface SourceFile {
|
|
|
667
667
|
* the CLI, the API and a test.
|
|
668
668
|
*/
|
|
669
669
|
declare function extractRoutes(files: SourceFile[]): RouteTable;
|
|
670
|
+
/**
|
|
671
|
+
* One upload's route claims, for a browser scan split across several
|
|
672
|
+
* requests. A path belongs to the first file that claims it, with the
|
|
673
|
+
* TanStack manifest ahead of every file, so the parts' claims are merged by
|
|
674
|
+
* mergeRouteClaims rather than by joining each part's route table.
|
|
675
|
+
*/
|
|
676
|
+
interface RouteClaims {
|
|
677
|
+
/** The first routeTree.gen.ts in a TanStack project, even when it lists nothing. */
|
|
678
|
+
manifest: {
|
|
679
|
+
source: string;
|
|
680
|
+
routes: AppRoute[];
|
|
681
|
+
} | null;
|
|
682
|
+
/** The file walk's claims in file order, first claim of each path only. */
|
|
683
|
+
declared: AppRoute[];
|
|
684
|
+
}
|
|
685
|
+
/** Same table extractRoutes builds over the parts' files in part order. */
|
|
686
|
+
declare function mergeRouteClaims(parts: readonly RouteClaims[]): RouteTable;
|
|
687
|
+
declare function collectRouteClaims(files: SourceFile[]): RouteClaims;
|
|
670
688
|
/**
|
|
671
689
|
* The route a given file is reachable at, if any.
|
|
672
690
|
*
|
|
@@ -823,6 +841,20 @@ interface IntentReport {
|
|
|
823
841
|
expectation: string;
|
|
824
842
|
}>;
|
|
825
843
|
}
|
|
844
|
+
/**
|
|
845
|
+
* What checkIntent otherwise derives from `files`. A browser scan split across
|
|
846
|
+
* several uploads passes the union of every part's statements and routes,
|
|
847
|
+
* because the last part holds only its own files.
|
|
848
|
+
*/
|
|
849
|
+
interface IntentInputs {
|
|
850
|
+
statements?: IntentStatement[];
|
|
851
|
+
routes?: AppRoute[];
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* harvestIntent over every part's files in part order. Shared files are
|
|
855
|
+
* copied into each part, so a source is read from the first part that has it.
|
|
856
|
+
*/
|
|
857
|
+
declare function mergeIntentStatements(parts: ReadonlyArray<readonly IntentStatement[]>): IntentStatement[];
|
|
826
858
|
/**
|
|
827
859
|
* Join stated intent against findings the scanner already produced.
|
|
828
860
|
*
|
|
@@ -832,7 +864,7 @@ interface IntentReport {
|
|
|
832
864
|
declare function checkIntent(files: Array<{
|
|
833
865
|
path: string;
|
|
834
866
|
content: string;
|
|
835
|
-
}>, findings: Finding[]): IntentReport;
|
|
867
|
+
}>, findings: Finding[], inputs?: IntentInputs): IntentReport;
|
|
836
868
|
|
|
837
869
|
/**
|
|
838
870
|
* Browser-exposed environment variables: which names a framework ships to the
|
|
@@ -1572,7 +1604,48 @@ interface FileInfo {
|
|
|
1572
1604
|
path: string;
|
|
1573
1605
|
content: string;
|
|
1574
1606
|
}
|
|
1575
|
-
|
|
1607
|
+
/**
|
|
1608
|
+
* Inputs for the last upload of a scan split across several requests. Both
|
|
1609
|
+
* are optional, and a call without them is the single-scan behaviour.
|
|
1610
|
+
*/
|
|
1611
|
+
interface MultiFileOptions {
|
|
1612
|
+
/** Route files resolved over every part (resolveSecretGuardedRoutes). Replaces the local computation. */
|
|
1613
|
+
guardedRoutes?: ReadonlySet<string>;
|
|
1614
|
+
/** `process.env` names the earlier parts use, in part order (envVarNamesUsed). Read before this part's files. */
|
|
1615
|
+
priorEnvNames?: readonly string[];
|
|
1616
|
+
}
|
|
1617
|
+
/** `process.env` names scanMultiFile's Check 5 would see in these files, first use first. */
|
|
1618
|
+
declare function envVarNamesUsed(files: FileInfo[]): string[];
|
|
1619
|
+
declare function scanMultiFile(files: FileInfo[], opts?: MultiFileOptions): Finding[];
|
|
1620
|
+
|
|
1621
|
+
/** A route whose handlers all delegate (or self-guard). `callees` is empty when every handler opens with the guard itself. */
|
|
1622
|
+
interface RouteDelegationFact {
|
|
1623
|
+
path: string;
|
|
1624
|
+
callees: Array<{
|
|
1625
|
+
fn: string;
|
|
1626
|
+
spec: string | null;
|
|
1627
|
+
}>;
|
|
1628
|
+
}
|
|
1629
|
+
/** Names whose single definition in `path` opens with the shared-secret guard. */
|
|
1630
|
+
interface GuardedHelperFact {
|
|
1631
|
+
path: string;
|
|
1632
|
+
names: string[];
|
|
1633
|
+
}
|
|
1634
|
+
interface RouteDelegationFacts {
|
|
1635
|
+
routes: RouteDelegationFact[];
|
|
1636
|
+
helpers: GuardedHelperFact[];
|
|
1637
|
+
}
|
|
1638
|
+
/** One upload's half of secretGuardedRoutes. */
|
|
1639
|
+
declare function routeDelegationFacts(files: Array<{
|
|
1640
|
+
path: string;
|
|
1641
|
+
content: string;
|
|
1642
|
+
}>): RouteDelegationFacts;
|
|
1643
|
+
/**
|
|
1644
|
+
* secretGuardedRoutes over facts. `paths` is every scanned path in every
|
|
1645
|
+
* part: a callee must resolve to exactly one of them, as it must to exactly
|
|
1646
|
+
* one file in a single scan.
|
|
1647
|
+
*/
|
|
1648
|
+
declare function resolveSecretGuardedRoutes(routes: readonly RouteDelegationFact[], helpers: readonly GuardedHelperFact[], paths: Iterable<string>): Set<string>;
|
|
1576
1649
|
|
|
1577
1650
|
/**
|
|
1578
1651
|
* URL recon — what can be learned about a deployed app from what it already
|
|
@@ -1868,4 +1941,4 @@ input: {
|
|
|
1868
1941
|
content: string;
|
|
1869
1942
|
}[] | QualityContext, rules?: QualityRule[]): Finding[];
|
|
1870
1943
|
|
|
1871
|
-
export { type AIFilterResult, type AiDegraded, AiReason, AiStatus, AiSurface, type AppRoute, BILLING_WEBHOOK_UNMATCHED_KEYS, 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, KEEP_SEVERITY_IN_TESTS, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PLAN_UNVERIFIED_NOTICE, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, PlanCause, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, SCANNER_VERSION, SCAN_AI_DEGRADED_KEYS, SCAN_TOKEN_NULL_KEYS, SERVER_ACTION_WRITE_RE, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, aiStatusLine, allRules, applyTestPathSeverity, assessHeaders, astMatch, authPrefixCovers, bearerProvenanceSafe, billingWebhookUnmatchedProps, bucketFiles, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, capabilityTokenHandler, 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, hardcodedSecretValues, hardcodedSecrets, hardenUntrustedPromptText, harvestIntent, insecureCookies, insecureRandomness, isAnchoredPublicAuthPath, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isOgRoutePath, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, maskSecretValue, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, perCallTimeoutMs, planCause, prepareUntrustedSpan, publicHttpsUrl, publicReadOnlyHandler, qualityRules, refineDirectObjectFindings, replaceBlockComments, resetStructuralState, routeForFile, routePathFromFile, runCustomRules, sanitizePromptField, scanAiDegradedProps, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, scanTokenNullProps, setStructuralFaultForTest, sqlInjection, stripeWebhookUnprotected, structuralParseCount, supabaseFunctionName, supabaseNoRLS, testPathHold, toAiDegraded, todoLeftInCode, tryParse, unknownAiStatus, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, widenedAuthSuppresses, xssVulnerability };
|
|
1944
|
+
export { type AIFilterResult, type AiDegraded, AiReason, AiStatus, AiSurface, type AppRoute, BILLING_WEBHOOK_UNMATCHED_KEYS, 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 GuardedHelperFact, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentInputs, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, KEEP_SEVERITY_IN_TESTS, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, type MultiFileOptions, NON_APP_PATH_PATTERNS, PLAN_UNVERIFIED_NOTICE, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, PlanCause, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteClaims, type RouteDelegationFact, type RouteDelegationFacts, type RouteFramework, type RouteTable, type RuleMatch, SCANNER_VERSION, SCAN_AI_DEGRADED_KEYS, SCAN_TOKEN_NULL_KEYS, SERVER_ACTION_WRITE_RE, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, aiStatusLine, allRules, applyTestPathSeverity, assessHeaders, astMatch, authPrefixCovers, bearerProvenanceSafe, billingWebhookUnmatchedProps, bucketFiles, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, capabilityTokenHandler, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, collectRouteClaims, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, deduplicateFindings, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, envVarNamesUsed, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecretValues, hardcodedSecrets, hardenUntrustedPromptText, harvestIntent, insecureCookies, insecureRandomness, isAnchoredPublicAuthPath, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isOgRoutePath, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, maskSecretValue, mergeIntentStatements, mergeRouteClaims, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, perCallTimeoutMs, planCause, prepareUntrustedSpan, publicHttpsUrl, publicReadOnlyHandler, qualityRules, refineDirectObjectFindings, replaceBlockComments, resetStructuralState, resolveSecretGuardedRoutes, routeDelegationFacts, routeForFile, routePathFromFile, runCustomRules, sanitizePromptField, scanAiDegradedProps, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, scanTokenNullProps, setStructuralFaultForTest, sqlInjection, stripeWebhookUnprotected, structuralParseCount, supabaseFunctionName, supabaseNoRLS, testPathHold, toAiDegraded, todoLeftInCode, tryParse, unknownAiStatus, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, widenedAuthSuppresses, xssVulnerability };
|
package/dist/index.d.ts
CHANGED
|
@@ -169,7 +169,7 @@ interface CustomRule {
|
|
|
169
169
|
* before a scan can be saved without enough provenance to explain a changed
|
|
170
170
|
* grade.
|
|
171
171
|
*/
|
|
172
|
-
declare const SCANNER_VERSION = "2.4.
|
|
172
|
+
declare const SCANNER_VERSION = "2.4.32";
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Line-oriented helpers shared by every rule. Pure string manipulation — no fs
|
|
@@ -667,6 +667,24 @@ interface SourceFile {
|
|
|
667
667
|
* the CLI, the API and a test.
|
|
668
668
|
*/
|
|
669
669
|
declare function extractRoutes(files: SourceFile[]): RouteTable;
|
|
670
|
+
/**
|
|
671
|
+
* One upload's route claims, for a browser scan split across several
|
|
672
|
+
* requests. A path belongs to the first file that claims it, with the
|
|
673
|
+
* TanStack manifest ahead of every file, so the parts' claims are merged by
|
|
674
|
+
* mergeRouteClaims rather than by joining each part's route table.
|
|
675
|
+
*/
|
|
676
|
+
interface RouteClaims {
|
|
677
|
+
/** The first routeTree.gen.ts in a TanStack project, even when it lists nothing. */
|
|
678
|
+
manifest: {
|
|
679
|
+
source: string;
|
|
680
|
+
routes: AppRoute[];
|
|
681
|
+
} | null;
|
|
682
|
+
/** The file walk's claims in file order, first claim of each path only. */
|
|
683
|
+
declared: AppRoute[];
|
|
684
|
+
}
|
|
685
|
+
/** Same table extractRoutes builds over the parts' files in part order. */
|
|
686
|
+
declare function mergeRouteClaims(parts: readonly RouteClaims[]): RouteTable;
|
|
687
|
+
declare function collectRouteClaims(files: SourceFile[]): RouteClaims;
|
|
670
688
|
/**
|
|
671
689
|
* The route a given file is reachable at, if any.
|
|
672
690
|
*
|
|
@@ -823,6 +841,20 @@ interface IntentReport {
|
|
|
823
841
|
expectation: string;
|
|
824
842
|
}>;
|
|
825
843
|
}
|
|
844
|
+
/**
|
|
845
|
+
* What checkIntent otherwise derives from `files`. A browser scan split across
|
|
846
|
+
* several uploads passes the union of every part's statements and routes,
|
|
847
|
+
* because the last part holds only its own files.
|
|
848
|
+
*/
|
|
849
|
+
interface IntentInputs {
|
|
850
|
+
statements?: IntentStatement[];
|
|
851
|
+
routes?: AppRoute[];
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* harvestIntent over every part's files in part order. Shared files are
|
|
855
|
+
* copied into each part, so a source is read from the first part that has it.
|
|
856
|
+
*/
|
|
857
|
+
declare function mergeIntentStatements(parts: ReadonlyArray<readonly IntentStatement[]>): IntentStatement[];
|
|
826
858
|
/**
|
|
827
859
|
* Join stated intent against findings the scanner already produced.
|
|
828
860
|
*
|
|
@@ -832,7 +864,7 @@ interface IntentReport {
|
|
|
832
864
|
declare function checkIntent(files: Array<{
|
|
833
865
|
path: string;
|
|
834
866
|
content: string;
|
|
835
|
-
}>, findings: Finding[]): IntentReport;
|
|
867
|
+
}>, findings: Finding[], inputs?: IntentInputs): IntentReport;
|
|
836
868
|
|
|
837
869
|
/**
|
|
838
870
|
* Browser-exposed environment variables: which names a framework ships to the
|
|
@@ -1572,7 +1604,48 @@ interface FileInfo {
|
|
|
1572
1604
|
path: string;
|
|
1573
1605
|
content: string;
|
|
1574
1606
|
}
|
|
1575
|
-
|
|
1607
|
+
/**
|
|
1608
|
+
* Inputs for the last upload of a scan split across several requests. Both
|
|
1609
|
+
* are optional, and a call without them is the single-scan behaviour.
|
|
1610
|
+
*/
|
|
1611
|
+
interface MultiFileOptions {
|
|
1612
|
+
/** Route files resolved over every part (resolveSecretGuardedRoutes). Replaces the local computation. */
|
|
1613
|
+
guardedRoutes?: ReadonlySet<string>;
|
|
1614
|
+
/** `process.env` names the earlier parts use, in part order (envVarNamesUsed). Read before this part's files. */
|
|
1615
|
+
priorEnvNames?: readonly string[];
|
|
1616
|
+
}
|
|
1617
|
+
/** `process.env` names scanMultiFile's Check 5 would see in these files, first use first. */
|
|
1618
|
+
declare function envVarNamesUsed(files: FileInfo[]): string[];
|
|
1619
|
+
declare function scanMultiFile(files: FileInfo[], opts?: MultiFileOptions): Finding[];
|
|
1620
|
+
|
|
1621
|
+
/** A route whose handlers all delegate (or self-guard). `callees` is empty when every handler opens with the guard itself. */
|
|
1622
|
+
interface RouteDelegationFact {
|
|
1623
|
+
path: string;
|
|
1624
|
+
callees: Array<{
|
|
1625
|
+
fn: string;
|
|
1626
|
+
spec: string | null;
|
|
1627
|
+
}>;
|
|
1628
|
+
}
|
|
1629
|
+
/** Names whose single definition in `path` opens with the shared-secret guard. */
|
|
1630
|
+
interface GuardedHelperFact {
|
|
1631
|
+
path: string;
|
|
1632
|
+
names: string[];
|
|
1633
|
+
}
|
|
1634
|
+
interface RouteDelegationFacts {
|
|
1635
|
+
routes: RouteDelegationFact[];
|
|
1636
|
+
helpers: GuardedHelperFact[];
|
|
1637
|
+
}
|
|
1638
|
+
/** One upload's half of secretGuardedRoutes. */
|
|
1639
|
+
declare function routeDelegationFacts(files: Array<{
|
|
1640
|
+
path: string;
|
|
1641
|
+
content: string;
|
|
1642
|
+
}>): RouteDelegationFacts;
|
|
1643
|
+
/**
|
|
1644
|
+
* secretGuardedRoutes over facts. `paths` is every scanned path in every
|
|
1645
|
+
* part: a callee must resolve to exactly one of them, as it must to exactly
|
|
1646
|
+
* one file in a single scan.
|
|
1647
|
+
*/
|
|
1648
|
+
declare function resolveSecretGuardedRoutes(routes: readonly RouteDelegationFact[], helpers: readonly GuardedHelperFact[], paths: Iterable<string>): Set<string>;
|
|
1576
1649
|
|
|
1577
1650
|
/**
|
|
1578
1651
|
* URL recon — what can be learned about a deployed app from what it already
|
|
@@ -1868,4 +1941,4 @@ input: {
|
|
|
1868
1941
|
content: string;
|
|
1869
1942
|
}[] | QualityContext, rules?: QualityRule[]): Finding[];
|
|
1870
1943
|
|
|
1871
|
-
export { type AIFilterResult, type AiDegraded, AiReason, AiStatus, AiSurface, type AppRoute, BILLING_WEBHOOK_UNMATCHED_KEYS, 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, KEEP_SEVERITY_IN_TESTS, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PLAN_UNVERIFIED_NOTICE, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, PlanCause, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, SCANNER_VERSION, SCAN_AI_DEGRADED_KEYS, SCAN_TOKEN_NULL_KEYS, SERVER_ACTION_WRITE_RE, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, aiStatusLine, allRules, applyTestPathSeverity, assessHeaders, astMatch, authPrefixCovers, bearerProvenanceSafe, billingWebhookUnmatchedProps, bucketFiles, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, capabilityTokenHandler, 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, hardcodedSecretValues, hardcodedSecrets, hardenUntrustedPromptText, harvestIntent, insecureCookies, insecureRandomness, isAnchoredPublicAuthPath, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isOgRoutePath, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, maskSecretValue, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, perCallTimeoutMs, planCause, prepareUntrustedSpan, publicHttpsUrl, publicReadOnlyHandler, qualityRules, refineDirectObjectFindings, replaceBlockComments, resetStructuralState, routeForFile, routePathFromFile, runCustomRules, sanitizePromptField, scanAiDegradedProps, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, scanTokenNullProps, setStructuralFaultForTest, sqlInjection, stripeWebhookUnprotected, structuralParseCount, supabaseFunctionName, supabaseNoRLS, testPathHold, toAiDegraded, todoLeftInCode, tryParse, unknownAiStatus, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, widenedAuthSuppresses, xssVulnerability };
|
|
1944
|
+
export { type AIFilterResult, type AiDegraded, AiReason, AiStatus, AiSurface, type AppRoute, BILLING_WEBHOOK_UNMATCHED_KEYS, 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 GuardedHelperFact, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentInputs, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, KEEP_SEVERITY_IN_TESTS, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, type MultiFileOptions, NON_APP_PATH_PATTERNS, PLAN_UNVERIFIED_NOTICE, PRO_RULE_COUNT, PUBLIC_ENV_PREFIX_RE, type ParsedFile, PlanCause, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteClaims, type RouteDelegationFact, type RouteDelegationFacts, type RouteFramework, type RouteTable, type RuleMatch, SCANNER_VERSION, SCAN_AI_DEGRADED_KEYS, SCAN_TOKEN_NULL_KEYS, SERVER_ACTION_WRITE_RE, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, aiStatusLine, allRules, applyTestPathSeverity, assessHeaders, astMatch, authPrefixCovers, bearerProvenanceSafe, billingWebhookUnmatchedProps, bucketFiles, buildProjectContext, buildQualityContext, buildReviewPrompt, buildTaintMap, calculateGrade, callSpreads, capabilityTokenHandler, checkIntent, classifyExposure, classifyPublicEnvVar, classifyStatement, clientSideAuth, collectRouteClaims, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, deduplicateFindings, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, dotenvValue, emptyCatchBlock, enclosingHandler, envNotGitignored, envVarNamesUsed, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findMatchesAt, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, gradeRuleFamily, hardcodedJWTSecret, hardcodedSecretValues, hardcodedSecrets, hardenUntrustedPromptText, harvestIntent, insecureCookies, insecureRandomness, isAnchoredPublicAuthPath, isCalleeNamed, isClientTarget, isCommentLine, isDotenvPath, isInlineSilenced, isInsideFixMessage, isLineSilenced, isLive, isMethodCall, isOgRoutePath, isPrivateAddress, isProtectedFromAiRemoval, isSbomPath, isServerSideFile, isServerTarget, isTestFile, isTestPath, isUngradedFinding, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, maskOutboundAuthNoise, maskSecretValue, mergeIntentStatements, mergeRouteClaims, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, newDataFence, nextPublicSecret, noRateLimiting, normalizeScanPath, packReviewBatches, parseFile, parseScanTarget, parseSupabaseConfig, perCallTimeoutMs, planCause, prepareUntrustedSpan, publicHttpsUrl, publicReadOnlyHandler, qualityRules, refineDirectObjectFindings, replaceBlockComments, resetStructuralState, resolveSecretGuardedRoutes, routeDelegationFacts, routeForFile, routePathFromFile, runCustomRules, sanitizePromptField, scanAiDegradedProps, scanConfigs, scanDependencies, scanEntropy, scanMultiFile, scanQuality, scanTokenNullProps, setStructuralFaultForTest, sqlInjection, stripeWebhookUnprotected, structuralParseCount, supabaseFunctionName, supabaseNoRLS, testPathHold, toAiDegraded, todoLeftInCode, tryParse, unknownAiStatus, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, widenedAuthSuppresses, 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.32";
|
|
3
3
|
|
|
4
4
|
// src/snippet.ts
|
|
5
5
|
var cacheContent = null;
|
|
@@ -1271,6 +1271,121 @@ function calleeIsGuarded(fn, route, files) {
|
|
|
1271
1271
|
const open = defs[0].index + defs[0][0].length - 1;
|
|
1272
1272
|
return opensWithGuard(targets[0].content.slice(open, open + 4e3));
|
|
1273
1273
|
}
|
|
1274
|
+
var DEF_HEAD_RE = /\b(?:function|const|let)\s+([A-Za-z_$][\w$]*)/g;
|
|
1275
|
+
var GENERIC_DEF_RE = new RegExp(
|
|
1276
|
+
`\\bfunction\\s+([A-Za-z_$][\\w$]*)\\s*\\([^()]{0,200}\\)[^{;]{0,80}\\{|\\b(?:const|let)\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=;\\n]{0,80})?=\\s*(?:async\\s*)?\\([^()]{0,200}\\)[^{;=]{0,80}=>\\s*\\{`,
|
|
1277
|
+
"y"
|
|
1278
|
+
);
|
|
1279
|
+
var ENV_READ = "process.env";
|
|
1280
|
+
var MAX_GUARDED_CANDIDATES = 50;
|
|
1281
|
+
function importSpec(fn, route) {
|
|
1282
|
+
for (const m of route.matchAll(/\bimport\s*\{([^{}]{0,1000})\}\s*from\s*["']([^"'\n]{1,200})["']/g)) {
|
|
1283
|
+
if (m[1].split(",").some((n) => n.trim() === fn)) return m[2];
|
|
1284
|
+
}
|
|
1285
|
+
return null;
|
|
1286
|
+
}
|
|
1287
|
+
function definesGuarded(fn, content) {
|
|
1288
|
+
const F = esc(fn);
|
|
1289
|
+
const defRe = new RegExp(
|
|
1290
|
+
`\\bfunction\\s+${F}\\s*\\([^()]{0,200}\\)[^{;]{0,80}\\{|\\b(?:const|let)\\s+${F}\\s*(?::[^=;\\n]{0,80})?=\\s*(?:async\\s*)?\\([^()]{0,200}\\)[^{;=]{0,80}=>\\s*\\{`,
|
|
1291
|
+
"g"
|
|
1292
|
+
);
|
|
1293
|
+
const defs = [...content.matchAll(defRe)];
|
|
1294
|
+
if (defs.length !== 1) return false;
|
|
1295
|
+
const open = defs[0].index + defs[0][0].length - 1;
|
|
1296
|
+
return opensWithGuard(content.slice(open, open + 4e3));
|
|
1297
|
+
}
|
|
1298
|
+
function envReads(content) {
|
|
1299
|
+
const out = [];
|
|
1300
|
+
for (let i = content.indexOf(ENV_READ); i !== -1; i = content.indexOf(ENV_READ, i + 1)) out.push(i);
|
|
1301
|
+
return out;
|
|
1302
|
+
}
|
|
1303
|
+
function anyIn(sorted, from, to) {
|
|
1304
|
+
let lo = 0;
|
|
1305
|
+
let hi = sorted.length;
|
|
1306
|
+
while (lo < hi) {
|
|
1307
|
+
const mid = lo + hi >>> 1;
|
|
1308
|
+
if (sorted[mid] < from) lo = mid + 1;
|
|
1309
|
+
else hi = mid;
|
|
1310
|
+
}
|
|
1311
|
+
return lo < sorted.length && sorted[lo] < to;
|
|
1312
|
+
}
|
|
1313
|
+
function guardedHelperNames(content) {
|
|
1314
|
+
const reads = envReads(content);
|
|
1315
|
+
if (reads.length === 0) return [];
|
|
1316
|
+
const candidates = [];
|
|
1317
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1318
|
+
DEF_HEAD_RE.lastIndex = 0;
|
|
1319
|
+
for (let m = DEF_HEAD_RE.exec(content); m !== null; m = DEF_HEAD_RE.exec(content)) {
|
|
1320
|
+
if (seen.has(m[1])) continue;
|
|
1321
|
+
GENERIC_DEF_RE.lastIndex = m.index;
|
|
1322
|
+
const def = GENERIC_DEF_RE.exec(content);
|
|
1323
|
+
if (def === null || (def[1] ?? def[2]) !== m[1]) continue;
|
|
1324
|
+
const open = m.index + def[0].length - 1;
|
|
1325
|
+
if (!anyIn(reads, open, open + 4e3)) continue;
|
|
1326
|
+
if (!opensWithGuard(content.slice(open, open + 4e3))) continue;
|
|
1327
|
+
seen.add(m[1]);
|
|
1328
|
+
candidates.push(m[1]);
|
|
1329
|
+
if (candidates.length >= MAX_GUARDED_CANDIDATES) break;
|
|
1330
|
+
}
|
|
1331
|
+
DEF_HEAD_RE.lastIndex = 0;
|
|
1332
|
+
return candidates.filter((name) => definesGuarded(name, content));
|
|
1333
|
+
}
|
|
1334
|
+
function routeDelegationFacts(files) {
|
|
1335
|
+
const routes = [];
|
|
1336
|
+
const helpers = [];
|
|
1337
|
+
for (const f of files) {
|
|
1338
|
+
if (/\.[jt]sx?$/.test(f.path)) {
|
|
1339
|
+
const names = guardedHelperNames(f.content);
|
|
1340
|
+
if (names.length > 0) helpers.push({ path: f.path, names });
|
|
1341
|
+
}
|
|
1342
|
+
if (!ROUTE_FILE_RE.test(f.path) || OTHER_EXPORT_RE.test(f.content)) continue;
|
|
1343
|
+
const exported = firstMatches(f.content, HANDLER_EXPORT_RE, 8);
|
|
1344
|
+
if (exported.length === 0 || exported.length > 7) continue;
|
|
1345
|
+
const callees = /* @__PURE__ */ new Set();
|
|
1346
|
+
let readable = true;
|
|
1347
|
+
for (const e of exported) {
|
|
1348
|
+
DELEGATING_HANDLER_RE.lastIndex = e.index;
|
|
1349
|
+
const h = DELEGATING_HANDLER_RE.exec(f.content);
|
|
1350
|
+
if (h !== null) {
|
|
1351
|
+
callees.add(h[2]);
|
|
1352
|
+
continue;
|
|
1353
|
+
}
|
|
1354
|
+
HANDLER_HEAD_RE.lastIndex = e.index;
|
|
1355
|
+
const head = HANDLER_HEAD_RE.exec(f.content);
|
|
1356
|
+
const open = head === null ? -1 : e.index + head[0].length - 1;
|
|
1357
|
+
if (open === -1 || !opensWithGuard(f.content.slice(open, open + 4e3))) {
|
|
1358
|
+
readable = false;
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
if (!readable) continue;
|
|
1363
|
+
routes.push({ path: f.path, callees: [...callees].map((fn) => ({ fn, spec: importSpec(fn, f.content) })) });
|
|
1364
|
+
}
|
|
1365
|
+
return { routes, helpers };
|
|
1366
|
+
}
|
|
1367
|
+
function resolveSecretGuardedRoutes(routes, helpers, paths) {
|
|
1368
|
+
const all = [...new Set(paths)];
|
|
1369
|
+
const guardedBy = /* @__PURE__ */ new Map();
|
|
1370
|
+
for (const h of helpers) {
|
|
1371
|
+
const set = guardedBy.get(h.path) ?? /* @__PURE__ */ new Set();
|
|
1372
|
+
for (const name of h.names) set.add(name);
|
|
1373
|
+
guardedBy.set(h.path, set);
|
|
1374
|
+
}
|
|
1375
|
+
const out = /* @__PURE__ */ new Set();
|
|
1376
|
+
for (const route of routes) {
|
|
1377
|
+
const ok = route.callees.every(({ fn, spec }) => {
|
|
1378
|
+
if (spec === null) return false;
|
|
1379
|
+
const tail = spec.replace(/^(?:@|~)\//, "").replace(/^(?:\.\.?\/)+/, "");
|
|
1380
|
+
const tailRe = new RegExp(`(?:^|/)${esc(tail)}(?:\\.[jt]sx?|/index\\.[jt]sx?)$`);
|
|
1381
|
+
const targets = all.filter((p) => tailRe.test(p));
|
|
1382
|
+
if (targets.length !== 1) return false;
|
|
1383
|
+
return guardedBy.get(targets[0])?.has(fn) === true;
|
|
1384
|
+
});
|
|
1385
|
+
if (ok) out.add(route.path);
|
|
1386
|
+
}
|
|
1387
|
+
return out;
|
|
1388
|
+
}
|
|
1274
1389
|
|
|
1275
1390
|
// src/project-context.ts
|
|
1276
1391
|
var TOML_FN_SECTION_RE = /^\s*\[functions\.(?:"([^"]+)"|([A-Za-z0-9._-]+))\]\s*$/;
|
|
@@ -1538,12 +1653,34 @@ function normalize2(p) {
|
|
|
1538
1653
|
return p;
|
|
1539
1654
|
}
|
|
1540
1655
|
function extractRoutes(files) {
|
|
1656
|
+
const claims = collectRouteClaims(files);
|
|
1657
|
+
return assembleRoutes([...claims.manifest?.routes ?? [], ...claims.declared]);
|
|
1658
|
+
}
|
|
1659
|
+
function mergeRouteClaims(parts) {
|
|
1660
|
+
const manifest = parts.find((part) => part.manifest !== null)?.manifest ?? null;
|
|
1661
|
+
return assembleRoutes([...manifest?.routes ?? [], ...parts.flatMap((part) => part.declared)]);
|
|
1662
|
+
}
|
|
1663
|
+
function assembleRoutes(claims) {
|
|
1541
1664
|
const routes = /* @__PURE__ */ new Map();
|
|
1542
1665
|
const frameworks = /* @__PURE__ */ new Set();
|
|
1543
|
-
|
|
1666
|
+
for (const claim of claims) {
|
|
1667
|
+
if (routes.has(claim.path)) continue;
|
|
1668
|
+
routes.set(claim.path, claim);
|
|
1669
|
+
frameworks.add(claim.framework);
|
|
1670
|
+
}
|
|
1671
|
+
return {
|
|
1672
|
+
frameworks: [...frameworks],
|
|
1673
|
+
routes: [...routes.values()].sort((a, b) => a.path.localeCompare(b.path))
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
function collectRouteClaims(files) {
|
|
1677
|
+
const declaredPaths = /* @__PURE__ */ new Set();
|
|
1678
|
+
const declared = [];
|
|
1679
|
+
let manifest = null;
|
|
1680
|
+
const claim = (raw, framework, source, kindOverride) => {
|
|
1544
1681
|
const path = normalize2(raw);
|
|
1545
|
-
if (!path
|
|
1546
|
-
|
|
1682
|
+
if (!path) return null;
|
|
1683
|
+
return {
|
|
1547
1684
|
path,
|
|
1548
1685
|
// The URL prefix is a fallback, not the authority. A Next `route.ts` is a
|
|
1549
1686
|
// handler wherever it lives: /free-trust-page/claim/start/route.ts is an
|
|
@@ -1553,8 +1690,13 @@ function extractRoutes(files) {
|
|
|
1553
1690
|
dynamic: DYNAMIC_RE.test(path),
|
|
1554
1691
|
framework,
|
|
1555
1692
|
source
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1693
|
+
};
|
|
1694
|
+
};
|
|
1695
|
+
const add = (raw, framework, source, kindOverride) => {
|
|
1696
|
+
const route = claim(raw, framework, source, kindOverride);
|
|
1697
|
+
if (!route || declaredPaths.has(route.path)) return;
|
|
1698
|
+
declaredPaths.add(route.path);
|
|
1699
|
+
declared.push(route);
|
|
1558
1700
|
};
|
|
1559
1701
|
const isNext = hasDep(files, "next");
|
|
1560
1702
|
const isExpress = hasDep(files, "express") || hasDep(files, "hono") || hasDep(files, "koa");
|
|
@@ -1562,10 +1704,16 @@ function extractRoutes(files) {
|
|
|
1562
1704
|
if (isTanstack) {
|
|
1563
1705
|
const gen = files.find((f) => f.path.endsWith("routeTree.gen.ts"));
|
|
1564
1706
|
if (gen) {
|
|
1707
|
+
const listed = [];
|
|
1708
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1565
1709
|
for (const m of gen.content.matchAll(/'(\/[A-Za-z0-9_\-/$.]*)'/g)) {
|
|
1566
1710
|
if (m[1].split("/").some((seg) => seg.startsWith("_"))) continue;
|
|
1567
|
-
|
|
1711
|
+
const route = claim(m[1], "tanstack-router", gen.path);
|
|
1712
|
+
if (!route || seen.has(route.path)) continue;
|
|
1713
|
+
seen.add(route.path);
|
|
1714
|
+
listed.push(route);
|
|
1568
1715
|
}
|
|
1716
|
+
manifest = { source: gen.path, routes: listed };
|
|
1569
1717
|
}
|
|
1570
1718
|
}
|
|
1571
1719
|
for (const file of files) {
|
|
@@ -1613,10 +1761,7 @@ function extractRoutes(files) {
|
|
|
1613
1761
|
}
|
|
1614
1762
|
}
|
|
1615
1763
|
}
|
|
1616
|
-
return {
|
|
1617
|
-
frameworks: [...frameworks],
|
|
1618
|
-
routes: [...routes.values()].sort((a, b) => a.path.localeCompare(b.path))
|
|
1619
|
-
};
|
|
1764
|
+
return { manifest, declared };
|
|
1620
1765
|
}
|
|
1621
1766
|
function routeForFile(table, filePath) {
|
|
1622
1767
|
const norm = filePath.replace(/^\.\//, "");
|
|
@@ -1870,10 +2015,24 @@ var CHECKABLE_CLAIMS = [
|
|
|
1870
2015
|
{ id: "verified-webhooks", label: "which webhooks are verified", example: "Stripe webhooks are signature verified." },
|
|
1871
2016
|
{ id: "rate-limited", label: "what is rate limited", example: "The public API is rate limited." }
|
|
1872
2017
|
];
|
|
1873
|
-
function
|
|
1874
|
-
const
|
|
2018
|
+
function mergeIntentStatements(parts) {
|
|
2019
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
2020
|
+
const out = [];
|
|
2021
|
+
for (const part of parts) {
|
|
2022
|
+
const own = /* @__PURE__ */ new Set();
|
|
2023
|
+
for (const statement of part) {
|
|
2024
|
+
if (claimed.has(statement.source)) continue;
|
|
2025
|
+
own.add(statement.source);
|
|
2026
|
+
out.push(statement);
|
|
2027
|
+
}
|
|
2028
|
+
for (const source of own) claimed.add(source);
|
|
2029
|
+
}
|
|
2030
|
+
return out;
|
|
2031
|
+
}
|
|
2032
|
+
function checkIntent(files, findings, inputs = {}) {
|
|
2033
|
+
const statements = inputs.statements ?? harvestIntent(files);
|
|
1875
2034
|
const sources = [...new Set(statements.map((s) => s.source))];
|
|
1876
|
-
const routes = extractRoutes(files).routes;
|
|
2035
|
+
const routes = inputs.routes ?? extractRoutes(files).routes;
|
|
1877
2036
|
const mismatches = [];
|
|
1878
2037
|
const unchallenged = [];
|
|
1879
2038
|
const uncheckable = [];
|
|
@@ -11574,9 +11733,24 @@ function getSnippet5(content, line) {
|
|
|
11574
11733
|
return `${prefix} ${String(lineNum).padStart(5)} | ${l}`;
|
|
11575
11734
|
}).join("\n");
|
|
11576
11735
|
}
|
|
11577
|
-
function
|
|
11736
|
+
function collectEnvNames(files, into) {
|
|
11737
|
+
for (const f of files) {
|
|
11738
|
+
if (/\.(ts|js|tsx|jsx)$/i.test(f.path)) {
|
|
11739
|
+
const matches = f.content.matchAll(/process\.env\.([A-Z_][A-Z0-9_]*)/g);
|
|
11740
|
+
for (const m of matches) {
|
|
11741
|
+
into.add(m[1]);
|
|
11742
|
+
}
|
|
11743
|
+
}
|
|
11744
|
+
}
|
|
11745
|
+
}
|
|
11746
|
+
function envVarNamesUsed(files) {
|
|
11747
|
+
const names = /* @__PURE__ */ new Set();
|
|
11748
|
+
collectEnvNames(files.filter((f) => !isSbomPath(f.path)), names);
|
|
11749
|
+
return [...names];
|
|
11750
|
+
}
|
|
11751
|
+
function scanMultiFile(files, opts = {}) {
|
|
11578
11752
|
files = files.filter((f) => !isSbomPath(f.path));
|
|
11579
|
-
const guarded = secretGuardedRoutes(files);
|
|
11753
|
+
const guarded = opts.guardedRoutes ?? secretGuardedRoutes(files);
|
|
11580
11754
|
const findings = [];
|
|
11581
11755
|
const fileMap = /* @__PURE__ */ new Map();
|
|
11582
11756
|
for (const f of files) {
|
|
@@ -11694,15 +11868,8 @@ function scanMultiFile(files) {
|
|
|
11694
11868
|
}
|
|
11695
11869
|
const envExample = files.find((f) => /\.env\.example$|\.env\.sample$|\.env\.template$/.test(f.path));
|
|
11696
11870
|
if (envExample) {
|
|
11697
|
-
const envVarsUsed =
|
|
11698
|
-
|
|
11699
|
-
if (/\.(ts|js|tsx|jsx)$/i.test(f.path)) {
|
|
11700
|
-
const matches = f.content.matchAll(/process\.env\.([A-Z_][A-Z0-9_]*)/g);
|
|
11701
|
-
for (const m of matches) {
|
|
11702
|
-
envVarsUsed.add(m[1]);
|
|
11703
|
-
}
|
|
11704
|
-
}
|
|
11705
|
-
}
|
|
11871
|
+
const envVarsUsed = new Set(opts.priorEnvNames ?? []);
|
|
11872
|
+
collectEnvNames(files, envVarsUsed);
|
|
11706
11873
|
const envVarsDocumented = /* @__PURE__ */ new Set();
|
|
11707
11874
|
const exampleMatches = envExample.content.matchAll(/^([A-Z_][A-Z0-9_]*)=/gm);
|
|
11708
11875
|
for (const m of exampleMatches) {
|
|
@@ -15505,6 +15672,7 @@ export {
|
|
|
15505
15672
|
classifyPublicEnvVar,
|
|
15506
15673
|
classifyStatement,
|
|
15507
15674
|
clientSideAuth,
|
|
15675
|
+
collectRouteClaims,
|
|
15508
15676
|
complianceMap,
|
|
15509
15677
|
consoleLogProduction,
|
|
15510
15678
|
corsWildcard,
|
|
@@ -15520,6 +15688,7 @@ export {
|
|
|
15520
15688
|
emptyCatchBlock,
|
|
15521
15689
|
enclosingHandler,
|
|
15522
15690
|
envNotGitignored,
|
|
15691
|
+
envVarNamesUsed,
|
|
15523
15692
|
evalUsage,
|
|
15524
15693
|
exposedAuthSecret,
|
|
15525
15694
|
exposedDebugMode,
|
|
@@ -15576,6 +15745,8 @@ export {
|
|
|
15576
15745
|
maskSecretValue,
|
|
15577
15746
|
maskStringLiterals,
|
|
15578
15747
|
matchIgnore,
|
|
15748
|
+
mergeIntentStatements,
|
|
15749
|
+
mergeRouteClaims,
|
|
15579
15750
|
missingAuthMiddleware,
|
|
15580
15751
|
missingCSP,
|
|
15581
15752
|
missingErrorBoundary,
|
|
@@ -15604,6 +15775,8 @@ export {
|
|
|
15604
15775
|
refineDirectObjectFindings,
|
|
15605
15776
|
replaceBlockComments,
|
|
15606
15777
|
resetStructuralState,
|
|
15778
|
+
resolveSecretGuardedRoutes,
|
|
15779
|
+
routeDelegationFacts,
|
|
15607
15780
|
routeForFile,
|
|
15608
15781
|
routePathFromFile,
|
|
15609
15782
|
runCustomRules,
|