xploitscan-shared-rules 1.36.3 → 2.0.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
@@ -139,12 +139,78 @@ interface CustomRule {
139
139
  check: (content: string, filePath: string, project?: ProjectContext) => RuleMatch[];
140
140
  }
141
141
 
142
+ /**
143
+ * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
144
+ * dependency — so safe in the CLI and in serverless/edge environments.
145
+ *
146
+ * Performance note (security review, June 2026): rules call `getSnippet` and a
147
+ * line-number lookup once PER match. Both used to do `content.split("\n")` /
148
+ * `content.substring(0, idx).split("\n")`, which is O(content) per call. A
149
+ * pathological single- or multi-line payload that produces O(content) matches
150
+ * therefore drove O(content^2) CPU and pinned the public scan endpoint (a
151
+ * remote DoS). We memoize the split + line-start offsets per content string
152
+ * (rules run synchronously over one file at a time, so a by-reference cache of
153
+ * size 1 hits for every match and every rule on that file). With the cache,
154
+ * `getSnippet` is O(contextLines) and `lineNumberAt` is O(log lines) per call —
155
+ * the whole scan is O(n log n) with byte-identical output to the old code.
156
+ */
157
+ /**
158
+ * 1-based line number containing character `index`. Replaces the
159
+ * `content.substring(0, index).split("\n").length` idiom (which was O(content)
160
+ * per call) with an O(log lines) binary search over memoized line offsets.
161
+ */
162
+ declare function lineNumberAt(content: string, index: number): number;
142
163
  /**
143
164
  * Return a small code snippet around a given line number with a `>` marker on
144
165
  * the matched line.
145
166
  */
146
167
  declare function getSnippet(content: string, line: number, contextLines?: number): string;
147
168
 
