@js-recon/js-recon 2.0.1 → 2.1.0-alpha.2

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.
Files changed (229) hide show
  1. package/.github/workflows/publish-js-recon.yml +4 -1
  2. package/AGENTS.md +13 -12
  3. package/CHANGELOG.md +38 -0
  4. package/README.md +1 -0
  5. package/build/analyze/engine/taintwireEngine.js +111 -0
  6. package/build/analyze/engine/taintwireEngine.js.map +1 -0
  7. package/build/analyze/helpers/schemas.js +32 -3
  8. package/build/analyze/helpers/schemas.js.map +1 -1
  9. package/build/analyze/helpers/validate.js +9 -5
  10. package/build/analyze/helpers/validate.js.map +1 -1
  11. package/build/analyze/index.js +33 -29
  12. package/build/analyze/index.js.map +1 -1
  13. package/build/cliProgram.js +40 -3
  14. package/build/cliProgram.js.map +1 -1
  15. package/build/globalConfig.js +1 -1
  16. package/build/globalConfig.js.map +1 -1
  17. package/build/index.js +3 -1
  18. package/build/index.js.map +1 -1
  19. package/build/lazyLoad/methodFilter.js +1 -0
  20. package/build/lazyLoad/methodFilter.js.map +1 -1
  21. package/build/lazyLoad/next_js/NextJsCrawler.js +26 -15
  22. package/build/lazyLoad/next_js/NextJsCrawler.js.map +1 -1
  23. package/build/lazyLoad/next_js/next_interceptRouteNextUrl.js +339 -0
  24. package/build/lazyLoad/next_js/next_interceptRouteNextUrl.js.map +1 -0
  25. package/build/lazyLoad/next_js/next_routerStateForge.js +1 -1
  26. package/build/lazyLoad/next_js/next_routerStateForge.js.map +1 -1
  27. package/build/lazyLoad/next_js/next_serverActionIdScan.js +2 -2
  28. package/build/map/{angular_js → babel-legacy/angular_js}/getAngularConnections.js +1 -1
  29. package/build/map/babel-legacy/angular_js/getAngularConnections.js.map +1 -0
  30. package/build/map/babel-legacy/angular_js/interactive.js.map +1 -0
  31. package/build/map/{graphql → babel-legacy/graphql}/resolveGraphql.js +2 -2
  32. package/build/map/babel-legacy/graphql/resolveGraphql.js.map +1 -0
  33. package/build/map/babel-legacy/interactive-mode/commandHandler.js.map +1 -0
  34. package/build/map/babel-legacy/interactive-mode/commandHelpers.js.map +1 -0
  35. package/build/map/babel-legacy/interactive-mode/esqueryGen.js.map +1 -0
  36. package/build/map/babel-legacy/interactive-mode/helpMenu.js.map +1 -0
  37. package/build/map/babel-legacy/interactive-mode/inputPatch.js.map +1 -0
  38. package/build/map/{interactive-mode → babel-legacy/interactive-mode}/interactive.js +1 -1
  39. package/build/map/babel-legacy/interactive-mode/interactive.js.map +1 -0
  40. package/build/map/babel-legacy/interactive-mode/keybindings.js.map +1 -0
  41. package/build/map/babel-legacy/interactive-mode/printer.js.map +1 -0
  42. package/build/map/babel-legacy/interactive-mode/ui.js.map +1 -0
  43. package/build/map/{next_js → babel-legacy/next_js}/getAxiosInstances.js +1 -1
  44. package/build/map/babel-legacy/next_js/getAxiosInstances.js.map +1 -0
  45. package/build/map/{next_js → babel-legacy/next_js}/getExports.js +1 -1
  46. package/build/map/babel-legacy/next_js/getExports.js.map +1 -0
  47. package/build/map/{next_js → babel-legacy/next_js}/getFetchInstances.js +1 -1
  48. package/build/map/babel-legacy/next_js/getFetchInstances.js.map +1 -0
  49. package/build/map/{next_js → babel-legacy/next_js}/getTurbopackConnections.js +3 -3
  50. package/build/map/babel-legacy/next_js/getTurbopackConnections.js.map +1 -0
  51. package/build/map/{next_js → babel-legacy/next_js}/getWebpackConnections.js +3 -3
  52. package/build/map/babel-legacy/next_js/getWebpackConnections.js.map +1 -0
  53. package/build/map/babel-legacy/next_js/interactive.js.map +1 -0
  54. package/build/map/babel-legacy/next_js/interactive_helpers/commandHandler.js.map +1 -0
  55. package/build/map/{next_js → babel-legacy/next_js}/interactive_helpers/commandHelpers.js +1 -1
  56. package/build/map/babel-legacy/next_js/interactive_helpers/commandHelpers.js.map +1 -0
  57. package/build/map/babel-legacy/next_js/interactive_helpers/helpMenu.js.map +1 -0
  58. package/build/map/{next_js → babel-legacy/next_js}/resolveAxios.js +1 -1
  59. package/build/map/babel-legacy/next_js/resolveAxios.js.map +1 -0
  60. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/astNodeToJsonString.js.map +1 -0
  61. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/directCallsWithoutAssignment.js.map +1 -0
  62. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/findAxiosClients.js +1 -1
  63. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/findAxiosClients.js.map +1 -0
  64. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/findAxiosInstance.js +1 -1
  65. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/findAxiosInstance.js.map +1 -0
  66. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/findCrossChunkParams.js +1 -1
  67. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/findCrossChunkParams.js.map +1 -0
  68. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/handleAxiosCreate.js +2 -2
  69. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/handleAxiosCreate.js.map +1 -0
  70. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/handleZDotCreate.js +2 -2
  71. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/handleZDotCreate.js.map +1 -0
  72. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/interceptorHeaders.js.map +1 -0
  73. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/processAxiosCall.js +3 -3
  74. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/processAxiosCall.js.map +1 -0
  75. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/processDirectAxiosCall.js +3 -3
  76. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/processDirectAxiosCall.js.map +1 -0
  77. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/processExportedEndpoints.js +2 -2
  78. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/processExportedEndpoints.js.map +1 -0
  79. package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/traceAxiosInstanceExports.js +2 -2
  80. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/traceAxiosInstanceExports.js.map +1 -0
  81. package/build/map/babel-legacy/next_js/resolveAxiosHelpers/traceBody.js.map +1 -0
  82. package/build/map/{next_js → babel-legacy/next_js}/resolveFetch.js +3 -3
  83. package/build/map/babel-legacy/next_js/resolveFetch.js.map +1 -0
  84. package/build/map/{next_js → babel-legacy/next_js}/resolveNewRequest.js +2 -2
  85. package/build/map/babel-legacy/next_js/resolveNewRequest.js.map +1 -0
  86. package/build/map/{next_js → babel-legacy/next_js}/resolveServerActions.js +36 -25
  87. package/build/map/babel-legacy/next_js/resolveServerActions.js.map +1 -0
  88. package/build/map/babel-legacy/next_js/utils.js.map +1 -0
  89. package/build/map/{react_js → babel-legacy/react_js}/getReactConnections.js +3 -3
  90. package/build/map/babel-legacy/react_js/getReactConnections.js.map +1 -0
  91. package/build/map/babel-legacy/react_js/interactive.js.map +1 -0
  92. package/build/map/babel-legacy/svelte_js/interactive.js.map +1 -0
  93. package/build/map/babel-legacy/svelte_js/interactive_helpers/commandHandler.js.map +1 -0
  94. package/build/map/babel-legacy/vue_js/bodyResolver.js.map +1 -0
  95. package/build/map/babel-legacy/vue_js/crossFileResolver.js.map +1 -0
  96. package/build/map/{vue_js → babel-legacy/vue_js}/getViteConnections.js +3 -3
  97. package/build/map/babel-legacy/vue_js/getViteConnections.js.map +1 -0
  98. package/build/map/babel-legacy/vue_js/interactive.js.map +1 -0
  99. package/build/map/babel-legacy/vue_js/interactive_helpers/commandHandler.js.map +1 -0
  100. package/build/map/babel-legacy/vue_js/interactive_helpers/commandHelpers.js.map +1 -0
  101. package/build/map/babel-legacy/vue_js/interactive_helpers/helpMenu.js.map +1 -0
  102. package/build/map/babel-legacy/vue_js/taint_utils.js.map +1 -0
  103. package/build/map/{vue_js → babel-legacy/vue_js}/vue_resolveFetch.js +4 -10
  104. package/build/map/babel-legacy/vue_js/vue_resolveFetch.js.map +1 -0
  105. package/build/map/{vue_js → babel-legacy/vue_js}/vue_resolveHttpClient.js +3 -17
  106. package/build/map/babel-legacy/vue_js/vue_resolveHttpClient.js.map +1 -0
  107. package/build/map/{vue_js → babel-legacy/vue_js}/vue_resolveXhr.js +4 -10
  108. package/build/map/babel-legacy/vue_js/vue_resolveXhr.js.map +1 -0
  109. package/build/map/index.js +56 -43
  110. package/build/map/index.js.map +1 -1
  111. package/build/map/taintwire/apiCalls.js +333 -0
  112. package/build/map/taintwire/apiCalls.js.map +1 -0
  113. package/build/map/taintwire/next_js/index.js +135 -0
  114. package/build/map/taintwire/next_js/index.js.map +1 -0
  115. package/build/map/taintwire/valueResolver.js +199 -0
  116. package/build/map/taintwire/valueResolver.js.map +1 -0
  117. package/build/mcp/mcpServer.js +3 -2
  118. package/build/mcp/mcpServer.js.map +1 -1
  119. package/build/report/index.js +11 -4
  120. package/build/report/index.js.map +1 -1
  121. package/build/report/utility/initGlobalReportDb.js +17 -0
  122. package/build/report/utility/initGlobalReportDb.js.map +1 -1
  123. package/build/report/utility/initReportDb.js +16 -0
  124. package/build/report/utility/initReportDb.js.map +1 -1
  125. package/build/report/utility/mergeDomainIntoGlobalDb.js +4 -0
  126. package/build/report/utility/mergeDomainIntoGlobalDb.js.map +1 -1
  127. package/build/report/utility/populateDb/populateRawFiles.js +58 -0
  128. package/build/report/utility/populateDb/populateRawFiles.js.map +1 -0
  129. package/build/run/batchOutcome.js +23 -0
  130. package/build/run/batchOutcome.js.map +1 -0
  131. package/build/run/index.js +23 -7
  132. package/build/run/index.js.map +1 -1
  133. package/build/taintwire/index.js +145 -0
  134. package/build/taintwire/index.js.map +1 -0
  135. package/build/utility/globals.js +17 -0
  136. package/build/utility/globals.js.map +1 -1
  137. package/build/utility/listFiles.js +22 -0
  138. package/build/utility/listFiles.js.map +1 -0
  139. package/build/utility/openapiGenerator.js +2 -1
  140. package/build/utility/openapiGenerator.js.map +1 -1
  141. package/build/utility/ruleVersionMap.js +1 -0
  142. package/build/utility/ruleVersionMap.js.map +1 -1
  143. package/build/utility/urlUtils.js +25 -0
  144. package/build/utility/urlUtils.js.map +1 -1
  145. package/npm-shrinkwrap.json +8087 -0
  146. package/package.json +10 -5
  147. package/build/map/angular_js/getAngularConnections.js.map +0 -1
  148. package/build/map/angular_js/interactive.js.map +0 -1
  149. package/build/map/graphql/resolveGraphql.js.map +0 -1
  150. package/build/map/interactive-mode/commandHandler.js.map +0 -1
  151. package/build/map/interactive-mode/commandHelpers.js.map +0 -1
  152. package/build/map/interactive-mode/esqueryGen.js.map +0 -1
  153. package/build/map/interactive-mode/helpMenu.js.map +0 -1
  154. package/build/map/interactive-mode/inputPatch.js.map +0 -1
  155. package/build/map/interactive-mode/interactive.js.map +0 -1
  156. package/build/map/interactive-mode/keybindings.js.map +0 -1
  157. package/build/map/interactive-mode/printer.js.map +0 -1
  158. package/build/map/interactive-mode/ui.js.map +0 -1
  159. package/build/map/next_js/getAxiosInstances.js.map +0 -1
  160. package/build/map/next_js/getExports.js.map +0 -1
  161. package/build/map/next_js/getFetchInstances.js.map +0 -1
  162. package/build/map/next_js/getTurbopackConnections.js.map +0 -1
  163. package/build/map/next_js/getWebpackConnections.js.map +0 -1
  164. package/build/map/next_js/interactive.js.map +0 -1
  165. package/build/map/next_js/interactive_helpers/commandHandler.js.map +0 -1
  166. package/build/map/next_js/interactive_helpers/commandHelpers.js.map +0 -1
  167. package/build/map/next_js/interactive_helpers/helpMenu.js.map +0 -1
  168. package/build/map/next_js/resolveAxios.js.map +0 -1
  169. package/build/map/next_js/resolveAxiosHelpers/astNodeToJsonString.js.map +0 -1
  170. package/build/map/next_js/resolveAxiosHelpers/directCallsWithoutAssignment.js.map +0 -1
  171. package/build/map/next_js/resolveAxiosHelpers/findAxiosClients.js.map +0 -1
  172. package/build/map/next_js/resolveAxiosHelpers/findAxiosInstance.js.map +0 -1
  173. package/build/map/next_js/resolveAxiosHelpers/findCrossChunkParams.js.map +0 -1
  174. package/build/map/next_js/resolveAxiosHelpers/handleAxiosCreate.js.map +0 -1
  175. package/build/map/next_js/resolveAxiosHelpers/handleZDotCreate.js.map +0 -1
  176. package/build/map/next_js/resolveAxiosHelpers/interceptorHeaders.js.map +0 -1
  177. package/build/map/next_js/resolveAxiosHelpers/processAxiosCall.js.map +0 -1
  178. package/build/map/next_js/resolveAxiosHelpers/processDirectAxiosCall.js.map +0 -1
  179. package/build/map/next_js/resolveAxiosHelpers/processExportedEndpoints.js.map +0 -1
  180. package/build/map/next_js/resolveAxiosHelpers/traceAxiosInstanceExports.js.map +0 -1
  181. package/build/map/next_js/resolveAxiosHelpers/traceBody.js.map +0 -1
  182. package/build/map/next_js/resolveFetch.js.map +0 -1
  183. package/build/map/next_js/resolveNewRequest.js.map +0 -1
  184. package/build/map/next_js/resolveServerActions.js.map +0 -1
  185. package/build/map/next_js/utils.js.map +0 -1
  186. package/build/map/react_js/getReactConnections.js.map +0 -1
  187. package/build/map/react_js/interactive.js.map +0 -1
  188. package/build/map/react_js/react_resolveFetch.js +0 -6
  189. package/build/map/react_js/react_resolveFetch.js.map +0 -1
  190. package/build/map/svelte_js/interactive.js.map +0 -1
  191. package/build/map/svelte_js/interactive_helpers/commandHandler.js.map +0 -1
  192. package/build/map/vue_js/bodyResolver.js.map +0 -1
  193. package/build/map/vue_js/crossFileResolver.js.map +0 -1
  194. package/build/map/vue_js/getViteConnections.js.map +0 -1
  195. package/build/map/vue_js/interactive.js.map +0 -1
  196. package/build/map/vue_js/interactive_helpers/commandHandler.js.map +0 -1
  197. package/build/map/vue_js/interactive_helpers/commandHelpers.js.map +0 -1
  198. package/build/map/vue_js/interactive_helpers/helpMenu.js.map +0 -1
  199. package/build/map/vue_js/taint_utils.js.map +0 -1
  200. package/build/map/vue_js/vue_resolveFetch.js.map +0 -1
  201. package/build/map/vue_js/vue_resolveHttpClient.js.map +0 -1
  202. package/build/map/vue_js/vue_resolveXhr.js.map +0 -1
  203. /package/build/map/{angular_js → babel-legacy/angular_js}/interactive.js +0 -0
  204. /package/build/map/{interactive-mode → babel-legacy/interactive-mode}/commandHandler.js +0 -0
  205. /package/build/map/{interactive-mode → babel-legacy/interactive-mode}/commandHelpers.js +0 -0
  206. /package/build/map/{interactive-mode → babel-legacy/interactive-mode}/esqueryGen.js +0 -0
  207. /package/build/map/{interactive-mode → babel-legacy/interactive-mode}/helpMenu.js +0 -0
  208. /package/build/map/{interactive-mode → babel-legacy/interactive-mode}/inputPatch.js +0 -0
  209. /package/build/map/{interactive-mode → babel-legacy/interactive-mode}/keybindings.js +0 -0
  210. /package/build/map/{interactive-mode → babel-legacy/interactive-mode}/printer.js +0 -0
  211. /package/build/map/{interactive-mode → babel-legacy/interactive-mode}/ui.js +0 -0
  212. /package/build/map/{next_js → babel-legacy/next_js}/interactive.js +0 -0
  213. /package/build/map/{next_js → babel-legacy/next_js}/interactive_helpers/commandHandler.js +0 -0
  214. /package/build/map/{next_js → babel-legacy/next_js}/interactive_helpers/helpMenu.js +0 -0
  215. /package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/astNodeToJsonString.js +0 -0
  216. /package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/directCallsWithoutAssignment.js +0 -0
  217. /package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/interceptorHeaders.js +0 -0
  218. /package/build/map/{next_js → babel-legacy/next_js}/resolveAxiosHelpers/traceBody.js +0 -0
  219. /package/build/map/{next_js → babel-legacy/next_js}/utils.js +0 -0
  220. /package/build/map/{react_js → babel-legacy/react_js}/interactive.js +0 -0
  221. /package/build/map/{svelte_js → babel-legacy/svelte_js}/interactive.js +0 -0
  222. /package/build/map/{svelte_js → babel-legacy/svelte_js}/interactive_helpers/commandHandler.js +0 -0
  223. /package/build/map/{vue_js → babel-legacy/vue_js}/bodyResolver.js +0 -0
  224. /package/build/map/{vue_js → babel-legacy/vue_js}/crossFileResolver.js +0 -0
  225. /package/build/map/{vue_js → babel-legacy/vue_js}/interactive.js +0 -0
  226. /package/build/map/{vue_js → babel-legacy/vue_js}/interactive_helpers/commandHandler.js +0 -0
  227. /package/build/map/{vue_js → babel-legacy/vue_js}/interactive_helpers/commandHelpers.js +0 -0
  228. /package/build/map/{vue_js → babel-legacy/vue_js}/interactive_helpers/helpMenu.js +0 -0
  229. /package/build/map/{vue_js → babel-legacy/vue_js}/taint_utils.js +0 -0
