xploitscan-shared-rules 1.35.2 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1342,6 +1342,19 @@ declare function buildQualityContext(files: {
1342
1342
  path: string;
1343
1343
  content: string;
1344
1344
  }[]): QualityContext;
1345
+ /** Line number for a byte offset, 1-based. Offsets survive maskComments. */
1346
+ /**
1347
+ * The gate a client-side rule applies before it looks at a file, named once.
1348
+ *
1349
+ * Four rules spelled these three conditions out, and the measurement harness
1350
+ * made a fifth copy that dropped `!isServer` — so `src/api/hooks/useThing.ts`
1351
+ * counted toward a denominator no client rule would ever run on, and counted
1352
+ * again on the server side. A denominator that does not match its numerator is
1353
+ * the one thing that harness exists not to produce.
1354
+ */
1355
+ declare function isClientTarget(file: QualityFile): boolean;
1356
+ /** The server-side counterpart. */
1357
+ declare function isServerTarget(file: QualityFile): boolean;
1345
1358
 
1346
1359
  /**
1347
1360
  * Worked examples for the quality catalogue, one vulnerable/safe pair per rule.
@@ -1403,18 +1416,18 @@ declare const unmeasuredQualityRules: QualityRule[];
1403
1416
  * Parallel to scanEntropy and scanDependencies: an engine, not a rule, because
1404
1417
  * most of these need more than the single file the rule contract allows.
1405
1418
  */
1406
- declare function scanQuality(files: {
1407
- path: string;
1408
- content: string;
1409
- }[], rules?: QualityRule[],
1419
+ declare function scanQuality(
1410
1420
  /**
1411
- * A context already built for these files. Building one parses every file
1412
- * into a Babel AST and holds them all at once, so a caller that needs the
1413
- * context for its own reasons — the measurement harness counts how many
1414
- * files each rule class applies to — would otherwise pay for two of them
1415
- * side by side. The AST cache is an LRU of 256 and the harness runs 1,200
1416
- * files per repository, so nothing is reused between the two passes.
1421
+ * The files to scan, or a context already built for them. Building one
1422
+ * parses every file into a Babel AST and holds them all at once, so a caller
1423
+ * that needs the context for its own reasons — the measurement harness counts
1424
+ * how many files each rule class applies to — should hand it over rather than
1425
+ * pay for a second one. Taking either here, instead of a third parameter,
1426
+ * means there is no pair of arguments that can disagree.
1417
1427
  */
1418
- prebuilt?: QualityContext): Finding[];
1428
+ input: {
1429
+ path: string;
1430
+ content: string;
1431
+ }[] | QualityContext, rules?: QualityRule[]): Finding[];
1419
1432
 
1420
- 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, buildQualityContext, 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, unmeasuredQualityRules, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, vendoredReason, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
1433
+ 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, buildQualityContext, 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, isClientTarget, isMethodCall, isPrivateAddress, isServerTarget, 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, unmeasuredQualityRules, 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
@@ -1342,6 +1342,19 @@ declare function buildQualityContext(files: {
1342
1342
  path: string;
1343
1343
  content: string;
1344
1344
  }[]): QualityContext;
1345
+ /** Line number for a byte offset, 1-based. Offsets survive maskComments. */
1346
+ /**
1347
+ * The gate a client-side rule applies before it looks at a file, named once.
1348
+ *
1349
+ * Four rules spelled these three conditions out, and the measurement harness
1350
+ * made a fifth copy that dropped `!isServer` — so `src/api/hooks/useThing.ts`
1351
+ * counted toward a denominator no client rule would ever run on, and counted
1352
+ * again on the server side. A denominator that does not match its numerator is
1353
+ * the one thing that harness exists not to produce.
1354
+ */
1355
+ declare function isClientTarget(file: QualityFile): boolean;
1356
+ /** The server-side counterpart. */
1357
+ declare function isServerTarget(file: QualityFile): boolean;
1345
1358
 