169
+ /**
170
+ * Inline finding suppression — the `// VC###-OK: <reason>` marker.
171
+ *
172
+ * Lives in its own module because both the regex rules (rules.ts) and the
173
+ * entropy scanner (entropy-scanner.ts) need it, and this repo has been bitten
174
+ * repeatedly by the same duplication pattern: `calculateGrade` had three
175
+ * copies, the score→letter ladder had three, `NON_APP_PATH_PATTERNS` had two
176
+ * that had already drifted. Import, don't restate.
177
+ */
178
+ /**
179
+ * Check whether a finding has been silenced via an inline comment marker.
180
+ *
181
+ * Supported placements:
182
+ * 1. Same line, trailing: `someCode(); // VC146-OK: magic-link token gates this`
183
+ * 2. Comment block above: `// VC146-OK: magic-link token gates this`
184
+ * `// (explanation may wrap across lines)`
185
+ * `someCode();`
186
+ * 3. Multi-line block: `/* VC146-OK: ... *\/` above the match
187
+ *
188
+ * The marker is `<RULE-ID>-OK` (with optional `:` and explanation) or the
189
+ * wildcard `scanner-OK`. Both `#` (Python/Ruby/sh) and `//` (JS/TS/Go)
190
+ * comment prefixes are accepted.
191
+ *
192
+ * Rationale: some findings aren't a regex-tightening problem — they're "I
193
+ * have reviewed this and accept it here." An intentionally public OG-image
194
+ * endpoint is genuinely unauthenticated; the rule is right and the developer
195
+ * is also right. Loosening the regex would weaken the rule for everyone,
196
+ * whereas an inline marker keeps the rule strict and gives one site an
197
+ * explicit, self-documenting escape valve.
198
+ *
199
+ * Note this is deliberately NOT wired into findMatches() globally — that
200
+ * would opt every rule in at once. Rules opt in individually, either by
201
+ * calling this directly from their match loop or by passing their results
202
+ * through filterSilenced().
203
+ */
204
+ declare function isInlineSilenced(content: string, matchIndex: number, ruleId: string): boolean;
205
+ /**
206
+ * Line-indexed variant. The entropy scanner walks the file line by line and
207
+ * never computes character offsets, so making it reconstruct one just to call
208
+ * the index-based entry point would be wasted work on every finding.
209
+ *
210
+ * `lineIdx` is 0-based, matching `content.split("\n")`.
211
+ */
212
+ declare function isLineSilenced(lines: string[], lineIdx: number, ruleId: string): boolean;
213
+
148
214
  /**
149
215
  * Claude model IDs — the single place they are written down.
150
216
  *
@@ -625,7 +691,119 @@ declare function checkIntent(files: Array<{
625
691
  content: string;
626
692
  }>, findings: Finding[]): IntentReport;
627
693
 
694
+ /**
695
+ * Centralized Babel parser with per-file caching.
696
+ *
697
+ * Rules that opt in to AST analysis call parseFile(content, filename) to get
698
+ * a Program node back. Parsing is expensive (~5-50ms per KB of source); the
699
+ * LRU cache ensures a single scan pass touches each file at most once even
700
+ * when multiple rules walk the same AST.
701
+ *
702
+ * Failure mode: returns null on parse errors. Callers fall back to regex-only
703
+ * behavior so a syntax-error file in the user's repo can never break a scan.
704
+ */
705
+
706
+ interface ParsedFile {
707
+ ast: ParseResult<File>;
708
+ language: "js" | "ts" | "jsx" | "tsx";
709
+ }
710
+ /**
711
+ * Parse a JS/TS file. Returns null for unsupported extensions, parse errors,
712
+ * or empty content. Callers MUST handle null and fall back to regex-only.
713
+ */
714
+ declare function parseFile(content: string, filename: string): ParsedFile | null;
715
+
716
+ /**
717
+ * Lightweight taint tracking for AST-based rules.
718
+ *
719
+ * "Tainted" means "derived from untrusted input" — an Express/Next request
720
+ * body, query string, params, or headers; process.argv; environment
721
+ * variables known to be user-controlled; or file contents read at runtime.
722
+ *
723
+ * This is deliberately a local-only analysis: we walk the AST of one file,
724
+ * track which identifiers bind to a tainted source, and propagate through
725
+ * direct assignments and destructuring. Cross-function and cross-file flow
726
+ * is out of scope for Phase A — those require a module graph we don't build
727
+ * yet. A conservative local analysis is still enough to flip the benchmark
728
+ * recall on the data-flow rules.
729
+ *
730
+ * The analysis returns a TaintMap the rules can query:
731
+ * isTainted(node) → "is this AST expression tainted?"
732
+ * isTaintedIdent(name) → "is this identifier currently bound to tainted
733
+ * data in the file-level scope?"
734
+ *
735
+ * Shape of recognized sources:
736
+ * req.body, req.query, req.params, req.headers, req.cookies
737
+ * request.body, request.query, ... (Fastify)
738
+ * ctx.request.body, ctx.query (Koa)
739
+ * process.argv, process.env[Keys known to be user-controllable]
740
+ * event.queryStringParameters, event.body (AWS Lambda / API Gateway)
741
+ * searchParams.get(...), url.searchParams (Next.js / Web fetch API)
742
+ */
743
+
744
+ interface TaintMap {
745
+ /** true iff the given expression node evaluates to tainted data. */
746
+ isTainted(node: Node | null | undefined): boolean;
747
+ /** true iff the named identifier is bound to tainted data somewhere visible. */
748
+ isTaintedIdent(name: string): boolean;
749
+ /** Debug: all identifiers the analysis marked tainted, in discovery order. */
750
+ taintedNames(): string[];
751
+ }
752
+ /**
753
+ * Build a TaintMap for one parsed file. Single traversal, propagates taint
754
+ * through:
755
+ * - const/let bindings: const x = req.body.foo → x tainted
756
+ * - destructuring: const { foo } = req.body → foo tainted
757
+ * - assignment expressions: y = x; x is tainted → y tainted
758
+ * - function params named req/request/ctx (inside handlers, `req.body` is
759
+ * tainted even if we didn't see the outer binding)
760
+ */
761
+ declare function buildTaintMap(parsed: ParsedFile): TaintMap;
762
+
763
+ /**
764
+ * Visitor helpers for rule authors. Each helper takes a parsed file and a
765
+ * callback, and walks the AST in the most common pattern (find call
766
+ * expressions to a particular function, find member expressions of a
767
+ * particular shape, etc.).
768
+ *
769
+ * The rule code stays short and declarative; this file carries the
770
+ * @babel/traverse boilerplate and default-export interop.
771
+ */
772
+
773
+ /**
774
+ * Visit every BinaryExpression in the parsed file. Rule authors use this to
775
+ * catch `a === b` / `a !== b` comparisons where one side is a secret identifier.
776
+ */
777
+ declare function visitBinary(parsed: ParsedFile, visit: (node: BinaryExpression, line: number) => void): void;
778
+ /**
779
+ * Visit every CallExpression. `matchCallee` decides whether to surface the
780
+ * call; if it returns true, `visit` is invoked with the node and its
781
+ * 1-indexed source line.
782
+ */
783
+ declare function visitCalls(parsed: ParsedFile, matchCallee: (callee: Node) => boolean, visit: (call: CallExpression, line: number) => void): void;
784
+ /**
785
+ * "Does this callee resolve to a member/global named <name>?" — handles
786
+ * foo(x)
787
+ * obj.foo(x)
788
+ * a.b.foo(x)
789
+ * foo?.(x)
790
+ * Matches the terminal identifier only; doesn't bind to a specific receiver.
791
+ */
792
+ declare function isCalleeNamed(callee: Node, name: string): boolean;
793
+ /**
794
+ * Matches a call to `objName.methodName(...)` — useful for things like
795
+ * `_.merge`, `Object.assign`, `Handlebars.compile`, `libxml.parseXml`.
796
+ */
797
+ declare function isMethodCall(callee: Node, objName: string, methodName: string): boolean;
798
+ /** Looks up an ObjectExpression property by key name. */
799
+ declare function getObjectProperty(node: ObjectExpression, key: string): {
800
+ value: Node;
801
+ } | null;
802
+ /** Does this CallExpression spread an expression `matcher` returns true for? */
803
+ declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
804
+
628
805
  declare const TEST_FILE_PATTERN: RegExp;
