xploitscan-shared-rules 1.18.0 → 1.21.0
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 +278 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -14
- package/dist/index.d.ts +102 -14
- package/dist/index.js +274 -12
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -34,6 +34,26 @@ interface Finding {
|
|
|
34
34
|
* itself by arriving with the flag already set.
|
|
35
35
|
*/
|
|
36
36
|
vendored?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The URL that reaches this finding's file, when one does.
|
|
39
|
+
*
|
|
40
|
+
* Severity is not a property of a line of code, it is a property of who can
|
|
41
|
+
* reach it: a hardcoded secret in `app/api/webhooks/stripe/route.ts` is
|
|
42
|
+
* reachable by anyone who can send a POST, while the same secret in a build
|
|
43
|
+
* script is not reachable at all.
|
|
44
|
+
*
|
|
45
|
+
* Advisory label for renderers, on the same terms as `vendored` above —
|
|
46
|
+
* `calculateGrade` never reads it, so a finding cannot raise or lower its own
|
|
47
|
+
* score by arriving with this set. It is populated from the file's declared
|
|
48
|
+
* route only; a helper imported BY a handler is reachable too, but proving
|
|
49
|
+
* that needs an import graph, and guessing would attach a confident wrong URL
|
|
50
|
+
* to a real finding.
|
|
51
|
+
*/
|
|
52
|
+
route?: {
|
|
53
|
+
path: string;
|
|
54
|
+
kind: "page" | "api";
|
|
55
|
+
framework: string;
|
|
56
|
+
};
|
|
37
57
|
}
|
|
38
58
|
interface RuleMatch {
|
|
39
59
|
rule: string;
|
|
@@ -324,17 +344,6 @@ declare function detectFramework(files: {
|
|
|
324
344
|
content: string;
|
|
325
345
|
}[]): DetectedFramework[];
|
|
326
346
|
type VibePlatform = "lovable" | "bolt" | "replit" | "cursor" | "v0" | "claude-code";
|
|
327
|
-
/**
|
|
328
|
-
* Detect the AI coding platform / scaffold behind a project from tell-tale
|
|
329
|
-
* files, dependencies, and generated-comment headers.
|
|
330
|
-
*
|
|
331
|
-
* Deliberately high-precision: signals are mostly exact config-file paths
|
|
332
|
-
* (`.replit`, `.cursorrules`, `.bolt/`) plus a couple of unambiguous content
|
|
333
|
-
* markers (`lovable-tagger`, `bolt.new`, `v0.dev`). A plain framework project
|
|
334
|
-
* with none of these returns `[]` — we never guess a platform, because a wrong
|
|
335
|
-
* "Detected: X" label reads worse than none. Returns every platform detected
|
|
336
|
-
* (a Lovable app opened in Cursor legitimately reports both).
|
|
337
|
-
*/
|
|
338
347
|
declare function detectPlatform(files: {
|
|
339
348
|
path: string;
|
|
340
349
|
content: string;
|
|
@@ -486,6 +495,8 @@ declare const graphqlCSRFDisabled: CustomRule;
|
|
|
486
495
|
declare const llmOutputToSink: CustomRule;
|
|
487
496
|
declare const secretInLLMPrompt: CustomRule;
|
|
488
497
|
declare const webhookMissingIdempotency: CustomRule;
|
|
498
|
+
declare const entitlementFromWebStorage: CustomRule;
|
|
499
|
+
declare const accountStateFromWebStorage: CustomRule;
|
|
489
500
|
declare const middlewareMatcherExcludesApi: CustomRule;
|
|
490
501
|
declare const hardcodedCreditCard: CustomRule;
|
|
491
502
|
declare const hardcodedSSN: CustomRule;
|
|
@@ -533,9 +544,9 @@ declare function runCustomRules(content: string, filePath: string, disabledRules
|
|
|
533
544
|
/** Rules any caller gets, including anonymous and free-tier CLI users. */
|
|
534
545
|
declare const FREE_RULE_COUNT = 30;
|
|
535
546
|
/** Rules gated behind a paid plan and served from the API, never bundled. */
|
|
536
|
-
declare const PRO_RULE_COUNT =
|
|
547
|
+
declare const PRO_RULE_COUNT = 184;
|
|
537
548
|
/** The full catalog. FREE_RULE_COUNT + PRO_RULE_COUNT, asserted in the test. */
|
|
538
|
-
declare const TOTAL_RULE_COUNT =
|
|
549
|
+
declare const TOTAL_RULE_COUNT = 214;
|
|
539
550
|
|
|
540
551
|
interface FilteredFinding {
|
|
541
552
|
finding: Finding;
|
|
@@ -608,6 +619,83 @@ declare function scanEntropy(files: {
|
|
|
608
619
|
content: string;
|
|
609
620
|
}[]): Finding[];
|
|
610
621
|
|
|
622
|
+
/**
|
|
623
|
+
* Route-table extraction — what URL, if any, reaches a given source file.
|
|
624
|
+
*
|
|
625
|
+
* WHY A SCANNER WANTS THIS. Severity is not a property of a line of code, it is
|
|
626
|
+
* a property of who can reach it. A hardcoded secret in
|
|
627
|
+
* `src/app/api/webhooks/stripe/route.ts` is reachable by anyone who can send a
|
|
628
|
+
* POST; the same secret in a build script is not reachable at all. Nothing in
|
|
629
|
+
* the finding itself carries that distinction, and a scanner that only reads
|
|
630
|
+
* files cannot invent it.
|
|
631
|
+
*
|
|
632
|
+
* Attaching a route to a finding turns "hardcoded secret in a file you have to
|
|
633
|
+
* go look up" into "hardcoded secret reachable at POST /api/webhooks/stripe".
|
|
634
|
+
*
|
|
635
|
+
* EVERY GATE BELOW EXISTS BECAUSE IT FIRED. Measured against real repositories:
|
|
636
|
+
*
|
|
637
|
+
* - `src/pages/*.tsx` is NOT Next routing in a Vite app. Lovable, Bolt and
|
|
638
|
+
* Base44 ship a plain `src/pages/` component folder; matching it invented
|
|
639
|
+
* 38 phantom routes in one repo, with case-duplicate pairs (/about AND
|
|
640
|
+
* /About) and entries like /Index and /NotFound that do not exist.
|
|
641
|
+
* - A config file is not a dependency. That same repo carries a stray unused
|
|
642
|
+
* `next.config.js` with no `next` in package.json; trusting the file
|
|
643
|
+
* re-invented all 38.
|
|
644
|
+
* - `app.get("/download", ...)` inside THIS repo's own rule-override examples
|
|
645
|
+
* produced phantom Express routes in a package with no express dependency.
|
|
646
|
+
* A scanner scanning a scanner finds "routes" in its documentation samples.
|
|
647
|
+
* - The homepage went missing from every Next project using `src/`: the
|
|
648
|
+
* pattern required `app/<seg>/page.tsx` or a TOP-LEVEL `app/page.tsx`, so
|
|
649
|
+
* nested `src/app/page.tsx` matched neither and "/" — the single most
|
|
650
|
+
* important route in any app — was silently absent.
|
|
651
|
+
*
|
|
652
|
+
* A phantom route is worse than a missing one: it attaches a confident, wrong
|
|
653
|
+
* URL to a real finding. Hence every framework's conventions are gated on that
|
|
654
|
+
* framework actually being a declared dependency.
|
|
655
|
+
*
|
|
656
|
+
* Accuracy at the time of writing, against hand-counted ground truth:
|
|
657
|
+
* Next App Router (this repo's web package) 135/135, "/" included
|
|
658
|
+
* React Router (a Lovable app) 40/40, 0 missed, 0 extra
|
|
659
|
+
* TanStack Start (a Lovable app) 6/6
|
|
660
|
+
* Flask (a Python dashboard) 53/53
|
|
661
|
+
*/
|
|
662
|
+
type RouteFramework = "next-app" | "next-pages" | "react-router" | "tanstack-router" | "flask-fastapi" | "express";
|
|
663
|
+
interface AppRoute {
|
|
664
|
+
/** URL path, e.g. "/api/webhooks/stripe". */
|
|
665
|
+
path: string;
|
|
666
|
+
/** `api` is a data endpoint; `page` renders a document. */
|
|
667
|
+
kind: "page" | "api";
|
|
668
|
+
/** Contains a parameter segment, so it cannot be fetched without a value. */
|
|
669
|
+
dynamic: boolean;
|
|
670
|
+
framework: RouteFramework;
|
|
671
|
+
/** Repo-relative file that declares it. */
|
|
672
|
+
source: string;
|
|
673
|
+
}
|
|
674
|
+
interface RouteTable {
|
|
675
|
+
frameworks: RouteFramework[];
|
|
676
|
+
routes: AppRoute[];
|
|
677
|
+
}
|
|
678
|
+
interface SourceFile {
|
|
679
|
+
path: string;
|
|
680
|
+
content: string;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Extract every route the given files declare.
|
|
684
|
+
*
|
|
685
|
+
* Pure: takes file contents, touches no filesystem, so it runs identically in
|
|
686
|
+
* the CLI, the API and a test.
|
|
687
|
+
*/
|
|
688
|
+
declare function extractRoutes(files: SourceFile[]): RouteTable;
|
|
689
|
+
/**
|
|
690
|
+
* The route a given file is reachable at, if any.
|
|
691
|
+
*
|
|
692
|
+
* Matches on the declaring file only. A helper imported BY a route handler is
|
|
693
|
+
* reachable too, but proving that needs an import graph — claiming it from a
|
|
694
|
+
* filename match would attach confident, wrong URLs to real findings, which is
|
|
695
|
+
* the failure mode every gate above exists to prevent.
|
|
696
|
+
*/
|
|
697
|
+
declare function routeForFile(table: RouteTable, filePath: string): AppRoute | undefined;
|
|
698
|
+
|
|
611
699
|
/**
|
|
612
700
|
* URL recon — what can be learned about a deployed app from what it already
|
|
613
701
|
* serves the public.
|
|
@@ -837,4 +925,4 @@ declare function getObjectProperty(node: ObjectExpression, key: string): {
|
|
|
837
925
|
/** Does this CallExpression spread an expression `matcher` returns true for? */
|
|
838
926
|
declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
|
|
839
927
|
|
|
840
|
-
export { type AIFilterResult, type BuilderFingerprint, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allCustomRules, allRules, androidDebuggable, assessHeaders, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, djangoDebug, dockerCopySensitive, dockerLatestTag, dockerRunAsRoot, dockerTooManyPorts, dockerfileADDInsteadOfCOPY, dockerfileMissingHealthcheck, dockerfileUnverifiedShellPipe, ecbModeEncryption, electronNavigationUnrestricted, emptyCatchBlock, envNotGitignored, evalUsage, eventListenerLeak, exposedAdminRoutes, exposedAuthSecret, exposedDBCredentials, exposedDatabaseStudio, exposedDebugMode, exposedDockerPorts, exposedEnvFile, exposedGitDir, exposedServerActions, exposedSourceMaps, exposedStackTraces, extractScriptUrls, filterFalsePositives, findSourceMapRefs, firebaseClientConfig, flaskSecretKey, freeRules, getObjectProperty, getSnippet, ghaExpressionInjection, ghaPermissionsWriteAll, ghaPullRequestTargetCheckout, ghaThirdPartyActionWithSecrets, githubActionsInjection, graphqlCSRFDisabled, graphqlIntrospection, graphqlNoComplexityLimit, graphqlNoDepthLimit, hardcodedAlgoliaAdminKey, hardcodedAnthropicKey, hardcodedCloudflareToken, hardcodedCohereKey, hardcodedCreditCard, hardcodedDatadogKey, hardcodedDiscordToken, hardcodedEncryptionKey, hardcodedFastlyToken, hardcodedFireworksKey, hardcodedFlyToken, hardcodedGCPServiceAccount, hardcodedGitHubPAT, hardcodedGitLabToken, hardcodedGroqKey, hardcodedHighlightKey, hardcodedIPAllowlist, hardcodedIntercomToken, hardcodedJWTSecret, hardcodedLinearKey, hardcodedLogtailToken, hardcodedLoopsKey, hardcodedMailgunKey, hardcodedMistralKey, hardcodedNetlifyToken, hardcodedNotionKey, hardcodedOAuthSecret, hardcodedPineconeKey, hardcodedPlivoToken, hardcodedPostmarkKey, hardcodedQdrantKey, hardcodedRailwayToken, hardcodedReplicateKey, hardcodedResendKey, hardcodedSSN, hardcodedSecrets, hardcodedSendGridKey, hardcodedSentryAuthToken, hardcodedShopifyToken, hardcodedSlackToken, hardcodedSupabaseServiceRole, hardcodedTogetherKey, hardcodedTwilioKey, hardcodedVaultToken, hardcodedVercelToken, hardcodedWeaviateKey, hostHeaderRedirect, httpRequestSmuggling, insecureCookies, insecureDeepLink, insecureDeserialization, insecureDirectObjectReference, insecureElectronWindow, insecureFileUpload, insecureGRPC, insecureHTTPMethods, insecurePasswordReset, insecureRandomness, insecureWebSocket, ipcPathTraversal, isCalleeNamed, isMethodCall, isPrivateAddress, isVendoredFinding, isVendoredPath, javaDeserialization, jwtAlgConfusion, k8sNoResourceLimits, k8sPrivileged, k8sSecretNotEncrypted, lambdaWithoutVPC, largeBundleImport, llmCallNoMaxTokens, llmOutputAsHTML, llmOutputToSink, llmPromptInjection, llmSystemPromptInjection, logInjection, magicNumbers, massAssignment, middlewareMatcherExcludesApi, missingAIRateLimit, missingAuthMiddleware, missingAuthRateLimit, missingBruteForce, missingCSP, missingCSRF, missingCertPinning, missingCloudTrail, missingContentDisposition, missingDBEncryption, missingErrorBoundary, missingFileSizeLimits, missingHSTS, missingHTTPS, missingLockFile, missingOAuthState, missingPagination, missingRequestSizeLimit, missingRequestValidation, missingSRI, missingSecurityMeta, nPlusOneQuery, nextPublicSecret, noRateLimiting, normalizeScanPath, nosqlInjection, openRedirectParams, overlyPermissiveIAM, parseFile, parseScanTarget, pathTraversal, pickleDeserialization, piiInLogs, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, runCustomRules, s3BucketNoEncryption, scanEntropy, secretInBundleConfig, secretInCLIArgument, secretInErrorResponse, secretInHTMLAttribute, secretInLLMPrompt, secretInURLParam, secretLoggedToConsole, secretsInCI, securityGroupAllInbound, sensitiveAsyncStorage, sensitiveLocalStorage, sensitiveURLParams, sessionFixation, sqlInjection, ssrfVulnerability, ssti, stripeWebhookUnprotected, supabaseAnonAdmin, supabaseNoRLS, syncFileOps, terraformStateExposed, timingAttack, todoLeftInCode, unencryptedPII, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, vendoredReason, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
|
|
928
|
+
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, type ParsedFile, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, accountStateFromWebStorage, allCustomRules, allRules, androidDebuggable, assessHeaders, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, djangoDebug, dockerCopySensitive, dockerLatestTag, dockerRunAsRoot, dockerTooManyPorts, dockerfileADDInsteadOfCOPY, dockerfileMissingHealthcheck, dockerfileUnverifiedShellPipe, ecbModeEncryption, electronNavigationUnrestricted, emptyCatchBlock, entitlementFromWebStorage, envNotGitignored, evalUsage, eventListenerLeak, exposedAdminRoutes, exposedAuthSecret, exposedDBCredentials, exposedDatabaseStudio, exposedDebugMode, exposedDockerPorts, exposedEnvFile, exposedGitDir, exposedServerActions, exposedSourceMaps, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, findSourceMapRefs, firebaseClientConfig, flaskSecretKey, freeRules, getObjectProperty, getSnippet, ghaExpressionInjection, ghaPermissionsWriteAll, ghaPullRequestTargetCheckout, ghaThirdPartyActionWithSecrets, githubActionsInjection, graphqlCSRFDisabled, graphqlIntrospection, graphqlNoComplexityLimit, graphqlNoDepthLimit, hardcodedAlgoliaAdminKey, hardcodedAnthropicKey, hardcodedCloudflareToken, hardcodedCohereKey, hardcodedCreditCard, hardcodedDatadogKey, hardcodedDiscordToken, hardcodedEncryptionKey, hardcodedFastlyToken, hardcodedFireworksKey, hardcodedFlyToken, hardcodedGCPServiceAccount, hardcodedGitHubPAT, hardcodedGitLabToken, hardcodedGroqKey, hardcodedHighlightKey, hardcodedIPAllowlist, hardcodedIntercomToken, hardcodedJWTSecret, hardcodedLinearKey, hardcodedLogtailToken, hardcodedLoopsKey, hardcodedMailgunKey, hardcodedMistralKey, hardcodedNetlifyToken, hardcodedNotionKey, hardcodedOAuthSecret, hardcodedPineconeKey, hardcodedPlivoToken, hardcodedPostmarkKey, hardcodedQdrantKey, hardcodedRailwayToken, hardcodedReplicateKey, hardcodedResendKey, hardcodedSSN, hardcodedSecrets, hardcodedSendGridKey, hardcodedSentryAuthToken, hardcodedShopifyToken, hardcodedSlackToken, hardcodedSupabaseServiceRole, hardcodedTogetherKey, hardcodedTwilioKey, hardcodedVaultToken, hardcodedVercelToken, hardcodedWeaviateKey, hostHeaderRedirect, httpRequestSmuggling, insecureCookies, insecureDeepLink, insecureDeserialization, insecureDirectObjectReference, insecureElectronWindow, insecureFileUpload, insecureGRPC, insecureHTTPMethods, insecurePasswordReset, insecureRandomness, insecureWebSocket, ipcPathTraversal, isCalleeNamed, isMethodCall, isPrivateAddress, isVendoredFinding, isVendoredPath, javaDeserialization, jwtAlgConfusion, k8sNoResourceLimits, k8sPrivileged, k8sSecretNotEncrypted, lambdaWithoutVPC, largeBundleImport, llmCallNoMaxTokens, llmOutputAsHTML, llmOutputToSink, llmPromptInjection, llmSystemPromptInjection, logInjection, magicNumbers, massAssignment, middlewareMatcherExcludesApi, missingAIRateLimit, missingAuthMiddleware, missingAuthRateLimit, missingBruteForce, missingCSP, missingCSRF, missingCertPinning, missingCloudTrail, missingContentDisposition, missingDBEncryption, missingErrorBoundary, missingFileSizeLimits, missingHSTS, missingHTTPS, missingLockFile, missingOAuthState, missingPagination, missingRequestSizeLimit, missingRequestValidation, missingSRI, missingSecurityMeta, nPlusOneQuery, nextPublicSecret, noRateLimiting, normalizeScanPath, nosqlInjection, openRedirectParams, overlyPermissiveIAM, parseFile, parseScanTarget, pathTraversal, pickleDeserialization, piiInLogs, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, routeForFile, runCustomRules, s3BucketNoEncryption, scanEntropy, secretInBundleConfig, secretInCLIArgument, secretInErrorResponse, secretInHTMLAttribute, secretInLLMPrompt, secretInURLParam, secretLoggedToConsole, secretsInCI, securityGroupAllInbound, sensitiveAsyncStorage, sensitiveLocalStorage, sensitiveURLParams, sessionFixation, sqlInjection, ssrfVulnerability, ssti, stripeWebhookUnprotected, supabaseAnonAdmin, supabaseNoRLS, syncFileOps, terraformStateExposed, timingAttack, todoLeftInCode, unencryptedPII, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, vendoredReason, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,26 @@ interface Finding {
|
|
|
34
34
|
* itself by arriving with the flag already set.
|
|
35
35
|
*/
|
|
36
36
|
vendored?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The URL that reaches this finding's file, when one does.
|
|
39
|
+
*
|
|
40
|
+
* Severity is not a property of a line of code, it is a property of who can
|
|
41
|
+
* reach it: a hardcoded secret in `app/api/webhooks/stripe/route.ts` is
|
|
42
|
+
* reachable by anyone who can send a POST, while the same secret in a build
|
|
43
|
+
* script is not reachable at all.
|
|
44
|
+
*
|
|
45
|
+
* Advisory label for renderers, on the same terms as `vendored` above —
|
|
46
|
+
* `calculateGrade` never reads it, so a finding cannot raise or lower its own
|
|
47
|
+
* score by arriving with this set. It is populated from the file's declared
|
|
48
|
+
* route only; a helper imported BY a handler is reachable too, but proving
|
|
49
|
+
* that needs an import graph, and guessing would attach a confident wrong URL
|
|
50
|
+
* to a real finding.
|
|
51
|
+
*/
|
|
52
|
+
route?: {
|
|
53
|
+
path: string;
|
|
54
|
+
kind: "page" | "api";
|
|
55
|
+
framework: string;
|
|
56
|
+
};
|
|
37
57
|
}
|
|
38
58
|
interface RuleMatch {
|
|
39
59
|
rule: string;
|
|
@@ -324,17 +344,6 @@ declare function detectFramework(files: {
|
|
|
324
344
|
content: string;
|
|
325
345
|
}[]): DetectedFramework[];
|
|
326
346
|
type VibePlatform = "lovable" | "bolt" | "replit" | "cursor" | "v0" | "claude-code";
|
|
327
|
-
/**
|
|
328
|
-
* Detect the AI coding platform / scaffold behind a project from tell-tale
|
|
329
|
-
* files, dependencies, and generated-comment headers.
|
|
330
|
-
*
|
|
331
|
-
* Deliberately high-precision: signals are mostly exact config-file paths
|
|
332
|
-
* (`.replit`, `.cursorrules`, `.bolt/`) plus a couple of unambiguous content
|
|
333
|
-
* markers (`lovable-tagger`, `bolt.new`, `v0.dev`). A plain framework project
|
|
334
|
-
* with none of these returns `[]` — we never guess a platform, because a wrong
|
|
335
|
-
* "Detected: X" label reads worse than none. Returns every platform detected
|
|
336
|
-
* (a Lovable app opened in Cursor legitimately reports both).
|
|
337
|
-
*/
|
|
338
347
|
declare function detectPlatform(files: {
|
|
339
348
|
path: string;
|
|
340
349
|
content: string;
|
|
@@ -486,6 +495,8 @@ declare const graphqlCSRFDisabled: CustomRule;
|
|
|
486
495
|
declare const llmOutputToSink: CustomRule;
|
|
487
496
|
declare const secretInLLMPrompt: CustomRule;
|
|
488
497
|
declare const webhookMissingIdempotency: CustomRule;
|
|
498
|
+
declare const entitlementFromWebStorage: CustomRule;
|
|
499
|
+
declare const accountStateFromWebStorage: CustomRule;
|
|
489
500
|
declare const middlewareMatcherExcludesApi: CustomRule;
|
|
490
501
|
declare const hardcodedCreditCard: CustomRule;
|
|
491
502
|
declare const hardcodedSSN: CustomRule;
|
|
@@ -533,9 +544,9 @@ declare function runCustomRules(content: string, filePath: string, disabledRules
|
|
|
533
544
|
/** Rules any caller gets, including anonymous and free-tier CLI users. */
|
|
534
545
|
declare const FREE_RULE_COUNT = 30;
|
|
535
546
|
/** Rules gated behind a paid plan and served from the API, never bundled. */
|
|
536
|
-
declare const PRO_RULE_COUNT =
|
|
547
|
+
declare const PRO_RULE_COUNT = 184;
|
|
537
548
|
/** The full catalog. FREE_RULE_COUNT + PRO_RULE_COUNT, asserted in the test. */
|
|
538
|
-
declare const TOTAL_RULE_COUNT =
|
|
549
|
+
declare const TOTAL_RULE_COUNT = 214;
|
|
539
550
|
|
|
540
551
|
interface FilteredFinding {
|
|
541
552
|
finding: Finding;
|
|
@@ -608,6 +619,83 @@ declare function scanEntropy(files: {
|
|
|
608
619
|
content: string;
|
|
609
620
|
}[]): Finding[];
|
|
610
621
|
|
|
622
|
+
/**
|
|
623
|
+
* Route-table extraction — what URL, if any, reaches a given source file.
|
|
624
|
+
*
|
|
625
|
+
* WHY A SCANNER WANTS THIS. Severity is not a property of a line of code, it is
|
|
626
|
+
* a property of who can reach it. A hardcoded secret in
|
|
627
|
+
* `src/app/api/webhooks/stripe/route.ts` is reachable by anyone who can send a
|
|
628
|
+
* POST; the same secret in a build script is not reachable at all. Nothing in
|
|
629
|
+
* the finding itself carries that distinction, and a scanner that only reads
|
|
630
|
+
* files cannot invent it.
|
|
631
|
+
*
|
|
632
|
+
* Attaching a route to a finding turns "hardcoded secret in a file you have to
|
|
633
|
+
* go look up" into "hardcoded secret reachable at POST /api/webhooks/stripe".
|
|
634
|
+
*
|
|
635
|
+
* EVERY GATE BELOW EXISTS BECAUSE IT FIRED. Measured against real repositories:
|
|
636
|
+
*
|
|
637
|
+
* - `src/pages/*.tsx` is NOT Next routing in a Vite app. Lovable, Bolt and
|
|
638
|
+
* Base44 ship a plain `src/pages/` component folder; matching it invented
|
|
639
|
+
* 38 phantom routes in one repo, with case-duplicate pairs (/about AND
|
|
640
|
+
* /About) and entries like /Index and /NotFound that do not exist.
|
|
641
|
+
* - A config file is not a dependency. That same repo carries a stray unused
|
|
642
|
+
* `next.config.js` with no `next` in package.json; trusting the file
|
|
643
|
+
* re-invented all 38.
|
|
644
|
+
* - `app.get("/download", ...)` inside THIS repo's own rule-override examples
|
|
645
|
+
* produced phantom Express routes in a package with no express dependency.
|
|
646
|
+
* A scanner scanning a scanner finds "routes" in its documentation samples.
|
|
647
|
+
* - The homepage went missing from every Next project using `src/`: the
|
|
648
|
+
* pattern required `app/<seg>/page.tsx` or a TOP-LEVEL `app/page.tsx`, so
|
|
649
|
+
* nested `src/app/page.tsx` matched neither and "/" — the single most
|
|
650
|
+
* important route in any app — was silently absent.
|
|
651
|
+
*
|
|
652
|
+
* A phantom route is worse than a missing one: it attaches a confident, wrong
|
|
653
|
+
* URL to a real finding. Hence every framework's conventions are gated on that
|
|
654
|
+
* framework actually being a declared dependency.
|
|
655
|
+
*
|
|
656
|
+
* Accuracy at the time of writing, against hand-counted ground truth:
|
|
657
|
+
* Next App Router (this repo's web package) 135/135, "/" included
|
|
658
|
+
* React Router (a Lovable app) 40/40, 0 missed, 0 extra
|
|
659
|
+
* TanStack Start (a Lovable app) 6/6
|
|
660
|
+
* Flask (a Python dashboard) 53/53
|
|
661
|
+
*/
|
|
662
|
+
type RouteFramework = "next-app" | "next-pages" | "react-router" | "tanstack-router" | "flask-fastapi" | "express";
|
|
663
|
+
interface AppRoute {
|
|
664
|
+
/** URL path, e.g. "/api/webhooks/stripe". */
|
|
665
|
+
path: string;
|
|
666
|
+
/** `api` is a data endpoint; `page` renders a document. */
|
|
667
|
+
kind: "page" | "api";
|
|
668
|
+
/** Contains a parameter segment, so it cannot be fetched without a value. */
|
|
669
|
+
dynamic: boolean;
|
|
670
|
+
framework: RouteFramework;
|
|
671
|
+
/** Repo-relative file that declares it. */
|
|
672
|
+
source: string;
|
|
673
|
+
}
|
|
674
|
+
interface RouteTable {
|
|
675
|
+
frameworks: RouteFramework[];
|
|
676
|
+
routes: AppRoute[];
|
|
677
|
+
}
|
|
678
|
+
interface SourceFile {
|
|
679
|
+
path: string;
|
|
680
|
+
content: string;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Extract every route the given files declare.
|
|
684
|
+
*
|
|
685
|
+
* Pure: takes file contents, touches no filesystem, so it runs identically in
|
|
686
|
+
* the CLI, the API and a test.
|
|
687
|
+
*/
|
|
688
|
+
declare function extractRoutes(files: SourceFile[]): RouteTable;
|
|
689
|
+
/**
|
|
690
|
+
* The route a given file is reachable at, if any.
|
|
691
|
+
*
|
|
692
|
+
* Matches on the declaring file only. A helper imported BY a route handler is
|
|
693
|
+
* reachable too, but proving that needs an import graph — claiming it from a
|
|
694
|
+
* filename match would attach confident, wrong URLs to real findings, which is
|
|
695
|
+
* the failure mode every gate above exists to prevent.
|
|
696
|
+
*/
|
|
697
|
+
declare function routeForFile(table: RouteTable, filePath: string): AppRoute | undefined;
|
|
698
|
+
|
|
611
699
|
/**
|
|
612
700
|
* URL recon — what can be learned about a deployed app from what it already
|
|
613
701
|
* serves the public.
|
|
@@ -837,4 +925,4 @@ declare function getObjectProperty(node: ObjectExpression, key: string): {
|
|
|
837
925
|
/** Does this CallExpression spread an expression `matcher` returns true for? */
|
|
838
926
|
declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
|
|
839
927
|
|
|
840
|
-
export { type AIFilterResult, type BuilderFingerprint, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, allCustomRules, allRules, androidDebuggable, assessHeaders, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, djangoDebug, dockerCopySensitive, dockerLatestTag, dockerRunAsRoot, dockerTooManyPorts, dockerfileADDInsteadOfCOPY, dockerfileMissingHealthcheck, dockerfileUnverifiedShellPipe, ecbModeEncryption, electronNavigationUnrestricted, emptyCatchBlock, envNotGitignored, evalUsage, eventListenerLeak, exposedAdminRoutes, exposedAuthSecret, exposedDBCredentials, exposedDatabaseStudio, exposedDebugMode, exposedDockerPorts, exposedEnvFile, exposedGitDir, exposedServerActions, exposedSourceMaps, exposedStackTraces, extractScriptUrls, filterFalsePositives, findSourceMapRefs, firebaseClientConfig, flaskSecretKey, freeRules, getObjectProperty, getSnippet, ghaExpressionInjection, ghaPermissionsWriteAll, ghaPullRequestTargetCheckout, ghaThirdPartyActionWithSecrets, githubActionsInjection, graphqlCSRFDisabled, graphqlIntrospection, graphqlNoComplexityLimit, graphqlNoDepthLimit, hardcodedAlgoliaAdminKey, hardcodedAnthropicKey, hardcodedCloudflareToken, hardcodedCohereKey, hardcodedCreditCard, hardcodedDatadogKey, hardcodedDiscordToken, hardcodedEncryptionKey, hardcodedFastlyToken, hardcodedFireworksKey, hardcodedFlyToken, hardcodedGCPServiceAccount, hardcodedGitHubPAT, hardcodedGitLabToken, hardcodedGroqKey, hardcodedHighlightKey, hardcodedIPAllowlist, hardcodedIntercomToken, hardcodedJWTSecret, hardcodedLinearKey, hardcodedLogtailToken, hardcodedLoopsKey, hardcodedMailgunKey, hardcodedMistralKey, hardcodedNetlifyToken, hardcodedNotionKey, hardcodedOAuthSecret, hardcodedPineconeKey, hardcodedPlivoToken, hardcodedPostmarkKey, hardcodedQdrantKey, hardcodedRailwayToken, hardcodedReplicateKey, hardcodedResendKey, hardcodedSSN, hardcodedSecrets, hardcodedSendGridKey, hardcodedSentryAuthToken, hardcodedShopifyToken, hardcodedSlackToken, hardcodedSupabaseServiceRole, hardcodedTogetherKey, hardcodedTwilioKey, hardcodedVaultToken, hardcodedVercelToken, hardcodedWeaviateKey, hostHeaderRedirect, httpRequestSmuggling, insecureCookies, insecureDeepLink, insecureDeserialization, insecureDirectObjectReference, insecureElectronWindow, insecureFileUpload, insecureGRPC, insecureHTTPMethods, insecurePasswordReset, insecureRandomness, insecureWebSocket, ipcPathTraversal, isCalleeNamed, isMethodCall, isPrivateAddress, isVendoredFinding, isVendoredPath, javaDeserialization, jwtAlgConfusion, k8sNoResourceLimits, k8sPrivileged, k8sSecretNotEncrypted, lambdaWithoutVPC, largeBundleImport, llmCallNoMaxTokens, llmOutputAsHTML, llmOutputToSink, llmPromptInjection, llmSystemPromptInjection, logInjection, magicNumbers, massAssignment, middlewareMatcherExcludesApi, missingAIRateLimit, missingAuthMiddleware, missingAuthRateLimit, missingBruteForce, missingCSP, missingCSRF, missingCertPinning, missingCloudTrail, missingContentDisposition, missingDBEncryption, missingErrorBoundary, missingFileSizeLimits, missingHSTS, missingHTTPS, missingLockFile, missingOAuthState, missingPagination, missingRequestSizeLimit, missingRequestValidation, missingSRI, missingSecurityMeta, nPlusOneQuery, nextPublicSecret, noRateLimiting, normalizeScanPath, nosqlInjection, openRedirectParams, overlyPermissiveIAM, parseFile, parseScanTarget, pathTraversal, pickleDeserialization, piiInLogs, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, runCustomRules, s3BucketNoEncryption, scanEntropy, secretInBundleConfig, secretInCLIArgument, secretInErrorResponse, secretInHTMLAttribute, secretInLLMPrompt, secretInURLParam, secretLoggedToConsole, secretsInCI, securityGroupAllInbound, sensitiveAsyncStorage, sensitiveLocalStorage, sensitiveURLParams, sessionFixation, sqlInjection, ssrfVulnerability, ssti, stripeWebhookUnprotected, supabaseAnonAdmin, supabaseNoRLS, syncFileOps, terraformStateExposed, timingAttack, todoLeftInCode, unencryptedPII, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, vendoredReason, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
|
|
928
|
+
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, type ParsedFile, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, accountStateFromWebStorage, allCustomRules, allRules, androidDebuggable, assessHeaders, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, djangoDebug, dockerCopySensitive, dockerLatestTag, dockerRunAsRoot, dockerTooManyPorts, dockerfileADDInsteadOfCOPY, dockerfileMissingHealthcheck, dockerfileUnverifiedShellPipe, ecbModeEncryption, electronNavigationUnrestricted, emptyCatchBlock, entitlementFromWebStorage, envNotGitignored, evalUsage, eventListenerLeak, exposedAdminRoutes, exposedAuthSecret, exposedDBCredentials, exposedDatabaseStudio, exposedDebugMode, exposedDockerPorts, exposedEnvFile, exposedGitDir, exposedServerActions, exposedSourceMaps, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, findSourceMapRefs, firebaseClientConfig, flaskSecretKey, freeRules, getObjectProperty, getSnippet, ghaExpressionInjection, ghaPermissionsWriteAll, ghaPullRequestTargetCheckout, ghaThirdPartyActionWithSecrets, githubActionsInjection, graphqlCSRFDisabled, graphqlIntrospection, graphqlNoComplexityLimit, graphqlNoDepthLimit, hardcodedAlgoliaAdminKey, hardcodedAnthropicKey, hardcodedCloudflareToken, hardcodedCohereKey, hardcodedCreditCard, hardcodedDatadogKey, hardcodedDiscordToken, hardcodedEncryptionKey, hardcodedFastlyToken, hardcodedFireworksKey, hardcodedFlyToken, hardcodedGCPServiceAccount, hardcodedGitHubPAT, hardcodedGitLabToken, hardcodedGroqKey, hardcodedHighlightKey, hardcodedIPAllowlist, hardcodedIntercomToken, hardcodedJWTSecret, hardcodedLinearKey, hardcodedLogtailToken, hardcodedLoopsKey, hardcodedMailgunKey, hardcodedMistralKey, hardcodedNetlifyToken, hardcodedNotionKey, hardcodedOAuthSecret, hardcodedPineconeKey, hardcodedPlivoToken, hardcodedPostmarkKey, hardcodedQdrantKey, hardcodedRailwayToken, hardcodedReplicateKey, hardcodedResendKey, hardcodedSSN, hardcodedSecrets, hardcodedSendGridKey, hardcodedSentryAuthToken, hardcodedShopifyToken, hardcodedSlackToken, hardcodedSupabaseServiceRole, hardcodedTogetherKey, hardcodedTwilioKey, hardcodedVaultToken, hardcodedVercelToken, hardcodedWeaviateKey, hostHeaderRedirect, httpRequestSmuggling, insecureCookies, insecureDeepLink, insecureDeserialization, insecureDirectObjectReference, insecureElectronWindow, insecureFileUpload, insecureGRPC, insecureHTTPMethods, insecurePasswordReset, insecureRandomness, insecureWebSocket, ipcPathTraversal, isCalleeNamed, isMethodCall, isPrivateAddress, isVendoredFinding, isVendoredPath, javaDeserialization, jwtAlgConfusion, k8sNoResourceLimits, k8sPrivileged, k8sSecretNotEncrypted, lambdaWithoutVPC, largeBundleImport, llmCallNoMaxTokens, llmOutputAsHTML, llmOutputToSink, llmPromptInjection, llmSystemPromptInjection, logInjection, magicNumbers, massAssignment, middlewareMatcherExcludesApi, missingAIRateLimit, missingAuthMiddleware, missingAuthRateLimit, missingBruteForce, missingCSP, missingCSRF, missingCertPinning, missingCloudTrail, missingContentDisposition, missingDBEncryption, missingErrorBoundary, missingFileSizeLimits, missingHSTS, missingHTTPS, missingLockFile, missingOAuthState, missingPagination, missingRequestSizeLimit, missingRequestValidation, missingSRI, missingSecurityMeta, nPlusOneQuery, nextPublicSecret, noRateLimiting, normalizeScanPath, nosqlInjection, openRedirectParams, overlyPermissiveIAM, parseFile, parseScanTarget, pathTraversal, pickleDeserialization, piiInLogs, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, routeForFile, runCustomRules, s3BucketNoEncryption, scanEntropy, secretInBundleConfig, secretInCLIArgument, secretInErrorResponse, secretInHTMLAttribute, secretInLLMPrompt, secretInURLParam, secretLoggedToConsole, secretsInCI, securityGroupAllInbound, sensitiveAsyncStorage, sensitiveLocalStorage, sensitiveURLParams, sessionFixation, sqlInjection, ssrfVulnerability, ssti, stripeWebhookUnprotected, supabaseAnonAdmin, supabaseNoRLS, syncFileOps, terraformStateExposed, timingAttack, todoLeftInCode, unencryptedPII, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, vendoredReason, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
|