xploitscan-shared-rules 1.15.2 → 1.17.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.d.cts CHANGED
@@ -578,6 +578,124 @@ declare function scanEntropy(files: {
578
578
  content: string;
579
579
  }[]): Finding[];
580
580
 
581
+ /**
582
+ * URL recon — what can be learned about a deployed app from what it already
583
+ * serves the public.
584
+ *
585
+ * Everything here is a PURE function over strings the caller has already
586
+ * fetched. No network access lives in this module, which is what makes the
587
+ * detection logic unit-testable and keeps the fetching — the dangerous part —
588
+ * in one auditable place in the caller.
589
+ *
590
+ * Scope, deliberately narrow:
591
+ *
592
+ * IN Reading what a site voluntarily serves to any browser: its HTML, its
593
+ * JavaScript bundles, its response headers. This is the same data a
594
+ * visitor's devtools shows, and no more.
595
+ *
596
+ * OUT Probing for vulnerabilities. No injection payloads, no auth-bypass
597
+ * attempts, no querying somebody's database with a key we found. Those
598
+ * are unauthorized security testing against a host the operator has not
599
+ * proven they own, and this product does not do that.
600
+ *
601
+ * The distinction matters commercially too: "your source maps are public" is a
602
+ * finding we can hand to a stranger safely, because acting on it requires
603
+ * access they already have. "Your database is unprotected, here is the key" is
604
+ * an attack map.
605
+ */
606
+ /**
607
+ * Is a dotted-quad or IPv6 literal outside the publicly routable ranges?
608
+ *
609
+ * Exported because the caller MUST re-check this against the address DNS
610
+ * actually resolved to, not merely against the hostname the user typed.
611
+ * Checking only the hostname is defeated by pointing `evil.example.com` at
612
+ * 169.254.169.254 — the DNS-rebinding shape — and by any of the dozens of
613
+ * decimal / octal / IPv4-mapped-IPv6 spellings of a private address.
614
+ */
615
+ declare function isPrivateAddress(address: string): boolean;
616
+ interface TargetRejection {
617
+ ok: false;
618
+ reason: string;
619
+ }
620
+ interface TargetAccepted {
621
+ ok: true;
622
+ url: string;
623
+ hostname: string;
624
+ }
625
+ type TargetCheck = TargetAccepted | TargetRejection;
626
+ /**
627
+ * Normalise and vet a user-supplied scan target.
628
+ *
629
+ * Accepts bare domains ("example.com") because that is what people paste, and
630
+ * upgrades them to https. Rejects anything that is not a public http(s)
631
+ * endpoint. This is a necessary gate, never a sufficient one — see
632
+ * isPrivateAddress on why the resolved IP must be checked separately.
633
+ */
634
+ declare function parseScanTarget(input: string): TargetCheck;
635
+ interface BuilderFingerprint {
636
+ id: string;
637
+ name: string;
638
+ /** What we actually saw. Shown to the user — never assert without evidence. */
639
+ evidence: string;
640
+ }
641
+ declare function detectBuilder(haystack: string): BuilderFingerprint | null;
642
+ /**
643
+ * Extract `//# sourceMappingURL=` references from a bundle.
644
+ *
645
+ * This is the highest-value thing a URL scan can find. A production build that
646
+ * ships its source maps is publishing its original TypeScript — comments,
647
+ * internal names, dead code, and often the server-side helpers that were
648
+ * tree-shaken from the runtime but not from the map. It is a real finding on
649
+ * its own, and it is also the bridge to the actual product: given the maps we
650
+ * can reconstruct sources and run the full rule set against real code, with no
651
+ * repository access at all.
652
+ *
653
+ * Data-URI maps are ignored: inline maps are a bundler default in development
654
+ * and expose nothing that the served bundle did not already contain.
655
+ */
656
+ declare function findSourceMapRefs(js: string, bundleUrl: string): string[];
657
+ interface ExposedConfig {
658
+ kind: "supabase" | "firebase";
659
+ /** Non-secret identifier, safe to echo back (project ref, project id). */
660
+ projectRef: string | null;
661
+ detail: string;
662
+ }
663
+ /**
664
+ * Backend configuration that a client bundle necessarily contains.
665
+ *
666
+ * IMPORTANT: finding these is NOT a vulnerability report. A Supabase anon key
667
+ * is designed to ship to the browser; every Supabase app has one. What matters
668
+ * is that it means the app's entire data-access security rests on row-level
669
+ * security being configured correctly — which cannot be determined from
670
+ * outside without querying their database, and we will not do that.
671
+ *
672
+ * So this is reported as an architectural fact plus a question the owner
673
+ * should answer, never as "you are exposed". Overstating it would be both
674
+ * wrong and the kind of scare-marketing this product exists to be the opposite
675
+ * of.
676
+ *
677
+ * A `service_role` key is a different matter entirely — that one is never
678
+ * supposed to reach a browser — and is flagged by the existing VC004 rule when
679
+ * the reconstructed source is scanned.
680
+ */
681
+ declare function detectExposedConfig(js: string): ExposedConfig[];
682
+ interface HeaderFinding {
683
+ header: string;
684
+ severity: "medium" | "low" | "info";
685
+ message: string;
686
+ }
687
+ /**
688
+ * Header hygiene. Deliberately the LAST thing reported, and never the headline.
689
+ *
690
+ * securityheaders.com and Mozilla Observatory do this for free and have done
691
+ * for a decade. Leading with it would tell a visitor we are a commodity tool
692
+ * competing with something free, when the differentiator is everything above.
693
+ * It is included because its absence is conspicuous, not because it sells.
694
+ */
695
+ declare function assessHeaders(headers: Record<string, string>): HeaderFinding[];
696
+ /** Script `src` URLs in an HTML document, resolved against the page URL. */
697
+ declare function extractScriptUrls(html: string, pageUrl: string, limit?: number): string[];
698
+
581
699
  /**
582
700
  * Centralized Babel parser with per-file caching.
583
701
  *
@@ -689,4 +807,4 @@ declare function getObjectProperty(node: ObjectExpression, key: string): {
689
807
  /** Does this CallExpression spread an expression `matcher` returns true for? */