1346
1359
  /**
1347
1360
  * Worked examples for the quality catalogue, one vulnerable/safe pair per rule.
@@ -1403,18 +1416,18 @@ declare const unmeasuredQualityRules: QualityRule[];
1403
1416
  * Parallel to scanEntropy and scanDependencies: an engine, not a rule, because
1404
1417
  * most of these need more than the single file the rule contract allows.
1405
1418
  */
1406
- declare function scanQuality(files: {
1407
- path: string;
1408
- content: string;
1409
- }[], rules?: QualityRule[],
1419
+ declare function scanQuality(
1410
1420
  /**
1411
- * A context already built for these files. Building one parses every file
1412
- * into a Babel AST and holds them all at once, so a caller that needs the
1413
- * context for its own reasons — the measurement harness counts how many
1414
- * files each rule class applies to — would otherwise pay for two of them
1415
- * side by side. The AST cache is an LRU of 256 and the harness runs 1,200
1416
- * files per repository, so nothing is reused between the two passes.
1421
+ * The files to scan, or a context already built for them. Building one
1422
+ * parses every file into a Babel AST and holds them all at once, so a caller
1423
+ * that needs the context for its own reasons — the measurement harness counts
1424
+ * how many files each rule class applies to — should hand it over rather than
1425
+ * pay for a second one. Taking either here, instead of a third parameter,
1426
+ * means there is no pair of arguments that can disagree.
1417
1427
  */
1418
- prebuilt?: QualityContext): Finding[];
1428
+ input: {
1429
+ path: string;
1430
+ content: string;
1431
+ }[] | QualityContext, rules?: QualityRule[]): Finding[];
1419
1432
 
1420
- 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, buildQualityContext, 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, unmeasuredQualityRules, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, vendoredReason, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
1433
+ 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, buildQualityContext, 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, isClientTarget, isMethodCall, isPrivateAddress, isServerTarget, 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, unmeasuredQualityRules, 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
@@ -10105,6 +10105,12 @@ function buildQualityContext(files) {
10105
10105
  });
10106
10106
  return { files: built, byPath: new Map(built.map((f) => [f.path, f])) };
10107
10107
  }
