xploitscan-shared-rules 1.14.4 → 1.15.1
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 +130 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +155 -2
- package/dist/index.d.ts +155 -2
- package/dist/index.js +125 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -23,6 +23,17 @@ interface Finding {
|
|
|
23
23
|
source: "custom" | "semgrep" | "gitleaks" | "ai" | "dependency" | "entropy" | "config" | "multi-file";
|
|
24
24
|
owasp?: string;
|
|
25
25
|
cwe?: string;
|
|
26
|
+
/**
|
|
27
|
+
* True when the finding sits in vendored, generated, or documentation code
|
|
28
|
+
* rather than code the app author wrote (see `vendored.ts`). Such findings
|
|
29
|
+
* are still reported everywhere — they are only held out of
|
|
30
|
+
* `calculateGrade`.
|
|
31
|
+
*
|
|
32
|
+
* Advisory label for renderers. `calculateGrade` never reads it; it
|
|
33
|
+
* re-derives the classification from `file` so a finding cannot exempt
|
|
34
|
+
* itself by arriving with the flag already set.
|
|
35
|
+
*/
|
|
36
|
+
vendored?: boolean;
|
|
26
37
|
}
|
|
27
38
|
interface RuleMatch {
|
|
28
39
|
rule: string;
|
|
@@ -105,6 +116,130 @@ declare const RULE_IMPACTS: Record<string, string>;
|
|
|
105
116
|
type Exposure = "public" | "internal" | "unknown";
|
|
106
117
|
declare function classifyExposure(filePath: string): Exposure;
|
|
107
118
|
|
|
119
|
+
/**
|
|
120
|
+
* APP vs VENDORED path classification.
|
|
121
|
+
*
|
|
122
|
+
* ── Why this exists ────────────────────────────────────────────────────────
|
|
123
|
+
*
|
|
124
|
+
* A 20-repo field study (5 each from Lovable, v0, Bolt and Base44, scanned
|
|
125
|
+
* with the full rule set — 2,961 findings) found four rules firing
|
|
126
|
+
* overwhelmingly on code the app author never wrote:
|
|
127
|
+
*
|
|
128
|
+
* rule sev repos/20 findings vendored mean vendored%
|
|
129
|
+
* VC063 critical 16 20 14 83%
|
|
130
|
+
* VC017 medium 15 35 20 79%
|
|
131
|
+
* VC007 high 17 46 26 69%
|
|
132
|
+
* ENTROPY high 15 286 208 66%
|
|
133
|
+
*
|
|
134
|
+
* The tell is that the hits are byte-identical at identical line numbers
|
|
135
|
+
* across unrelated repos: `components/ui/chart.tsx:81`, `sidebar.tsx:87`.
|
|
136
|
+
* That is the signature of scaffold code, not of authored vulnerabilities.
|
|
137
|
+
* Every one of these builders copies shadcn/ui verbatim into the project
|
|
138
|
+
* (49–63 primitives per repo), and shadcn's `ChartStyle` legitimately writes
|
|
139
|
+
* CSS custom properties into a `<style dangerouslySetInnerHTML>`.
|
|
140
|
+
*
|
|
141
|
+
* A further 458 findings in the same sweep fired inside markdown — rules
|
|
142
|
+
* matching prose and example code in READMEs and docs.
|
|
143
|
+
*
|
|
144
|
+
* VC063 is the worst of these because it is `critical`, and `calculateGrade`
|
|
145
|
+
* caps a project at D for a single critical. It is also a free-tier rule, so
|
|
146
|
+
* a Lovable user's first contact with the product was an "F — critical XSS"
|
|
147
|
+
* on a library file they did not author.
|
|
148
|
+
*
|
|
149
|
+
* ── Why classification and not per-rule suppression ────────────────────────
|
|
150
|
+
*
|
|
151
|
+
* A per-rule fix for VC063 was written and reverted (2026-07-27): genuine
|
|
152
|
+
* shadcn `ChartStyle` *does* interpolate React props, so no file-local rule
|
|
153
|
+
* can stay silent on shadcn while still firing on a `<style>` whose `__html`
|
|
154
|
+
* comes from a prop. Every attempt to encode "this particular `<style>` is
|
|
155
|
+
* safe" ended up spoofable from inside the scanned file. The distinguishing
|
|
156
|
+
* fact is not in the code — it is *whose* code it is. So classify the file.
|
|
157
|
+
*
|
|
158
|
+
* ── What it does and does not do ───────────────────────────────────────────
|
|
159
|
+
*
|
|
160
|
+
* Vendored findings are still detected, still reported, and still shown. They
|
|
161
|
+
* are excluded from `calculateGrade` only, and every surface that shows a
|
|
162
|
+
* grade also shows how many findings were held out. Nothing is silently
|
|
163
|
+
* dropped — that distinction is the whole point.
|
|
164
|
+
*
|
|
165
|
+
* ── Trust model ────────────────────────────────────────────────────────────
|
|
166
|
+
*
|
|
167
|
+
* This is path-based, and the paths come from the repository being scanned —
|
|
168
|
+
* i.e. from the same person reading the report. It is the trust model the
|
|
169
|
+
* product already ships with `.xploitscanignore`: you can always tell a tool
|
|
170
|
+
* scanning your own code to ignore your own code. There is no external
|
|
171
|
+
* attacker in this model, because there is no third party whose grade you can
|
|
172
|
+
* influence by naming your own files.
|
|
173
|
+
*
|
|
174
|
+
* Two consequences are handled explicitly rather than assumed away:
|
|
175
|
+
*
|
|
176
|
+
* 1. A user who puts genuinely-authored code under `components/ui/` gets it
|
|
177
|
+
* held out of the grade. That is a real cost, accepted knowingly: the
|
|
178
|
+
* finding is still reported, and the held-out count is on-screen.
|
|
179
|
+
* 2. Because a grade can be published (Trust Pages), the held-out count
|
|
180
|
+
* travels with the grade everywhere the grade travels. A grade that
|
|
181
|
+
* excluded findings can never render as though it excluded none.
|
|
182
|
+
*
|
|
183
|
+
* The classifier itself resolves `.`/`..` before matching, so a path cannot
|
|
184
|
+
* claim a vendored prefix and then climb back out of it
|
|
185
|
+
* (`src/components/ui/../../server/auth.ts` classifies as app code).
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* Paths whose findings are not attributable to the code the app author wrote.
|
|
189
|
+
*
|
|
190
|
+
* gitignore-style patterns; see `globToRegExp` for the supported subset. The
|
|
191
|
+
* list is empirical, not guessed — it comes from the FP sweep described above.
|
|
192
|
+
*
|
|
193
|
+
* Four families:
|
|
194
|
+
*
|
|
195
|
+
* 1. VENDORED UI PRIMITIVES — shadcn/ui and friends, copied verbatim into the
|
|
196
|
+
* project by the builder. `components/ui/chart.tsx` and `sidebar.tsx` alone
|
|
197
|
+
* account for the VC063 / VC007 / VC017 clusters.
|
|
198
|
+
* 2. DOCUMENTATION — markdown and MDX. The sweep's 458 markdown findings were
|
|
199
|
+
* rules matching example code inside docs, not deployed code. Note this
|
|
200
|
+
* holdout does not weaken secret detection in markdown one way or the
|
|
201
|
+
* other: the secret rules already decline to run on `.md` (VC001 bails on
|
|
202
|
+
* `/\.(md|txt|rst|adoc)$/`, `secretRuleCheck` gates on SECRET_FILE_EXT, and
|
|
203
|
+
* the entropy scanner's SKIP_FILES covers `md`), so there is nothing here
|
|
204
|
+
* for the grade to hold out. Whether that's the right call for READMEs is a
|
|
205
|
+
* separate question from this one, and unchanged by it.
|
|
206
|
+
* 3. AGENT / EDITOR ARTIFACTS — committed AI-assistant scratch state. One repo
|
|
207
|
+
* in the sweep contributed 164 of the corpus's 286 entropy findings from a
|
|
208
|
+
* single committed LLM-benchmark result set under `.agent/skills/`.
|
|
209
|
+
* 4. EXPLICITLY THIRD-PARTY OR MACHINE-GENERATED TREES — the path names below
|
|
210
|
+
* only ever mean "not hand-written here".
|
|
211
|
+
*/
|
|
212
|
+
declare const NON_APP_PATH_PATTERNS: readonly string[];
|
|
213
|
+
/**
|
|
214
|
+
* Reduce a scanner-reported path to a repo-relative, dot-segment-free form.
|
|
215
|
+
*
|
|
216
|
+
* Resolving `.`/`..` *before* matching is load-bearing, not cosmetic: without
|
|
217
|
+
* it, `src/components/ui/../../server/auth.ts` would match the
|
|
218
|
+
* `components/ui/**` pattern while actually naming a file in `server/`.
|
|
219
|
+
* Windows separators and drive letters are normalised for the same reason.
|
|
220
|
+
*/
|
|
221
|
+
declare function normalizeScanPath(filePath: string): string;
|
|
222
|
+
/** True when a repo-relative path belongs to the vendored / non-app bucket. */
|
|
223
|
+
declare function isVendoredPath(filePath: string): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* True when a finding should be reported but held out of the grade.
|
|
226
|
+
*
|
|
227
|
+
* Derived from `finding.file` every time, on purpose. `Finding.vendored` is an
|
|
228
|
+
* advisory label for renderers; it is never the input to a scoring decision,
|
|
229
|
+
* so a finding object that arrives over the wire with `vendored: true` cannot
|
|
230
|
+
* talk `calculateGrade` out of counting it.
|
|
231
|
+
*/
|
|
232
|
+
declare function isVendoredFinding(finding: {
|
|
233
|
+
file?: string;
|
|
234
|
+
rule?: string;
|
|
235
|
+
category?: string;
|
|
236
|
+
}): boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Human-readable reason a path was held out, for tooltips and `--verbose`.
|
|
239
|
+
* Returns null for app code.
|
|
240
|
+
*/
|
|
241
|
+
declare function vendoredReason(filePath: string): string | null;
|
|
242
|
+
|
|
108
243
|
declare const hardcodedSecrets: CustomRule;
|
|
109
244
|
declare const exposedEnvFile: CustomRule;
|
|
110
245
|
declare const missingAuthMiddleware: CustomRule;
|
|
@@ -209,8 +344,26 @@ interface GradeResult {
|
|
|
209
344
|
grade: SecurityGrade;
|
|
210
345
|
score: number;
|
|
211
346
|
summary: string;
|
|
347
|
+
/**
|
|
348
|
+
* How many of the supplied findings were held out of the score because they
|
|
349
|
+
* sit in vendored / generated / documentation paths (see `vendored.ts`).
|
|
350
|
+
*
|
|
351
|
+
* Always present, and always reflected in `summary` when non-zero. Every
|
|
352
|
+
* surface that renders a grade must render this too: a grade that excluded
|
|
353
|
+
* findings may never be displayed as though it excluded none.
|
|
354
|
+
*/
|
|
355
|
+
ungraded: number;
|
|
356
|
+
}
|
|
357
|
+
interface GradeOptions {
|
|
358
|
+
/**
|
|
359
|
+
* Score vendored / generated / documentation findings as if they were app
|
|
360
|
+
* code — i.e. the pre-classification behaviour. Opt-out escape hatch for
|
|
361
|
+
* users who vendor code they consider their own responsibility. Exposed as
|
|
362
|
+
* `--grade-vendored` on the CLI.
|
|
363
|
+
*/
|
|
364
|
+
gradeVendored?: boolean;
|
|
212
365
|
}
|
|
213
|
-
declare function calculateGrade(findings: Finding[], _totalFiles: number): GradeResult;
|
|
366
|
+
declare function calculateGrade(findings: Finding[], _totalFiles: number, options?: GradeOptions): GradeResult;
|
|
214
367
|
declare const jwtAlgConfusion: CustomRule;
|
|
215
368
|
declare const regexDos: CustomRule;
|
|
216
369
|
declare const xxeVulnerability: CustomRule;
|
|
@@ -536,4 +689,4 @@ declare function getObjectProperty(node: ObjectExpression, key: string): {
|
|
|
536
689
|
/** Does this CallExpression spread an expression `matcher` returns true for? */
|
|
537
690
|
declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
|
|
538
691
|
|
|
539
|
-
export { type AIFilterResult, type Confidence, type CustomRule, type DetectedFramework, type Exposure, type FilteredFinding, type Finding, type GradeResult, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, type TaintMap, type VibePlatform, allCustomRules, allRules, androidDebuggable, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, detectFramework, detectPlatform, disabledTLSVerification, djangoDebug, dockerCopySensitive, dockerLatestTag, dockerRunAsRoot, dockerTooManyPorts, dockerfileADDInsteadOfCOPY, dockerfileMissingHealthcheck, dockerfileUnverifiedShellPipe, ecbModeEncryption, electronNavigationUnrestricted, emptyCatchBlock, envNotGitignored, evalUsage, eventListenerLeak, exposedAdminRoutes, exposedAuthSecret, exposedDBCredentials, exposedDatabaseStudio, exposedDebugMode, exposedDockerPorts, exposedEnvFile, exposedGitDir, exposedServerActions, exposedSourceMaps, exposedStackTraces, filterFalsePositives, firebaseClientConfig, flaskSecretKey, freeRules, getObjectProperty, getSnippet, ghaExpressionInjection, ghaPermissionsWriteAll, ghaPullRequestTargetCheckout, ghaThirdPartyActionWithSecrets, githubActionsInjection, graphqlCSRFDisabled, graphqlIntrospection, graphqlNoComplexityLimit, graphqlNoDepthLimit, hardcodedAlgoliaAdminKey, hardcodedAnthropicKey, hardcodedCloudflareToken, hardcodedCohereKey, hardcodedCreditCard, hardcodedDatadogKey, hardcodedDiscordToken, hardcodedEncryptionKey, hardcodedFastlyToken, hardcodedFireworksKey, hardcodedFlyToken, hardcodedGCPServiceAccount, hardcodedGitHubPAT, hardcodedGitLabToken, hardcodedGroqKey, hardcodedHighlightKey, hardcodedIPAllowlist, hardcodedIntercomToken, hardcodedJWTSecret, hardcodedLinearKey, hardcodedLogtailToken, hardcodedLoopsKey, hardcodedMailgunKey, hardcodedMistralKey, hardcodedNetlifyToken, hardcodedNotionKey, hardcodedOAuthSecret, hardcodedPineconeKey, hardcodedPlivoToken, hardcodedPostmarkKey, hardcodedQdrantKey, hardcodedRailwayToken, hardcodedReplicateKey, hardcodedResendKey, hardcodedSSN, hardcodedSecrets, hardcodedSendGridKey, hardcodedSentryAuthToken, hardcodedShopifyToken, hardcodedSlackToken, hardcodedSupabaseServiceRole, hardcodedTogetherKey, hardcodedTwilioKey, hardcodedVaultToken, hardcodedVercelToken, hardcodedWeaviateKey, hostHeaderRedirect, httpRequestSmuggling, insecureCookies, insecureDeepLink, insecureDeserialization, insecureDirectObjectReference, insecureElectronWindow, insecureFileUpload, insecureGRPC, insecureHTTPMethods, insecurePasswordReset, insecureRandomness, insecureWebSocket, ipcPathTraversal, isCalleeNamed, isMethodCall, javaDeserialization, jwtAlgConfusion, k8sNoResourceLimits, k8sPrivileged, k8sSecretNotEncrypted, lambdaWithoutVPC, largeBundleImport, llmCallNoMaxTokens, llmOutputAsHTML, llmOutputToSink, llmPromptInjection, llmSystemPromptInjection, logInjection, magicNumbers, massAssignment, middlewareMatcherExcludesApi, missingAIRateLimit, missingAuthMiddleware, missingAuthRateLimit, missingBruteForce, missingCSP, missingCSRF, missingCertPinning, missingCloudTrail, missingContentDisposition, missingDBEncryption, missingErrorBoundary, missingFileSizeLimits, missingHSTS, missingHTTPS, missingLockFile, missingOAuthState, missingPagination, missingRequestSizeLimit, missingRequestValidation, missingSRI, missingSecurityMeta, nPlusOneQuery, nextPublicSecret, noRateLimiting, nosqlInjection, openRedirectParams, overlyPermissiveIAM, parseFile, pathTraversal, pickleDeserialization, piiInLogs, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, runCustomRules, s3BucketNoEncryption, scanEntropy, secretInBundleConfig, secretInCLIArgument, secretInErrorResponse, secretInHTMLAttribute, secretInLLMPrompt, secretInURLParam, secretLoggedToConsole, secretsInCI, securityGroupAllInbound, sensitiveAsyncStorage, sensitiveLocalStorage, sensitiveURLParams, sessionFixation, sqlInjection, ssrfVulnerability, ssti, stripeWebhookUnprotected, supabaseAnonAdmin, supabaseNoRLS, syncFileOps, terraformStateExposed, timingAttack, todoLeftInCode, unencryptedPII, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
|
|
692
|
+
export { type AIFilterResult, type Confidence, type CustomRule, type DetectedFramework, type Exposure, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, NON_APP_PATH_PATTERNS, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, type TaintMap, type VibePlatform, allCustomRules, allRules, androidDebuggable, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, detectFramework, detectPlatform, disabledTLSVerification, djangoDebug, dockerCopySensitive, dockerLatestTag, dockerRunAsRoot, dockerTooManyPorts, dockerfileADDInsteadOfCOPY, dockerfileMissingHealthcheck, dockerfileUnverifiedShellPipe, ecbModeEncryption, electronNavigationUnrestricted, emptyCatchBlock, envNotGitignored, evalUsage, eventListenerLeak, exposedAdminRoutes, exposedAuthSecret, exposedDBCredentials, exposedDatabaseStudio, exposedDebugMode, exposedDockerPorts, exposedEnvFile, exposedGitDir, exposedServerActions, exposedSourceMaps, exposedStackTraces, filterFalsePositives, firebaseClientConfig, flaskSecretKey, freeRules, getObjectProperty, getSnippet, ghaExpressionInjection, ghaPermissionsWriteAll, ghaPullRequestTargetCheckout, ghaThirdPartyActionWithSecrets, githubActionsInjection, graphqlCSRFDisabled, graphqlIntrospection, graphqlNoComplexityLimit, graphqlNoDepthLimit, hardcodedAlgoliaAdminKey, hardcodedAnthropicKey, hardcodedCloudflareToken, hardcodedCohereKey, hardcodedCreditCard, hardcodedDatadogKey, hardcodedDiscordToken, hardcodedEncryptionKey, hardcodedFastlyToken, hardcodedFireworksKey, hardcodedFlyToken, hardcodedGCPServiceAccount, hardcodedGitHubPAT, hardcodedGitLabToken, hardcodedGroqKey, hardcodedHighlightKey, hardcodedIPAllowlist, hardcodedIntercomToken, hardcodedJWTSecret, hardcodedLinearKey, hardcodedLogtailToken, hardcodedLoopsKey, hardcodedMailgunKey, hardcodedMistralKey, hardcodedNetlifyToken, hardcodedNotionKey, hardcodedOAuthSecret, hardcodedPineconeKey, hardcodedPlivoToken, hardcodedPostmarkKey, hardcodedQdrantKey, hardcodedRailwayToken, hardcodedReplicateKey, hardcodedResendKey, hardcodedSSN, hardcodedSecrets, hardcodedSendGridKey, hardcodedSentryAuthToken, hardcodedShopifyToken, hardcodedSlackToken, hardcodedSupabaseServiceRole, hardcodedTogetherKey, hardcodedTwilioKey, hardcodedVaultToken, hardcodedVercelToken, hardcodedWeaviateKey, hostHeaderRedirect, httpRequestSmuggling, insecureCookies, insecureDeepLink, insecureDeserialization, insecureDirectObjectReference, insecureElectronWindow, insecureFileUpload, insecureGRPC, insecureHTTPMethods, insecurePasswordReset, insecureRandomness, insecureWebSocket, ipcPathTraversal, isCalleeNamed, isMethodCall, isVendoredFinding, isVendoredPath, javaDeserialization, jwtAlgConfusion, k8sNoResourceLimits, k8sPrivileged, k8sSecretNotEncrypted, lambdaWithoutVPC, largeBundleImport, llmCallNoMaxTokens, llmOutputAsHTML, llmOutputToSink, llmPromptInjection, llmSystemPromptInjection, logInjection, magicNumbers, massAssignment, middlewareMatcherExcludesApi, missingAIRateLimit, missingAuthMiddleware, missingAuthRateLimit, missingBruteForce, missingCSP, missingCSRF, missingCertPinning, missingCloudTrail, missingContentDisposition, missingDBEncryption, missingErrorBoundary, missingFileSizeLimits, missingHSTS, missingHTTPS, missingLockFile, missingOAuthState, missingPagination, missingRequestSizeLimit, missingRequestValidation, missingSRI, missingSecurityMeta, nPlusOneQuery, nextPublicSecret, noRateLimiting, normalizeScanPath, nosqlInjection, openRedirectParams, overlyPermissiveIAM, parseFile, pathTraversal, pickleDeserialization, piiInLogs, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, runCustomRules, s3BucketNoEncryption, scanEntropy, secretInBundleConfig, secretInCLIArgument, secretInErrorResponse, secretInHTMLAttribute, secretInLLMPrompt, secretInURLParam, secretLoggedToConsole, secretsInCI, securityGroupAllInbound, sensitiveAsyncStorage, sensitiveLocalStorage, sensitiveURLParams, sessionFixation, sqlInjection, ssrfVulnerability, ssti, stripeWebhookUnprotected, supabaseAnonAdmin, supabaseNoRLS, syncFileOps, terraformStateExposed, timingAttack, todoLeftInCode, unencryptedPII, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, vendoredReason, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,17 @@ interface Finding {
|
|
|
23
23
|
source: "custom" | "semgrep" | "gitleaks" | "ai" | "dependency" | "entropy" | "config" | "multi-file";
|
|
24
24
|
owasp?: string;
|
|
25
25
|
cwe?: string;
|
|
26
|
+
/**
|
|
27
|
+
* True when the finding sits in vendored, generated, or documentation code
|
|
28
|
+
* rather than code the app author wrote (see `vendored.ts`). Such findings
|
|
29
|
+
* are still reported everywhere — they are only held out of
|
|
30
|
+
* `calculateGrade`.
|
|
31
|
+
*
|
|
32
|
+
* Advisory label for renderers. `calculateGrade` never reads it; it
|
|
33
|
+
* re-derives the classification from `file` so a finding cannot exempt
|
|
34
|
+
* itself by arriving with the flag already set.
|
|
35
|
+
*/
|
|
36
|
+
vendored?: boolean;
|
|
26
37
|
}
|
|
27
38
|
interface RuleMatch {
|
|
28
39
|
rule: string;
|
|
@@ -105,6 +116,130 @@ declare const RULE_IMPACTS: Record<string, string>;
|
|
|
105
116
|
type Exposure = "public" | "internal" | "unknown";
|
|
106
117
|
declare function classifyExposure(filePath: string): Exposure;
|
|
107
118
|
|
|
119
|
+
/**
|
|
120
|
+
* APP vs VENDORED path classification.
|
|
121
|
+
*
|
|
122
|
+
* ── Why this exists ────────────────────────────────────────────────────────
|
|
123
|
+
*
|
|
124
|
+
* A 20-repo field study (5 each from Lovable, v0, Bolt and Base44, scanned
|
|
125
|
+
* with the full rule set — 2,961 findings) found four rules firing
|
|
126
|
+
* overwhelmingly on code the app author never wrote:
|
|
127
|
+
*
|
|
128
|
+
* rule sev repos/20 findings vendored mean vendored%
|
|
129
|
+
* VC063 critical 16 20 14 83%
|
|
130
|
+
* VC017 medium 15 35 20 79%
|
|
131
|
+
* VC007 high 17 46 26 69%
|
|
132
|
+
* ENTROPY high 15 286 208 66%
|
|
133
|
+
*
|
|
134
|
+
* The tell is that the hits are byte-identical at identical line numbers
|
|
135
|
+
* across unrelated repos: `components/ui/chart.tsx:81`, `sidebar.tsx:87`.
|
|
136
|
+
* That is the signature of scaffold code, not of authored vulnerabilities.
|
|
137
|
+
* Every one of these builders copies shadcn/ui verbatim into the project
|
|
138
|
+
* (49–63 primitives per repo), and shadcn's `ChartStyle` legitimately writes
|
|
139
|
+
* CSS custom properties into a `<style dangerouslySetInnerHTML>`.
|
|
140
|
+
*
|
|
141
|
+
* A further 458 findings in the same sweep fired inside markdown — rules
|
|
142
|
+
* matching prose and example code in READMEs and docs.
|
|
143
|
+
*
|
|
144
|
+
* VC063 is the worst of these because it is `critical`, and `calculateGrade`
|
|
145
|
+
* caps a project at D for a single critical. It is also a free-tier rule, so
|
|
146
|
+
* a Lovable user's first contact with the product was an "F — critical XSS"
|
|
147
|
+
* on a library file they did not author.
|
|
148
|
+
*
|
|
149
|
+
* ── Why classification and not per-rule suppression ────────────────────────
|
|
150
|
+
*
|
|
151
|
+
* A per-rule fix for VC063 was written and reverted (2026-07-27): genuine
|
|
152
|
+
* shadcn `ChartStyle` *does* interpolate React props, so no file-local rule
|
|
153
|
+
* can stay silent on shadcn while still firing on a `<style>` whose `__html`
|
|
154
|
+
* comes from a prop. Every attempt to encode "this particular `<style>` is
|
|
155
|
+
* safe" ended up spoofable from inside the scanned file. The distinguishing
|
|
156
|
+
* fact is not in the code — it is *whose* code it is. So classify the file.
|
|
157
|
+
*
|
|
158
|
+
* ── What it does and does not do ───────────────────────────────────────────
|
|
159
|
+
*
|
|
160
|
+
* Vendored findings are still detected, still reported, and still shown. They
|
|
161
|
+
* are excluded from `calculateGrade` only, and every surface that shows a
|
|
162
|
+
* grade also shows how many findings were held out. Nothing is silently
|
|
163
|
+
* dropped — that distinction is the whole point.
|
|
164
|
+
*
|
|
165
|
+
* ── Trust model ────────────────────────────────────────────────────────────
|
|
166
|
+
*
|
|
167
|
+
* This is path-based, and the paths come from the repository being scanned —
|
|
168
|
+
* i.e. from the same person reading the report. It is the trust model the
|
|
169
|
+
* product already ships with `.xploitscanignore`: you can always tell a tool
|
|
170
|
+
* scanning your own code to ignore your own code. There is no external
|
|
171
|
+
* attacker in this model, because there is no third party whose grade you can
|
|
172
|
+
* influence by naming your own files.
|
|
173
|
+
*
|
|
174
|
+
* Two consequences are handled explicitly rather than assumed away:
|
|
175
|
+
*
|
|
176
|
+
* 1. A user who puts genuinely-authored code under `components/ui/` gets it
|
|
177
|
+
* held out of the grade. That is a real cost, accepted knowingly: the
|
|
178
|
+
* finding is still reported, and the held-out count is on-screen.
|
|
179
|
+
* 2. Because a grade can be published (Trust Pages), the held-out count
|
|
180
|
+
* travels with the grade everywhere the grade travels. A grade that
|
|
181
|
+
* excluded findings can never render as though it excluded none.
|
|
182
|
+
*
|
|
183
|
+
* The classifier itself resolves `.`/`..` before matching, so a path cannot
|
|
184
|
+
* claim a vendored prefix and then climb back out of it
|
|
185
|
+
* (`src/components/ui/../../server/auth.ts` classifies as app code).
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* Paths whose findings are not attributable to the code the app author wrote.
|
|
189
|
+
*
|
|
190
|
+
* gitignore-style patterns; see `globToRegExp` for the supported subset. The
|
|
191
|
+
* list is empirical, not guessed — it comes from the FP sweep described above.
|
|
192
|
+
*
|
|
193
|
+
* Four families:
|
|
194
|
+
*
|
|
195
|
+
* 1. VENDORED UI PRIMITIVES — shadcn/ui and friends, copied verbatim into the
|
|
196
|
+
* project by the builder. `components/ui/chart.tsx` and `sidebar.tsx` alone
|
|
197
|
+
* account for the VC063 / VC007 / VC017 clusters.
|
|
198
|
+
* 2. DOCUMENTATION — markdown and MDX. The sweep's 458 markdown findings were
|
|
199
|
+
* rules matching example code inside docs, not deployed code. Note this
|
|
200
|
+
* holdout does not weaken secret detection in markdown one way or the
|
|
201
|
+
* other: the secret rules already decline to run on `.md` (VC001 bails on
|
|
202
|
+
* `/\.(md|txt|rst|adoc)$/`, `secretRuleCheck` gates on SECRET_FILE_EXT, and
|
|
203
|
+
* the entropy scanner's SKIP_FILES covers `md`), so there is nothing here
|
|
204
|
+
* for the grade to hold out. Whether that's the right call for READMEs is a
|
|
205
|
+
* separate question from this one, and unchanged by it.
|
|
206
|
+
* 3. AGENT / EDITOR ARTIFACTS — committed AI-assistant scratch state. One repo
|
|
207
|
+
* in the sweep contributed 164 of the corpus's 286 entropy findings from a
|
|
208
|
+
* single committed LLM-benchmark result set under `.agent/skills/`.
|
|
209
|
+
* 4. EXPLICITLY THIRD-PARTY OR MACHINE-GENERATED TREES — the path names below
|
|
210
|
+
* only ever mean "not hand-written here".
|
|
211
|
+
*/
|
|
212
|
+
declare const NON_APP_PATH_PATTERNS: readonly string[];
|
|
213
|
+
/**
|
|
214
|
+
* Reduce a scanner-reported path to a repo-relative, dot-segment-free form.
|
|
215
|
+
*
|
|
216
|
+
* Resolving `.`/`..` *before* matching is load-bearing, not cosmetic: without
|
|
217
|
+
* it, `src/components/ui/../../server/auth.ts` would match the
|
|
218
|
+
* `components/ui/**` pattern while actually naming a file in `server/`.
|
|
219
|
+
* Windows separators and drive letters are normalised for the same reason.
|
|
220
|
+
*/
|
|
221
|
+
declare function normalizeScanPath(filePath: string): string;
|
|
222
|
+
/** True when a repo-relative path belongs to the vendored / non-app bucket. */
|
|
223
|
+
declare function isVendoredPath(filePath: string): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* True when a finding should be reported but held out of the grade.
|
|
226
|
+
*
|
|
227
|
+
* Derived from `finding.file` every time, on purpose. `Finding.vendored` is an
|
|
228
|
+
* advisory label for renderers; it is never the input to a scoring decision,
|
|
229
|
+
* so a finding object that arrives over the wire with `vendored: true` cannot
|
|
230
|
+
* talk `calculateGrade` out of counting it.
|
|
231
|
+
*/
|
|
232
|
+
declare function isVendoredFinding(finding: {
|
|
233
|
+
file?: string;
|
|
234
|
+
rule?: string;
|
|
235
|
+
category?: string;
|
|
236
|
+
}): boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Human-readable reason a path was held out, for tooltips and `--verbose`.
|
|
239
|
+
* Returns null for app code.
|
|
240
|
+
*/
|
|
241
|
+
declare function vendoredReason(filePath: string): string | null;
|
|
242
|
+
|
|
108
243
|
declare const hardcodedSecrets: CustomRule;
|
|
109
244
|
declare const exposedEnvFile: CustomRule;
|
|
110
245
|
declare const missingAuthMiddleware: CustomRule;
|
|
@@ -209,8 +344,26 @@ interface GradeResult {
|
|
|
209
344
|
grade: SecurityGrade;
|
|
210
345
|
score: number;
|
|
211
346
|
summary: string;
|
|
347
|
+
/**
|
|
348
|
+
* How many of the supplied findings were held out of the score because they
|
|
349
|
+
* sit in vendored / generated / documentation paths (see `vendored.ts`).
|
|
350
|
+
*
|
|
351
|
+
* Always present, and always reflected in `summary` when non-zero. Every
|
|
352
|
+
* surface that renders a grade must render this too: a grade that excluded
|
|
353
|
+
* findings may never be displayed as though it excluded none.
|
|
354
|
+
*/
|
|
355
|
+
ungraded: number;
|
|
356
|
+
}
|
|
357
|
+
interface GradeOptions {
|
|
358
|
+
/**
|
|
359
|
+
* Score vendored / generated / documentation findings as if they were app
|
|
360
|
+
* code — i.e. the pre-classification behaviour. Opt-out escape hatch for
|
|
361
|
+
* users who vendor code they consider their own responsibility. Exposed as
|
|
362
|
+
* `--grade-vendored` on the CLI.
|
|
363
|
+
*/
|
|
364
|
+
gradeVendored?: boolean;
|
|
212
365
|
}
|
|
213
|
-
declare function calculateGrade(findings: Finding[], _totalFiles: number): GradeResult;
|
|
366
|
+
declare function calculateGrade(findings: Finding[], _totalFiles: number, options?: GradeOptions): GradeResult;
|
|
214
367
|
declare const jwtAlgConfusion: CustomRule;
|
|
215
368
|
declare const regexDos: CustomRule;
|
|
216
369
|
declare const xxeVulnerability: CustomRule;
|
|
@@ -536,4 +689,4 @@ declare function getObjectProperty(node: ObjectExpression, key: string): {
|
|
|
536
689
|
/** Does this CallExpression spread an expression `matcher` returns true for? */
|
|
537
690
|
declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
|
|
538
691
|
|
|
539
|
-
export { type AIFilterResult, type Confidence, type CustomRule, type DetectedFramework, type Exposure, type FilteredFinding, type Finding, type GradeResult, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, type TaintMap, type VibePlatform, allCustomRules, allRules, androidDebuggable, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, detectFramework, detectPlatform, disabledTLSVerification, djangoDebug, dockerCopySensitive, dockerLatestTag, dockerRunAsRoot, dockerTooManyPorts, dockerfileADDInsteadOfCOPY, dockerfileMissingHealthcheck, dockerfileUnverifiedShellPipe, ecbModeEncryption, electronNavigationUnrestricted, emptyCatchBlock, envNotGitignored, evalUsage, eventListenerLeak, exposedAdminRoutes, exposedAuthSecret, exposedDBCredentials, exposedDatabaseStudio, exposedDebugMode, exposedDockerPorts, exposedEnvFile, exposedGitDir, exposedServerActions, exposedSourceMaps, exposedStackTraces, filterFalsePositives, firebaseClientConfig, flaskSecretKey, freeRules, getObjectProperty, getSnippet, ghaExpressionInjection, ghaPermissionsWriteAll, ghaPullRequestTargetCheckout, ghaThirdPartyActionWithSecrets, githubActionsInjection, graphqlCSRFDisabled, graphqlIntrospection, graphqlNoComplexityLimit, graphqlNoDepthLimit, hardcodedAlgoliaAdminKey, hardcodedAnthropicKey, hardcodedCloudflareToken, hardcodedCohereKey, hardcodedCreditCard, hardcodedDatadogKey, hardcodedDiscordToken, hardcodedEncryptionKey, hardcodedFastlyToken, hardcodedFireworksKey, hardcodedFlyToken, hardcodedGCPServiceAccount, hardcodedGitHubPAT, hardcodedGitLabToken, hardcodedGroqKey, hardcodedHighlightKey, hardcodedIPAllowlist, hardcodedIntercomToken, hardcodedJWTSecret, hardcodedLinearKey, hardcodedLogtailToken, hardcodedLoopsKey, hardcodedMailgunKey, hardcodedMistralKey, hardcodedNetlifyToken, hardcodedNotionKey, hardcodedOAuthSecret, hardcodedPineconeKey, hardcodedPlivoToken, hardcodedPostmarkKey, hardcodedQdrantKey, hardcodedRailwayToken, hardcodedReplicateKey, hardcodedResendKey, hardcodedSSN, hardcodedSecrets, hardcodedSendGridKey, hardcodedSentryAuthToken, hardcodedShopifyToken, hardcodedSlackToken, hardcodedSupabaseServiceRole, hardcodedTogetherKey, hardcodedTwilioKey, hardcodedVaultToken, hardcodedVercelToken, hardcodedWeaviateKey, hostHeaderRedirect, httpRequestSmuggling, insecureCookies, insecureDeepLink, insecureDeserialization, insecureDirectObjectReference, insecureElectronWindow, insecureFileUpload, insecureGRPC, insecureHTTPMethods, insecurePasswordReset, insecureRandomness, insecureWebSocket, ipcPathTraversal, isCalleeNamed, isMethodCall, javaDeserialization, jwtAlgConfusion, k8sNoResourceLimits, k8sPrivileged, k8sSecretNotEncrypted, lambdaWithoutVPC, largeBundleImport, llmCallNoMaxTokens, llmOutputAsHTML, llmOutputToSink, llmPromptInjection, llmSystemPromptInjection, logInjection, magicNumbers, massAssignment, middlewareMatcherExcludesApi, missingAIRateLimit, missingAuthMiddleware, missingAuthRateLimit, missingBruteForce, missingCSP, missingCSRF, missingCertPinning, missingCloudTrail, missingContentDisposition, missingDBEncryption, missingErrorBoundary, missingFileSizeLimits, missingHSTS, missingHTTPS, missingLockFile, missingOAuthState, missingPagination, missingRequestSizeLimit, missingRequestValidation, missingSRI, missingSecurityMeta, nPlusOneQuery, nextPublicSecret, noRateLimiting, nosqlInjection, openRedirectParams, overlyPermissiveIAM, parseFile, pathTraversal, pickleDeserialization, piiInLogs, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, runCustomRules, s3BucketNoEncryption, scanEntropy, secretInBundleConfig, secretInCLIArgument, secretInErrorResponse, secretInHTMLAttribute, secretInLLMPrompt, secretInURLParam, secretLoggedToConsole, secretsInCI, securityGroupAllInbound, sensitiveAsyncStorage, sensitiveLocalStorage, sensitiveURLParams, sessionFixation, sqlInjection, ssrfVulnerability, ssti, stripeWebhookUnprotected, supabaseAnonAdmin, supabaseNoRLS, syncFileOps, terraformStateExposed, timingAttack, todoLeftInCode, unencryptedPII, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
|
|
692
|
+
export { type AIFilterResult, type Confidence, type CustomRule, type DetectedFramework, type Exposure, type FilteredFinding, type Finding, type GradeOptions, type GradeResult, NON_APP_PATH_PATTERNS, type ParsedFile, RULE_IMPACTS, type RuleMatch, type SecurityGrade, type Severity, type TaintMap, type VibePlatform, allCustomRules, allRules, androidDebuggable, blockingMainThread, buildTaintMap, calculateGrade, callSpreads, callbackHell, classifyExposure, clickjacking, clientComponentSecret, clientSideAuth, commandInjection, complianceMap, consoleLogProduction, corsLocalhost, corsServerless, corsWildcard, dangerousInnerHTML, deprecatedTLS, detectFramework, detectPlatform, disabledTLSVerification, djangoDebug, dockerCopySensitive, dockerLatestTag, dockerRunAsRoot, dockerTooManyPorts, dockerfileADDInsteadOfCOPY, dockerfileMissingHealthcheck, dockerfileUnverifiedShellPipe, ecbModeEncryption, electronNavigationUnrestricted, emptyCatchBlock, envNotGitignored, evalUsage, eventListenerLeak, exposedAdminRoutes, exposedAuthSecret, exposedDBCredentials, exposedDatabaseStudio, exposedDebugMode, exposedDockerPorts, exposedEnvFile, exposedGitDir, exposedServerActions, exposedSourceMaps, exposedStackTraces, filterFalsePositives, firebaseClientConfig, flaskSecretKey, freeRules, getObjectProperty, getSnippet, ghaExpressionInjection, ghaPermissionsWriteAll, ghaPullRequestTargetCheckout, ghaThirdPartyActionWithSecrets, githubActionsInjection, graphqlCSRFDisabled, graphqlIntrospection, graphqlNoComplexityLimit, graphqlNoDepthLimit, hardcodedAlgoliaAdminKey, hardcodedAnthropicKey, hardcodedCloudflareToken, hardcodedCohereKey, hardcodedCreditCard, hardcodedDatadogKey, hardcodedDiscordToken, hardcodedEncryptionKey, hardcodedFastlyToken, hardcodedFireworksKey, hardcodedFlyToken, hardcodedGCPServiceAccount, hardcodedGitHubPAT, hardcodedGitLabToken, hardcodedGroqKey, hardcodedHighlightKey, hardcodedIPAllowlist, hardcodedIntercomToken, hardcodedJWTSecret, hardcodedLinearKey, hardcodedLogtailToken, hardcodedLoopsKey, hardcodedMailgunKey, hardcodedMistralKey, hardcodedNetlifyToken, hardcodedNotionKey, hardcodedOAuthSecret, hardcodedPineconeKey, hardcodedPlivoToken, hardcodedPostmarkKey, hardcodedQdrantKey, hardcodedRailwayToken, hardcodedReplicateKey, hardcodedResendKey, hardcodedSSN, hardcodedSecrets, hardcodedSendGridKey, hardcodedSentryAuthToken, hardcodedShopifyToken, hardcodedSlackToken, hardcodedSupabaseServiceRole, hardcodedTogetherKey, hardcodedTwilioKey, hardcodedVaultToken, hardcodedVercelToken, hardcodedWeaviateKey, hostHeaderRedirect, httpRequestSmuggling, insecureCookies, insecureDeepLink, insecureDeserialization, insecureDirectObjectReference, insecureElectronWindow, insecureFileUpload, insecureGRPC, insecureHTTPMethods, insecurePasswordReset, insecureRandomness, insecureWebSocket, ipcPathTraversal, isCalleeNamed, isMethodCall, isVendoredFinding, isVendoredPath, javaDeserialization, jwtAlgConfusion, k8sNoResourceLimits, k8sPrivileged, k8sSecretNotEncrypted, lambdaWithoutVPC, largeBundleImport, llmCallNoMaxTokens, llmOutputAsHTML, llmOutputToSink, llmPromptInjection, llmSystemPromptInjection, logInjection, magicNumbers, massAssignment, middlewareMatcherExcludesApi, missingAIRateLimit, missingAuthMiddleware, missingAuthRateLimit, missingBruteForce, missingCSP, missingCSRF, missingCertPinning, missingCloudTrail, missingContentDisposition, missingDBEncryption, missingErrorBoundary, missingFileSizeLimits, missingHSTS, missingHTTPS, missingLockFile, missingOAuthState, missingPagination, missingRequestSizeLimit, missingRequestValidation, missingSRI, missingSecurityMeta, nPlusOneQuery, nextPublicSecret, noRateLimiting, normalizeScanPath, nosqlInjection, openRedirectParams, overlyPermissiveIAM, parseFile, pathTraversal, pickleDeserialization, piiInLogs, prototypePollution, pyDjangoAllowedHostsWildcard, pyDjangoMarkSafe, pyJWTDecodeWeakConfig, pyJinja2AutoescapeOff, pyParamikoAutoAdd, pyRequestsVerifyFalse, pyTempfileMktemp, raceCondition, rdsPubliclyAccessible, reflectedCORSOrigin, regexDos, runCustomRules, s3BucketNoEncryption, scanEntropy, secretInBundleConfig, secretInCLIArgument, secretInErrorResponse, secretInHTMLAttribute, secretInLLMPrompt, secretInURLParam, secretLoggedToConsole, secretsInCI, securityGroupAllInbound, sensitiveAsyncStorage, sensitiveLocalStorage, sensitiveURLParams, sessionFixation, sqlInjection, ssrfVulnerability, ssti, stripeWebhookUnprotected, supabaseAnonAdmin, supabaseNoRLS, syncFileOps, terraformStateExposed, timingAttack, todoLeftInCode, unencryptedPII, unpinnedGitHubAction, unprotectedAPIRoutes, unprotectedDownload, unsafeObjectAssign, unsanitizedFilenames, unsanitizedHTMLExport, unvalidatedAPIParams, unvalidatedEventData, unvalidatedRedirect, vectorStoreQueryNoUserFilter, vectorStoreUpsertNoMetadata, vendoredReason, visitBinary, visitCalls, vulnerableDependencies, weakHashing, weakPasswordRequirements, weakRSAKeySize, webhookMissingIdempotency, webhookSignatureVerification, xssVulnerability, xxeVulnerability };
|
package/dist/index.js
CHANGED
|
@@ -282,6 +282,97 @@ function classifyExposure(filePath) {
|
|
|
282
282
|
return "unknown";
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
// src/vendored.ts
|
|
286
|
+
var NON_APP_PATH_PATTERNS = [
|
|
287
|
+
// 1. vendored UI component libraries
|
|
288
|
+
"**/components/ui/**",
|
|
289
|
+
"**/ui/shadcn/**",
|
|
290
|
+
"**/shadcn/ui/**",
|
|
291
|
+
"**/shadcn/**",
|
|
292
|
+
// 2. documentation prose
|
|
293
|
+
"**/*.md",
|
|
294
|
+
"**/*.mdx",
|
|
295
|
+
// 3. AI-agent and editor tooling artifacts. Each gets a `**/`-prefixed form
|
|
296
|
+
// as well as the root-anchored one: these directories turn up per-package
|
|
297
|
+
// in a monorepo, and a finding's `file` is occasionally an absolute path,
|
|
298
|
+
// which makes even a repo-root `.claude/` a nested segment.
|
|
299
|
+
".claude/**",
|
|
300
|
+
".agent/**",
|
|
301
|
+
".cursor/**",
|
|
302
|
+
".superpowers/**",
|
|
303
|
+
".windsurf/**",
|
|
304
|
+
"**/.claude/**",
|
|
305
|
+
"**/.agent/**",
|
|
306
|
+
"**/.cursor/**",
|
|
307
|
+
"**/.superpowers/**",
|
|
308
|
+
"**/.windsurf/**",
|
|
309
|
+
// 4. explicitly third-party or machine-generated trees
|
|
310
|
+
"**/vendor/**",
|
|
311
|
+
"**/vendored/**",
|
|
312
|
+
"**/third_party/**",
|
|
313
|
+
"**/generated/**",
|
|
314
|
+
"**/__generated__/**"
|
|
315
|
+
];
|
|
316
|
+
function globToRegExp(pattern) {
|
|
317
|
+
const segments = pattern.split("/");
|
|
318
|
+
let src = "^";
|
|
319
|
+
for (let i = 0; i < segments.length; i++) {
|
|
320
|
+
const seg = segments[i];
|
|
321
|
+
const isLast = i === segments.length - 1;
|
|
322
|
+
if (seg === "**") {
|
|
323
|
+
src += isLast ? ".+" : "(?:[^/]+/)*";
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
src += seg.replace(/[.*+?^${}()|[\]\\]/g, (ch) => ch === "*" ? "[^/]*" : "\\" + ch);
|
|
327
|
+
if (!isLast) src += "/";
|
|
328
|
+
}
|
|
329
|
+
return new RegExp(src + "$", "i");
|
|
330
|
+
}
|
|
331
|
+
var NON_APP_MATCHERS = NON_APP_PATH_PATTERNS.map(globToRegExp);
|
|
332
|
+
function normalizeScanPath(filePath) {
|
|
333
|
+
const raw = typeof filePath === "string" ? filePath : "";
|
|
334
|
+
const trimmed = raw.trim();
|
|
335
|
+
const looksWindows = !trimmed.includes("/") && trimmed.includes("\\");
|
|
336
|
+
const withForwardSlashes = (looksWindows ? trimmed.replace(/\\/g, "/") : trimmed).replace(/^[A-Za-z]:\//, "/");
|
|
337
|
+
const out = [];
|
|
338
|
+
for (const segment of withForwardSlashes.split("/")) {
|
|
339
|
+
if (segment === "" || segment === ".") continue;
|
|
340
|
+
if (segment === "..") {
|
|
341
|
+
if (out.length > 0 && out[out.length - 1] !== "..") out.pop();
|
|
342
|
+
else out.push("..");
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
out.push(segment);
|
|
346
|
+
}
|
|
347
|
+
return out.join("/");
|
|
348
|
+
}
|
|
349
|
+
function isVendoredPath(filePath) {
|
|
350
|
+
const normalized = normalizeScanPath(filePath);
|
|
351
|
+
if (!normalized) return false;
|
|
352
|
+
return NON_APP_MATCHERS.some((re) => re.test(normalized));
|
|
353
|
+
}
|
|
354
|
+
var HEURISTIC_SECRET_RULES = /* @__PURE__ */ new Set(["ENTROPY"]);
|
|
355
|
+
var ALWAYS_GRADED_RULES = /* @__PURE__ */ new Set(["VC115", "VC062"]);
|
|
356
|
+
function isAlwaysGraded(finding) {
|
|
357
|
+
const rule = finding?.rule ?? "";
|
|
358
|
+
if (ALWAYS_GRADED_RULES.has(rule)) return true;
|
|
359
|
+
if (finding?.category !== "Secrets") return false;
|
|
360
|
+
return !HEURISTIC_SECRET_RULES.has(rule);
|
|
361
|
+
}
|
|
362
|
+
function isVendoredFinding(finding) {
|
|
363
|
+
if (isAlwaysGraded(finding)) return false;
|
|
364
|
+
return isVendoredPath(finding?.file ?? "");
|
|
365
|
+
}
|
|
366
|
+
function vendoredReason(filePath) {
|
|
367
|
+
const normalized = normalizeScanPath(filePath);
|
|
368
|
+
if (!normalized) return null;
|
|
369
|
+
if (/\.mdx?$/.test(normalized)) return "documentation";
|
|
370
|
+
if (/(^|\/)(components\/ui|shadcn)(\/|$)/.test(normalized)) return "vendored UI component library";
|
|
371
|
+
if (/(^|\/)\.(claude|agent|cursor|superpowers|windsurf)(\/|$)/.test(normalized)) return "AI-agent tooling artifact";
|
|
372
|
+
if (isVendoredPath(normalized)) return "third-party or generated code";
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
|
|
285
376
|
// src/ast/parse.ts
|
|
286
377
|
import { parse } from "@babel/parser";
|
|
287
378
|
var MAX_CACHE = 256;
|
|
@@ -3892,12 +3983,20 @@ function detectPlatform(files) {
|
|
|
3892
3983
|
}
|
|
3893
3984
|
return [...platforms];
|
|
3894
3985
|
}
|
|
3895
|
-
function calculateGrade(findings, _totalFiles) {
|
|
3896
|
-
|
|
3897
|
-
|
|
3986
|
+
function calculateGrade(findings, _totalFiles, options = {}) {
|
|
3987
|
+
const scored = options.gradeVendored ? findings : findings.filter((f) => !isVendoredFinding(f));
|
|
3988
|
+
const ungraded = findings.length - scored.length;
|
|
3989
|
+
const holdout = ungraded > 0 ? ` ${ungraded} finding${ungraded === 1 ? "" : "s"} in vendored, generated, or documentation files ${ungraded === 1 ? "is" : "are"} reported but not graded.` : "";
|
|
3990
|
+
if (scored.length === 0) {
|
|
3991
|
+
return {
|
|
3992
|
+
grade: "A+",
|
|
3993
|
+
score: 100,
|
|
3994
|
+
summary: (ungraded > 0 ? "No security issues detected in your own code." : "No security issues detected. Excellent.") + holdout,
|
|
3995
|
+
ungraded
|
|
3996
|
+
};
|
|
3898
3997
|
}
|
|
3899
3998
|
let critical = 0, high = 0, medium = 0, low = 0;
|
|
3900
|
-
for (const f of
|
|
3999
|
+
for (const f of scored) {
|
|
3901
4000
|
if (f.severity === "critical") critical++;
|
|
3902
4001
|
else if (f.severity === "high") high++;
|
|
3903
4002
|
else if (f.severity === "medium") medium++;
|
|
@@ -3937,7 +4036,7 @@ function calculateGrade(findings, _totalFiles) {
|
|
|
3937
4036
|
} else {
|
|
3938
4037
|
summary = "No security issues detected.";
|
|
3939
4038
|
}
|
|
3940
|
-
return { grade, score: rawScore, summary };
|
|
4039
|
+
return { grade, score: rawScore, summary: summary + holdout, ungraded };
|
|
3941
4040
|
}
|
|
3942
4041
|
var jwtAlgConfusion = {
|
|
3943
4042
|
id: "VC079",
|
|
@@ -8515,13 +8614,16 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
8515
8614
|
}
|
|
8516
8615
|
if (maxLineLen > 5e4) return findings;
|
|
8517
8616
|
if (/onboarding|demo-data|example-vulnerable|code-sample/i.test(filePath)) return findings;
|
|
8617
|
+
const vendoredFile = isVendoredPath(filePath);
|
|
8518
8618
|
const ruleset = tier === "pro" && extraRules.length > 0 ? [...freeRules, ...extraRules] : freeRules;
|
|
8519
8619
|
for (const rule of ruleset) {
|
|
8520
8620
|
if (disabledRules.includes(rule.id)) continue;
|
|
8521
8621
|
const matches = rule.check(content, filePath);
|
|
8522
8622
|
const compliance = complianceMap[rule.id];
|
|
8623
|
+
const vendored = vendoredFile && isVendoredFinding({ file: filePath, rule: rule.id, category: rule.category });
|
|
8523
8624
|
for (const match of matches) {
|
|
8524
8625
|
findings.push({
|
|
8626
|
+
...vendored ? { vendored: true } : {},
|
|
8525
8627
|
id: `${match.rule}-${match.file}:${match.line}`,
|
|
8526
8628
|
rule: match.rule,
|
|
8527
8629
|
severity: match.severity,
|
|
@@ -8676,6 +8778,17 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
8676
8778
|
{
|
|
8677
8779
|
model: "claude-haiku-4-5-20251001",
|
|
8678
8780
|
max_tokens: 1024,
|
|
8781
|
+
// Pinned, NOT left to the API default of 1.0. This is a binary
|
|
8782
|
+
// classification (real vs. false positive), not generation — there
|
|
8783
|
+
// is no upside to sampling variety and a real downside to it: a
|
|
8784
|
+
// filtered finding is a finding the user never sees, so drift here
|
|
8785
|
+
// means scanning the same unchanged code twice can yield different
|
|
8786
|
+
// results. Temperature 0 does not make the model bit-deterministic
|
|
8787
|
+
// (Anthropic makes no such guarantee), but it removes the one
|
|
8788
|
+
// variance source that was ours to control. See
|
|
8789
|
+
// scripts/fp-filter-repeatability.cjs for the measured flip rate,
|
|
8790
|
+
// and the assertion in ai-fp-filter.test.ts that keeps it pinned.
|
|
8791
|
+
temperature: 0,
|
|
8679
8792
|
system: REVIEW_SYSTEM_PROMPT,
|
|
8680
8793
|
messages: [{ role: "user", content: prompt }]
|
|
8681
8794
|
},
|
|
@@ -8858,6 +8971,7 @@ function scanEntropy(files) {
|
|
|
8858
8971
|
if (filePath.includes(".min.")) continue;
|
|
8859
8972
|
if (/pro-rules-bundle|\.bundle\.|\.chunk\./i.test(filePath)) continue;
|
|
8860
8973
|
if (/(?:\.test\.|\.spec\.|__tests__|__mocks__|fixtures?\/)/i.test(filePath)) continue;
|
|
8974
|
+
const vendored = isVendoredPath(filePath);
|
|
8861
8975
|
const lines = content.split("\n");
|
|
8862
8976
|
for (let i = 0; i < lines.length; i++) {
|
|
8863
8977
|
const line = lines[i];
|
|
@@ -8888,6 +9002,7 @@ function scanEntropy(files) {
|
|
|
8888
9002
|
if (entropy < 4.5 && !isLikelySecret) continue;
|
|
8889
9003
|
const masked = value.substring(0, 6) + "..." + value.substring(value.length - 4);
|
|
8890
9004
|
findings.push({
|
|
9005
|
+
...vendored ? { vendored: true } : {},
|
|
8891
9006
|
id: `ENTROPY-${filePath}:${i + 1}`,
|
|
8892
9007
|
rule: "ENTROPY",
|
|
8893
9008
|
severity: isLikelySecret ? "critical" : "high",
|
|
@@ -8908,6 +9023,7 @@ function scanEntropy(files) {
|
|
|
8908
9023
|
return findings;
|
|
8909
9024
|
}
|
|
8910
9025
|
export {
|
|
9026
|
+
NON_APP_PATH_PATTERNS,
|
|
8911
9027
|
RULE_IMPACTS,
|
|
8912
9028
|
allCustomRules,
|
|
8913
9029
|
allRules,
|
|
@@ -9034,6 +9150,8 @@ export {
|
|
|
9034
9150
|
ipcPathTraversal,
|
|
9035
9151
|
isCalleeNamed,
|
|
9036
9152
|
isMethodCall,
|
|
9153
|
+
isVendoredFinding,
|
|
9154
|
+
isVendoredPath,
|
|
9037
9155
|
javaDeserialization,
|
|
9038
9156
|
jwtAlgConfusion,
|
|
9039
9157
|
k8sNoResourceLimits,
|
|
@@ -9074,6 +9192,7 @@ export {
|
|
|
9074
9192
|
nPlusOneQuery,
|
|
9075
9193
|
nextPublicSecret,
|
|
9076
9194
|
noRateLimiting,
|
|
9195
|
+
normalizeScanPath,
|
|
9077
9196
|
nosqlInjection,
|
|
9078
9197
|
openRedirectParams,
|
|
9079
9198
|
overlyPermissiveIAM,
|
|
@@ -9131,6 +9250,7 @@ export {
|
|
|
9131
9250
|
unvalidatedRedirect,
|
|
9132
9251
|
vectorStoreQueryNoUserFilter,
|
|
9133
9252
|
vectorStoreUpsertNoMetadata,
|
|
9253
|
+
vendoredReason,
|
|
9134
9254
|
visitBinary,
|
|
9135
9255
|
visitCalls,
|
|
9136
9256
|
vulnerableDependencies,
|