690
808
  declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
691
809
 
692
- export { type AIFilterResult, type Confidence, type CustomRule, type DetectedFramework, type Exposure, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, NON_APP_PATH_PATTERNS, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, type TaintMap, type VibePlatform, allCustomRules, allRules, androidDebuggable, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, 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, filterFalsePositives, 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, 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, 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 };
810
+ export { type AIFilterResult, type BuilderFingerprint, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, NON_APP_PATH_PATTERNS, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, 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 };
package/dist/index.d.ts CHANGED
@@ -578,6 +578,124 @@ declare function scanEntropy(files: {
578
578
  content: string;
579
579
  }[]): Finding[];
580
580
 
581
+ /**
582
+ * URL recon — what can be learned about a deployed app from what it already
583
+ * serves the public.
584
+ *
585
+ * Everything here is a PURE function over strings the caller has already
586
+ * fetched. No network access lives in this module, which is what makes the
587
+ * detection logic unit-testable and keeps the fetching — the dangerous part —
588
+ * in one auditable place in the caller.
589
+ *
590
+ * Scope, deliberately narrow:
591
+ *
592
+ * IN Reading what a site voluntarily serves to any browser: its HTML, its
593
+ * JavaScript bundles, its response headers. This is the same data a
594
+ * visitor's devtools shows, and no more.
595
+ *
596
+ * OUT Probing for vulnerabilities. No injection payloads, no auth-bypass
597
+ * attempts, no querying somebody's database with a key we found. Those
598
+ * are unauthorized security testing against a host the operator has not
599
+ * proven they own, and this product does not do that.
600
+ *
601
+ * The distinction matters commercially too: "your source maps are public" is a
602
+ * finding we can hand to a stranger safely, because acting on it requires
603
+ * access they already have. "Your database is unprotected, here is the key" is
604
+ * an attack map.
605
+ */
606
+ /**
607
+ * Is a dotted-quad or IPv6 literal outside the publicly routable ranges?
608
+ *
609
+ * Exported because the caller MUST re-check this against the address DNS
610
+ * actually resolved to, not merely against the hostname the user typed.
611
+ * Checking only the hostname is defeated by pointing `evil.example.com` at
612
+ * 169.254.169.254 — the DNS-rebinding shape — and by any of the dozens of
613
+ * decimal / octal / IPv4-mapped-IPv6 spellings of a private address.
614
+ */
615
+ declare function isPrivateAddress(address: string): boolean;
616
+ interface TargetRejection {
617
+ ok: false;
618
+ reason: string;
619
+ }
620
+ interface TargetAccepted {
621
+ ok: true;
622
+ url: string;
623
+ hostname: string;
624
+ }
625
+ type TargetCheck = TargetAccepted | TargetRejection;
626
+ /**
627
+ * Normalise and vet a user-supplied scan target.
628
+ *
629
+ * Accepts bare domains ("example.com") because that is what people paste, and
630
+ * upgrades them to https. Rejects anything that is not a public http(s)
631
+ * endpoint. This is a necessary gate, never a sufficient one — see
632
+ * isPrivateAddress on why the resolved IP must be checked separately.
633
+ */
634
+ declare function parseScanTarget(input: string): TargetCheck;
635
+ interface BuilderFingerprint {
636
+ id: string;
637
+ name: string;
638
+ /** What we actually saw. Shown to the user — never assert without evidence. */
639
+ evidence: string;
640
+ }
641
+ declare function detectBuilder(haystack: string): BuilderFingerprint | null;
642
+ /**
643
+ * Extract `//# sourceMappingURL=` references from a bundle.
644
+ *
645
+ * This is the highest-value thing a URL scan can find. A production build that
646
+ * ships its source maps is publishing its original TypeScript — comments,
647
+ * internal names, dead code, and often the server-side helpers that were
648
+ * tree-shaken from the runtime but not from the map. It is a real finding on
649
+ * its own, and it is also the bridge to the actual product: given the maps we
650
+ * can reconstruct sources and run the full rule set against real code, with no
651
+ * repository access at all.
652
+ *
653
+ * Data-URI maps are ignored: inline maps are a bundler default in development
654
+ * and expose nothing that the served bundle did not already contain.
655
+ */
656
+ declare function findSourceMapRefs(js: string, bundleUrl: string): string[];
657
+ interface ExposedConfig {
658
+ kind: "supabase" | "firebase";
659
+ /** Non-secret identifier, safe to echo back (project ref, project id). */
660
+ projectRef: string | null;
661
+ detail: string;
662
+ }
663
+ /**
664
+ * Backend configuration that a client bundle necessarily contains.
665
+ *
666
+ * IMPORTANT: finding these is NOT a vulnerability report. A Supabase anon key
667
+ * is designed to ship to the browser; every Supabase app has one. What matters
668
+ * is that it means the app's entire data-access security rests on row-level
669
+ * security being configured correctly — which cannot be determined from
670
+ * outside without querying their database, and we will not do that.
671
+ *
672
+ * So this is reported as an architectural fact plus a question the owner
673
+ * should answer, never as "you are exposed". Overstating it would be both
674
+ * wrong and the kind of scare-marketing this product exists to be the opposite
675
+ * of.
676
+ *
677
+ * A `service_role` key is a different matter entirely — that one is never
678
+ * supposed to reach a browser — and is flagged by the existing VC004 rule when
679
+ * the reconstructed source is scanned.
680
+ */
681
+ declare function detectExposedConfig(js: string): ExposedConfig[];
682
+ interface HeaderFinding {
683
+ header: string;
684
+ severity: "medium" | "low" | "info";
685
+ message: string;
686
+ }
687
+ /**
688
+ * Header hygiene. Deliberately the LAST thing reported, and never the headline.
689
+ *
690
+ * securityheaders.com and Mozilla Observatory do this for free and have done
691
+ * for a decade. Leading with it would tell a visitor we are a commodity tool
692
+ * competing with something free, when the differentiator is everything above.
693
+ * It is included because its absence is conspicuous, not because it sells.
694
+ */
695
+ declare function assessHeaders(headers: Record<string, string>): HeaderFinding[];
696
+ /** Script `src` URLs in an HTML document, resolved against the page URL. */
697
+ declare function extractScriptUrls(html: string, pageUrl: string, limit?: number): string[];
698
+
581
699
  /**
582
700
  * Centralized Babel parser with per-file caching.
583
701
  *
@@ -689,4 +807,4 @@ declare function getObjectProperty(node: ObjectExpression, key: string): {
689
807
  /** Does this CallExpression spread an expression `matcher` returns true for? */