806
+ declare function isTestFile(filePath: string): boolean;
629
807
  /**
630
808
  * Blank out comments while preserving every byte offset and newline.
631
809
  *
@@ -642,6 +820,75 @@ declare const TEST_FILE_PATTERN: RegExp;
642
820
  * beneath them, so this is not a fixture artefact.
643
821
  */
644
822
  declare function maskComments(content: string): string;
823
+ /**
824
+ * Return the source of the handler enclosing `index`, or null if none is found.
825
+ *
826
+ * WHY THIS EXISTS. VC003 and VC158 both decided "is this route protected?" by
827
+ * grepping the ENTIRE FILE for auth or ownership vocabulary. A single matching
828
+ * token anywhere in a file exempted every handler in it, no matter how far away
829
+ * the token was or what it was doing.
830
+ *
831
+ * The held-out DVNA IDOR case is the clean demonstration. Its vulnerable
832
+ * handler runs `db.User.find({ where: { 'id': req.body.id } })` with no
833
+ * ownership scoping at all — but a DIFFERENT function in the same file calls
834
+ * `res.render('app/useredit', { userId: req.user.id })`. The whole-file greps
835
+ * saw `userId` and `req.user`, concluded the file was safe, and returned before
836
+ * reaching any detection logic.
837
+ *
838
+ * The distinction the fixtures already encode is proximity, not vocabulary:
839
+ * clean/VC158-express-ownership-check scopes with
840
+ * `where: { id: req.params.id, userId: req.user.id }` — the ownership token is
841
+ * INSIDE the query. This narrows the guards to the handler actually performing
842
+ * the lookup, which is the only scope in which "is ownership enforced here?"
843
+ * is a meaningful question.
844
+ *
845
+ * Heuristic and deliberately conservative: brace counting, no parser, and it
846
+ * does not understand braces inside strings, template literals or regex
847
+ * literals. When it cannot confidently identify a handler it returns null, and
848
+ * both callers then fall back to whole-file behaviour — so a failure to parse
849
+ * can only preserve today's result, never invent a new finding.
850
+ */
851
+ declare function enclosingHandler(content: string, index: number): string | null;
852
+ declare function isServerSideFile(filePath: string, content?: string): boolean;
853
+ /**
854
+ * The full text of the line containing `index`.
855
+ *
856
+ * Exists because `content.substring(lineStart, content.indexOf("\n", index))`
857
+ * is wrong for a match on the LAST line of a file with no trailing newline:
858
+ * indexOf returns -1, and `substring(start, -1)` does not return "" — it
859
+ * clamps and swaps, handing back `content.substring(0, lineStart)`, which is
860
+ * everything BEFORE the line.
861
+ *
862
+ * That silently dropped findings. isCommentLine would test the top of the file
863
+ * instead of the match's line, so any file that opens with a comment — a
864
+ * licence header, a docblock, an explanatory note — lost every finding on its
865
+ * last line. It runs for every regex rule, so this was not one rule's problem.
866
+ *
867
+ * Four other sites in this file already guard the -1 explicitly. This is the
868
+ * same fix, in one place, for the seven that did not.
869
+ */
870
+ declare function lineTextAt(content: string, index: number): string;
871
+ declare function isCommentLine(content: string, matchIndex: number): boolean;
872
+ declare function isInsideFixMessage(content: string, matchIndex: number): boolean;
873
+ /**
874
+ * Drop findMatches-style results that sit at an inline-silenced site. Lets any
875
+ * rule honor `// VC###-OK:` / `// scanner-OK` with a one-liner, even when it
876
+ * only has line numbers (not match indices) to work with. Used to give the
877
+ * high/critical rules a per-site escape valve so users don't disable a whole
878
+ * rule to suppress one reviewed-and-accepted finding.
879
+ */
880
+ declare function filterSilenced(matches: RuleMatch[], content: string, ruleId: string): RuleMatch[];
881
+ declare function findMatches(content: string, pattern: RegExp, rule: Omit<CustomRule, "check">, filePath: string, fixTemplate?: (match: RegExpExecArray) => string): RuleMatch[];
882
+ /**
883
+ * Build a RuleMatch from an AST-derived location. Mirrors findMatches' output
884
+ * shape so AST-based rules can be mixed into the same Finding stream. `line`
885
+ * comes from node.loc; we still call getSnippet for consistent UI.
886
+ */
887
+ declare function astMatch(content: string, filePath: string, line: number, rule: Omit<CustomRule, "check">, fix?: string): RuleMatch;
888
+ declare function tryParse(content: string, filePath: string): {
889
+ parsed: ParsedFile;
890
+ taint: TaintMap;
891
+ } | null;
645
892
  declare const hardcodedSecrets: CustomRule;