@@ -46,6 +46,9 @@ jobs:
46
46
  - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
47
47
  with:
48
48
  node-version: 22
49
+ # npm 10's retired quick-audit endpoint rejects lockfiles with npm: aliases; npm 12's ci refuses npm-shrinkwrap.json
50
+ - name: Update npm
51
+ run: npm install -g npm@11
49
52
  - run: npm ci
50
53
  - name: Run npm audit
51
54
  run: npm audit
@@ -102,7 +105,7 @@ jobs:
102
105
  - run: npm ci
103
106
  - run: npm run build
104
107
  - name: Ensure npm CLI supports OIDC trusted publishing
105
- run: npm install -g npm@latest
108
+ run: npm install -g npm@11
106
109
  - name: Stage release to npm via OIDC
107
110
  run: |
108
111
  TAG="latest"
package/AGENTS.md CHANGED
@@ -71,6 +71,7 @@ npm run start -- <subcommand> [options]
71
71
  | `mcp` | AI-powered CLI / one-shot chat (`-c`) / Model Context Protocol server (`--server`) |
72
72
  | `cs-mast` | Compute CS-MAST structural hashes for downloaded JS files; find hash collisions |
73
73
  | `sourcemaps` | Extract source files from `.map` sourcemap file(s) |
74
+ | `taintwire` | `build` a PookieGraph (`.pg`) from JS files; `analyze`/`validate` `.pgq` query files |
74
75
 