10108
+ function isClientTarget(file) {
10109
+ return !file.excluded && file.isClient && !file.isServer;
10110
+ }
10111
+ function isServerTarget(file) {
10112
+ return !file.excluded && file.isServer;
10113
+ }
10108
10114
  function lineAt(content, index) {
10109
10115
  let line = 1;
10110
10116
  for (let i = 0; i < index && i < content.length; i++) {
@@ -12319,6 +12325,55 @@ var unassociatedLabel = {
12319
12325
 
12320
12326
  // src/quality/rules/failed-read-empty-state.ts
12321
12327
  import _traverse4 from "@babel/traverse";
12328
+ import { getBindingIdentifiers } from "@babel/types";
12329
+
12330
+ // src/quality/rules/scope.ts
12331
+ function unwrap(node) {
12332
+ let cur = node;
12333
+ while (cur.type === "TSAsExpression" || cur.type === "TSNonNullExpression" || cur.type === "TSTypeAssertion" || cur.type === "TSSatisfiesExpression") {
12334
+ cur = cur.expression;
12335
+ }
12336
+ return cur;
12337
+ }
12338
+ function calleeName3(node) {
12339
+ if (node.type !== "CallExpression" && node.type !== "OptionalCallExpression") return null;
12340
+ const c = node.callee;
12341
+ if (c.type === "Identifier") return c.name;
12342
+ if ((c.type === "MemberExpression" || c.type === "OptionalMemberExpression") && c.property.type === "Identifier") {
12343
+ return c.property.name;
12344
+ }
12345
+ return null;
12346
+ }
12347
+ function useStateBinding(at, name) {
12348
+ const binding = at.scope.getBinding(name);
12349
+ if (!binding) return void 0;
12350
+ const decl = binding.path;
12351
+ if (!decl.isVariableDeclarator()) return void 0;
12352
+ const id = decl.node.id;
12353
+ const init = decl.node.init;
12354
+ if (id.type !== "ArrayPattern") return void 0;
12355
+ if (!init || calleeName3(init) !== "useState") return void 0;
12356
+ const first = id.elements[0];
12357
+ if (!first || first.type !== "Identifier" || first.name !== name) return void 0;
12358
+ const second = id.elements[1];
12359
+ return {
12360
+ initial: init.arguments[0],
12361
+ setter: second && second.type === "Identifier" ? second.name : null,
12362
+ decl
12363
+ };
12364
+ }
12365
+ function isEmptyInitial(node) {
12366
+ if (!node) return false;
12367
+ if (node.type === "ArrayExpression") return node.elements.length === 0;
12368
+ if (node.type === "ObjectExpression") return node.properties.length === 0;
12369
+ if (node.type === "StringLiteral") return node.value === "";
12370
+ if (node.type === "TemplateLiteral") {
12371
+ return node.quasis.length === 1 && node.quasis[0].value.raw === "";
12372
+ }
12373
+ return false;
12374
+ }
12375
+
12376
+ // src/quality/rules/failed-read-empty-state.ts
12322
12377
  var traverse4 = typeof _traverse4 === "function" ? _traverse4 : _traverse4.default;
12323
12378
  var READ_ERROR_PATH_SIGNALS = ERROR_PATH_SIGNALS.filter(
12324
12379
  (re) => re.source !== /\.catch\s*\(/.source
@@ -12336,19 +12391,15 @@ function setterName(callee) {
12336
12391
  function isPropertyRead(node) {
12337
12392
  return node.type === "MemberExpression" || node.type === "OptionalMemberExpression";
12338
12393
  }
12339
- function unwrap(node) {
12340
- let cur = node;
12341
- while (cur && (cur.type === "TSAsExpression" || cur.type === "TSNonNullExpression" || cur.type === "TSTypeAssertion" || cur.type === "TSSatisfiesExpression" || cur.type === "ParenthesizedExpression")) {
12342
- cur = cur.expression;
12343
- }
12344
- return cur;
12394
+ function mentionsJsonParse(node, code) {
12395
+ return /\.json\s*\(/.test(code.slice(nodeStart(node), nodeEnd(node)));
12345
12396
  }
12346
12397
  function chainParsesBody(node, code) {
12347
12398
  let cur = unwrap(node);
12348
- while (cur) {
12399
+ for (; ; ) {
12349
12400
  if (cur.type === "CallExpression" || cur.type === "OptionalCallExpression") {
12350
12401
  const callee = unwrap(cur.callee);
12351
- if (callee && (callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") && callee.property.type === "Identifier") {
12402
+ if ((callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") && callee.property.type === "Identifier") {
12352
12403
  const method = callee.property.name;
12353
12404
  if (method === "json") return true;
12354
12405
  if (method === "then" || method === "catch") {
@@ -12360,7 +12411,7 @@ function chainParsesBody(node, code) {
12360
12411
  cur = unwrap(callee.object);
12361
12412
  continue;
12362
12413
  }
12363
- cur = unwrap(cur.callee);
12414
+ cur = callee;
12364
12415
  continue;
12365
12416
  }
12366
12417
  if (cur.type === "MemberExpression" || cur.type === "OptionalMemberExpression") {
@@ -12372,23 +12423,14 @@ function chainParsesBody(node, code) {
12372
12423
  return false;
12373
12424
  }
12374
12425
  function boundNames(id, into) {
12375
- if (id.type === "Identifier") {
12376
- into.add(id.name);
12377
- return;
12378
- }
12379
- if (id.type === "ObjectPattern") {
12380
- for (const prop of id.properties) {
12381
- if (prop.type === "ObjectProperty") boundNames(prop.value, into);
12382
- else if (prop.type === "RestElement") boundNames(prop.argument, into);
12383
- }
12384
- }
12426
+ for (const name of Object.keys(getBindingIdentifiers(id))) into.add(name);
12385
12427
  }
12386
12428
  function parsedBodyBindings(unit, code) {
12387
12429
  const names = /* @__PURE__ */ new Set();
12388
12430
  const record = (id, init) => {
12389
- if (!id) return;
12431
+ if (!id || !init) return;
12390
12432
  const awaited = unwrap(init);
12391
- if (!awaited || awaited.type !== "AwaitExpression") return;
12433
+ if (awaited.type !== "AwaitExpression") return;
12392
12434
  if (!chainParsesBody(awaited.argument, code)) return;
12393
12435
  boundNames(id, names);
12394
12436
  };
@@ -12412,7 +12454,7 @@ function parsedBodyBindings(unit, code) {
12412
12454
  return;
12413
12455
  if (callee.property.type !== "Identifier" || callee.property.name !== "then") return;
12414
12456
  const receiver = callee.object;
12415
- if (!/\.json\s*\(/.test(code.slice(nodeStart(receiver), nodeEnd(receiver)))) return;
12457
+ if (!mentionsJsonParse(receiver, code)) return;
12416
12458
  const cb = call.node.arguments[0];
12417
12459
  if (!cb) return;
12418
12460
  if (cb.type !== "ArrowFunctionExpression" && cb.type !== "FunctionExpression") return;
@@ -12427,13 +12469,9 @@ function derivesFromParsedBody(node, bodies, code) {
12427
12469
  while (cur && (cur.type === "MemberExpression" || cur.type === "OptionalMemberExpression")) {
12428
12470
  cur = unwrap(cur.object);
12429
12471
  }
12430
- if (!cur) return false;
12431
12472
  if (cur.type === "Identifier") return bodies.has(cur.name);
12432
- if (cur.type === "AwaitExpression") return chainParsesBody(cur.argument, code);
12433
- if (cur.type === "CallExpression" || cur.type === "OptionalCallExpression") {
12434
- return chainParsesBody(cur, code);
12435
- }
12436
- return false;
12473
+ if (cur.type === "AwaitExpression") cur = unwrap(cur.argument);
12474
+ return chainParsesBody(cur, code);
12437
12475
  }
12438
12476
  function emptyFallbackArgument(node) {
12439
12477
  if (node.type !== "LogicalExpression") return null;
@@ -12483,6 +12521,7 @@ var failedReadEmptyState = {
12483
12521
  if (!file.isClient) continue;
12484
12522
  if (file.isServer) continue;
12485
12523
  if (/^\s*["']use server["']/m.test(file.code)) continue;
12524
+ if (!file.code.includes("fetch")) continue;
12486
12525
  const parsed = file.parsed;
12487
12526
  if (!parsed) continue;
12488
12527
  const examined = /* @__PURE__ */ new Set();
@@ -12528,6 +12567,20 @@ var failedReadEmptyState = {
12528
12567
  // src/quality/rules/autosave-armed-by-failed-load.ts
12529
12568
  import _traverse5 from "@babel/traverse";
12530
12569
  var traverse5 = typeof _traverse5 === "function" ? _traverse5 : _traverse5.default;
12570
+ function writerTouchesEmptyState(writers) {
12571
+ for (const writer of writers) {
12572
+ let found = false;
12573
+ writer.traverse({
12574
+ Identifier(id) {
12575
+ if (found) return;
12576
+ if (!id.isReferencedIdentifier()) return;
12577
+ if (isEmptyInitial(useStateBinding(id, id.node.name)?.initial)) found = true;
12578
+ }
12579
+ });
12580
+ if (found) return true;
12581
+ }
12582
+ return false;
12583
+ }
12531
12584
  var PERSISTENT_WRITE = /\bfetch\s*\([^)]{0,400}?method\s*:\s*["'`](?:POST|PUT|PATCH)["'`]|\blocalStorage\s*\.\s*setItem\s*\(|\bsessionStorage\s*\.\s*setItem\s*\(/is;
12532
12585
  var EMPTY_INITIAL = /\buseState\s*(?:<[^>]*>)?\s*\(\s*(?:\[\s*\]|\{\s*\}|""|''|``)\s*\)/;
12533
12586
  function calleeIdentifier(node) {
@@ -12541,22 +12594,6 @@ function isEffectCall2(node) {
12541
12594
  const name = calleeIdentifier(node);
12542
12595
  return name === "useEffect" || name === "useLayoutEffect";
12543
12596
  }
12544
- function initialFor(call, state) {
12545
- const binding = call.scope.getBinding(state);
12546
- if (!binding) return void 0;
12547
- const decl = binding.path;
12548
- if (!decl.isVariableDeclarator()) return void 0;
12549
- const id = decl.node.id;
12550
- const init = decl.node.init;
12551
- if (!id || id.type !== "ArrayPattern") return void 0;
12552
- if (!init || init.type !== "CallExpression") return void 0;
12553
- const callee = init.callee;
12554
- const name = callee.type === "Identifier" ? callee.name : callee.type === "MemberExpression" && callee.property.type === "Identifier" ? callee.property.name : null;
12555
- if (name !== "useState") return void 0;
12556
- const first = id.elements[0];
12557
- if (!first || first.type !== "Identifier" || first.name !== state) return void 0;
12558
- return init.arguments[0];
12559
- }
12560
12597
  function sameLiteral(a, b) {
12561
12598
  if (!a || !b || a.type !== b.type) return false;
12562
12599
  switch (a.type) {
@@ -12604,9 +12641,7 @@ var autosaveArmedByFailedLoad = {
12604
12641
  check(ctx) {
12605
12642
  const hits = [];
12606
12643
  for (const file of ctx.files) {
12607
- if (file.excluded) continue;
12608
- if (!file.isClient) continue;
12609
- if (file.isServer) continue;
12644
+ if (!isClientTarget(file)) continue;
12610
12645
  const parsed = file.parsed;
12611
12646
  if (!parsed) continue;
12612
12647
  if (!EMPTY_INITIAL.test(file.code)) continue;
@@ -12621,29 +12656,32 @@ var autosaveArmedByFailedLoad = {
12621
12656
  if (!name) return;
12622
12657
  const state = stateFromSetter(name);
12623
12658
  if (!state) return;
12624
- if (setsBackToInitial(call.node, initialFor(call, state))) return;
12659
+ if (setsBackToInitial(call.node, useStateBinding(call, state)?.initial)) return;
12625
12660
  armedInFinally.set(state, nodeStart(call.node));
12626
12661
  }
12627
12662
  });
12628
12663
  }
12629
12664
  });
12630
12665
  if (armedInFinally.size === 0) continue;
12631
- const writingFunctions = /* @__PURE__ */ new Set();
12666
+ const writingFunctions = /* @__PURE__ */ new Map();
12632
12667
  traverse5(parsed.ast, {
12633
12668
  Function(path) {
12634
12669
  const src = file.code.slice(nodeStart(path.node), nodeEnd(path.node));
12635
12670
  if (!PERSISTENT_WRITE.test(src)) return;
12671
+ const deps = [];
12636
12672
  let owner = path.parentPath;
12637
12673
  for (let hops = 0; owner && hops < 3; hops++, owner = owner.parentPath) {
12638
12674
  const node = owner.node;
12639
12675
  if (node.type === "VariableDeclarator" && node.id.type === "Identifier") {
12640
- writingFunctions.add(node.id.name);
12676
+ writingFunctions.set(node.id.name, [path, ...deps]);
12641
12677
  break;
12642
12678
  }
12643
12679
  if (node.type !== "CallExpression") break;
12680
+ const depArg = owner.get("arguments.1");
12681
+ if (depArg && depArg.node) deps.push(depArg);
12644
12682
  }
12645
12683
  const n = path.node;
12646
- if (n.id && n.id.name) writingFunctions.add(n.id.name);
12684
+ if (n.id && n.id.name) writingFunctions.set(n.id.name, [path, ...deps]);
12647
12685
  }
12648
12686
  });
12649
12687
  const reported = /* @__PURE__ */ new Set();
@@ -12655,8 +12693,15 @@ var autosaveArmedByFailedLoad = {
12655
12693
  const body = file.code.slice(nodeStart(cb.node), nodeEnd(cb.node));
12656
12694
  const names = identifiersIn(cb);
12657
12695
  const writesDirectly = PERSISTENT_WRITE.test(body);
12658
- const writesViaCallback = [...writingFunctions].some((fn) => names.has(fn));
12659
- if (!writesDirectly && !writesViaCallback) return;
12696
+ const calledWriters = [...writingFunctions.entries()].filter(([fn]) => names.has(fn)).flatMap(([, paths]) => paths);
12697
+ if (!writesDirectly && calledWriters.length === 0) return;
12698
+ const effectDeps = path.get("arguments.1");
12699
+ const writers = [
12700
+ ...writesDirectly ? [cb] : [],
12701
+ ...calledWriters,
12702
+ ...effectDeps && effectDeps.node ? [effectDeps] : []
12703
+ ];
12704
+ if (!writerTouchesEmptyState(writers)) return;
12660
12705
  for (const [state, armLine] of armedInFinally) {
12661
12706
  if (!names.has(state)) continue;
12662
12707
  if (reported.has(state)) continue;
@@ -12683,7 +12728,7 @@ var DURABLE_WRITE = /\b(?:INSERT\s+INTO\b|UPDATE\s+\w+\s+SET\b|DELETE\s+FROM\b)|
12683
12728
  var EXTERNAL_MUTATION = /\b\w+\s*\.\s*\w+\s*\.\s*(?:create|send|update|delete|cancel|charge|capture|refund)\s*\(|\bfetch\s*\([^)]{0,300}?method\s*:\s*["'`](?:POST|PUT|PATCH|DELETE)["'`]/is;
12684
12729
  var BOOKKEEPING = /analytics|telemetry|track|metric|event|beacon|log|audit|ping/i;
12685
12730
  var DIRECT_ENV_TEST = /\bprocess\s*\.\s*env\b|\bDeno\s*\.\s*env\s*\.\s*get\s*\(/;
12686
- function calleeName3(node) {
12731
+ function calleeName4(node) {
12687
12732
  if (node.type !== "CallExpression") return null;
12688
12733
  const c = node.callee;
12689
12734
  if (c.type === "Identifier") return c.name;
@@ -12705,11 +12750,11 @@ function successPayloadShape(ret, source, offset) {
12705
12750
  if (!arg || arg.type !== "CallExpression") return null;
12706
12751
  const text = source.slice(nodeStart(ret) - offset, nodeEnd(ret) - offset);
12707
12752
  if (/status\s*:\s*[45]\d\d|,\s*\{\s*status\s*:\s*[45]\d\d/.test(text)) return null;
12708
- const name = calleeName3(arg);
12753
+ const name = calleeName4(arg);
12709
12754
  if (name !== "json" && name !== "Response" && name !== "NextResponse") return null;
12710
12755
  const first = arg.arguments[0];
12711
12756
  if (!first) return null;
12712
- if (first.type === "CallExpression" && calleeName3(first) === "stringify") {
12757
+ if (first.type === "CallExpression" && calleeName4(first) === "stringify") {
12713
12758
  return keyShape(first.arguments[0]);
12714
12759
  }
12715
12760
  return keyShape(first);
@@ -12889,9 +12934,7 @@ var staleResponseWins = {
12889
12934
  check(ctx) {
12890
12935
  const hits = [];
12891
12936
  for (const file of ctx.files) {
12892
- if (file.excluded) continue;
12893
- if (!file.isClient) continue;
12894
- if (file.isServer) continue;
12937
+ if (!isClientTarget(file)) continue;
12895
12938
  const parsed = file.parsed;
12896
12939
  if (!parsed) continue;
12897
12940
  traverse7(parsed.ast, {
@@ -12936,7 +12979,10 @@ var staleResponseWins = {
12936
12979
  for (const ident2 of interpolated) {
12937
12980
  if (!derivesFromDep(ident2, deps, cb, file.code)) continue;
12938
12981
  if (new RegExp(`\\b${ident2}\\b`).test(afterCall)) continue;
12939
- if (![...deps].some((d) => userDriven(d, file.code))) continue;
12982
+ const driving = [...deps].filter(
12983
+ (d) => derivesFromDep(ident2, /* @__PURE__ */ new Set([d]), cb, file.code)
12984
+ );
12985
+ if (!driving.some((d) => userDriven(d, cb))) continue;
12940
12986
  hit = { line: lineAt(file.content, nodeStart(inner.node)), ident: ident2 };
12941
12987
  return;
12942
12988
  }
@@ -12955,10 +13001,26 @@ var staleResponseWins = {
12955
13001
  return hits;
12956
13002
  }
12957
13003
  };
12958
- function userDriven(dep, code) {
12959
- const setter = `set${dep.charAt(0).toUpperCase()}${dep.slice(1)}`;
12960
- if (!new RegExp(`\\[\\s*${dep}\\s*,\\s*${setter}\\s*\\]\\s*=\\s*useState`).test(code)) return false;
12961
- return new RegExp(`on(?:Change|Click|Input|Select)\\s*=\\s*\\{[^}]{0,200}\\b${setter}\\b`, "s").test(code);
13004
+ function userDriven(dep, at) {
13005
+ const binding = useStateBinding(at, dep);
13006
+ const setter = binding?.setter;
13007
+ if (!setter) return false;
13008
+ const owner = binding.decl.getFunctionParent() ?? binding.decl.scope.path;
13009
+ let wired = false;
13010
+ owner.traverse({
13011
+ JSXAttribute(attr) {
13012
+ if (wired) return;
13013
+ const name = attr.node.name;
13014
+ if (name.type !== "JSXIdentifier") return;
13015
+ if (!/^on(?:Change|Click|Input|Select)$/.test(name.name)) return;
13016
+ attr.traverse({
13017
+ Identifier(id) {
13018
+ if (id.node.name === setter) wired = true;
13019
+ }
13020
+ });
13021
+ }
13022
+ });
13023
+ return wired;
12962
13024
  }
12963
13025
 
12964
13026
  // src/quality/rules/lost-update-counter.ts
@@ -13479,8 +13541,8 @@ var qualityRules = [
13479
13541
  var unmeasuredQualityRules = [
13480
13542
  lostUpdateCounter
13481
13543
  ];
13482
- function scanQuality(files, rules = qualityRules, prebuilt) {
13483
- const ctx = prebuilt ?? buildQualityContext(files);
13544
+ function scanQuality(input, rules = qualityRules) {
13545
+ const ctx = Array.isArray(input) ? buildQualityContext(input) : input;
13484
13546
  const findings = [];
13485
13547
  for (const rule of rules) {
13486
13548
  let hits;
@@ -13664,8 +13726,10 @@ export {
13664
13726
  insecureWebSocket,
13665
13727
  ipcPathTraversal,
13666
13728
  isCalleeNamed,
13729
+ isClientTarget,
13667
13730
  isMethodCall,
13668
13731
  isPrivateAddress,
13732
+ isServerTarget,
13669
13733
  isVendoredFinding,
13670
13734
  isVendoredPath,
13671
13735
  javaDeserialization,