646
893
  declare const exposedEnvFile: CustomRule;
647
894
  declare const missingAuthMiddleware: CustomRule;
@@ -653,73 +900,22 @@ declare const noRateLimiting: CustomRule;
653
900
  declare const corsWildcard: CustomRule;
654
901
  declare const clientSideAuth: CustomRule;
655
902
  declare const nextPublicSecret: CustomRule;
656
- declare const firebaseClientConfig: CustomRule;
657
- declare const supabaseAnonAdmin: CustomRule;
658
903
  declare const envNotGitignored: CustomRule;
659
904
  declare const evalUsage: CustomRule;
660
905
  declare const unvalidatedRedirect: CustomRule;
661
906
  declare const insecureCookies: CustomRule;
662
907
  declare const exposedAuthSecret: CustomRule;
663
- declare const insecureElectronWindow: CustomRule;
664
908
  declare const missingCSP: CustomRule;
665
- declare const ipcPathTraversal: CustomRule;
666
- declare const unsanitizedHTMLExport: CustomRule;
667
- declare const prototypePollution: CustomRule;
668
- declare const missingFileSizeLimits: CustomRule;
669
- declare const unsanitizedFilenames: CustomRule;
670
- declare const electronNavigationUnrestricted: CustomRule;
671
- declare const missingSecurityMeta: CustomRule;
672
- declare const unvalidatedAPIParams: CustomRule;
673
- declare const unvalidatedEventData: CustomRule;
674
- declare const insecureDeserialization: CustomRule;
675
909
  declare const hardcodedJWTSecret: CustomRule;
676
910
  declare const missingHTTPS: CustomRule;
677
911
  declare const exposedDebugMode: CustomRule;
678
912
  declare const insecureRandomness: CustomRule;
679
- declare const openRedirectParams: CustomRule;
680
913
  declare const missingErrorBoundary: CustomRule;
681
914
  declare const exposedStackTraces: CustomRule;
682
- declare const insecureFileUpload: CustomRule;
683
915
  declare const missingLockFile: CustomRule;
684
- declare const exposedGitDir: CustomRule;
685
- declare const ssrfVulnerability: CustomRule;
686
- declare const massAssignment: CustomRule;
687
- declare const timingAttack: CustomRule;
688
- declare const logInjection: CustomRule;
689
- declare const weakPasswordRequirements: CustomRule;
690
- declare const sessionFixation: CustomRule;
691
- declare const missingBruteForce: CustomRule;
692
- declare const nosqlInjection: CustomRule;
693
- declare const exposedDBCredentials: CustomRule;
694
- declare const missingDBEncryption: CustomRule;
695
- declare const graphqlIntrospection: CustomRule;
696
- declare const missingRequestSizeLimit: CustomRule;
697
- declare const hardcodedIPAllowlist: CustomRule;
698
- declare const sensitiveLocalStorage: CustomRule;
699
- declare const exposedSourceMaps: CustomRule;
700
- declare const clickjacking: CustomRule;
701
- declare const overlyPermissiveIAM: CustomRule;
702
- declare const dockerRunAsRoot: CustomRule;
703
- declare const exposedDockerPorts: CustomRule;
704
916
  declare const weakHashing: CustomRule;
705
917
  declare const disabledTLSVerification: CustomRule;
706
- declare const hardcodedEncryptionKey: CustomRule;
707
918
  declare const dangerousInnerHTML: CustomRule;
708
- declare const exposedServerActions: CustomRule;
709
- declare const unprotectedAPIRoutes: CustomRule;
710
- declare const clientComponentSecret: CustomRule;
711
- declare const insecureDeepLink: CustomRule;
712
- declare const sensitiveAsyncStorage: CustomRule;
713
- declare const missingCertPinning: CustomRule;
714
- declare const androidDebuggable: CustomRule;
715
- declare const djangoDebug: CustomRule;
716
- declare const flaskSecretKey: CustomRule;
717
- declare const pickleDeserialization: CustomRule;
718
- declare const missingCSRF: CustomRule;
719
- declare const githubActionsInjection: CustomRule;
720
- declare const secretsInCI: CustomRule;
721
- declare const corsServerless: CustomRule;
722
- declare const k8sPrivileged: CustomRule;
723
919
  type DetectedFramework = "next.js" | "react" | "react-native" | "express" | "hono" | "fastify" | "django" | "flask" | "electron" | "vue" | "svelte" | "unknown";