75
76
  ## Key source files
76
77
 
@@ -80,26 +81,26 @@ npm run start -- <subcommand> [options]
80
81
  - `src/analyze/helpers/initRules.ts` — downloads/caches rules from GitHub to `~/.js-recon/rules`
81
82
  - `src/analyze/helpers/validate.ts` — validates rules and checks `js_recon_version` compatibility
82
83
  - `src/analyze/helpers/schemas.ts` — Zod schema for rule YAML files
83
- - `src/map/graphql/resolveGraphql.ts` — framework-agnostic GraphQL operation scanner. Visits every `StringLiteral` and `TemplateLiteral` in every JS file, validates with the `graphql` library's `parse()`, and emits each operation as a POST request under a flat `GraphQL` collection folder. Inlines transitively-referenced fragment definitions into each printed query so emitted requests are self-contained. Runs in every framework branch of `map/index.ts` when `--openapi` is on and `--no-graphql`/`--ngql` is not set.
84
- - `src/map/next_js/resolveFetch.ts` — resolves `fetch()` calls, detects Next.js framework chunks
85
- - `src/map/next_js/resolveServerActions.ts` — detects `createServerReference(actionId, ...)` calls, derives App Router routes from chunk file paths, traces argument call sites (same-chunk and cross-chunk), and emits POST endpoints with `next-action` headers and typed arg hints (e.g. `<string:userId>`) into the global OpenAPI output
86
- - `src/map/next_js/utils.ts` — `resolveNodeValue`, `resolveVariableInChunk`, `substituteVariablesInString`
87
- - `src/map/vue_js/vue_resolveXhr.ts` — directory-scan resolver for `new XMLHttpRequest()` + `.open()/.setRequestHeader()/.send()` patterns. Shared by Vue/React/Svelte pipelines; the `frameworkName` arg only changes log labels. Reaches ground-truth XHR sites but in axios/Got/Ky-style bundles the URL/method come from a dispatcher config (`re.url`, `re.method`) and resolve only to opaque `[member:re.url]` placeholders that taint analysis cannot unwind across the library's internal dispatch chain — those entries fail the `looksLikeUrl` check at emit time. Catch the wrapper-level call instead via `vue_resolveHttpClient`.
88
- - `src/map/vue_js/vue_resolveHttpClient.ts` — directory-scan resolver for `<obj>.<verb>(<url>, [body], [config])` calls where `<verb>` ∈ {get,post,put,delete,patch,head,options}. Designed for bundles whose transport layer overrides `XMLHttpRequest.prototype.{open,send,setRequestHeader}` (axios xhrAdapter and similar wrappers): the override layer is irrelevant to URL extraction because the literal URL is composed at the client-instance method call site, not inside the adapter. The `looksLikeUrl` heuristic (post-placeholder-strip, must contain `/` or scheme) filters out `Map.get` / `Headers.delete` / `EventBus.post` false positives while keeping partially-resolved URLs like `[call:base()]<literal>/[var X]`. Three resolution stages run on every captured callsite — each addresses a separate gap exposed when an RPC wrapper is hidden behind multiple layers of webpack-exported helpers:
84
+ - `src/map/babel-legacy/graphql/resolveGraphql.ts` — framework-agnostic GraphQL operation scanner. Visits every `StringLiteral` and `TemplateLiteral` in every JS file, validates with the `graphql` library's `parse()`, and emits each operation as a POST request under a flat `GraphQL` collection folder. Inlines transitively-referenced fragment definitions into each printed query so emitted requests are self-contained. Runs in every framework branch of `map/index.ts` when `--openapi` is on and `--no-graphql`/`--ngql` is not set.
85
+ - `src/map/babel-legacy/next_js/resolveFetch.ts` — resolves `fetch()` calls, detects Next.js framework chunks
86
+ - `src/map/babel-legacy/next_js/resolveServerActions.ts` — detects `createServerReference(actionId, ...)` calls, derives App Router routes from chunk file paths, traces argument call sites (same-chunk and cross-chunk), and emits POST endpoints with `next-action` headers and typed arg hints (e.g. `<string:userId>`) into the global OpenAPI output
87
+ - `src/map/babel-legacy/next_js/utils.ts` — `resolveNodeValue`, `resolveVariableInChunk`, `substituteVariablesInString`
88
+ - `src/map/babel-legacy/vue_js/vue_resolveXhr.ts` — directory-scan resolver for `new XMLHttpRequest()` + `.open()/.setRequestHeader()/.send()` patterns. Shared by Vue/React/Svelte pipelines; the `frameworkName` arg only changes log labels. Reaches ground-truth XHR sites but in axios/Got/Ky-style bundles the URL/method come from a dispatcher config (`re.url`, `re.method`) and resolve only to opaque `[member:re.url]` placeholders that taint analysis cannot unwind across the library's internal dispatch chain — those entries fail the `looksLikeUrl` check at emit time. Catch the wrapper-level call instead via `vue_resolveHttpClient`.
89
+ - `src/map/babel-legacy/vue_js/vue_resolveHttpClient.ts` — directory-scan resolver for `<obj>.<verb>(<url>, [body], [config])` calls where `<verb>` ∈ {get,post,put,delete,patch,head,options}. Designed for bundles whose transport layer overrides `XMLHttpRequest.prototype.{open,send,setRequestHeader}` (axios xhrAdapter and similar wrappers): the override layer is irrelevant to URL extraction because the literal URL is composed at the client-instance method call site, not inside the adapter. The `looksLikeUrl` heuristic (post-placeholder-strip, must contain `/` or scheme) filters out `Map.get` / `Headers.delete` / `EventBus.post` false positives while keeping partially-resolved URLs like `[call:base()]<literal>/[var X]`. Three resolution stages run on every captured callsite — each addresses a separate gap exposed when an RPC wrapper is hidden behind multiple layers of webpack-exported helpers:
89
90
  1. `resolveFromAssignments` — walks `binding.constantViolations` for `[unresolved: NAME]` markers, so identifiers declared as `let X;` and assigned later in the function body (e.g. `(X = a + "/" + b)` inside a sequence expression) resolve to their RHS. `resolveNodeValue`'s Identifier handler only looks at `binding.init`, which is empty for late-assigned locals.
