xploitscan-shared-rules 1.28.1 → 1.30.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 +373 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +372 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1336,6 +1336,36 @@ interface QualityFile {
|
|
|
1336
1336
|
isServer: boolean;
|
|
1337
1337
|
}
|
|
1338
1338
|
|
|
1339
|
+
/**
|
|
1340
|
+
* Worked examples for the quality catalogue, one vulnerable/safe pair per rule.
|
|
1341
|
+
*
|
|
1342
|
+
* These are published on xploitscan.com/quality/<id>, which is the reason they
|
|
1343
|
+
* are here and not in the web package: `quality.test.ts` runs every one of them
|
|
1344
|
+
* through the real scanner and asserts that the vulnerable sample fires its own
|
|
1345
|
+
* rule and the safe sample does not. A page that shows a reader "this is what
|
|
1346
|
+
* we catch" has to be right, and the only way to keep it right through a year
|
|
1347
|
+
* of rule edits is to make a wrong example fail the build.
|
|
1348
|
+
*
|
|
1349
|
+
* Writing them this way also found things. QA002's first draft ended in
|
|
1350
|
+
* `setRevoked(true)`, which is not a success assertion the rule recognises, so
|
|
1351
|
+
* the "vulnerable" sample was quietly correct code. QA004's used a bare
|
|
1352
|
+
* comparison rather than an interpolated secret, and QA005's had no click
|
|
1353
|
+
* affordance. All three would have shipped as documentation of behaviour the
|
|
1354
|
+
* scanner does not have.
|
|
1355
|
+
*/
|
|
1356
|
+
interface QualityExample {
|
|
1357
|
+
/** Path the sample is scanned at — several rules gate on the path shape. */
|
|
1358
|
+
path: string;
|
|
1359
|
+
language: string;
|
|
1360
|
+
/** Fires the rule. */
|
|
1361
|
+
vulnerable: string;
|
|
1362
|
+
/** The same code, corrected. Must NOT fire the rule. */
|
|
1363
|
+
safe: string;
|
|
1364
|
+
/** What changed between them, in one sentence. */
|
|
1365
|
+
difference: string;
|
|
1366
|
+
}
|
|
1367
|
+
declare const QUALITY_EXAMPLES: Record<string, QualityExample>;
|
|
1368
|
+
|
|
1339
1369
|
/**
|
|
1340
1370
|
* The quality catalogue.
|
|
1341
1371
|
*
|
|
@@ -1356,4 +1386,4 @@ declare function scanQuality(files: {
|
|
|
1356
1386
|
content: string;
|
|
1357
1387
|
}[], rules?: QualityRule[]): Finding[];
|
|
1358
1388
|
|
|
1359
|
-
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, type ParsedFile, type ProjectContext, type QualityContext, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, accountStateFromWebStorage, allCustomRules, allRules, androidDebuggable, assessHeaders, blockingMainThread, buildProjectContext, buildTaintMap, calculateGrade, callSpreads, callbackHell, checkIntent, classifyExposure, classifyStatement, 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, harvestIntent, 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, maskComments, 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, proOnlyRules, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, qualityRules, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, routeForFile, runCustomRules, s3BucketNoEncryption, scanEntropy, scanQuality, 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 };
|
|
1389
|
+
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, accountStateFromWebStorage, allCustomRules, allRules, androidDebuggable, assessHeaders, blockingMainThread, buildProjectContext, buildTaintMap, calculateGrade, callSpreads, callbackHell, checkIntent, classifyExposure, classifyStatement, 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, harvestIntent, 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, maskComments, 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, proOnlyRules, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, qualityRules, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, routeForFile, runCustomRules, s3BucketNoEncryption, scanEntropy, scanQuality, 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
|
@@ -1336,6 +1336,36 @@ interface QualityFile {
|
|
|
1336
1336
|
isServer: boolean;
|
|
1337
1337
|
}
|
|
1338
1338
|
|
|
1339
|
+
/**
|
|
1340
|
+
* Worked examples for the quality catalogue, one vulnerable/safe pair per rule.
|
|
1341
|
+
*
|
|
1342
|
+
* These are published on xploitscan.com/quality/<id>, which is the reason they
|
|
1343
|
+
* are here and not in the web package: `quality.test.ts` runs every one of them
|
|
1344
|
+
* through the real scanner and asserts that the vulnerable sample fires its own
|
|
1345
|
+
* rule and the safe sample does not. A page that shows a reader "this is what
|
|
1346
|
+
* we catch" has to be right, and the only way to keep it right through a year
|
|
1347
|
+
* of rule edits is to make a wrong example fail the build.
|
|
1348
|
+
*
|
|
1349
|
+
* Writing them this way also found things. QA002's first draft ended in
|
|
1350
|
+
* `setRevoked(true)`, which is not a success assertion the rule recognises, so
|
|
1351
|
+
* the "vulnerable" sample was quietly correct code. QA004's used a bare
|
|
1352
|
+
* comparison rather than an interpolated secret, and QA005's had no click
|
|
1353
|
+
* affordance. All three would have shipped as documentation of behaviour the
|
|
1354
|
+
* scanner does not have.
|
|
1355
|
+
*/
|
|
1356
|
+
interface QualityExample {
|
|
1357
|
+
/** Path the sample is scanned at — several rules gate on the path shape. */
|
|
1358
|
+
path: string;
|
|
1359
|
+
language: string;
|
|
1360
|
+
/** Fires the rule. */
|
|
1361
|
+
vulnerable: string;
|
|
1362
|
+
/** The same code, corrected. Must NOT fire the rule. */
|
|
1363
|
+
safe: string;
|
|
1364
|
+
/** What changed between them, in one sentence. */
|
|
1365
|
+
difference: string;
|
|
1366
|
+
}
|
|
1367
|
+
declare const QUALITY_EXAMPLES: Record<string, QualityExample>;
|
|
1368
|
+
|
|
1339
1369
|
/**
|
|
1340
1370
|
* The quality catalogue.
|
|
1341
1371
|
*
|
|
@@ -1356,4 +1386,4 @@ declare function scanQuality(files: {
|
|
|
1356
1386
|
content: string;
|
|
1357
1387
|
}[], rules?: QualityRule[]): Finding[];
|
|
1358
1388
|
|
|
1359
|
-
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, type ParsedFile, type ProjectContext, type QualityContext, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, accountStateFromWebStorage, allCustomRules, allRules, androidDebuggable, assessHeaders, blockingMainThread, buildProjectContext, buildTaintMap, calculateGrade, callSpreads, callbackHell, checkIntent, classifyExposure, classifyStatement, 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, harvestIntent, 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, maskComments, 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, proOnlyRules, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, qualityRules, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, routeForFile, runCustomRules, s3BucketNoEncryption, scanEntropy, scanQuality, 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 };
|
|
1389
|
+
export { type AIFilterResult, type AppRoute, type BuilderFingerprint, CHECKABLE_CLAIMS, type Confidence, type CustomRule, type DetectedFramework, type ExposedConfig, type Exposure, FREE_RULE_COUNT, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, type HeaderFinding, INTENT_EXPECTATIONS, type IntentExpectation, type IntentMismatch, type IntentOrigin, type IntentReport, type IntentStatement, MODEL_ANALYSIS, MODEL_POLICY_REVIEWED, MODEL_REVIEW_INTERVAL_DAYS, MODEL_TEMPERATURE, MODEL_TRIAGE, NON_APP_PATH_PATTERNS, PRO_RULE_COUNT, type ParsedFile, type ProjectContext, QUALITY_EXAMPLES, type QualityContext, type QualityExample, type QualityFile, type QualityHit, type QualityRule, RULE_IMPACTS, type RouteFramework, type RouteTable, type RuleMatch, type SecurityGrade, type Severity, TEST_FILE_PATTERN, TOTAL_RULE_COUNT, type TaintMap, type TargetCheck, type VibePlatform, accountStateFromWebStorage, allCustomRules, allRules, androidDebuggable, assessHeaders, blockingMainThread, buildProjectContext, buildTaintMap, calculateGrade, callSpreads, callbackHell, checkIntent, classifyExposure, classifyStatement, 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, harvestIntent, 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, maskComments, 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, proOnlyRules, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, qualityRules, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, routeForFile, runCustomRules, s3BucketNoEncryption, scanEntropy, scanQuality, 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
|
@@ -12296,6 +12296,375 @@ var unassociatedLabel = {
|
|
|
12296
12296
|
}
|
|
12297
12297
|
};
|
|
12298
12298
|
|
|
12299
|
+
// src/quality/rules/failed-read-empty-state.ts
|
|
12300
|
+
import _traverse4 from "@babel/traverse";
|
|
12301
|
+
var traverse4 = typeof _traverse4 === "function" ? _traverse4 : _traverse4.default;
|
|
12302
|
+
var READ_ERROR_PATH_SIGNALS = ERROR_PATH_SIGNALS.filter(
|
|
12303
|
+
(re) => re.source !== /\.catch\s*\(/.source
|
|
12304
|
+
);
|
|
12305
|
+
function isEmptyCollectionLiteral(node) {
|
|
12306
|
+
if (node.type === "ArrayExpression") return node.elements.length === 0;
|
|
12307
|
+
if (node.type === "ObjectExpression") return node.properties.length === 0;
|
|
12308
|
+
return false;
|
|
12309
|
+
}
|
|
12310
|
+
var SETTER = /^set[A-Z][A-Za-z0-9_]*$/;
|
|
12311
|
+
function setterName(callee) {
|
|
12312
|
+
if (callee.type === "Identifier" && SETTER.test(callee.name)) return callee.name;
|
|
12313
|
+
return null;
|
|
12314
|
+
}
|
|
12315
|
+
function isPropertyRead(node) {
|
|
12316
|
+
return node.type === "MemberExpression" || node.type === "OptionalMemberExpression";
|
|
12317
|
+
}
|
|
12318
|
+
function emptyFallbackArgument(node) {
|
|
12319
|
+
if (node.type !== "LogicalExpression") return null;
|
|
12320
|
+
if (node.operator !== "||" && node.operator !== "??") return null;
|
|
12321
|
+
if (!isEmptyCollectionLiteral(node.right)) return null;
|
|
12322
|
+
if (!isPropertyRead(node.left)) return null;
|
|
12323
|
+
return node;
|
|
12324
|
+
}
|
|
12325
|
+
function isEffectCall(node) {
|
|
12326
|
+
if (node.type !== "CallExpression") return false;
|
|
12327
|
+
const callee = node.callee;
|
|
12328
|
+
const name = callee.type === "Identifier" ? callee.name : callee.type === "MemberExpression" && callee.property.type === "Identifier" ? callee.property.name : null;
|
|
12329
|
+
return name === "useEffect" || name === "useLayoutEffect";
|
|
12330
|
+
}
|
|
12331
|
+
function looksLikeComponent(path) {
|
|
12332
|
+
const parent = path.parent;
|
|
12333
|
+
if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier") {
|
|
12334
|
+
return /^[A-Z]/.test(parent.id.name);
|
|
12335
|
+
}
|
|
12336
|
+
const node = path.node;
|
|
12337
|
+
if ((node.type === "FunctionDeclaration" || node.type === "FunctionExpression") && node.id && /^[A-Z]/.test(node.id.name)) {
|
|
12338
|
+
return true;
|
|
12339
|
+
}
|
|
12340
|
+
return false;
|
|
12341
|
+
}
|
|
12342
|
+
function unitFor(fetchPath) {
|
|
12343
|
+
let candidate = null;
|
|
12344
|
+
for (let fn = fetchPath.getFunctionParent(); fn !== null; fn = fn.getFunctionParent()) {
|
|
12345
|
+
if (looksLikeComponent(fn)) break;
|
|
12346
|
+
candidate = fn;
|
|
12347
|
+
if (fn.parent && isEffectCall(fn.parent)) return fn;
|
|
12348
|
+
}
|
|
12349
|
+
return candidate;
|
|
12350
|
+
}
|
|
12351
|
+
var failedReadEmptyState = {
|
|
12352
|
+
id: "QA009",
|
|
12353
|
+
title: "A failed read is rendered as an empty state",
|
|
12354
|
+
severity: "high",
|
|
12355
|
+
category: "Correctness",
|
|
12356
|
+
description: "This loader turns a failed or unexpected response into an empty list and renders it, so the page shows the same thing it would show a brand-new account: no sessions, no scans, no members. Nothing tells the user the request failed, and anything they do next \u2014 including saving \u2014 acts on data the app never actually received.",
|
|
12357
|
+
fix: "Check the response before using it: on a non-2xx, or a body without the field you expected, set an error state and render that instead of the empty state. Keep the `|| []` only for a response you have already confirmed arrived.",
|
|
12358
|
+
precisionNotes: "Client files only, and only a unit containing the literal global `fetch(` \u2014 throwing clients (ky, wretch, ofetch) reject on non-2xx, so `|| []` after them is correct, and in-file wrappers that check `.ok` and rethrow leave their callers containing no `fetch(` at all. The empty fallback must be `|| []`/`?? []`/`{}` over a PROPERTY READ passed straight to a `setX` state setter: `setRows(rows || [])` defaults a value the component already holds, and a pure helper's argument is never rendered. The unit is the effect callback, or the outermost non-component function \u2014 the nearest function cannot see the `.catch` below it, and the whole component would let an unrelated toast.error exonerate a broken loader. Exoneration is QA002's ERROR_PATH_SIGNALS with `.catch(` REMOVED: for a write a `.catch` means the author handled it, for a read `.catch(() => setLoaded(true))` is the defect itself. Measured at 6 fires over 5 sites in 437 real .tsx files with zero false positives, and silent on all three sites after they were fixed by hand.",
|
|
12359
|
+
check(ctx) {
|
|
12360
|
+
const hits = [];
|
|
12361
|
+
for (const file of ctx.files) {
|
|
12362
|
+
if (file.excluded) continue;
|
|
12363
|
+
if (!file.isClient) continue;
|
|
12364
|
+
if (file.isServer) continue;
|
|
12365
|
+
if (/^\s*["']use server["']/m.test(file.code)) continue;
|
|
12366
|
+
const parsed = file.parsed;
|
|
12367
|
+
if (!parsed) continue;
|
|
12368
|
+
const reported = /* @__PURE__ */ new Set();
|
|
12369
|
+
traverse4(parsed.ast, {
|
|
12370
|
+
CallExpression(path) {
|
|
12371
|
+
if (!isFetchCallee(path.node.callee)) return;
|
|
12372
|
+
const unit = unitFor(path);
|
|
12373
|
+
if (!unit) return;
|
|
12374
|
+
const start = nodeStart(unit.node);
|
|
12375
|
+
if (reported.has(start)) return;
|
|
12376
|
+
const unitSource = file.code.slice(start, nodeEnd(unit.node));
|
|
12377
|
+
if (READ_ERROR_PATH_SIGNALS.some((re) => re.test(unitSource))) return;
|
|
12378
|
+
let hit = null;
|
|
12379
|
+
unit.traverse({
|
|
12380
|
+
CallExpression(inner) {
|
|
12381
|
+
if (hit) return;
|
|
12382
|
+
const name = setterName(inner.node.callee);
|
|
12383
|
+
if (!name) return;
|
|
12384
|
+
const arg = inner.node.arguments[0];
|
|
12385
|
+
if (!arg) return;
|
|
12386
|
+
const fallback = emptyFallbackArgument(arg);
|
|
12387
|
+
if (!fallback) return;
|
|
12388
|
+
hit = { line: lineAt(file.content, nodeStart(fallback)), setter: name };
|
|
12389
|
+
}
|
|
12390
|
+
});
|
|
12391
|
+
if (!hit) return;
|
|
12392
|
+
reported.add(start);
|
|
12393
|
+
const { line, setter } = hit;
|
|
12394
|
+
hits.push({
|
|
12395
|
+
file: file.path,
|
|
12396
|
+
line,
|
|
12397
|
+
detail: `\`${setter}\` is handed an empty collection whenever this read fails or the body is missing that field, and nothing in this loader tells the user the request did not succeed. The page renders its empty state \u2014 the same screen a brand-new account sees.`
|
|
12398
|
+
});
|
|
12399
|
+
}
|
|
12400
|
+
});
|
|
12401
|
+
}
|
|
12402
|
+
return hits;
|
|
12403
|
+
}
|
|
12404
|
+
};
|
|
12405
|
+
|
|
12406
|
+
// src/quality/examples.ts
|
|
12407
|
+
var QUALITY_EXAMPLES = {
|
|
12408
|
+
QA001: {
|
|
12409
|
+
path: "supabase/functions/list-items/index.ts",
|
|
12410
|
+
language: "typescript",
|
|
12411
|
+
difference: "The catch answers with 500 and an error instead of 200 and an empty list, so the caller can tell a broken query from an account with no items.",
|
|
12412
|
+
vulnerable: `Deno.serve(async (req) => {
|
|
12413
|
+
try {
|
|
12414
|
+
const { data } = await supabase.from("items").select("*");
|
|
12415
|
+
return new Response(JSON.stringify({ items: data }), { status: 200 });
|
|
12416
|
+
} catch (err) {
|
|
12417
|
+
console.error(err);
|
|
12418
|
+
return new Response(JSON.stringify({ items: [] }), { status: 200 });
|
|
12419
|
+
}
|
|
12420
|
+
});`,
|
|
12421
|
+
safe: `Deno.serve(async (req) => {
|
|
12422
|
+
try {
|
|
12423
|
+
const { data } = await supabase.from("items").select("*");
|
|
12424
|
+
return new Response(JSON.stringify({ items: data }), { status: 200 });
|
|
12425
|
+
} catch (err) {
|
|
12426
|
+
console.error(err);
|
|
12427
|
+
return new Response(JSON.stringify({ error: "Could not load items" }), { status: 500 });
|
|
12428
|
+
}
|
|
12429
|
+
});`
|
|
12430
|
+
},
|
|
12431
|
+
QA009: {
|
|
12432
|
+
path: "app/settings/ApiKeysSection.tsx",
|
|
12433
|
+
language: "tsx",
|
|
12434
|
+
difference: "The loader checks the response and sets an error the page can render, so a failed read no longer looks like an account with no keys.",
|
|
12435
|
+
vulnerable: `"use client";
|
|
12436
|
+
|
|
12437
|
+
export function ApiKeysSection() {
|
|
12438
|
+
const [keys, setKeys] = useState([]);
|
|
12439
|
+
|
|
12440
|
+
const load = async () => {
|
|
12441
|
+
try {
|
|
12442
|
+
const res = await fetch("/api/api-keys");
|
|
12443
|
+
const data = await res.json();
|
|
12444
|
+
setKeys(data.keys || []);
|
|
12445
|
+
} catch {
|
|
12446
|
+
/* ignore */
|
|
12447
|
+
}
|
|
12448
|
+
};
|
|
12449
|
+
|
|
12450
|
+
useEffect(() => { load(); }, []);
|
|
12451
|
+
}`,
|
|
12452
|
+
safe: `"use client";
|
|
12453
|
+
|
|
12454
|
+
export function ApiKeysSection() {
|
|
12455
|
+
const [keys, setKeys] = useState([]);
|
|
12456
|
+
const [loadError, setLoadError] = useState(null);
|
|
12457
|
+
|
|
12458
|
+
const load = async () => {
|
|
12459
|
+
const res = await fetch("/api/api-keys");
|
|
12460
|
+
if (!res.ok) {
|
|
12461
|
+
setLoadError("Could not load your API keys. Try again.");
|
|
12462
|
+
return;
|
|
12463
|
+
}
|
|
12464
|
+
const data = await res.json();
|
|
12465
|
+
setKeys(data.keys ?? []);
|
|
12466
|
+
};
|
|
12467
|
+
|
|
12468
|
+
useEffect(() => { load(); }, []);
|
|
12469
|
+
}`
|
|
12470
|
+
},
|
|
12471
|
+
QA002: {
|
|
12472
|
+
path: "app/settings/ApiKeyRow.tsx",
|
|
12473
|
+
language: "tsx",
|
|
12474
|
+
difference: "The failure branch tells the user instead of returning silently, so a revoke that did not happen cannot show as one that did.",
|
|
12475
|
+
vulnerable: `"use client";
|
|
12476
|
+
import { toast } from "sonner";
|
|
12477
|
+
|
|
12478
|
+
export function ApiKeyRow({ keyId }) {
|
|
12479
|
+
async function handleRevoke() {
|
|
12480
|
+
const res = await fetch(\`/api/keys/\${keyId}/revoke\`, { method: "POST" });
|
|
12481
|
+
if (!res.ok) return;
|
|
12482
|
+
toast.success("API key revoked");
|
|
12483
|
+
}
|
|
12484
|
+
|
|
12485
|
+
return <button onClick={handleRevoke}>Revoke</button>;
|
|
12486
|
+
}`,
|
|
12487
|
+
safe: `"use client";
|
|
12488
|
+
import { toast } from "sonner";
|
|
12489
|
+
|
|
12490
|
+
export function ApiKeyRow({ keyId }) {
|
|
12491
|
+
async function handleRevoke() {
|
|
12492
|
+
const res = await fetch(\`/api/keys/\${keyId}/revoke\`, { method: "POST" });
|
|
12493
|
+
if (!res.ok) {
|
|
12494
|
+
toast.error("Could not revoke the key. Try again.");
|
|
12495
|
+
return;
|
|
12496
|
+
}
|
|
12497
|
+
toast.success("API key revoked");
|
|
12498
|
+
}
|
|
12499
|
+
|
|
12500
|
+
return <button onClick={handleRevoke}>Revoke</button>;
|
|
12501
|
+
}`
|
|
12502
|
+
},
|
|
12503
|
+
QA003: {
|
|
12504
|
+
path: "app/api/billing/webhook/route.ts",
|
|
12505
|
+
language: "typescript",
|
|
12506
|
+
difference: "The catch rethrows, so the row is not left saying a credit was issued that never left Stripe \u2014 and the webhook is redelivered.",
|
|
12507
|
+
vulnerable: `export async function POST(req) {
|
|
12508
|
+
const referral = await db.get("SELECT id FROM referrals WHERE status = 'pending' LIMIT 1");
|
|
12509
|
+
await db.run("UPDATE referrals SET status = 'rewarded' WHERE id = ?", referral.id);
|
|
12510
|
+
try {
|
|
12511
|
+
await stripe.customers.createBalanceTransaction(customerId, { amount: -1000, currency: "usd" });
|
|
12512
|
+
} catch (err) {
|
|
12513
|
+
logError("credit failed", err);
|
|
12514
|
+
}
|
|
12515
|
+
return new Response(JSON.stringify({ ok: true }), { status: 200 });
|
|
12516
|
+
}`,
|
|
12517
|
+
safe: `export async function POST(req) {
|
|
12518
|
+
const referral = await db.get("SELECT id FROM referrals WHERE status = 'pending' LIMIT 1");
|
|
12519
|
+
await db.run("UPDATE referrals SET status = 'rewarded' WHERE id = ?", referral.id);
|
|
12520
|
+
try {
|
|
12521
|
+
await stripe.customers.createBalanceTransaction(customerId, { amount: -1000, currency: "usd" });
|
|
12522
|
+
} catch (err) {
|
|
12523
|
+
logError("credit failed", err);
|
|
12524
|
+
throw err;
|
|
12525
|
+
}
|
|
12526
|
+
return new Response(JSON.stringify({ ok: true }), { status: 200 });
|
|
12527
|
+
}`
|
|
12528
|
+
},
|
|
12529
|
+
QA004: {
|
|
12530
|
+
path: "app/api/cron/cleanup/route.ts",
|
|
12531
|
+
language: "typescript",
|
|
12532
|
+
difference: 'The secret is read once and the handler refuses to run without it, so an unset variable can no longer make the comparison succeed against "Bearer undefined".',
|
|
12533
|
+
vulnerable: `export async function GET(req) {
|
|
12534
|
+
const auth = req.headers.get("authorization");
|
|
12535
|
+
if (auth !== \`Bearer \${process.env.CRON_SECRET}\`) {
|
|
12536
|
+
return new Response("Unauthorized", { status: 401 });
|
|
12537
|
+
}
|
|
12538
|
+
await purgeExpiredRows();
|
|
12539
|
+
return new Response("ok");
|
|
12540
|
+
}`,
|
|
12541
|
+
safe: `export async function GET(req) {
|
|
12542
|
+
const secret = process.env.CRON_SECRET;
|
|
12543
|
+
if (!secret) throw new Error("CRON_SECRET is not set");
|
|
12544
|
+
const auth = req.headers.get("authorization");
|
|
12545
|
+
if (auth !== \`Bearer \${secret}\`) {
|
|
12546
|
+
return new Response("Unauthorized", { status: 401 });
|
|
12547
|
+
}
|
|
12548
|
+
await purgeExpiredRows();
|
|
12549
|
+
return new Response("ok");
|
|
12550
|
+
}`
|
|
12551
|
+
},
|
|
12552
|
+
QA005: {
|
|
12553
|
+
path: "app/components/SortableTable.tsx",
|
|
12554
|
+
language: "tsx",
|
|
12555
|
+
difference: "The handler moves onto a real button, which the browser makes focusable, Enter- and Space-activatable, and announces as a control.",
|
|
12556
|
+
vulnerable: `export function SortableTable({ rows, onSort }) {
|
|
12557
|
+
return (
|
|
12558
|
+
<table>
|
|
12559
|
+
<thead>
|
|
12560
|
+
<tr>
|
|
12561
|
+
<th className="cursor-pointer select-none" onClick={() => onSort("name")}>
|
|
12562
|
+
Name
|
|
12563
|
+
</th>
|
|
12564
|
+
</tr>
|
|
12565
|
+
</thead>
|
|
12566
|
+
</table>
|
|
12567
|
+
);
|
|
12568
|
+
}`,
|
|
12569
|
+
safe: `export function SortableTable({ rows, onSort }) {
|
|
12570
|
+
return (
|
|
12571
|
+
<table>
|
|
12572
|
+
<thead>
|
|
12573
|
+
<tr>
|
|
12574
|
+
<th>
|
|
12575
|
+
<button type="button" className="cursor-pointer select-none" onClick={() => onSort("name")}>
|
|
12576
|
+
Name
|
|
12577
|
+
</button>
|
|
12578
|
+
</th>
|
|
12579
|
+
</tr>
|
|
12580
|
+
</thead>
|
|
12581
|
+
</table>
|
|
12582
|
+
);
|
|
12583
|
+
}`
|
|
12584
|
+
},
|
|
12585
|
+
QA006: {
|
|
12586
|
+
path: "app/components/ConfirmDialog.tsx",
|
|
12587
|
+
language: "tsx",
|
|
12588
|
+
difference: "The panel declares itself a modal dialog, takes focus when it opens and closes on Escape, so a screen reader announces it and a keyboard can reach and leave it.",
|
|
12589
|
+
vulnerable: `export function ConfirmDialog({ open, onClose, onConfirm }) {
|
|
12590
|
+
if (!open) return null;
|
|
12591
|
+
return (
|
|
12592
|
+
<div className="fixed inset-0 bg-black/50 flex items-center justify-center">
|
|
12593
|
+
<div className="bg-white rounded-xl p-6">
|
|
12594
|
+
<h2>Delete this project?</h2>
|
|
12595
|
+
<button onClick={onClose}>Cancel</button>
|
|
12596
|
+
<button onClick={onConfirm}>Delete</button>
|
|
12597
|
+
</div>
|
|
12598
|
+
</div>
|
|
12599
|
+
);
|
|
12600
|
+
}`,
|
|
12601
|
+
safe: `export function ConfirmDialog({ open, onClose, onConfirm }) {
|
|
12602
|
+
const ref = useRef(null);
|
|
12603
|
+
useEffect(() => {
|
|
12604
|
+
if (!open) return;
|
|
12605
|
+
ref.current?.focus();
|
|
12606
|
+
const onKey = (e) => { if (e.key === "Escape") onClose(); };
|
|
12607
|
+
document.addEventListener("keydown", onKey);
|
|
12608
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
12609
|
+
}, [open, onClose]);
|
|
12610
|
+
|
|
12611
|
+
if (!open) return null;
|
|
12612
|
+
return (
|
|
12613
|
+
<div className="fixed inset-0 bg-black/50 flex items-center justify-center">
|
|
12614
|
+
<div
|
|
12615
|
+
role="dialog"
|
|
12616
|
+
aria-modal="true"
|
|
12617
|
+
aria-labelledby="confirm-title"
|
|
12618
|
+
ref={ref}
|
|
12619
|
+
tabIndex={-1}
|
|
12620
|
+
className="bg-white rounded-xl p-6"
|
|
12621
|
+
>
|
|
12622
|
+
<h2 id="confirm-title">Delete this project?</h2>
|
|
12623
|
+
<button onClick={onClose}>Cancel</button>
|
|
12624
|
+
<button onClick={onConfirm}>Delete</button>
|
|
12625
|
+
</div>
|
|
12626
|
+
</div>
|
|
12627
|
+
);
|
|
12628
|
+
}`
|
|
12629
|
+
},
|
|
12630
|
+
QA007: {
|
|
12631
|
+
path: "app/api/orders/route.ts",
|
|
12632
|
+
language: "typescript",
|
|
12633
|
+
difference: "The query takes a bounded page, so one account with years of history cannot decide how much memory the request uses.",
|
|
12634
|
+
vulnerable: `export async function GET(req) {
|
|
12635
|
+
const userId = await requireUser(req);
|
|
12636
|
+
const orders = await prisma.order.findMany({ where: { userId } });
|
|
12637
|
+
return Response.json({ orders });
|
|
12638
|
+
}`,
|
|
12639
|
+
safe: `export async function GET(req) {
|
|
12640
|
+
const userId = await requireUser(req);
|
|
12641
|
+
const orders = await prisma.order.findMany({ where: { userId }, take: 50 });
|
|
12642
|
+
return Response.json({ orders });
|
|
12643
|
+
}`
|
|
12644
|
+
},
|
|
12645
|
+
QA008: {
|
|
12646
|
+
path: "app/components/SignupForm.tsx",
|
|
12647
|
+
language: "tsx",
|
|
12648
|
+
difference: "The label points at the input, so a screen reader reads the field's name and clicking the text focuses the field.",
|
|
12649
|
+
vulnerable: `export function SignupForm() {
|
|
12650
|
+
return (
|
|
12651
|
+
<form>
|
|
12652
|
+
<label>Email address</label>
|
|
12653
|
+
<input type="email" name="email" />
|
|
12654
|
+
</form>
|
|
12655
|
+
);
|
|
12656
|
+
}`,
|
|
12657
|
+
safe: `export function SignupForm() {
|
|
12658
|
+
return (
|
|
12659
|
+
<form>
|
|
12660
|
+
<label htmlFor="email">Email address</label>
|
|
12661
|
+
<input id="email" type="email" name="email" />
|
|
12662
|
+
</form>
|
|
12663
|
+
);
|
|
12664
|
+
}`
|
|
12665
|
+
}
|
|
12666
|
+
};
|
|
12667
|
+
|
|
12299
12668
|
// src/quality/index.ts
|
|
12300
12669
|
var qualityRules = [
|
|
12301
12670
|
silentFailedRead,
|
|
@@ -12305,7 +12674,8 @@ var qualityRules = [
|
|
|
12305
12674
|
mouseOnlyControl,
|
|
12306
12675
|
undeclaredModal,
|
|
12307
12676
|
unboundedList,
|
|
12308
|
-
unassociatedLabel
|
|
12677
|
+
unassociatedLabel,
|
|
12678
|
+
failedReadEmptyState
|
|
12309
12679
|
];
|
|
12310
12680
|
function scanQuality(files, rules = qualityRules) {
|
|
12311
12681
|
const ctx = buildQualityContext(files);
|
|
@@ -12351,6 +12721,7 @@ export {
|
|
|
12351
12721
|
MODEL_TRIAGE,
|
|
12352
12722
|
NON_APP_PATH_PATTERNS,
|
|
12353
12723
|
PRO_RULE_COUNT,
|
|
12724
|
+
QUALITY_EXAMPLES,
|
|
12354
12725
|
RULE_IMPACTS,
|
|
12355
12726
|
TEST_FILE_PATTERN,
|
|
12356
12727
|
TOTAL_RULE_COUNT,
|