724
920
  declare function detectFramework(files: {
725
921
  path: string;
@@ -755,166 +951,15 @@ interface GradeOptions {
755
951
  gradeVendored?: boolean;
756
952
  }
757
953
  declare function calculateGrade(findings: Finding[], _totalFiles: number, options?: GradeOptions): GradeResult;
758
- declare const jwtAlgConfusion: CustomRule;
759
- declare const regexDos: CustomRule;
760
- declare const xxeVulnerability: CustomRule;
761
- declare const ssti: CustomRule;
762
- declare const javaDeserialization: CustomRule;
763
- declare const missingSRI: CustomRule;
764
- declare const exposedAdminRoutes: CustomRule;
765
- declare const insecureWebSocket: CustomRule;
766
- declare const missingHSTS: CustomRule;
767
- declare const sensitiveURLParams: CustomRule;
768
- declare const missingContentDisposition: CustomRule;
769
- declare const hostHeaderRedirect: CustomRule;
770
- declare const raceCondition: CustomRule;
771
- declare const unsafeObjectAssign: CustomRule;
772
- declare const unprotectedDownload: CustomRule;
773
- declare const commandInjection: CustomRule;
774
- declare const corsLocalhost: CustomRule;
775
- declare const insecureGRPC: CustomRule;
776
954
  declare const complianceMap: Record<string, {
777
955
  owasp: string;
778
956
  cwe: string;
779
957
  }>;
780
958
  declare const consoleLogProduction: CustomRule;
781
- declare const syncFileOps: CustomRule;
782
- declare const eventListenerLeak: CustomRule;
783
- declare const nPlusOneQuery: CustomRule;
784
- declare const largeBundleImport: CustomRule;
785
- declare const blockingMainThread: CustomRule;
786
959
  declare const todoLeftInCode: CustomRule;
787
960
  declare const emptyCatchBlock: CustomRule;
788
- declare const callbackHell: CustomRule;
789
- declare const magicNumbers: CustomRule;
790
- declare const s3BucketNoEncryption: CustomRule;
791
- declare const securityGroupAllInbound: CustomRule;
792
- declare const rdsPubliclyAccessible: CustomRule;
793
- declare const missingCloudTrail: CustomRule;
794
- declare const lambdaWithoutVPC: CustomRule;
795
- declare const dockerLatestTag: CustomRule;
796
- declare const dockerCopySensitive: CustomRule;
797
- declare const dockerTooManyPorts: CustomRule;
798
- declare const k8sSecretNotEncrypted: CustomRule;
799
- declare const k8sNoResourceLimits: CustomRule;
800
- declare const pathTraversal: CustomRule;
801
- declare const piiInLogs: CustomRule;
802
- declare const hardcodedOAuthSecret: CustomRule;
803
- declare const missingOAuthState: CustomRule;
804
- declare const unpinnedGitHubAction: CustomRule;
805
- declare const deprecatedTLS: CustomRule;
806
- declare const weakRSAKeySize: CustomRule;
807
- declare const ecbModeEncryption: CustomRule;
808
- declare const insecurePasswordReset: CustomRule;
809
- declare const terraformStateExposed: CustomRule;
810
- declare const insecureHTTPMethods: CustomRule;
811
- declare const httpRequestSmuggling: CustomRule;
812
- declare const unencryptedPII: CustomRule;
813
- declare const missingAuthRateLimit: CustomRule;
814
- declare const vulnerableDependencies: CustomRule;
815
- declare const hardcodedAnthropicKey: CustomRule;
816
- declare const hardcodedGitHubPAT: CustomRule;
817
- declare const hardcodedSendGridKey: CustomRule;
818
- declare const hardcodedSlackToken: CustomRule;
819
- declare const hardcodedGCPServiceAccount: CustomRule;
820
- declare const hardcodedShopifyToken: CustomRule;
821
- declare const hardcodedGitLabToken: CustomRule;
822
- declare const hardcodedTwilioKey: CustomRule;
823
- declare const hardcodedMailgunKey: CustomRule;
824
- declare const hardcodedDatadogKey: CustomRule;
825
- declare const hardcodedVercelToken: CustomRule;
826
- declare const hardcodedSupabaseServiceRole: CustomRule;
827
- declare const hardcodedVaultToken: CustomRule;
828
- declare const hardcodedPineconeKey: CustomRule;
829
- declare const hardcodedCohereKey: CustomRule;
830
- declare const hardcodedReplicateKey: CustomRule;
831
- declare const hardcodedMistralKey: CustomRule;
832
- declare const hardcodedTogetherKey: CustomRule;
833
- declare const hardcodedGroqKey: CustomRule;
834
- declare const hardcodedFireworksKey: CustomRule;
835
- declare const hardcodedPostmarkKey: CustomRule;
836
- declare const hardcodedResendKey: CustomRule;
837
- declare const hardcodedLoopsKey: CustomRule;
838
- declare const hardcodedCloudflareToken: CustomRule;
839
- declare const hardcodedFastlyToken: CustomRule;
840
- declare const hardcodedNetlifyToken: CustomRule;
841
- declare const hardcodedRailwayToken: CustomRule;
842
- declare const hardcodedFlyToken: CustomRule;
843
- declare const hardcodedAlgoliaAdminKey: CustomRule;
844
- declare const hardcodedQdrantKey: CustomRule;
845
- declare const hardcodedWeaviateKey: CustomRule;
846
- declare const hardcodedLinearKey: CustomRule;
847
- declare const hardcodedNotionKey: CustomRule;
848
- declare const hardcodedDiscordToken: CustomRule;
849
- declare const hardcodedIntercomToken: CustomRule;
850
- declare const hardcodedSentryAuthToken: CustomRule;
851
- declare const hardcodedLogtailToken: CustomRule;
852
- declare const hardcodedHighlightKey: CustomRule;
853
- declare const hardcodedPlivoToken: CustomRule;
854
- declare const ghaPullRequestTargetCheckout: CustomRule;
855
- declare const ghaPermissionsWriteAll: CustomRule;
856
- declare const ghaExpressionInjection: CustomRule;
857
- declare const ghaThirdPartyActionWithSecrets: CustomRule;
858
- declare const dockerfileADDInsteadOfCOPY: CustomRule;
859
- declare const dockerfileUnverifiedShellPipe: CustomRule;
860
- declare const dockerfileMissingHealthcheck: CustomRule;
861
- declare const pyRequestsVerifyFalse: CustomRule;
862
- declare const pyJinja2AutoescapeOff: CustomRule;
863
- declare const pyTempfileMktemp: CustomRule;
864
- declare const pyDjangoMarkSafe: CustomRule;
865
- declare const pyParamikoAutoAdd: CustomRule;
866
- declare const pyDjangoAllowedHostsWildcard: CustomRule;
867
- declare const pyJWTDecodeWeakConfig: CustomRule;
868
- declare const llmPromptInjection: CustomRule;
869
- declare const llmSystemPromptInjection: CustomRule;
870
- declare const llmOutputAsHTML: CustomRule;
871
- declare const vectorStoreQueryNoUserFilter: CustomRule;
872
- declare const vectorStoreUpsertNoMetadata: CustomRule;
873
- declare const llmCallNoMaxTokens: CustomRule;
874
- declare const graphqlNoDepthLimit: CustomRule;
875
- declare const graphqlNoComplexityLimit: CustomRule;
876
- declare const graphqlCSRFDisabled: CustomRule;
877
- declare const llmOutputToSink: CustomRule;
878
- declare const secretInLLMPrompt: CustomRule;
879
- declare const webhookMissingIdempotency: CustomRule;
880
- declare const entitlementFromWebStorage: CustomRule;
881
- declare const accountStateFromWebStorage: CustomRule;
882
- declare const middlewareMatcherExcludesApi: CustomRule;
883
- declare const hardcodedCreditCard: CustomRule;
884
- declare const hardcodedSSN: CustomRule;
885
- declare const secretInURLParam: CustomRule;
886
- declare const secretLoggedToConsole: CustomRule;
887
- declare const secretInErrorResponse: CustomRule;
888
- declare const secretInBundleConfig: CustomRule;
889
- declare const secretInHTMLAttribute: CustomRule;
890
- declare const secretInCLIArgument: CustomRule;
891
- declare const webhookSignatureVerification: CustomRule;
892
- declare const reflectedCORSOrigin: CustomRule;
893
- declare const missingRequestValidation: CustomRule;
894
- declare const missingAIRateLimit: CustomRule;
895
- declare const missingPagination: CustomRule;
896
- declare const exposedDatabaseStudio: CustomRule;
897
- declare const insecureDirectObjectReference: CustomRule;
898
961
  declare const freeRules: CustomRule[];
899
962
  declare const allRules: CustomRule[];
900
- declare const allCustomRules: CustomRule[];
901
- /**
902
- * Every rule that is NOT in the free tier, derived — never hand-listed.
903
- *
904
- * `runCustomRules()` always runs `freeRules` internally; its `extraRules`
905
- * argument is how a caller adds the rest. Passing `allCustomRules` there
906
- * therefore runs the 30 free rules TWICE, and every free-tier finding is
907
- * reported twice. That is exactly what the MCP server and the VS Code
908
- * extension were doing — both shipped, on npm and the Marketplace — while
909
- * the CLI passed the complement and was correct.
910
- *
911
- * The free/Pro split had been restated in three places by hand: this file's
912
- * `freeRules`, a literal ID Set in scripts/vsi/vsi-lib.cjs, and a 184-entry
913
- * import list in packages/cli/src/pro-bundle-entry.ts. Deriving it once is
914
- * the fix the repo keeps re-learning — a shared value makes the drift
915
- * unexpressible, where a guard only catches it afterwards.
916
- */
917
- declare const proOnlyRules: CustomRule[];
918
963
  declare function runCustomRules(content: string, filePath: string, disabledRules?: string[], tier?: "free" | "pro", extraRules?: CustomRule[],
919
964
  /**
920
965
  * Cross-file facts for the project being scanned, from
@@ -940,10 +985,15 @@ project?: ProjectContext): Finding[];
940
985
  * not shipped in npm package." A count is a number, and a number is all the
941
986
  * CLI should have to import to print one.
942
987
  *
943
- * So: literals here, and `rule-counts.test.ts` asserts each one equals the
944
- * real array's length. The value is *derived at test time* and *shipped as a
945
- * constant* — drift fails CI instead of reaching npm, and nothing in this file
946
- * references a rule, so a bundler can tree-shake the catalog away.
988
+ * Since 2.0.0 the Pro rules are not in this package at all — they live in the
989
+ * private packages/pro-rules — so this package CANNOT compute 184 or 214: the
990
+ * arrays those numbers describe do not exist here. Literals are the only way
991
+ * to publish them.
992
+ *
993
+ * So: literals here, and packages/pro-rules/src/rule-counts.test.ts asserts
994
+ * each one equals the real array's length. The value is *derived at test time*
995
+ * and *shipped as a constant* — drift fails CI instead of reaching npm, and
996
+ * nothing in this file references a rule.
947
997
  *
948
998
  * THIS FILE MUST NOT IMPORT FROM ./rules.js. That import is the entire bug.
949
999
  */
@@ -1143,117 +1193,6 @@ declare function assessHeaders(headers: Record<string, string>): HeaderFinding[]
1143
1193
  /** Script `src` URLs in an HTML document, resolved against the page URL. */
1144
1194
  declare function extractScriptUrls(html: string, pageUrl: string, limit?: number): string[];
1145
1195
 
1146
- /**
1147
- * Centralized Babel parser with per-file caching.
1148
- *
1149
- * Rules that opt in to AST analysis call parseFile(content, filename) to get
1150
- * a Program node back. Parsing is expensive (~5-50ms per KB of source); the
1151
- * LRU cache ensures a single scan pass touches each file at most once even
1152
- * when multiple rules walk the same AST.
1153
- *
1154
- * Failure mode: returns null on parse errors. Callers fall back to regex-only
1155
- * behavior so a syntax-error file in the user's repo can never break a scan.
1156
- */
1157
-
1158
- interface ParsedFile {
1159
- ast: ParseResult<File>;
1160
- language: "js" | "ts" | "jsx" | "tsx";
1161
- }
1162
- /**
1163
- * Parse a JS/TS file. Returns null for unsupported extensions, parse errors,
1164
- * or empty content. Callers MUST handle null and fall back to regex-only.
1165
- */
1166
- declare function parseFile(content: string, filename: string): ParsedFile | null;
1167
-
1168
- /**
1169
- * Lightweight taint tracking for AST-based rules.
1170
- *
1171
- * "Tainted" means "derived from untrusted input" — an Express/Next request
1172
- * body, query string, params, or headers; process.argv; environment
1173
- * variables known to be user-controlled; or file contents read at runtime.
1174
- *
1175
- * This is deliberately a local-only analysis: we walk the AST of one file,
1176
- * track which identifiers bind to a tainted source, and propagate through
1177
- * direct assignments and destructuring. Cross-function and cross-file flow
1178
- * is out of scope for Phase A — those require a module graph we don't build
1179
- * yet. A conservative local analysis is still enough to flip the benchmark
1180
- * recall on the data-flow rules.
1181
- *
1182
- * The analysis returns a TaintMap the rules can query:
1183
- * isTainted(node) → "is this AST expression tainted?"
1184
- * isTaintedIdent(name) → "is this identifier currently bound to tainted
1185
- * data in the file-level scope?"
1186
- *
1187
- * Shape of recognized sources:
1188
- * req.body, req.query, req.params, req.headers, req.cookies
1189
- * request.body, request.query, ... (Fastify)
1190
- * ctx.request.body, ctx.query (Koa)
1191
- * process.argv, process.env[Keys known to be user-controllable]
1192
- * event.queryStringParameters, event.body (AWS Lambda / API Gateway)
1193
- * searchParams.get(...), url.searchParams (Next.js / Web fetch API)
1194
- */
1195
-
1196
- interface TaintMap {
1197
- /** true iff the given expression node evaluates to tainted data. */
1198
- isTainted(node: Node | null | undefined): boolean;
1199
- /** true iff the named identifier is bound to tainted data somewhere visible. */
1200
- isTaintedIdent(name: string): boolean;
1201
- /** Debug: all identifiers the analysis marked tainted, in discovery order. */
1202
- taintedNames(): string[];
1203
- }
1204
- /**
1205
- * Build a TaintMap for one parsed file. Single traversal, propagates taint
1206
- * through:
1207
- * - const/let bindings: const x = req.body.foo → x tainted
1208
- * - destructuring: const { foo } = req.body → foo tainted
1209
- * - assignment expressions: y = x; x is tainted → y tainted
1210
- * - function params named req/request/ctx (inside handlers, `req.body` is
1211
- * tainted even if we didn't see the outer binding)
1212
- */
1213
- declare function buildTaintMap(parsed: ParsedFile): TaintMap;
1214
-
1215
- /**
1216
- * Visitor helpers for rule authors. Each helper takes a parsed file and a
1217
- * callback, and walks the AST in the most common pattern (find call
1218
- * expressions to a particular function, find member expressions of a
1219
- * particular shape, etc.).
1220
- *
1221
- * The rule code stays short and declarative; this file carries the
1222
- * @babel/traverse boilerplate and default-export interop.
1223
- */
1224
-
1225
- /**
1226
- * Visit every BinaryExpression in the parsed file. Rule authors use this to
1227
- * catch `a === b` / `a !== b` comparisons where one side is a secret identifier.
1228
- */
1229
- declare function visitBinary(parsed: ParsedFile, visit: (node: BinaryExpression, line: number) => void): void;
1230
- /**
1231
- * Visit every CallExpression. `matchCallee` decides whether to surface the
1232
- * call; if it returns true, `visit` is invoked with the node and its
1233
- * 1-indexed source line.
1234
- */
1235
- declare function visitCalls(parsed: ParsedFile, matchCallee: (callee: Node) => boolean, visit: (call: CallExpression, line: number) => void): void;
1236
- /**
1237
- * "Does this callee resolve to a member/global named <name>?" — handles
1238
- * foo(x)
1239
- * obj.foo(x)
1240
- * a.b.foo(x)
1241
- * foo?.(x)
1242
- * Matches the terminal identifier only; doesn't bind to a specific receiver.
1243
- */
1244
- declare function isCalleeNamed(callee: Node, name: string): boolean;
1245
- /**
1246
- * Matches a call to `objName.methodName(...)` — useful for things like
1247
- * `_.merge`, `Object.assign`, `Handlebars.compile`, `libxml.parseXml`.
1248
- */
1249
- declare function isMethodCall(callee: Node, objName: string, methodName: string): boolean;
1250
- /** Looks up an ObjectExpression property by key name. */
1251
- declare function getObjectProperty(node: ObjectExpression, key: string): {
1252
- value: Node;
1253
- } | null;
1254
- /** Does this CallExpression spread an expression `matcher` returns true for? */
1255
- declare function callSpreads(call: CallExpression, matcher: (node: Node) => boolean): boolean;
1256
-
1257
1196
  /**
1258
1197
  * Quality rules — a separate catalogue from the VC security rules.
1259
1198
  *
@@ -1430,4 +1369,4 @@ input: {
1430
1369
  content: string;
1431
1370
  }[] | QualityContext, rules?: QualityRule[]): Finding[];
1432
1371
 
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 };
1372
+ 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, allRules, assessHeaders, astMatch, buildProjectContext, buildQualityContext, buildTaintMap, calculateGrade, callSpreads, checkIntent, classifyExposure, classifyStatement, clientSideAuth, complianceMap, consoleLogProduction, corsWildcard, dangerousInnerHTML, detectBuilder, detectExposedConfig, detectFramework, detectPlatform, disabledTLSVerification, emptyCatchBlock, enclosingHandler, envNotGitignored, evalUsage, exposedAuthSecret, exposedDebugMode, exposedEnvFile, exposedStackTraces, extractRoutes, extractScriptUrls, filterFalsePositives, filterSilenced, findMatches, findSourceMapRefs, freeRules, getObjectProperty, getSnippet, hardcodedJWTSecret, hardcodedSecrets, harvestIntent, insecureCookies, insecureRandomness, isCalleeNamed, isClientTarget, isCommentLine, isInlineSilenced, isInsideFixMessage, isLineSilenced, isMethodCall, isPrivateAddress, isServerSideFile, isServerTarget, isTestFile, isVendoredFinding, isVendoredPath, lineNumberAt, lineTextAt, maskComments, missingAuthMiddleware, missingCSP, missingErrorBoundary, missingHTTPS, missingLockFile, nextPublicSecret, noRateLimiting, normalizeScanPath, parseFile, parseScanTarget, parseSupabaseConfig, qualityRules, routeForFile, runCustomRules, scanEntropy, scanQuality, sqlInjection, stripeWebhookUnprotected, supabaseFunctionName, supabaseNoRLS, todoLeftInCode, tryParse, unmeasuredQualityRules, unvalidatedRedirect, vendoredReason, visitBinary, visitCalls, weakHashing, xssVulnerability };