90
91
  2. `expandParamPlaceholders` — fans out one captured callsite into one URL per caller chain. Walks the `enclosingFn.parent` chain to find which named function declares each `[param:X]`, then substitutes **every** placeholder owned by that same function from a single caller's args (keeps `[param:e]`/`[param:t]` consistent across one caller — never mixing args from different callsites). Recurses on the caller's `enclosingFn` so a forwarding wrapper (`Se(e,t,n) → ae.request(e,t,n,...)`) walks up to the wrapper's own callers.
91
92
  3. Taint substitution falls back to `substituteCallerPlaceholders` / `substituteCallerHeaders` for body/header placeholders that don't have multi-caller fan-out semantics.
92
93
 
93
94
  Wired into Vue / React / Svelte pipelines in `map/index.ts`.
94
95
 
95
- - `src/map/vue_js/taint_utils.ts` — shared taint analysis primitives. Several pieces are non-obvious and exist to make `vue_resolveHttpClient` (and `vue_resolveXhr`) work on webpack output:
96
+ - `src/map/babel-legacy/vue_js/taint_utils.ts` — shared taint analysis primitives. Several pieces are non-obvious and exist to make `vue_resolveHttpClient` (and `vue_resolveXhr`) work on webpack output:
96
97
  - `EnclosingFn.paramNames` + `parent` chain: `resolveNodeValue` emits `[param:X]` for any param at any index in any enclosing function. The chain lets the helpers resolve such a marker against whichever enclosing scope actually declared X — bundled code routinely nests the resolution callsite inside an anonymous `.then(function ($) {…})` whose own params don't include X, while X is a param of an outer named function.
97
98
  - `buildAliasMap`: collects `{ exportedName: localBinding }` and `{ exportedName: () => localBinding }` patterns from object literals on a **per-file** basis. Webpack's `a.d(b, { name: () => Binding })` getter exports and re-export registries (`const ae = { request: Me }`) hide the local minifier name behind a meaningful key; without this map, `getCallers("Me")` would miss every `ae.request(...)` / `r.default.request(...)` callsite. **The map must be file-scoped** — minifier locals (`Se`, `Me`) collide across modules, and a global alias map blends unrelated functions into the same name set.
98
99
  - `makeGetCallers` accepts an optional `sourceFile` argument so callers can scope alias lookup to the file where the binding was declared. Direct minifier-local matches (`bindingName.length ≤ 2`) are dropped from the candidate list because they generate too many false positives across files; meaningful aliases (length > 2) are kept and used for both bare-identifier (`X(...)`) and member-expression (`<anything>.X(...)`) callsite matching. Overflow returns the partial caller list rather than nothing — the file-scoped alias map already suppresses noise, so partial coverage beats none.