690
808
  declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
691
809
 
692
- export { type AIFilterResult, type Confidence, type CustomRule, type DetectedFramework, type Exposure, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, NON_APP_PATH_PATTERNS, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, type TaintMap, type VibePlatform, allCustomRules, allRules, androidDebuggable, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, 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, filterFalsePositives, 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, 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, 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 };
810
+ export { type AIFilterResult, type BuilderFingerprint, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, NON_APP_PATH_PATTERNS, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, 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 };
package/dist/index.js CHANGED
@@ -1190,6 +1190,80 @@ var exposedEnvFile = {
1190
1190
  }];
1191
1191
  }
1192
1192
  };
1193
+ var SUPABASE_EDGE_FN_RE = /(?:^|\/)supabase\/functions\/[^/]+\/.*\.(?:m?[jt]s)$/;
1194
+ function isDenoEdgeEntry(codeOnly) {
1195
+ if (/\bDeno\s*\.\s*serve\s*\(/.test(codeOnly)) return true;
1196
+ const importsStdServe = /from\s+["']https?:\/\/deno\.land\/[^"']{0,120}\/http\/server(?:\.ts)?["']/.test(codeOnly) || /from\s+["'](?:jsr:)?@std\/http[^"']{0,40}["']/.test(codeOnly);
1197
+ return importsStdServe && /(?<![.\w])serve\s*\(/.test(codeOnly);
1198
+ }
1199
+ var DENO_EDGE_ENTRY_RE = /(?:\bDeno\s*\.\s*serve|(?<![.\w])serve)\s*\(/g;
1200
+ var EDGE_WEAK_AUTH_HINTS = [
1201
+ // WEAK_AUTH — the author touched the caller's identity somehow.
1202
+ // Covers the classifier's `/\bheaders\s*(?:\.\s*get\s*\(\s*)?["'`]?[Aa]uthorization/`
1203
+ // via the plain `authorization` token.
1204
+ /\bauthorization\b/i,
1205
+ /\bbearer\b/i,
1206
+ /\btoken\b/i,
1207
+ /\bsession\b/i,
1208
+ /\bapi[_-]?key\b/i,
1209
+ /\buser\b/,
1210
+ // Beyond the classifier's WEAK_AUTH list — these are strong-auth or
1211
+ // ownership signals there, and suppressing on them here can only remove
1212
+ // findings.
1213
+ /\b401\b/,
1214
+ /\b403\b/,
1215
+ /\bunauthori[sz]ed\b/i,
1216
+ /\bforbidden\b/i,
1217
+ /\bgetSession\b/,
1218
+ /\bgetClaims\b/,
1219
+ // RLS_DELEGATED — the database is the gate
1220
+ /\bcreateServerClient\s*\(/,
1221
+ /\bcreateRouteHandlerClient\s*\(/,
1222
+ /\bcreateServerComponentClient\s*\(/,
1223
+ /\bpersistSession\b/,
1224
+ // SIGNATURE_VERIFY — a receiver that authenticates its caller with a
1225
+ // signature or a shared secret rather than a session. Matched on content
1226
+ // rather than on the function's name, because the name is only a
1227
+ // convention: an edge function called `sync-inventory` can still be a
1228
+ // signed webhook receiver, and flagging it for "missing authentication"
1229
+ // would be wrong in the most embarrassing possible way.
1230
+ /\bconstructEvent\w*\s*\(/,
1231
+ /\bcreateHmac\s*\(/,
1232
+ // `hmac` bare, not just Node's `createHmac`. Deno edge functions verify
1233
+ // signatures with Web Crypto — `crypto.subtle.importKey(…, { name: "HMAC" })`
1234
+ // — which contains no other token on this list. Its absence flagged
1235
+ // correctly-signed receivers, which is the worst false positive this rule
1236
+ // can produce.
1237
+ /\bhmac\b/i,
1238
+ /\btimingSafeEqual\s*\(/,
1239
+ /\bsvix\b/i,
1240
+ /\bWebhook\s*\(\s*\w{0,64}SECRET/i,
1241
+ // Header names, quoted or bare. The quoted form below requires the literal
1242
+ // to END at `-signature`, so it misses `"X-Hub-Signature-256"` — the header
1243
+ // GitHub actually sends.
1244
+ /\bx-hub-signature\b/i,
1245
+ /\bx-signature\b/i,
1246
+ /\bstripe-signature\b/i,
1247
+ /\bverifyHeader\s*\(/,
1248
+ /\bverifySignature\b/i,
1249
+ /\bwebhook[_-]?secret\b/i,
1250
+ /\bsigning[_-]?secret\b/i,
1251
+ // Beyond the classifier's SIGNATURE_VERIFY list.
1252
+ /["'`][\w-]*-signature["'`]/i,
1253
+ /\b\w*(?:webhook|shared|signing|cron|admin|internal)[_-]?secret\b/i
1254
+ ];
1255
+ var EDGE_PUBLIC_PATH_RE = /(^|[/_-])(health(?:z|check)?|ping|status|version|readyz|livez|robots|sitemap|manifest|favicon|opengraph|og-image|og|rss|feed|_?static|public|metrics)([/_.-]|$)/i;
1256
+ var EDGE_AUTH_FLOW_PATH_RE = /(^|[/_[-])(auth|login|signin|sign-in|signup|sign-up|register|logout|signout|sign-out|callback|oauth|sso|session|csrf|reset-password|forgot-password|forgot|magic-?link|verify-?email|confirm|nextauth|otp|invite|token)([/\]_.-]|$)/i;
1257
+ var EDGE_CRON_PATH_RE = /(^|[/_-])(cron|jobs?|scheduled?|tasks?)([/_.-]|$)/i;
1258
+ function isPublicByDesignEdgePath(filePath) {
1259
+ return EDGE_PUBLIC_PATH_RE.test(filePath) || EDGE_AUTH_FLOW_PATH_RE.test(filePath) || EDGE_CRON_PATH_RE.test(filePath);
1260
+ }
1261
+ function stripCorsHeaderList(codeOnly) {
1262
+ return codeOnly.replace(
1263
+ /["'`]?Access-Control-(?:Allow|Expose)-Headers["'`]?\s*:\s*["'`][^"'`]*["'`]/gi,
1264
+ ""
1265
+ );
1266
+ }
1193
1267
  var missingAuthMiddleware = {
1194
1268
  id: "VC003",
1195
1269
  title: "API Route Missing Authentication",
@@ -1201,14 +1275,19 @@ var missingAuthMiddleware = {
1201
1275
  const routePatterns = [
1202
1276
  // Express/Hono style
1203
1277
  /\.(get|post|put|patch|delete)\s*\(\s*["'`][^"'`]+["'`]\s*,\s*(?:async\s+)?\(?(?:req|c|ctx)/gi,
1204
- // Next.js API routes
1278
+ // Next.js API routes — named function declaration
1205
1279
  /export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|PATCH|DELETE)\s*\(/gi
1206
1280
  ];
1281
+ if (/(?:^|\/)(?:src\/)?app\/(?:.*\/)?route\.(?:m?[jt]sx?)$/.test(filePath)) {
1282
+ routePatterns.push(
1283
+ /export\s+const\s+(?:GET|POST|PUT|PATCH|DELETE)\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?(?:function\b|\()/g
1284
+ );
1285
+ }
1207
1286
  if (isTestFile(filePath)) return [];
1208
1287
  if (filePath.match(/\.(md|txt|rst|html|css|json|yaml|yml)$/)) return [];
1209
1288
  const isAuthRoute = /\/auth\/|\/login|\/signup|\/register|\/logout|\/password\/|\/forgot|\/reset/i.test(filePath);
1210
1289
  if (isAuthRoute) return [];
1211
- const isWebhookRoute = /\/webhook/i.test(filePath);
1290
+ const isWebhookRoute = /\/webhook/i.test(filePath) || /(?:^|[/_-])webhooks?(?:[/_.-]|$)/i.test(filePath);
1212
1291
  if (isWebhookRoute) return [];
1213
1292
  const codeOnly = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/^\s*#.*$/gm, "");
1214
1293
  const authPatterns = [
@@ -1253,6 +1332,21 @@ var missingAuthMiddleware = {
1253
1332
  )
1254
1333
  );
1255
1334
  }
1335
+ if (matches.length === 0 && SUPABASE_EDGE_FN_RE.test(filePath) && isDenoEdgeEntry(codeOnly) && !isPublicByDesignEdgePath(filePath)) {
1336
+ const withoutCors = stripCorsHeaderList(codeOnly);
1337
+ const hasWeakHint = EDGE_WEAK_AUTH_HINTS.some((p) => p.test(withoutCors));
1338
+ if (!hasWeakHint) {
1339
+ matches.push(
1340
+ ...findMatches(
1341
+ content,
1342
+ DENO_EDGE_ENTRY_RE,
1343
+ missingAuthMiddleware,
1344
+ filePath,
1345
+ () => "This edge function does not establish who is calling it. Read the caller's token from the Authorization header and resolve it (`const { data: { user } } = await supabase.auth.getUser(token)`), or build the Supabase client with that token so row-level security scopes every query to the caller. If the endpoint is public by design, add an inline `// VC003-OK: <reason>` comment above the handler to silence."
1346
+ )
1347
+ );
1348
+ }
1349
+ }
1256
1350
  return filterSilenced(matches, content, "VC003");
1257
1351
  }
1258
1352
  };
@@ -9032,12 +9126,186 @@ function scanEntropy(files) {
9032
9126
  }
9033
9127
  return findings;
9034
9128
  }
9129
+
9130
+ // src/url-recon.ts
9131
+ var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
9132
+ "localhost",
9133
+ "127.0.0.1",
9134
+ "0.0.0.0",
9135
+ "::1",
9136
+ "[::1]",
9137
+ "metadata.google.internal",
9138
+ "metadata.goog",
9139
+ "instance-data"
9140
+ ]);
9141
+ var BLOCKED_SUFFIXES = [".local", ".localhost", ".internal", ".home.arpa", ".cluster.local"];
9142
+ function isPrivateAddress(address) {
9143
+ const addr = address.trim().toLowerCase().replace(/^\[|\]$/g, "");
9144
+ const mapped = addr.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
9145
+ if (mapped) return isPrivateAddress(mapped[1]);
9146
+ const v4 = addr.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
9147
+ if (v4) {
9148
+ const [a, b] = [Number(v4[1]), Number(v4[2])];
9149
+ if ([a, Number(v4[2]), Number(v4[3]), Number(v4[4])].some((o) => o > 255)) return true;
9150
+ if (a === 0) return true;
9151
+ if (a === 10) return true;
9152
+ if (a === 127) return true;
9153
+ if (a === 169 && b === 254) return true;
9154
+ if (a === 172 && b >= 16 && b <= 31) return true;
9155
+ if (a === 192 && b === 168) return true;
9156
+ if (a === 100 && b >= 64 && b <= 127) return true;
9157
+ if (a === 192 && b === 0) return true;
9158
+ if (a === 198 && (b === 18 || b === 19)) return true;
9159
+ if (a >= 224) return true;
9160
+ return false;
9161
+ }
9162
+ if (addr === "::" || addr === "::1") return true;
9163
+ if (/^f[cd][0-9a-f]{2}:/.test(addr)) return true;
9164
+ if (/^fe[89ab][0-9a-f]:/.test(addr)) return true;
9165
+ return false;
9166
+ }
9167
+ function parseScanTarget(input) {
9168
+ const raw = (input || "").trim();
9169
+ if (!raw) return { ok: false, reason: "Enter a URL to scan." };
9170
+ if (raw.length > 2048) return { ok: false, reason: "That URL is too long." };
9171
+ const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw : `https://${raw}`;
9172
+ let url;
9173
+ try {
9174
+ url = new URL(withScheme);
9175
+ } catch {
9176
+ return { ok: false, reason: "That doesn't look like a valid URL." };
9177
+ }
9178
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
9179
+ return { ok: false, reason: "Only http and https URLs can be scanned." };
9180
+ }
9181
+ if (url.username || url.password) {
9182
+ return { ok: false, reason: "Remove the username and password from the URL." };
9183
+ }
9184
+ if (url.port && url.port !== "80" && url.port !== "443") {
9185
+ return { ok: false, reason: "Only the standard web ports (80 and 443) can be scanned." };
9186
+ }
9187
+ const host = url.hostname.toLowerCase();
9188
+ if (BLOCKED_HOSTNAMES.has(host)) {
9189
+ return { ok: false, reason: "That address is not publicly reachable." };
9190
+ }
9191
+ if (BLOCKED_SUFFIXES.some((s) => host.endsWith(s))) {
9192
+ return { ok: false, reason: "That address is not publicly reachable." };
9193
+ }
9194
+ if (isPrivateAddress(host)) {
9195
+ return { ok: false, reason: "That address is not publicly reachable." };
9196
+ }
9197
+ if (!host.includes(".")) {
9198
+ return { ok: false, reason: "Enter a full domain name." };
9199
+ }
9200
+ return { ok: true, url: url.toString(), hostname: host };
9201
+ }
9202
+ var BUILDER_SIGNATURES = [
9203
+ {
9204
+ id: "lovable",
9205
+ name: "Lovable",
9206
+ patterns: [/lovable-tagger/i, /lovable\.dev/i, /data-lov-id=/i, /gpteng\.co/i]
9207
+ },
9208
+ { id: "v0", name: "v0", patterns: [/v0-user-next/i, /v0\.dev/i, /_next\/static.*v0-/i] },
9209
+ { id: "bolt", name: "Bolt", patterns: [/bolt-vite-react/i, /stackblitz/i, /bolt\.new/i] },
9210
+ { id: "base44", name: "Base44", patterns: [/@base44\/sdk/i, /base44\.app/i, /base44\.com/i] }
9211
+ ];
9212
+ function detectBuilder(haystack) {
9213
+ for (const sig of BUILDER_SIGNATURES) {
9214
+ for (const p of sig.patterns) {
9215
+ const m = haystack.match(p);
9216
+ if (m) return { id: sig.id, name: sig.name, evidence: m[0].slice(0, 120) };
9217
+ }
9218
+ }
9219
+ return null;
9220
+ }
9221
+ function findSourceMapRefs(js, bundleUrl) {
9222
+ const out = [];
9223
+ const re = /[#@]\s*sourceMappingURL\s*=\s*([^\s*'"]+)/g;
9224
+ let m;
9225
+ while ((m = re.exec(js)) !== null) {
9226
+ const ref = m[1].trim();
9227
+ if (!ref || ref.startsWith("data:")) continue;
9228
+ try {
9229
+ out.push(new URL(ref, bundleUrl).toString());
9230
+ } catch {
9231
+ }
9232
+ }
9233
+ return [...new Set(out)];
9234
+ }
9235
+ function detectExposedConfig(js) {
9236
+ const out = [];
9237
+ const supabase = js.match(/https:\/\/([a-z0-9]{16,32})\.supabase\.co/i);
9238
+ if (supabase) {
9239
+ out.push({
9240
+ kind: "supabase",
9241
+ projectRef: supabase[1],
9242
+ detail: "A Supabase project URL is present in the client bundle. This is normal and expected \u2014 but it means row-level security is the only thing standing between a visitor and your data."
9243
+ });
9244
+ }
9245
+ const firebase = js.match(/["']?projectId["']?\s*:\s*["']([a-z0-9-]{4,60})["']/i);
9246
+ if (firebase && /firebase/i.test(js)) {
9247
+ out.push({
9248
+ kind: "firebase",
9249
+ projectRef: firebase[1],
9250
+ detail: "A Firebase project configuration is present in the client bundle. This is normal and expected \u2014 but it means your Firestore/Storage rules are the only access control."
9251
+ });
9252
+ }
9253
+ return out;
9254
+ }
9255
+ function assessHeaders(headers) {
9256
+ const h = {};
9257
+ for (const [k, v] of Object.entries(headers)) h[k.toLowerCase()] = v;
9258
+ const out = [];
9259
+ if (!h["content-security-policy"]) {
9260
+ out.push({
9261
+ header: "Content-Security-Policy",
9262
+ severity: "medium",
9263
+ message: "No CSP. A single injected script has nothing stopping it from loading or exfiltrating."
9264
+ });
9265
+ }
9266
+ if (!h["strict-transport-security"]) {
9267
+ out.push({
9268
+ header: "Strict-Transport-Security",
9269
+ severity: "medium",
9270
+ message: "No HSTS. A first visit over http can be intercepted before the redirect to https."
9271
+ });
9272
+ }
9273
+ if (!h["x-content-type-options"]) {
9274
+ out.push({
9275
+ header: "X-Content-Type-Options",
9276
+ severity: "low",
9277
+ message: "Missing nosniff. Browsers may re-interpret a response as a type you did not intend."
9278
+ });
9279
+ }
9280
+ if (!h["referrer-policy"]) {
9281
+ out.push({
9282
+ header: "Referrer-Policy",
9283
+ severity: "low",
9284
+ message: "No referrer policy. Full URLs \u2014 including any ids in the path \u2014 leak to third parties."
9285
+ });
9286
+ }
9287
+ return out;
9288
+ }
9289
+ function extractScriptUrls(html, pageUrl, limit = 12) {
9290
+ const out = [];
9291
+ const re = /<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["']/gi;
9292
+ let m;
9293
+ while ((m = re.exec(html)) !== null && out.length < limit) {
9294
+ try {
9295
+ const u = new URL(m[1], pageUrl);
9296
+ if (u.protocol === "http:" || u.protocol === "https:") out.push(u.toString());
9297
+ } catch {
9298
+ }
9299
+ }
9300
+ return [...new Set(out)];
9301
+ }
9035
9302
  export {
9036
9303
  NON_APP_PATH_PATTERNS,
9037
9304
  RULE_IMPACTS,
9038
9305
  allCustomRules,
9039
9306
  allRules,
9040
9307
  androidDebuggable,
9308
+ assessHeaders,
9041
9309
  blockingMainThread,
9042
9310
  buildTaintMap,
9043
9311
  calculateGrade,
@@ -9055,6 +9323,8 @@ export {
9055
9323
  corsWildcard,
9056
9324
  dangerousInnerHTML,
9057
9325
  deprecatedTLS,
9326
+ detectBuilder,
9327
+ detectExposedConfig,
9058
9328
  detectFramework,
9059
9329
  detectPlatform,
9060
9330
  disabledTLSVerification,
@@ -9083,7 +9353,9 @@ export {
9083
9353
  exposedServerActions,
9084
9354
  exposedSourceMaps,
9085
9355
  exposedStackTraces,
9356
+ extractScriptUrls,
9086
9357
  filterFalsePositives,
9358
+ findSourceMapRefs,
9087
9359
  firebaseClientConfig,
9088
9360
  flaskSecretKey,
9089
9361
  freeRules,
@@ -9160,6 +9432,7 @@ export {
9160
9432
  ipcPathTraversal,
9161
9433
  isCalleeNamed,
9162
9434
  isMethodCall,
9435
+ isPrivateAddress,
9163
9436
  isVendoredFinding,
9164
9437
  isVendoredPath,
9165
9438
  javaDeserialization,
@@ -9207,6 +9480,7 @@ export {
9207
9480
  openRedirectParams,
9208
9481
  overlyPermissiveIAM,
9209
9482
  parseFile,
9483
+ parseScanTarget,
9210
9484
  pathTraversal,
9211
9485
  pickleDeserialization,
9212
9486
  piiInLogs,