xploitscan-shared-rules 1.20.0 → 1.22.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 +183 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -3
- package/dist/index.d.ts +74 -3
- package/dist/index.js +180 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
import { ParseResult } from '@babel/parser';
|
|
2
2
|
import { File, Node, CallExpression, ObjectExpression, BinaryExpression } from '@babel/types';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Cross-file facts a rule cannot learn from the file it is scanning.
|
|
6
|
+
*
|
|
7
|
+
* Rules are deliberately single-file: `check(content, filePath)` sees one file
|
|
8
|
+
* and nothing else. That keeps them fast, order-independent and honest about
|
|
9
|
+
* what they can prove, and it is the right default. But some questions are
|
|
10
|
+
* genuinely answered in a different file, and answering them by guessing from
|
|
11
|
+
* the current one is worse than not answering at all.
|
|
12
|
+
*
|
|
13
|
+
* ProjectContext is the narrow exception: a small set of facts computed ONCE
|
|
14
|
+
* over the whole file list before any rule runs, then handed to every rule.
|
|
15
|
+
* It is intentionally not "here is every file" — that would let rules re-parse
|
|
16
|
+
* the project 214 times and quietly become a cross-file analyser, which the
|
|
17
|
+
* roadmap explicitly rules out as an unwinnable race against CodeQL.
|
|
18
|
+
*
|
|
19
|
+
* Every field is optional and every consumer must behave correctly when the
|
|
20
|
+
* context is absent, because most callers (the MCP server, the VS Code
|
|
21
|
+
* extension, single-file scans) have no project to build one from.
|
|
22
|
+
*/
|
|
23
|
+
/** Parsed facts about the project being scanned. */
|
|
24
|
+
interface ProjectContext {
|
|
25
|
+
/**
|
|
26
|
+
* Supabase Edge Functions and whether the PLATFORM verifies a JWT before
|
|
27
|
+
* the function runs, from `supabase/config.toml`. Keyed by function name —
|
|
28
|
+
* the directory under `supabase/functions/`.
|
|
29
|
+
*
|
|
30
|
+
* A missing entry means "not declared", which is not the same as false:
|
|
31
|
+
* Supabase's own default is `verify_jwt = true`, but a function absent from
|
|
32
|
+
* config.toml may simply be undeclared, so callers must treat absent as
|
|
33
|
+
* unknown rather than assuming either way.
|
|
34
|
+
*/
|
|
35
|
+
supabaseEdgeVerifyJwt?: Map<string, boolean>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse `supabase/config.toml` for per-function `verify_jwt` settings.
|
|
39
|
+
*
|
|
40
|
+
* Deliberately a line scanner rather than a TOML parser. Only two constructs
|
|
41
|
+
* matter, adding a TOML dependency to a package that ships in a browser bundle
|
|
42
|
+
* is a poor trade for that, and a malformed config should yield fewer facts
|
|
43
|
+
* rather than an exception during a scan.
|
|
44
|
+
*/
|
|
45
|
+
declare function parseSupabaseConfig(toml: string): Map<string, boolean>;
|
|
46
|
+
/** The function name for a path under `supabase/functions/<name>/…`. */
|
|
47
|
+
declare function supabaseFunctionName(filePath: string): string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Build the context from the files about to be scanned.
|
|
50
|
+
*
|
|
51
|
+
* Cheap by construction: it reads a fixed, tiny set of paths rather than
|
|
52
|
+
* walking content, so adding a fact here costs one more lookup, not another
|
|
53
|
+
* pass over the project.
|
|
54
|
+
*/
|
|
55
|
+
declare function buildProjectContext(files: Array<{
|
|
56
|
+
path: string;
|
|
57
|
+
content: string;
|
|
58
|
+
}>): ProjectContext;
|
|
59
|
+
|
|
4
60
|
type Severity = "critical" | "high" | "medium" | "low" | "info";
|
|
5
61
|
type Confidence = "high" | "medium" | "low";
|
|
6
62
|
interface Finding {
|
|
@@ -66,13 +122,21 @@ interface RuleMatch {
|
|
|
66
122
|
snippet: string;
|
|
67
123
|
fix?: string;
|
|
68
124
|
}
|
|
125
|
+
|
|
69
126
|
interface CustomRule {
|
|
70
127
|
id: string;
|
|
71
128
|
title: string;
|
|
72
129
|
severity: Severity;
|
|
73
130
|
category: string;
|
|
74
131
|
description: string;
|
|
75
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Optional third argument: cross-file facts computed once per scan. Optional
|
|
134
|
+
* on purpose — every existing rule ignores it and still satisfies this type,
|
|
135
|
+
* and every caller that has no project (single-file scans, the MCP server,
|
|
136
|
+
* the editor extension) can omit it. A rule that uses it must behave
|
|
137
|
+
* correctly when it is undefined.
|
|
138
|
+
*/
|
|
139
|
+
check: (content: string, filePath: string, project?: ProjectContext) => RuleMatch[];
|
|
76
140
|
}
|
|
77
141
|
|
|
78
142
|
/**
|
|
@@ -516,7 +580,14 @@ declare const insecureDirectObjectReference: CustomRule;
|
|
|
516
580
|
declare const freeRules: CustomRule[];
|
|
517
581
|
declare const allRules: CustomRule[];
|
|
518
582
|
declare const allCustomRules: CustomRule[];
|
|
519
|
-
declare function runCustomRules(content: string, filePath: string, disabledRules?: string[], tier?: "free" | "pro", extraRules?: CustomRule[]
|
|
583
|
+
declare function runCustomRules(content: string, filePath: string, disabledRules?: string[], tier?: "free" | "pro", extraRules?: CustomRule[],
|
|
584
|
+
/**
|
|
585
|
+
* Cross-file facts for the project being scanned, from
|
|
586
|
+
* buildProjectContext(). Optional: callers that scan a single file with no
|
|
587
|
+
* project around it (the MCP server, the editor extension, a pasted
|
|
588
|
+
* snippet) pass nothing, and every rule must still work.
|
|
589
|
+
*/
|
|
590
|
+
project?: ProjectContext): Finding[];
|
|
520
591
|
|
|
521
592
|
/**
|
|
522
593
|
* Rule-set sizes as plain numbers, importable without dragging the rules in.
|
|
@@ -925,4 +996,4 @@ declare function getObjectProperty(node: ObjectExpression, key: string): {
|
|
|
925
996
|
/** Does this CallExpression spread an expression `matcher` returns true for? */
|
|
926
997
|
declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
|
|
927
998
|
|
|
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 };
|
|
999
|
+
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, type ProjectContext, 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, buildProjectContext, 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, parseSupabaseConfig, 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, supabaseFunctionName, 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
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
import { ParseResult } from '@babel/parser';
|
|
2
2
|
import { File, Node, CallExpression, ObjectExpression, BinaryExpression } from '@babel/types';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Cross-file facts a rule cannot learn from the file it is scanning.
|
|
6
|
+
*
|
|
7
|
+
* Rules are deliberately single-file: `check(content, filePath)` sees one file
|
|
8
|
+
* and nothing else. That keeps them fast, order-independent and honest about
|
|
9
|
+
* what they can prove, and it is the right default. But some questions are
|
|
10
|
+
* genuinely answered in a different file, and answering them by guessing from
|
|
11
|
+
* the current one is worse than not answering at all.
|
|
12
|
+
*
|
|
13
|
+
* ProjectContext is the narrow exception: a small set of facts computed ONCE
|
|
14
|
+
* over the whole file list before any rule runs, then handed to every rule.
|
|
15
|
+
* It is intentionally not "here is every file" — that would let rules re-parse
|
|
16
|
+
* the project 214 times and quietly become a cross-file analyser, which the
|
|
17
|
+
* roadmap explicitly rules out as an unwinnable race against CodeQL.
|
|
18
|
+
*
|
|
19
|
+
* Every field is optional and every consumer must behave correctly when the
|
|
20
|
+
* context is absent, because most callers (the MCP server, the VS Code
|
|
21
|
+
* extension, single-file scans) have no project to build one from.
|
|
22
|
+
*/
|
|
23
|
+
/** Parsed facts about the project being scanned. */
|
|
24
|
+
interface ProjectContext {
|
|
25
|
+
/**
|
|
26
|
+
* Supabase Edge Functions and whether the PLATFORM verifies a JWT before
|
|
27
|
+
* the function runs, from `supabase/config.toml`. Keyed by function name —
|
|
28
|
+
* the directory under `supabase/functions/`.
|
|
29
|
+
*
|
|
30
|
+
* A missing entry means "not declared", which is not the same as false:
|
|
31
|
+
* Supabase's own default is `verify_jwt = true`, but a function absent from
|
|
32
|
+
* config.toml may simply be undeclared, so callers must treat absent as
|
|
33
|
+
* unknown rather than assuming either way.
|
|
34
|
+
*/
|
|
35
|
+
supabaseEdgeVerifyJwt?: Map<string, boolean>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse `supabase/config.toml` for per-function `verify_jwt` settings.
|
|
39
|
+
*
|
|
40
|
+
* Deliberately a line scanner rather than a TOML parser. Only two constructs
|
|
41
|
+
* matter, adding a TOML dependency to a package that ships in a browser bundle
|
|
42
|
+
* is a poor trade for that, and a malformed config should yield fewer facts
|
|
43
|
+
* rather than an exception during a scan.
|
|
44
|
+
*/
|
|
45
|
+
declare function parseSupabaseConfig(toml: string): Map<string, boolean>;
|
|
46
|
+
/** The function name for a path under `supabase/functions/<name>/…`. */
|
|
47
|
+
declare function supabaseFunctionName(filePath: string): string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Build the context from the files about to be scanned.
|
|
50
|
+
*
|
|
51
|
+
* Cheap by construction: it reads a fixed, tiny set of paths rather than
|
|
52
|
+
* walking content, so adding a fact here costs one more lookup, not another
|
|
53
|
+
* pass over the project.
|
|
54
|
+
*/
|
|
55
|
+
declare function buildProjectContext(files: Array<{
|
|
56
|
+
path: string;
|
|
57
|
+
content: string;
|
|
58
|
+
}>): ProjectContext;
|
|
59
|
+
|
|
4
60
|
type Severity = "critical" | "high" | "medium" | "low" | "info";
|
|
5
61
|
type Confidence = "high" | "medium" | "low";
|
|
6
62
|
interface Finding {
|
|
@@ -66,13 +122,21 @@ interface RuleMatch {
|
|
|
66
122
|
snippet: string;
|
|
67
123
|
fix?: string;
|
|
68
124
|
}
|
|
125
|
+
|
|
69
126
|
interface CustomRule {
|
|
70
127
|
id: string;
|
|
71
128
|
title: string;
|
|
72
129
|
severity: Severity;
|
|
73
130
|
category: string;
|
|
74
131
|
description: string;
|
|
75
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Optional third argument: cross-file facts computed once per scan. Optional
|
|
134
|
+
* on purpose — every existing rule ignores it and still satisfies this type,
|
|
135
|
+
* and every caller that has no project (single-file scans, the MCP server,
|
|
136
|
+
* the editor extension) can omit it. A rule that uses it must behave
|
|
137
|
+
* correctly when it is undefined.
|
|
138
|
+
*/
|
|
139
|
+
check: (content: string, filePath: string, project?: ProjectContext) => RuleMatch[];
|
|
76
140
|
}
|
|
77
141
|
|
|
78
142
|
/**
|
|
@@ -516,7 +580,14 @@ declare const insecureDirectObjectReference: CustomRule;
|
|
|
516
580
|
declare const freeRules: CustomRule[];
|
|
517
581
|
declare const allRules: CustomRule[];
|
|
518
582
|
declare const allCustomRules: CustomRule[];
|
|
519
|
-
declare function runCustomRules(content: string, filePath: string, disabledRules?: string[], tier?: "free" | "pro", extraRules?: CustomRule[]
|
|
583
|
+
declare function runCustomRules(content: string, filePath: string, disabledRules?: string[], tier?: "free" | "pro", extraRules?: CustomRule[],
|
|
584
|
+
/**
|
|
585
|
+
* Cross-file facts for the project being scanned, from
|
|
586
|
+
* buildProjectContext(). Optional: callers that scan a single file with no
|
|
587
|
+
* project around it (the MCP server, the editor extension, a pasted
|
|
588
|
+
* snippet) pass nothing, and every rule must still work.
|
|
589
|
+
*/
|
|
590
|
+
project?: ProjectContext): Finding[];
|
|
520
591
|
|
|
521
592
|
/**
|
|
522
593
|
* Rule-set sizes as plain numbers, importable without dragging the rules in.
|
|
@@ -925,4 +996,4 @@ declare function getObjectProperty(node: ObjectExpression, key: string): {
|
|
|
925
996
|
/** Does this CallExpression spread an expression `matcher` returns true for? */
|
|
926
997
|
declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
|
|
927
998
|
|
|
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 };
|
|
999
|
+
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, type ProjectContext, 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, buildProjectContext, 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, parseSupabaseConfig, 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, supabaseFunctionName, 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
|
@@ -284,6 +284,42 @@ function classifyExposure(filePath) {
|
|
|
284
284
|
return "unknown";
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
// src/project-context.ts
|
|
288
|
+
var TOML_FN_SECTION_RE = /^\s*\[functions\.(?:"([^"]+)"|([A-Za-z0-9._-]+))\]\s*$/;
|
|
289
|
+
var TOML_VERIFY_JWT_RE = /^\s*verify_jwt\s*=\s*(true|false)\s*(?:#.*)?$/i;
|
|
290
|
+
function parseSupabaseConfig(toml) {
|
|
291
|
+
const out = /* @__PURE__ */ new Map();
|
|
292
|
+
let current = null;
|
|
293
|
+
for (const line of toml.split(/\r?\n/)) {
|
|
294
|
+
const section = line.match(TOML_FN_SECTION_RE);
|
|
295
|
+
if (section) {
|
|
296
|
+
current = section[1] ?? section[2];
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (/^\s*\[/.test(line)) {
|
|
300
|
+
current = null;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (!current) continue;
|
|
304
|
+
const verify = line.match(TOML_VERIFY_JWT_RE);
|
|
305
|
+
if (verify) out.set(current, verify[1].toLowerCase() === "true");
|
|
306
|
+
}
|
|
307
|
+
return out;
|
|
308
|
+
}
|
|
309
|
+
function supabaseFunctionName(filePath) {
|
|
310
|
+
const m = filePath.match(/(?:^|\/)supabase\/functions\/([^/]+)\//);
|
|
311
|
+
return m ? m[1] : null;
|
|
312
|
+
}
|
|
313
|
+
function buildProjectContext(files) {
|
|
314
|
+
const ctx = {};
|
|
315
|
+
const config = files.find((f) => /(?:^|\/)supabase\/config\.toml$/.test(f.path));
|
|
316
|
+
if (config) {
|
|
317
|
+
const parsed = parseSupabaseConfig(config.content);
|
|
318
|
+
if (parsed.size > 0) ctx.supabaseEdgeVerifyJwt = parsed;
|
|
319
|
+
}
|
|
320
|
+
return ctx;
|
|
321
|
+
}
|
|
322
|
+
|
|
287
323
|
// src/vendored.ts
|
|
288
324
|
var NON_APP_PATH_PATTERNS = [
|
|
289
325
|
// 1. vendored UI component libraries
|
|
@@ -940,6 +976,69 @@ var TEST_FILE_PATTERN = /(?:\.test\.|\.spec\.|__tests__|__mocks__|\.stories\.|\.
|
|
|
940
976
|
function isTestFile(filePath) {
|
|
941
977
|
return TEST_FILE_PATTERN.test(filePath);
|
|
942
978
|
}
|
|
979
|
+
var HANDLER_HEADER_RE = /(?:\b(?:async\s+)?function\b|=>\s*$|=>\s*\{?\s*$|\.(?:get|post|put|patch|delete|use|all)\s*\(|\bexport\s+(?:async\s+)?(?:function|const)\s+(?:GET|POST|PUT|PATCH|DELETE)\b|\b(?:Deno\.)?serve\s*\()/i;
|
|
980
|
+
function maskComments(content) {
|
|
981
|
+
return content.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " ")).replace(/(^|[^:])\/\/[^\n]*/gm, (m, p1) => p1 + " ".repeat(m.length - p1.length));
|
|
982
|
+
}
|
|
983
|
+
function queryScope(content, index) {
|
|
984
|
+
const open = content.indexOf("(", index);
|
|
985
|
+
if (open === -1 || open - index > 80) return null;
|
|
986
|
+
let depth = 0;
|
|
987
|
+
for (let i = open; i < content.length; i++) {
|
|
988
|
+
const c = content[i];
|
|
989
|
+
if (c === "(") depth++;
|
|
990
|
+
else if (c === ")") {
|
|
991
|
+
depth--;
|
|
992
|
+
if (depth === 0) return content.slice(open, i + 1);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
997
|
+
function enclosingHandler(content, index) {
|
|
998
|
+
const MAX_LEVELS = 6;
|
|
999
|
+
let searchFrom = index;
|
|
1000
|
+
for (let level = 0; level < MAX_LEVELS; level++) {
|
|
1001
|
+
let depth = 0;
|
|
1002
|
+
let open = -1;
|
|
1003
|
+
for (let i = searchFrom; i >= 0; i--) {
|
|
1004
|
+
const c = content[i];
|
|
1005
|
+
if (c === "}") depth++;
|
|
1006
|
+
else if (c === "{") {
|
|
1007
|
+
if (depth === 0) {
|
|
1008
|
+
open = i;
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
depth--;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
if (open === -1) return null;
|
|
1015
|
+
let fwd = 0;
|
|
1016
|
+
let close = -1;
|
|
1017
|
+
for (let i = open; i < content.length; i++) {
|
|
1018
|
+
const c = content[i];
|
|
1019
|
+
if (c === "{") fwd++;
|
|
1020
|
+
else if (c === "}") {
|
|
1021
|
+
fwd--;
|
|
1022
|
+
if (fwd === 0) {
|
|
1023
|
+
close = i;
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
if (close === -1 || close < index) return null;
|
|
1029
|
+
const rawStart = Math.max(0, open - 240);
|
|
1030
|
+
const window = content.slice(rawStart, open);
|
|
1031
|
+
const cut = Math.max(window.lastIndexOf("}"), window.lastIndexOf(";"));
|
|
1032
|
+
const headerStart = cut === -1 ? rawStart : rawStart + cut + 1;
|
|
1033
|
+
const header = content.slice(headerStart, open);
|
|
1034
|
+
if (HANDLER_HEADER_RE.test(header)) {
|
|
1035
|
+
return content.slice(headerStart, close + 1);
|
|
1036
|
+
}
|
|
1037
|
+
searchFrom = open - 1;
|
|
1038
|
+
if (searchFrom < 0) return null;
|
|
1039
|
+
}
|
|
1040
|
+
return null;
|
|
1041
|
+
}
|
|
943
1042
|
var SERVER_SIDE_PATH_RE = new RegExp(
|
|
944
1043
|
[
|
|
945
1044
|
// Directory-style anchors — match with OR without leading slash so
|
|
@@ -969,6 +1068,7 @@ var SERVER_SIDE_CONTENT_RE = /\b(?:req|request)\.(?:body|query|params|headers|co
|
|
|
969
1068
|
function isServerSideFile(filePath, content) {
|
|
970
1069
|
if (isTestFile(filePath)) return false;
|
|
971
1070
|
if (SERVER_SIDE_PATH_RE.test(filePath)) return true;
|
|
1071
|
+
if (content && /^\s*["']use server["']/m.test(content)) return true;
|
|
972
1072
|
if (content && SERVER_SIDE_CONTENT_RE.test(content)) return true;
|
|
973
1073
|
return false;
|
|
974
1074
|
}
|
|
@@ -1272,7 +1372,7 @@ var missingAuthMiddleware = {
|
|
|
1272
1372
|
severity: "high",
|
|
1273
1373
|
category: "Authentication",
|
|
1274
1374
|
description: "API routes without authentication checks allow unauthorized access.",
|
|
1275
|
-
check(content, filePath) {
|
|
1375
|
+
check(content, filePath, project) {
|
|
1276
1376
|
if (!isServerSideFile(filePath, content)) return [];
|
|
1277
1377
|
const routePatterns = [
|
|
1278
1378
|
// Express/Hono style
|
|
@@ -1280,6 +1380,27 @@ var missingAuthMiddleware = {
|
|
|
1280
1380
|
// Next.js API routes — named function declaration
|
|
1281
1381
|
/export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|PATCH|DELETE)\s*\(/gi
|
|
1282
1382
|
];
|
|
1383
|
+
const VERCEL_API_FN_RE = /(?:^|\/)api\/[^/]+\.(?:m?[jt]s)$/;
|
|
1384
|
+
const isNextTree = /(?:^|\/)(?:src\/)?(?:app|pages)\//.test(filePath);
|
|
1385
|
+
if (VERCEL_API_FN_RE.test(filePath) && !isNextTree) {
|
|
1386
|
+
routePatterns.push(
|
|
1387
|
+
/export\s+default\s+(?:async\s+)?(?:function\b|\()/g,
|
|
1388
|
+
/module\.exports\s*=\s*(?:async\s+)?(?:function\b|\()/g
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
if (/^\s*["']use server["']/m.test(content)) {
|
|
1392
|
+
routePatterns.push(
|
|
1393
|
+
/export\s+(?:async\s+)?function\s+\w+\s*\(/g,
|
|
1394
|
+
/export\s+const\s+\w+\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?\(/g
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
const EDGE_FN_DIR_RE = /(?:^|\/)(?:netlify\/(?:edge-)?functions|functions|edge-functions)\/[^/]+\/?[^/]*\.(?:m?[jt]s)$/;
|
|
1398
|
+
if (EDGE_FN_DIR_RE.test(filePath) && !SUPABASE_EDGE_FN_RE.test(filePath)) {
|
|
1399
|
+
routePatterns.push(
|
|
1400
|
+
/(?:exports\s*\.\s*handler|export\s+const\s+handler)\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?(?:function\b|\()/g,
|
|
1401
|
+
/export\s+default\s+(?:async\s+)?(?:function\b|\()/g
|
|
1402
|
+
);
|
|
1403
|
+
}
|
|
1283
1404
|
if (/(?:^|\/)(?:src\/)?app\/(?:.*\/)?route\.(?:m?[jt]sx?)$/.test(filePath)) {
|
|
1284
1405
|
routePatterns.push(
|
|
1285
1406
|
/export\s+const\s+(?:GET|POST|PUT|PATCH|DELETE)\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?(?:function\b|\()/g
|
|
@@ -1320,8 +1441,24 @@ var missingAuthMiddleware = {
|
|
|
1320
1441
|
/\b(?:protect|guard)\(/i,
|
|
1321
1442
|
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i
|
|
1322
1443
|
];
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1444
|
+
const APP_LEVEL_AUTH = [
|
|
1445
|
+
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i,
|
|
1446
|
+
/\bpassport\b/i,
|
|
1447
|
+
/\bclerk\b/i,
|
|
1448
|
+
/\bwithAuth\b/i
|
|
1449
|
+
];
|
|
1450
|
+
if (APP_LEVEL_AUTH.some((p) => p.test(codeOnly))) return [];
|
|
1451
|
+
const handlerAuthPatterns = authPatterns.filter(
|
|
1452
|
+
(p) => !APP_LEVEL_AUTH.some((a) => a.source === p.source)
|
|
1453
|
+
);
|
|
1454
|
+
const maskedForScope = maskComments(content);
|
|
1455
|
+
const handlerHasAuth = (index) => {
|
|
1456
|
+
const bodyStart = maskedForScope.indexOf("{", index);
|
|
1457
|
+
const probe = bodyStart === -1 ? index : bodyStart + 1;
|
|
1458
|
+
const scope = enclosingHandler(maskedForScope, probe);
|
|
1459
|
+
if (scope === null) return handlerAuthPatterns.some((p) => p.test(codeOnly));
|
|
1460
|
+
return handlerAuthPatterns.some((p) => p.test(scope));
|
|
1461
|
+
};
|
|
1325
1462
|
const matches = [];
|
|
1326
1463
|
for (const pattern of routePatterns) {
|
|
1327
1464
|
matches.push(
|
|
@@ -1335,21 +1472,31 @@ var missingAuthMiddleware = {
|
|
|
1335
1472
|
);
|
|
1336
1473
|
}
|
|
1337
1474
|
if (matches.length === 0 && SUPABASE_EDGE_FN_RE.test(filePath) && isDenoEdgeEntry(codeOnly) && !isPublicByDesignEdgePath(filePath)) {
|
|
1338
|
-
const
|
|
1339
|
-
const
|
|
1340
|
-
if (
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1475
|
+
const fnName = supabaseFunctionName(filePath);
|
|
1476
|
+
const verifyJwt = fnName && project?.supabaseEdgeVerifyJwt ? project.supabaseEdgeVerifyJwt.get(fnName) : void 0;
|
|
1477
|
+
if (verifyJwt !== true) {
|
|
1478
|
+
const withoutCors = stripCorsHeaderList(codeOnly);
|
|
1479
|
+
const hasWeakHint = verifyJwt === false ? false : EDGE_WEAK_AUTH_HINTS.some((p) => p.test(withoutCors));
|
|
1480
|
+
if (!hasWeakHint) {
|
|
1481
|
+
matches.push(
|
|
1482
|
+
...findMatches(
|
|
1483
|
+
content,
|
|
1484
|
+
DENO_EDGE_ENTRY_RE,
|
|
1485
|
+
missingAuthMiddleware,
|
|
1486
|
+
filePath,
|
|
1487
|
+
() => "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."
|
|
1488
|
+
)
|
|
1489
|
+
);
|
|
1490
|
+
}
|
|
1350
1491
|
}
|
|
1351
1492
|
}
|
|
1352
|
-
|
|
1493
|
+
const lineStarts = [0];
|
|
1494
|
+
for (let i = 0; i < content.length; i++) {
|
|
1495
|
+
if (content[i] === "\n") lineStarts.push(i + 1);
|
|
1496
|
+
}
|
|
1497
|
+
const indexOfLine = (line) => lineStarts[Math.max(0, Math.min(line - 1, lineStarts.length - 1))];
|
|
1498
|
+
const unauthenticated = matches.filter((m) => !handlerHasAuth(indexOfLine(m.line)));
|
|
1499
|
+
return filterSilenced(unauthenticated, content, "VC003");
|
|
1353
1500
|
}
|
|
1354
1501
|
};
|
|
1355
1502
|
var supabaseNoRLS = {
|
|
@@ -8465,15 +8612,22 @@ var insecureDirectObjectReference = {
|
|
|
8465
8612
|
if (!filePath.match(/\.(js|ts|jsx|tsx)$/)) return [];
|
|
8466
8613
|
if (isTestFile(filePath)) return [];
|
|
8467
8614
|
if (/admin/i.test(filePath)) return [];
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8615
|
+
const scan = maskComments(content);
|
|
8616
|
+
const LOOKUP_RE = /findUnique|findFirst|findById|\.findOne\b|\.find\s*\(\s*\{|WHERE[\s\S]{0,120}?(?:params|req\.(?:body|query))|\.get\([^)]*(?:params|req\.(?:body|query))/i;
|
|
8617
|
+
const lookup = scan.match(LOOKUP_RE);
|
|
8618
|
+
if (!lookup || lookup.index === void 0) return [];
|
|
8619
|
+
const handlerScope = enclosingHandler(scan, lookup.index) ?? scan;
|
|
8620
|
+
const qScope = queryScope(scan, lookup.index) ?? handlerScope;
|
|
8621
|
+
if (/userId|ownerId|createdBy|user_id|owner_id|AND.*user|where.*user|authorize|canAccess|checkPermission|isOwner|belongsTo/i.test(qScope)) return [];
|
|
8622
|
+
if (/requireUser|requireUserForApi|requireAuth|withAuth|getServerSession|auth\(\)|passport|isAuthenticated/i.test(handlerScope)) return [];
|
|
8471
8623
|
const isNextApiIdor = /\/api\//i.test(filePath) && /export\s+(?:async\s+)?function\s+(?:GET|PUT|PATCH|DELETE)/i.test(content) && /params\.id|params\.(?:slug|uuid)|req\.params\./i.test(content);
|
|
8472
8624
|
const hasExpressHandler = /\.(get|post|put|patch|delete)\s*\(\s*["'`][^"'`]*["'`]\s*,/i.test(content);
|
|
8473
8625
|
const readsObjectRef = /req\.params\b|req\.(?:body|query)\.\w*id\b/i.test(content);
|
|
8474
8626
|
const isExpressIdor = hasExpressHandler && readsObjectRef;
|
|
8475
|
-
|
|
8476
|
-
const
|
|
8627
|
+
const hasExportedHandler = /(?:module\.)?exports\.\w+\s*=\s*(?:async\s+)?(?:function\s*)?\(\s*req\b[^)]*\)/i.test(content) || /(?:module\.)?exports\.\w+\s*=\s*(?:async\s*)?\(\s*req\b[^)]*\)\s*=>/i.test(content);
|
|
8628
|
+
const isControllerIdor = hasExportedHandler && readsObjectRef;
|
|
8629
|
+
if (!isNextApiIdor && !isExpressIdor && !isControllerIdor) return [];
|
|
8630
|
+
const m = scan.match(/params\.id|params\.(?:slug|uuid)|req\.params\.\w+|req\.params\b|req\.(?:body|query)\.\w*id/i);
|
|
8477
8631
|
if (!m || m.index === void 0) return [];
|
|
8478
8632
|
const lineNum = lineNumberAt(content, m.index);
|
|
8479
8633
|
return [{
|
|
@@ -8781,7 +8935,7 @@ var allCustomRules = [
|
|
|
8781
8935
|
entitlementFromWebStorage,
|
|
8782
8936
|
accountStateFromWebStorage
|
|
8783
8937
|
];
|
|
8784
|
-
function runCustomRules(content, filePath, disabledRules = [], tier = "free", extraRules = []) {
|
|
8938
|
+
function runCustomRules(content, filePath, disabledRules = [], tier = "free", extraRules = [], project) {
|
|
8785
8939
|
const findings = [];
|
|
8786
8940
|
if (/function runScan\(files\)|export function runCustomRules/.test(content) && /const (?:rules|allRules)\s*[:=]/.test(content) && /findMatches/.test(content)) {
|
|
8787
8941
|
return findings;
|
|
@@ -8803,7 +8957,7 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
8803
8957
|
const ruleset = tier === "pro" && extraRules.length > 0 ? [...freeRules, ...extraRules] : freeRules;
|
|
8804
8958
|
for (const rule of ruleset) {
|
|
8805
8959
|
if (disabledRules.includes(rule.id)) continue;
|
|
8806
|
-
const matches = rule.check(content, filePath);
|
|
8960
|
+
const matches = rule.check(content, filePath, project);
|
|
8807
8961
|
const compliance = complianceMap[rule.id];
|
|
8808
8962
|
const vendored = vendoredFile && isVendoredFinding({ file: filePath, rule: rule.id, category: rule.category });
|
|
8809
8963
|
for (const match of matches) {
|
|
@@ -9504,6 +9658,7 @@ export {
|
|
|
9504
9658
|
androidDebuggable,
|
|
9505
9659
|
assessHeaders,
|
|
9506
9660
|
blockingMainThread,
|
|
9661
|
+
buildProjectContext,
|
|
9507
9662
|
buildTaintMap,
|
|
9508
9663
|
calculateGrade,
|
|
9509
9664
|
callSpreads,
|
|
@@ -9680,6 +9835,7 @@ export {
|
|
|
9680
9835
|
overlyPermissiveIAM,
|
|
9681
9836
|
parseFile,
|
|
9682
9837
|
parseScanTarget,
|
|
9838
|
+
parseSupabaseConfig,
|
|
9683
9839
|
pathTraversal,
|
|
9684
9840
|
pickleDeserialization,
|
|
9685
9841
|
piiInLogs,
|
|
@@ -9717,6 +9873,7 @@ export {
|
|
|
9717
9873
|
ssti,
|
|
9718
9874
|
stripeWebhookUnprotected,
|
|
9719
9875
|
supabaseAnonAdmin,
|
|
9876
|
+
supabaseFunctionName,
|
|
9720
9877
|
supabaseNoRLS,
|
|
9721
9878
|
syncFileOps,
|
|
9722
9879
|
terraformStateExposed,
|