99
- - `src/map/next_js/getWebpackConnections.ts` — extracts chunk code from webpack bundles
100
- - `src/map/next_js/interactive_helpers/esqueryGen.ts` — `esquery` interactive command: minifies a pasted snippet, matches it against each chunk's minified AST nodes, prints loose/strict selectors. Vue's command handler imports the same module — keep it framework-agnostic.
101
- - `src/map/next_js/interactive.ts` / `src/map/vue_js/interactive.ts` — export both the blessed-backed `interactive()` entry and a headless `runCommands(chunks, mapFile, commands)` that pipes `outputBox.log` to stdout for `-c/--command` execution.
102
- - `src/map/next_js/interactive_helpers/inputPatch.ts` — `enableCursorInput(inputBox)` patches a blessed textbox instance to support cursor movement, mid-string insertion, and paste-at-cursor. It overrides `_listener`/`setValue`/`_updateCursor`/`clearValue` on the instance. **Don't try to remove blessed's listener after the fact** — blessed re-binds `this._listener` on every focus, so overriding `_listener` on the instance is the only race-free approach. Shared by Next.js and Vue interactive entries.
100
+ - `src/map/babel-legacy/next_js/getWebpackConnections.ts` — extracts chunk code from webpack bundles
101
+ - `src/map/babel-legacy/next_js/interactive_helpers/esqueryGen.ts` — `esquery` interactive command: minifies a pasted snippet, matches it against each chunk's minified AST nodes, prints loose/strict selectors. Vue's command handler imports the same module — keep it framework-agnostic.
102
+ - `src/map/babel-legacy/next_js/interactive.ts` / `src/map/babel-legacy/vue_js/interactive.ts` — export both the blessed-backed `interactive()` entry and a headless `runCommands(chunks, mapFile, commands)` that pipes `outputBox.log` to stdout for `-c/--command` execution.
103
+ - `src/map/babel-legacy/next_js/interactive_helpers/inputPatch.ts` — `enableCursorInput(inputBox)` patches a blessed textbox instance to support cursor movement, mid-string insertion, and paste-at-cursor. It overrides `_listener`/`setValue`/`_updateCursor`/`clearValue` on the instance. **Don't try to remove blessed's listener after the fact** — blessed re-binds `this._listener` on every focus, so overriding `_listener` on the instance is the only race-free approach. Shared by Next.js and Vue interactive entries.
103
104
  - `src/globalConfig.ts` — current version string and tool-wide constants
104
105
  - `src/utility/globals.ts` — mutable global state (tech detection result, AI config, OpenAPI flag, etc.)
105
106
 
@@ -290,7 +291,7 @@ Covered components:
290
291
  | `utility/resolvePath.ts` — `resolvePath` | `src/__tests__/utility/resolvePath.test.ts` |
291
292
  | `strings/index.ts` — `extractStrings` | `src/__tests__/strings/extractStrings.test.ts` |
292
293
  | `analyze/helpers/validate.ts` — `parseVersion`, `compareVersions`, `isVersionCompatible` | `src/__tests__/analyze/versionCompat.test.ts` |
293
- | `map/next_js/utils.ts` — `memberChainToString` | `src/__tests__/map/memberChainToString.test.ts` |
294
+ | `map/babel-legacy/next_js/utils.ts` — `memberChainToString` | `src/__tests__/map/memberChainToString.test.ts` |
294
295
  | `fingerprint/index.ts` — `deriveOutputPath` | `src/__tests__/fingerprint/deriveOutputPath.test.ts` |
295
296
 
296
297
  When adding new pure-logic helpers, add a corresponding test file. Components that require Puppeteer, network I/O, or the full pipeline are still validated through the `run` subcommand.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.1.0-alpha.2 - 2026-11-06
4
+
5
+ ### Security
6
+
7
+ - `npm audit` is clean again; it had reported 51 vulnerabilities (32 high). `zod` moves to 4.6.7: no 3.x release fixes the memory-exhaustion advisory, and `jimp`, which `cli-print-img` uses, is overridden to the same version. `undici` moves to 7.30.2. Transitive `@hono/node-server`, `body-parser`, `fast-uri`, `glob`, `ip-address`, `minimatch` and `qs` are updated, and `deepmerge` is pinned to 4.1.2, which predates the prototype-poisoning advisory. (all)
8
+
9
+ ### Added
10
+
11
+ - New `taintwire` command builds a PookieGraph (a `.pg` file) once and queries it with `.pgq` files. `taintwire build -d <dir> -o graph.pg` loads every JS file of a directory (for example lazyload's `output/<host>`) into one [taintwire](https://taintwire.js-recon.io) graph. The files are linked through the webpack or Turbopack module registry, so a value can flow from one chunk into another. `taintwire analyze -g graph.pg -q <file/dir>` runs the rules in `.pgq` query files against it and writes the findings to `taintwire.json` (the `analyze.json` shape). `taintwire validate -q <file/dir>` checks query files without a graph. A `.pgq` file is a TypeScript module of Cypher selectors and rules, evaluated in a separate, locked-down Node.js process that can read only its query pack (Node.js 22.15 or newer); the [taintwire-queries](https://github.com/js-recon/taintwire-queries) repository is the public pack. Each finding's `message` is the rule's own message. A rule that fails while running is reported and the other rules still run; the command then exits with `41`. New exit codes `37` to `41`. (`taintwire`)
12
+ - New rule type `taintwire` and the `--analyze-taintwire` flag on `analyze` and `run`. A taintwire rule's steps are Cypher queries over a [taintwire](https://taintwire.js-recon.io) graph of each `mapped.json` chunk: a step's row ids are passed to later steps as `$<step name>`, and a step with `taintFrom` keeps only the rows that a value from that step flows into (strict, lenient or deep, with an optional `maxHops`), following variables, function arguments and return values. An optional rule-level `prefilter` regex skips chunks before they are loaded. The rules run through taintwire's pgq runner (`runPgq`). They are opt-in because loading the graphs is slow: without the flag, `analyze` prints `Skipped N taintwire rule(s)`. A `taintFrom` must name an earlier step and `maxHops` can be `0`; a step whose `requires` names no earlier step gives no findings. Chunks over 8 MB are skipped with a warning, like `map --map-taintwire` files. When a taintwire rule fails, the other rules' findings are still written and the command exits with `41` (`run` still writes the report). js-recon-rules 2.0.0 ships 31 of them. (`analyze`, `run`)
13
+ - New Next.js lazyload method `next_interceptRouteNextUrl` covers intercepting routes defined under a path that middleware guards, such as `app/admin/@modal/(..)pub/[id]`. Next.js serves such a route through its public source route when the request sends a `Next-Url` header naming the guarded path, and the middleware matcher only sees the public URL. The method reads the intercepting-route rules from `_buildManifest.js` (`__rewrites.beforeFiles`, the `next-url` condition). When the crawl hasn't found that file, it builds the URL from the buildId in the landing page. Each rule's parent path and every crawled, `strings`-extracted or `--wordlist` path gets a plain request. A path that redirects then gets the same path and its `/_next/data/<buildId>/<path>.json` route with `x-nextjs-data: 1`. The path counts as middleware-guarded if a response carries a header only middleware sets (any `x-middleware-*`, `x-nextjs-redirect` or `x-nextjs-rewrite`). For each rule whose condition matches a guarded path, the public route is requested with `Next-Url: <parent>`, and chunk paths that are missing from the plain response are downloaded. Without a manifest, the method tries every pair of guarded path and public page, up to 200 pairs. Manifest strings that Next.js hoisted into the manifest function's parameters are resolved, only `header` conditions count, and a manifest that doesn't parse falls back to the pairs mode. Each matching guarded path is also tried as `Next-Url`, next to the rule's parent path. Data routes keep the `basePath`, new chunks resolve against the asset prefix or `basePath` of the known chunk URLs, and the crawl target is always a candidate. The rule's `next-url` regex comes from the target, so each match runs with a 100 ms time limit. It runs after `next_routerStateForge` on every Next.js lazyload pass, and `--include-methods`/`--exclude-methods` control it. (`lazyload`, `run`)
14
+
15
+ ### Changed
16
+
17
+ - taintwire is updated to 0.2.0-alpha.2. (`analyze`, `map`, `run`, `taintwire`)
18
+ - `--wordlist` entries now also feed `next_interceptRouteNextUrl`, as well as `next_routerStateForge`. (`lazyload`, `run`)
19
+
20
+ ### Fixed
21
+
22
+ - `mcp --server` no longer prints the banner. The banner is an image written to stdout, which is the server's JSON-RPC channel, so MCP clients got a corrupted stream. (`mcp`)
23
+
24
+ ## 2.1.0-alpha.1 - 2026-10-21
25
+
26
+ ### Added
27
+
28
+ - `js-recon.db` now has a `raw_files` table holding the JavaScript files `lazyload` downloaded, so the database is a self-contained export of a session. Each row stores the file's path (relative to the database's directory), the URL it was downloaded from, and its contents. `run` fills it automatically; the `report` module fills it when given the new `-d/--js-dir <dir>` option (the MCP `report` tool takes `jsDir`). In a batch run the combined database gets the same table with a `domain` column. (`report`, `run`)
29
+ - New `--map-taintwire` flag on `map` and `run` resolves API calls with [taintwire](https://taintwire.js-recon.io) instead of the Babel resolvers, for every tech (`next`, `react`, `vue`/Nuxt, `svelte`, `angular`). taintwire loads the JavaScript files (for Next.js, each webpack/Turbopack module) into a graph of their syntax tree and value flow, and Cypher queries find the calls and trace where their URL, method, headers and body come from: `fetch` and `$fetch`, a `fetch` passed in by destructuring (SvelteKit `load`), Nuxt's compiled `useFetch`, `XMLHttpRequest`, HTTP clients (`.get`/`.post`/..., prefixed with the `baseURL` of the `create()` call the client comes from), `({ url, method })` config-object calls such as `axios({...})` and `new X({...})`, and Next.js Server Actions. It follows local wrappers to each caller, so a wrapper called with two paths yields both URLs. The Babel resolvers moved to `src/map/babel-legacy/` with no change in behavior, and are still the default. (`map`, `run`)
30
+ - OpenAPI output keeps `{param}` placeholders of absolute URLs as path parameters instead of percent-encoding them to `%7Bparam%7D`. (`map`)
31
+
32
+ ### Changed
33
+
34
+ - `report` now creates any missing tables in an existing `js-recon.db`, so a database from an older version gains new tables such as `raw_files` instead of failing on insert. (`report`)
35
+ - A batch run (`-u <file>`) in which some targets fail now exits with code `36` instead of `1`, after printing `[!] Batch completed: <failed> of <total> targets failed`. The targets that succeeded have already written their output and been merged into the batch's `js-recon.db`, so a caller can keep them instead of discarding the whole run. A batch in which every target fails, or one stopped by an error outside the per-target loop, still exits with `1`. (`run`)
36
+
37
+ ### Fixed
38
+
39
+ - An Angular target whose script URLs all answered with an HTML fallback page made `map` fail with `ENOENT ... scandir` on the host directory lazyload never created, which failed the target and, in a batch, the whole run's exit code. In a batch run the same target instead went through `map`, `analyze` and `report` with no files. The target now ends after lazyload with a notice in both modes, as a generic target without JavaScript does. (`run`)
40
+
3
41
  ## 2.0.1 - 2026-10-20
4
42
 
5
43
  ### Security
package/README.md CHANGED
@@ -149,6 +149,7 @@ Oxylabs traffic goes through the datacenter entry endpoint `dc.oxylabs.io:8000`
149
149
  | `load` | Populates the response cache from a Caido or Burp Suite export. | [Read Docs](https://js-recon.io/docs/docs/modules/load) |
150
150
  | `cs-mast` | Computes CS-MAST structural hashes for JS files and finds hash collisions. | [Read Docs](https://js-recon.io/docs/docs/modules/cs-mast) |
151
151
  | `sourcemaps` | Extracts original source files from `.map` sourcemap files. | [Read Docs](https://js-recon.io/docs/docs/modules/sourcemaps) |
152
+ | `taintwire` | Builds a PookieGraph (`.pg`) from JS files and queries it with `.pgq` rules. | [Read Docs](https://js-recon.io/docs/docs/modules/taintwire) |
152
153
  | `completion` | Generates shell completion scripts for bash, zsh, or fish. | [Read Docs](https://js-recon.io/docs/docs/modules/completion) |
153
154
 
154
155
  ## Key Features
@@ -0,0 +1,111 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { forEachGraph } from "../../map/taintwire/apiCalls.js";
11
+ import { printMsg, MSG } from "../../utility/printMsg.js";
12
+ // Characters of the sink expression kept in findingLocation.
13
+ const MAX_CODE = 300;
14
+ const SEVERITY_MSG = { info: MSG.Header, low: MSG.Warn, medium: MSG.Info, high: MSG.Err, critical: MSG.Err };
15
+ /**
16
+ * Print a runPgq finding and turn it into an EngineOutput: the rule's own message (its diagnostic), and the location
17
+ * plus up to 300 characters of the sink's code. The console line names the rule and the chunk.
18
+ */
19
+ export const toEngineOutput = (graph, f, meta) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const at = (x) => `${x.file}:${x.line}:${x.col}`;
21
+ const message = `[+] "${meta.ruleName}" found in chunk ${f.file}`;
22
+ const code = (yield graph.code(f.id)).slice(0, MAX_CODE);
23
+ const via = f.source ? ` <- ${at(f.source)} (${f.hops} hops)` : "";
24
+ printMsg(SEVERITY_MSG[f.severity], message);
25
+ printMsg(MSG.Plain, `${at(f)}${via}\n${code}`);
26
+ return Object.assign(Object.assign({ ruleId: f.ruleId }, meta), { severity: f.severity, message: f.message, findingLocation: `// ${at(f)}${via}\n\n${code}` });
27
+ });
28
+ /**
29
+ * A YAML taintwire rule as a pgq rule. Steps run in order: each step's row ids are a Cypher parameter
30
+ * (`$<step name>`) for the steps after it, so step k `uses` every earlier step (an empty one empties it, as a step
31
+ * with no rows used to end the rule). `taintFrom` becomes `from`, with no hop limit unless the rule sets one. The
32
+ * last step's rows are the findings. A `taintFrom` or `requires` that names no earlier step leaves the rule without
33
+ * findings, as in the AST engine, where such a step never completes.
34
+ */
35
+ export const toPgRule = (rule) => {
36
+ var _a, _b, _c, _d;
37
+ // A Map, so a step name such as `toString` or `__proto__` can't resolve to an Object.prototype member.
38
+ const steps = new Map();
39
+ let last;
40
+ let broken = false;
41
+ for (const step of rule.steps) {
42
+ const tw = step.taintwire;
43
+ const sel = {
44
+ cypher: [tw.query].flat().map((query) => ({ query })),
45
+ uses: Object.fromEntries(steps),
46
+ };
47
+ if ((_a = step.requires) === null || _a === void 0 ? void 0 : _a.some((r) => !steps.has(r)))
48
+ broken = true;
49
+ if (tw.taintFrom) {
50
+ if (!steps.has(tw.taintFrom))
51
+ broken = true; // no such earlier step: nothing flows, so no findings
52
+ sel.from = steps.get(tw.taintFrom);
53
+ sel.mode = (_b = tw.mode) !== null && _b !== void 0 ? _b : "deep";
54
+ sel.maxHops = (_c = tw.maxHops) !== null && _c !== void 0 ? _c : Number.POSITIVE_INFINITY;
55
+ }
56
+ steps.set(step.name, (last = sel));
57
+ }
58
+ const lastStep = rule.steps[rule.steps.length - 1];
59
+ return {
60
+ id: rule.id,
61
+ name: rule.name,
62
+ severity: rule.severity,
63
+ message: (_d = lastStep === null || lastStep === void 0 ? void 0 : lastStep.message) !== null && _d !== void 0 ? _d : rule.name,
64
+ return: last && !broken ? [last] : [],
65
+ };
66
+ };
67
+ /** Runs YAML taintwire `rules` on one graph through taintwire's pgq runner. */
68
+ export const runTaintwireRules = (graph, rules) => __awaiter(void 0, void 0, void 0, function* () {
69
+ const { runPgq } = yield import("@js-recon/taintwire");
70
+ const byId = new Map(rules.map((r) => [r.id, r]));
71
+ const { findings, errors } = yield runPgq(graph, rules.map(toPgRule));
72
+ for (const e of errors)
73
+ printMsg(MSG.Err, `[!] taintwire rule ${e.ruleId} failed: ${e.message}`);
74
+ const out = [];
75
+ for (const f of findings) {
76
+ const r = byId.get(f.ruleId);
77
+ out.push(yield toEngineOutput(graph, f, {
78
+ ruleName: r.name,
79
+ ruleType: r.type,
80
+ ruleDescription: r.description,
81
+ ruleAuthor: r.author,
82
+ ruleTech: r.tech,
83
+ }));
84
+ }
85
+ return { findings: out, failedRules: errors.map((e) => e.ruleId) };
86
+ });
87
+ /**
88
+ * Loads the chunks of `mapped.json` into taintwire graphs (one graph file per chunk, about 2 MB of
89
+ * source per graph) and runs every rule on each. A chunk is loaded only if some rule's prefilter
90
+ * matches it, or some rule has none: taintwire builds no cross-chunk edges, so a chunk without a
91
+ * source can't produce a finding. A rule that fails on any graph is listed in `failedRules`.
92
+ */
93
+ const taintwireEngine = (rules, chunks) => __awaiter(void 0, void 0, void 0, function* () {
94
+ const filters = rules.map((r) => (r.prefilter ? new RegExp(r.prefilter) : null));
95
+ const units = Object.values(chunks)
96
+ .filter((c) => c.code && filters.some((f) => !f || f.test(c.code)))
97
+ .map((c) => ({ name: c.id, size: c.code.length, code: () => c.code }));
98
+ printMsg(MSG.Header, `[i] Running ${rules.length} taintwire rule(s) on ${units.length} of ${Object.keys(chunks).length} chunk(s)`);
99
+ const findings = [];
100
+ const failed = new Set();
101
+ yield forEachGraph(units, (graph) => __awaiter(void 0, void 0, void 0, function* () {
102
+ const run = yield runTaintwireRules(graph, rules);
103
+ for (const f of run.findings)
104
+ findings.push(f);
105
+ for (const id of run.failedRules)
106
+ failed.add(id);
107
+ }));
108
+ return { findings, failedRules: [...failed] };
109
+ });
110
+ export default taintwireEngine;
111
+ //# sourceMappingURL=taintwireEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taintwireEngine.js","sourceRoot":"","sources":["../../../src/analyze/engine/taintwireEngine.ts"],"names":[],"mappings":";;;;;;;;;AAIA,OAAO,EAAa,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAE1D,6DAA6D;AAC7D,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAW,CAAC;AAKtH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAO,KAAkB,EAAE,CAAa,EAAE,IAAiB,EAAyB,EAAE;IAChH,MAAM,EAAE,GAAG,CAAC,CAAc,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;IAC9D,MAAM,OAAO,GAAG,QAAQ,IAAI,CAAC,QAAQ,oBAAoB,CAAC,CAAC,IAAI,EAAE,CAAC;IAClE,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,QAAQ,CA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38
  });
39
+ const taintwireStepSchema = z.object({
40
+ query: z.union([z.string(), z.array(z.string()).min(1)]),
41
+ taintFrom: z.string().optional(),
42
+ mode: z.enum(["strict", "lenient", "deep"]).optional(),
43
+ maxHops: z.number().int().nonnegative().optional(),
44
+ });
39
45
  const stepSchema = z.object({
40
46
  name: z.string(),
41
47
  message: z.string(),
@@ -46,8 +52,10 @@ const stepSchema = z.object({
46
52
  checkAssignmentExist: checkAssignmentExistStepSchema.optional(),
47
53
  regexMatch: regexMatchStepSchema.optional(),
48
54
  csMastS: csMastSStepSchema.optional(),
55
+ taintwire: taintwireStepSchema.optional(),
49
56
  });
50
- export const ruleSchema = z.object({
57
+ export const ruleSchema = z
58
+ .object({
51
59
  id: z.string(),
52
60
  name: z.string(),
53
61
  author: z.string(),
@@ -56,7 +64,28 @@ export const ruleSchema = z.object({
56
64
  js_recon_max_version: z.string().optional(),
57
65
  tech: z.array(z.enum(["next", "vue", "react", "svelte", "angular", "all"])),
58
66
  severity: z.enum(["info", "low", "medium", "high"]),
59
- type: z.enum(["request", "ast", "cs-mast-s"]),
67
+ type: z.enum(["request", "ast", "cs-mast-s", "taintwire"]),
68
+ prefilter: z.string().optional(),
60
69
  steps: z.array(stepSchema),
61
- });
70
+ })
71
+ .refine((r) => r.type !== "taintwire" ||
72
+ r.steps.every((s) => s.taintwire && /^[A-Za-z_]\w*$/.test(s.name) && s.name !== "__proto__"),
73
+ // step names become Cypher parameters ($<name>) for later steps; __proto__ would be lost as an object key
74
+ {
75
+ message: "every step of a taintwire rule needs a taintwire block and a name made of letters, digits and _ (not __proto__)",
76
+ })
77
+ .refine((r) => r.type !== "taintwire" ||
78
+ r.steps.every((s, i) => {
79
+ var _a;
80
+ const from = (_a = s.taintwire) === null || _a === void 0 ? void 0 : _a.taintFrom;
81
+ return from === undefined || r.steps.slice(0, i).some((earlier) => earlier.name === from);
82
+ }), { message: "a taintwire step's taintFrom must name an earlier step" })
83
+ .refine((r) => {
84
+ try {
85
+ return !r.prefilter || !!new RegExp(r.prefilter);
86
+ }
87
+ catch (_a) {
88
+ return false;
89
+ }
90
+ }, { message: "prefilter must be a valid regular expression", path: ["prefilter"] });
62
91
  //# sourceMappingURL=schemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/analyze/helpers/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC9B,CAAC,CAAC,MAAM,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;QAC1B,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;KACnB,CAAC;IACF,CAAC,CAAC,MAAM,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;QACtB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;KACnB,CAAC;IACF,CAAC,CAAC,MAAM,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;KACnB,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,CAAC,CAAC,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CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC9F,CAAC,CAAC,EACN,EAAE,OAAO,EAAE,wDAAwD,EAAE,CACxE;KACA,MAAM,CACH,CAAC,CAAC,EAAE,EAAE;IACF,IAAI,CAAC;QACD,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAAC,WAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC,EACD,EAAE,OAAO,EAAE,8CAA8C,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CACnF,CAAC"}
@@ -66,22 +66,26 @@ const validateRules = (ruleFiles) => __awaiter(void 0, void 0, void 0, function*
66
66
  try {
67
67
  const ruleData = fs.readFileSync(ruleFile, "utf8");
68
68
  const rule = yaml.parse(ruleData);
69
- ruleSchema.parse(rule);
70
- if (!isVersionCompatible(rule.js_recon_version, CONFIG.version)) {
69
+ // Version first: a rule written for a newer js-recon (say, a rule type this version
70
+ // doesn't know) is skipped rather than failing schema validation.
71
+ if (typeof (rule === null || rule === void 0 ? void 0 : rule.js_recon_version) === "string" &&
72
+ !isVersionCompatible(rule.js_recon_version, CONFIG.version)) {
71
73
  printMsg(MSG.Warn, `[!] Skipping ${ruleFile}: requires js-recon ${rule.js_recon_version} (current: ${CONFIG.version})`);
72
74
  continue;
73
75
  }
74
- if (rule.js_recon_max_version && !isVersionCompatible(rule.js_recon_max_version, CONFIG.version)) {
76
+ if (typeof (rule === null || rule === void 0 ? void 0 : rule.js_recon_max_version) === "string" &&
77
+ !isVersionCompatible(rule.js_recon_max_version, CONFIG.version)) {
75
78
  printMsg(MSG.Warn, `[!] Skipping ${ruleFile}: requires js-recon ${rule.js_recon_max_version} (current: ${CONFIG.version})`);
76
79
  continue;
77
80
  }
81
+ ruleSchema.parse(rule);
78
82
  compatibleRuleFiles.push(ruleFile);
79
83
  }
80
84
  catch (error) {
81
85
  allValid = false;
82
86
  printMsg(MSG.Err, `[!] Invalid rule in ${ruleFile}:`);
83
- if (error.errors) {
84
- for (const err of error.errors) {
87
+ if (error.issues) {
88
+ for (const err of error.issues) {
85
89
  printMsg(MSG.Err, ` - ${err.path.join(".")} - ${err.message}`);
86
90
  }
87
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/analyze/helpers/validate.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAA4B,EAAE;IACtE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAA2B,EAAE,CAA2B,EAAU,EAAE;IAChG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC,CAAC,CAA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,CAAA,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -16,6 +16,8 @@ import yaml from "yaml";
16
16
  import initRules from "./helpers/initRules.js";
17
17
  import { generateEngineOutput } from "./helpers/outputHelper.js";
18
18
  import { printMsg, MSG } from "../utility/printMsg.js";
19
+ import { getAnalyzeTaintwire } from "../utility/globals.js";
20
+ import { listFilesRecursive } from "../utility/listFiles.js";
19
21
  const availableTechs = {
20
22
  next: "Next.js",
21
23
  vue: "Vue.js",
@@ -23,32 +25,6 @@ const availableTechs = {
23
25
  svelte: "Svelte/Astro",
24
26
  angular: "Angular",
25
27
  };
26
- /**
27
- * Recursively searches for YAML rule files in a directory.
28
- *
29
- * @param dir - The directory path to search for rule files
30
- * @returns An array of file paths to YAML rule files (.yml or .yaml)
31
- */
32
- const getRuleFilesRecursive = (dir) => {
33
- let results = [];
34
- const list = fs.readdirSync(dir);
35
- list.forEach(function (entry) {
36
- // skip hidden directories (e.g. .github)
37
- if (entry.startsWith("."))
38
- return;
39
- const file = path.join(dir, entry);
40
- const stat = fs.statSync(file);
41
- if (stat && stat.isDirectory()) {
42
- results = results.concat(getRuleFilesRecursive(file));
43
- }
44
- else {
45
- if (file.endsWith(".yml") || file.endsWith(".yaml")) {
46
- results.push(file);
47
- }
48
- }
49
- });
50
- return results;
51
- };
52
28
  /**
53
29
  * Analyzes JavaScript code using custom rules and generates findings.
54
30
  *
@@ -82,7 +58,7 @@ const analyze = (rulesPath_1, mappedJson_1, tech_1, list_1, openapi_1, validate_
82
58
  // now that the rule thing exist, check if it is a direcotory or a file
83
59
  let ruleFiles = [];
84
60
  if (fs.lstatSync(rulesPath).isDirectory()) {
85
- ruleFiles = getRuleFilesRecursive(rulesPath);
61
+ ruleFiles = listFilesRecursive(rulesPath, [".yml", ".yaml"]);
86
62
  }
87
63
  else {
88
64
  ruleFiles = [rulesPath];
@@ -145,18 +121,46 @@ const analyze = (rulesPath_1, mappedJson_1, tech_1, list_1, openapi_1, validate_
145
121
  }
146
122
  // iterate over the ruleFiles
147
123
  const ruleFindings = [];
124
+ const taintwireRules = [];
148
125
  for (const ruleFile of compatibleRuleFiles) {
149
126
  // load the rule
150
127
  const rule = yaml.parse(fs.readFileSync(ruleFile, "utf8"));
128
+ // taintwire rules share one set of graphs, so they run together below
129
+ if (rule.type === "taintwire") {
130
+ if (rule.tech.includes(tech) || rule.tech.includes("all"))
131
+ taintwireRules.push(rule);
132
+ continue;
133
+ }
151
134
  // run the rule
152
135
  const engineFindings = yield engine(rule, mappedJsonData, openapiData, tech);
153
136
  // add findings to the global findings
154
- if (engineFindings) {
155
- ruleFindings.push(...engineFindings);
137
+ // one at a time: spreading a large array into push() exceeds the argument limit
138
+ if (engineFindings)
139
+ for (const finding of engineFindings)
140
+ ruleFindings.push(finding);
141
+ }
142
+ let failedTaintwireRules = [];
143
+ if (taintwireRules.length > 0 && mappedJsonData) {
144
+ if (getAnalyzeTaintwire()) {
145
+ // dynamic import: the native graph database loads only when taintwire rules run
146
+ const { default: taintwireEngine } = yield import("./engine/taintwireEngine.js");
147
+ const { findings, failedRules } = yield taintwireEngine(taintwireRules, mappedJsonData);
148
+ for (const finding of findings)
149
+ ruleFindings.push(finding);
150
+ failedTaintwireRules = failedRules;
151
+ }
152
+ else {
153
+ printMsg(MSG.Info, `[i] Skipped ${taintwireRules.length} taintwire rule(s); pass --analyze-taintwire to run them`);
156
154
  }
157
155
  }
158
156
  // generate the engine output
159
157
  generateEngineOutput(outputFile, ruleFindings);
158
+ // The findings of the other rules are written; the exit code tells a caller this analysis is incomplete.
159
+ // exitCode, not exit(): run keeps going to the report step and exits with it.
160
+ if (failedTaintwireRules.length > 0) {
161
+ printMsg(MSG.Err, `[!] ${failedTaintwireRules.length} taintwire rule(s) failed: ${failedTaintwireRules.join(", ")}`);
162
+ process.exitCode = 41;
163
+ }
160
164
  });
161
165
  export default analyze;
162
166
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/analy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