loadwise 0.8.0 → 0.9.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.
Files changed (584) hide show
  1. package/PERFORMANCE.md +17 -0
  2. package/README.md +238 -713
  3. package/agent/hooks/check-edited-file.mjs +682 -0
  4. package/dist/bin/github-action.js +143 -18
  5. package/dist/bin/loadwise.js +15 -28
  6. package/dist/lib/accessibility/angular-literal.js +1 -1
  7. package/dist/lib/accessibility/astro-template.js +111 -0
  8. package/dist/lib/accessibility/autofocus.js +94 -0
  9. package/dist/lib/accessibility/document-reference-rules.js +133 -0
  10. package/dist/lib/accessibility/form-context.js +7 -2
  11. package/dist/lib/accessibility/frontend-detect.js +18 -8
  12. package/dist/lib/accessibility/heading-order.js +59 -0
  13. package/dist/lib/accessibility/interaction-semantics.js +90 -0
  14. package/dist/lib/accessibility/jinja-template.js +150 -0
  15. package/dist/lib/accessibility/jsx-elements.js +134 -9
  16. package/dist/lib/accessibility/language-tags.js +18 -0
  17. package/dist/lib/accessibility/markup-files.js +44 -17
  18. package/dist/lib/accessibility/markup.js +4 -1
  19. package/dist/lib/accessibility/media-rules.js +81 -0
  20. package/dist/lib/accessibility/native-interactive.js +107 -0
  21. package/dist/lib/accessibility/rule-ids.js +30 -0
  22. package/dist/lib/accessibility/rule-utilities.js +92 -0
  23. package/dist/lib/accessibility/rules.js +74 -139
  24. package/dist/lib/accessibility/site-fixes/buttons.js +4 -11
  25. package/dist/lib/accessibility/site-fixes/email-autocomplete.js +103 -0
  26. package/dist/lib/accessibility/site-fixes/html-language.js +48 -0
  27. package/dist/lib/accessibility/site-fixes/media-autoplay.js +87 -0
  28. package/dist/lib/accessibility/site-fixes/positive-tabindex.js +102 -0
  29. package/dist/lib/accessibility/site-fixes/source-position.js +11 -0
  30. package/dist/lib/accessibility/site-fixes/viewport.js +107 -0
  31. package/dist/lib/accessibility/table-headers.js +70 -0
  32. package/dist/lib/accessibility/template-attributes.js +13 -2
  33. package/dist/lib/accessibility/template-binding-scope.js +122 -0
  34. package/dist/lib/accessibility/template-elements.js +257 -109
  35. package/dist/lib/accessibility/template-file.js +111 -22
  36. package/dist/lib/accessibility/template-tag-tables.js +86 -0
  37. package/dist/lib/accessibility/usage.js +1 -1
  38. package/dist/lib/editor/accessibility-examples.js +5 -0
  39. package/dist/lib/editor/actions.js +11 -5
  40. package/dist/lib/editor/apply-fix.js +30 -2
  41. package/dist/lib/editor/configured-setup.js +9 -14
  42. package/dist/lib/editor/diagnostics.js +9 -26
  43. package/dist/lib/editor/dismissals.js +21 -10
  44. package/dist/lib/editor/doctor.js +167 -0
  45. package/dist/lib/editor/editor-document.js +17 -1
  46. package/dist/lib/editor/editor-launcher.js +60 -26
  47. package/dist/lib/editor/fix-edits.js +87 -8
  48. package/dist/lib/editor/jetbrains-setup.js +2 -1
  49. package/dist/lib/editor/language-server.js +220 -47
  50. package/dist/lib/editor/native-setup.js +7 -2
  51. package/dist/lib/editor/perf-watch.js +7 -5
  52. package/dist/lib/editor/performance-examples.js +31 -0
  53. package/dist/lib/editor/polyglot-selection.js +193 -0
  54. package/dist/lib/editor/project-policy.js +146 -0
  55. package/dist/lib/editor/project-watches.js +86 -0
  56. package/dist/lib/editor/release-vsix.js +23 -1
  57. package/dist/lib/editor/reliability-examples.js +36 -0
  58. package/dist/lib/editor/scan-session.js +210 -61
  59. package/dist/lib/editor/security-examples.js +24 -14
  60. package/dist/lib/editor/server-commands.js +24 -11
  61. package/dist/lib/editor/setup.js +7 -12
  62. package/dist/lib/editor/standalone-performance-examples.js +3 -0
  63. package/dist/lib/editor/workspace-files.js +32 -8
  64. package/dist/lib/editor/workspace-paths.js +29 -7
  65. package/dist/lib/editor/zed-settings.js +118 -0
  66. package/dist/lib/editor/zed-setup.js +88 -0
  67. package/dist/lib/maintainability/analysis/analyze-source.js +6 -3
  68. package/dist/lib/maintainability/analysis/source-exclusions.js +2 -1
  69. package/dist/lib/maintainability/analysis/source-facts.js +2 -2
  70. package/dist/lib/maintainability/architecture/graph.js +2 -1
  71. package/dist/lib/maintainability/architecture/layout.js +2 -1
  72. package/dist/lib/maintainability/cli/apply-fix.js +32 -7
  73. package/dist/lib/maintainability/cli/changed-lines.js +7 -113
  74. package/dist/lib/maintainability/cli/finding-ids.js +3 -6
  75. package/dist/lib/maintainability/cli/fix-cli.js +1 -9
  76. package/dist/lib/maintainability/cli/git-inventory.js +5 -6
  77. package/dist/lib/maintainability/cli/inputs.js +12 -11
  78. package/dist/lib/maintainability/cli/scan-arguments.js +33 -0
  79. package/dist/lib/maintainability/cli/site-fix.js +28 -13
  80. package/dist/lib/maintainability/cli.js +25 -35
  81. package/dist/lib/maintainability/entry-points/entry-points.js +27 -68
  82. package/dist/lib/maintainability/examples.js +12 -0
  83. package/dist/lib/maintainability/polyglot-duplicates.js +1 -0
  84. package/dist/lib/maintainability/polyglot.js +337 -12
  85. package/dist/lib/maintainability/project.js +4 -4
  86. package/dist/lib/maintainability/quality/console-tooling.js +114 -0
  87. package/dist/lib/maintainability/quality/declarative-imports.js +18 -0
  88. package/dist/lib/maintainability/quality/deprecated-apis.js +227 -40
  89. package/dist/lib/maintainability/quality/duplicates.js +5 -11
  90. package/dist/lib/maintainability/quality/generic-assertion-target.js +75 -0
  91. package/dist/lib/maintainability/quality/limits.js +5 -1
  92. package/dist/lib/maintainability/quality/size-limits.js +2 -1
  93. package/dist/lib/maintainability/quality/stray-console.js +31 -7
  94. package/dist/lib/maintainability/quality/tsconfig-strict.js +125 -6
  95. package/dist/lib/maintainability/quality/type-escape-hatches.js +411 -0
  96. package/dist/lib/maintainability/quality/type-safety-hygiene.js +132 -42
  97. package/dist/lib/maintainability/quality/unowned-source.js +15 -0
  98. package/dist/lib/maintainability/rule-ids.js +9 -0
  99. package/dist/lib/maintainability/scan-changed.js +6 -1
  100. package/dist/lib/maintainability/scan-worker.js +3 -5
  101. package/dist/lib/maintainability/scan.js +16 -3
  102. package/dist/lib/maintainability/site-fixes/duplicate-edits.js +3 -2
  103. package/dist/lib/maintainability/site-fixes/duplicate-methods.js +7 -2
  104. package/dist/lib/maintainability/site-fixes/duplicates.js +3 -2
  105. package/dist/lib/maintainability/site-fixes/focused-test.js +230 -0
  106. package/dist/lib/maintainability/site-fixes/helpers.js +2 -6
  107. package/dist/lib/maintainability/site-fixes/if-rewrites.js +1 -7
  108. package/dist/lib/maintainability/site-fixes/large-module.js +2 -1
  109. package/dist/lib/maintainability/unused/ancestor-aliases.js +2 -2
  110. package/dist/lib/maintainability/unused/module-usage-dynamic.js +2 -1
  111. package/dist/lib/maintainability/unused/module-usage-named-exports.js +125 -0
  112. package/dist/lib/maintainability/unused/module-usage.js +8 -3
  113. package/dist/lib/maintainability/unused/unused-modules.js +35 -1
  114. package/dist/lib/performance/analysis/call-syntax.js +2 -1
  115. package/dist/lib/performance/analysis/function-kinds.js +1 -5
  116. package/dist/lib/performance/analysis/missing-packages.js +10 -7
  117. package/dist/lib/performance/analysis/package-types.js +10 -2
  118. package/dist/lib/performance/analysis/schema-tooling.js +157 -8
  119. package/dist/lib/performance/analysis/source-inputs.js +17 -12
  120. package/dist/lib/performance/analysis/unscanned-javascript.js +6 -5
  121. package/dist/lib/performance/analyze.js +22 -6
  122. package/dist/lib/performance/async/async-errors.js +162 -14
  123. package/dist/lib/performance/async/await-before-early-exit.js +1 -6
  124. package/dist/lib/performance/async/floating-promises.js +2 -2
  125. package/dist/lib/performance/async/promise-return-escapes-catch.js +35 -2
  126. package/dist/lib/performance/async/stream-errors.js +1 -3
  127. package/dist/lib/performance/cli/changed-lines.js +14 -111
  128. package/dist/lib/performance/cli/cli-arguments.js +11 -9
  129. package/dist/lib/performance/cli/cli-markup.js +42 -0
  130. package/dist/lib/performance/cli/cli-policy.js +150 -16
  131. package/dist/lib/performance/cli/cli-scan.js +148 -118
  132. package/dist/lib/performance/cli/finding-ids.js +7 -7
  133. package/dist/lib/performance/cli/fix-cli.js +83 -34
  134. package/dist/lib/performance/cli/prisma-schema-findings.js +23 -0
  135. package/dist/lib/performance/cli/watch-security.js +33 -0
  136. package/dist/lib/performance/cli/watch.js +17 -9
  137. package/dist/lib/performance/cli.js +8 -7
  138. package/dist/lib/performance/collections/array-drains.js +354 -0
  139. package/dist/lib/performance/collections/collection-bindings.js +1 -2
  140. package/dist/lib/performance/collections/collection-bounds.js +3 -2
  141. package/dist/lib/performance/collections/collection-copy.js +51 -1
  142. package/dist/lib/performance/collections/collection-lookups.js +47 -3
  143. package/dist/lib/performance/collections/collection-reduce.js +0 -4
  144. package/dist/lib/performance/collections/collections.js +6 -2
  145. package/dist/lib/performance/collections/json-clone.js +137 -17
  146. package/dist/lib/performance/collections/regex-allocation.js +156 -0
  147. package/dist/lib/performance/collections/repeated.js +2 -8
  148. package/dist/lib/performance/collections/sort-extreme.js +18 -1
  149. package/dist/lib/performance/collections/workbook-decodes.js +3 -2
  150. package/dist/lib/performance/contracts/cli.js +329 -21
  151. package/dist/lib/performance/contracts/git-files.js +57 -5
  152. package/dist/lib/performance/contracts/openapi-schema.js +187 -0
  153. package/dist/lib/performance/contracts/openapi-sources.js +260 -0
  154. package/dist/lib/performance/contracts/openapi.js +172 -233
  155. package/dist/lib/performance/contracts/protobuf.js +301 -0
  156. package/dist/lib/performance/contracts/trpc-moves.js +46 -0
  157. package/dist/lib/performance/contracts/trpc.js +477 -0
  158. package/dist/lib/performance/datastores/pg-integrity.js +2 -1
  159. package/dist/lib/performance/datastores/pooling.js +2 -1
  160. package/dist/lib/performance/datastores/redis-keys.js +4 -3
  161. package/dist/lib/performance/datastores/redis.js +8 -1
  162. package/dist/lib/performance/datastores/repeated-reads.js +104 -0
  163. package/dist/lib/performance/datastores/search-clients.js +9 -0
  164. package/dist/lib/performance/datastores/session-store.js +166 -7
  165. package/dist/lib/performance/datastores/supabase.js +73 -0
  166. package/dist/lib/performance/db/checks.js +1 -1
  167. package/dist/lib/performance/db/cli-mysql.js +12 -2
  168. package/dist/lib/performance/db/cli.js +38 -5
  169. package/dist/lib/performance/db/drivers.js +20 -4
  170. package/dist/lib/performance/db/measure.js +1 -1
  171. package/dist/lib/performance/db/mysql-catalog.js +1 -1
  172. package/dist/lib/performance/db/plan-estimates.js +46 -7
  173. package/dist/lib/performance/db/redact.js +1 -3
  174. package/dist/lib/performance/db/snapshot.js +1 -1
  175. package/dist/lib/performance/db/sqlite-plan.js +95 -0
  176. package/dist/lib/performance/engine/compiler.js +3 -2
  177. package/dist/lib/performance/engine/native-checker.js +85 -10
  178. package/dist/lib/performance/engine/native-syntax.js +17 -0
  179. package/dist/lib/performance/engine/native-workspaces.js +36 -8
  180. package/dist/lib/performance/engine/native.js +38 -16
  181. package/dist/lib/performance/engine/review-config-inputs.js +57 -0
  182. package/dist/lib/performance/evidence/plans.js +14 -16
  183. package/dist/lib/performance/evidence/trace-formats.js +182 -0
  184. package/dist/lib/performance/evidence/traces.js +6 -6
  185. package/dist/lib/performance/frontend/angular-bootstrap.js +309 -0
  186. package/dist/lib/performance/frontend/barrel-subpaths.js +204 -0
  187. package/dist/lib/performance/frontend/effect-cleanup.js +30 -4
  188. package/dist/lib/performance/frontend/frontend-dom-perf.js +11 -7
  189. package/dist/lib/performance/frontend/frontend-perf.js +4 -5
  190. package/dist/lib/performance/frontend/frontend-render-perf.js +10 -10
  191. package/dist/lib/performance/frontend/layout-binary-probe.js +186 -0
  192. package/dist/lib/performance/frontend/next-fetch-waterfall.js +88 -0
  193. package/dist/lib/performance/frontend/template-tracking.js +131 -0
  194. package/dist/lib/performance/index-rules/index-rules-table.js +3 -3
  195. package/dist/lib/performance/index-rules/redundant-indexes.js +6 -13
  196. package/dist/lib/performance/migrations/cli.js +65 -14
  197. package/dist/lib/performance/migrations/discover.js +63 -32
  198. package/dist/lib/performance/migrations/enforce.js +5 -12
  199. package/dist/lib/performance/migrations/extract-code-sql.js +10 -7
  200. package/dist/lib/performance/migrations/extract-code.js +1 -0
  201. package/dist/lib/performance/migrations/extract-sql.js +45 -4
  202. package/dist/lib/performance/migrations/extract-sqlite.js +302 -0
  203. package/dist/lib/performance/migrations/operations.js +122 -8
  204. package/dist/lib/performance/migrations/postgres-registry.js +6 -6
  205. package/dist/lib/performance/migrations/postgres-table-history.js +147 -0
  206. package/dist/lib/performance/migrations/rules-postgres-shared.js +4 -6
  207. package/dist/lib/performance/migrations/rules-postgres.js +67 -13
  208. package/dist/lib/performance/migrations/rules-sqlite.js +118 -0
  209. package/dist/lib/performance/migrations/sqlserver-creation.js +131 -0
  210. package/dist/lib/performance/migrations/sqlserver.js +81 -0
  211. package/dist/lib/performance/models/client-imports.js +286 -0
  212. package/dist/lib/performance/models/index.js +46 -8
  213. package/dist/lib/performance/orm/cartesian-includes.js +49 -22
  214. package/dist/lib/performance/orm/drizzle.js +86 -27
  215. package/dist/lib/performance/orm/knex-loop-operations.js +96 -0
  216. package/dist/lib/performance/orm/orm-owners.js +3 -5
  217. package/dist/lib/performance/orm/orm-queries.js +50 -152
  218. package/dist/lib/performance/orm/orm-result-uses.js +116 -0
  219. package/dist/lib/performance/orm/prisma-integrity.js +24 -3
  220. package/dist/lib/performance/orm/prisma.js +31 -8
  221. package/dist/lib/performance/orm/typeorm-batch-filter.js +43 -0
  222. package/dist/lib/performance/orm/typeorm-projection.js +2 -2
  223. package/dist/lib/performance/orm/typeorm-transaction-loops.js +3 -4
  224. package/dist/lib/performance/orm/typeorm-updates.js +1 -3
  225. package/dist/lib/performance/orm/unbounded-list-page-size.js +179 -0
  226. package/dist/lib/performance/orm/unbounded-list-queries.js +63 -146
  227. package/dist/lib/performance/polyglot.js +173 -61
  228. package/dist/lib/performance/probe-caches.js +42 -0
  229. package/dist/lib/performance/program-batches.js +138 -0
  230. package/dist/lib/performance/projects.js +85 -89
  231. package/dist/lib/performance/query-loops/guard-queries.js +2 -1
  232. package/dist/lib/performance/query-loops/parallel-reads-policy.js +1 -3
  233. package/dist/lib/performance/query-loops/query-loop-batch.js +81 -7
  234. package/dist/lib/performance/query-loops/query-loop-bounds.js +1 -13
  235. package/dist/lib/performance/query-loops/query-policy.js +19 -20
  236. package/dist/lib/performance/query-loops/query-results.js +1 -6
  237. package/dist/lib/performance/query-loops/query-write-context.js +89 -0
  238. package/dist/lib/performance/query-loops/sequential-loops.js +6 -24
  239. package/dist/lib/performance/query-loops/service-call-resolution.js +17 -2
  240. package/dist/lib/performance/query-loops/service-loop-source.js +124 -0
  241. package/dist/lib/performance/query-loops/service-loops.js +48 -17
  242. package/dist/lib/performance/query-loops/throw-on-miss-loops.js +141 -0
  243. package/dist/lib/performance/request/backend-mastery.js +18 -30
  244. package/dist/lib/performance/request/fixed-emitter-loop.js +98 -0
  245. package/dist/lib/performance/request/fresh-mapped-elements.js +137 -0
  246. package/dist/lib/performance/request/graphql-list-lookups.js +258 -0
  247. package/dist/lib/performance/request/http-options-writes.js +2 -8
  248. package/dist/lib/performance/request/http-timeouts.js +3 -2
  249. package/dist/lib/performance/request/json-stringify-output.js +139 -0
  250. package/dist/lib/performance/request/llm-max-tokens.js +27 -8
  251. package/dist/lib/performance/request/mongoose-lean.js +15 -10
  252. package/dist/lib/performance/request/node-event-listener-leak.js +190 -35
  253. package/dist/lib/performance/request/node-fs-context.js +6 -8
  254. package/dist/lib/performance/request/node-fs.js +4 -6
  255. package/dist/lib/performance/request/password-hashing.js +4 -3
  256. package/dist/lib/performance/request/phase5-ast.js +3 -9
  257. package/dist/lib/performance/request/phase5-rules.js +50 -102
  258. package/dist/lib/performance/request/pure-js-hashing.js +2 -1
  259. package/dist/lib/performance/request/request-handlers.js +1 -3
  260. package/dist/lib/performance/request/request-inputs.js +121 -26
  261. package/dist/lib/performance/request/unbounded-promise-all.js +132 -3
  262. package/dist/lib/performance/rule-ids.js +47 -4
  263. package/dist/lib/performance/schema/context.js +7 -16
  264. package/dist/lib/performance/schema/model.js +1 -9
  265. package/dist/lib/performance/schema/prisma-owners.js +15 -1
  266. package/dist/lib/performance/schema/prisma-schema.js +5 -6
  267. package/dist/lib/performance/schema/project-indexes-events.js +8 -2
  268. package/dist/lib/performance/schema/project-indexes.js +4 -2
  269. package/dist/lib/performance/schema/query-site-support.js +1 -1
  270. package/dist/lib/performance/schema/sequelize-schema.js +1 -3
  271. package/dist/lib/performance/schema/ts-helpers.js +3 -7
  272. package/dist/lib/performance/shared-libs.js +48 -0
  273. package/dist/lib/performance/site-fix.js +32 -7
  274. package/dist/lib/performance/site-fixes/collection-copy.js +2 -1
  275. package/dist/lib/performance/site-fixes/collection-existence.js +2 -1
  276. package/dist/lib/performance/site-fixes/collection-find.js +2 -1
  277. package/dist/lib/performance/site-fixes/collection-helpers.js +0 -6
  278. package/dist/lib/performance/site-fixes/collection-lookups.js +2 -1
  279. package/dist/lib/performance/site-fixes/database.js +7 -16
  280. package/dist/lib/performance/site-fixes/drizzle-index.js +2 -9
  281. package/dist/lib/performance/site-fixes/frontend-fixes.js +47 -15
  282. package/dist/lib/performance/site-fixes/helpers.js +19 -18
  283. package/dist/lib/performance/site-fixes/last-insert-id.js +2 -1
  284. package/dist/lib/performance/site-fixes/llm-max-tokens.js +56 -0
  285. package/dist/lib/performance/site-fixes/migration-column-rules.js +11 -7
  286. package/dist/lib/performance/site-fixes/migration-lock-rules.js +6 -3
  287. package/dist/lib/performance/site-fixes/migrations.js +4 -0
  288. package/dist/lib/performance/site-fixes/pure-js-hashing.js +2 -2
  289. package/dist/lib/performance/site-fixes/query-shapes.js +1 -4
  290. package/dist/lib/performance/site-fixes/service-loop-ast.js +1 -9
  291. package/dist/lib/performance/site-fixes/small-rewrites.js +28 -2
  292. package/dist/lib/performance/site-fixes/template-tracking-fixes.js +82 -0
  293. package/dist/lib/performance/site-fixes/writes.js +1 -6
  294. package/dist/lib/performance/sql/local-statements.js +108 -0
  295. package/dist/lib/performance/sql/mysql-tokens.js +1 -4
  296. package/dist/lib/performance/sql/pg-parser.js +3 -5
  297. package/dist/lib/performance/sql/sqlserver-control.js +43 -0
  298. package/dist/lib/reliability/analyze.js +48 -5
  299. package/dist/lib/reliability/boundary-access.js +34 -27
  300. package/dist/lib/reliability/callback-completion.js +10 -2
  301. package/dist/lib/reliability/child-process.js +2 -2
  302. package/dist/lib/reliability/crlf-line-split.js +124 -73
  303. package/dist/lib/reliability/crlf-references.js +78 -0
  304. package/dist/lib/reliability/default-numeric-sort.js +25 -0
  305. package/dist/lib/reliability/error-cause-plan.js +29 -0
  306. package/dist/lib/reliability/error-values.js +68 -27
  307. package/dist/lib/reliability/json-cast.js +368 -0
  308. package/dist/lib/reliability/key-test-callee.js +50 -0
  309. package/dist/lib/reliability/lossy-text-rewrite.js +94 -0
  310. package/dist/lib/reliability/manifest-boundary.js +466 -0
  311. package/dist/lib/reliability/manifest-snapshot.js +40 -0
  312. package/dist/lib/reliability/parse-failure-flow.js +5 -2
  313. package/dist/lib/reliability/parse-failure-paths.js +39 -8
  314. package/dist/lib/reliability/parse-failure-reset.js +5 -17
  315. package/dist/lib/reliability/pool-timeout.js +31 -7
  316. package/dist/lib/reliability/promise-usage.js +281 -0
  317. package/dist/lib/reliability/react-bugs.js +7 -6
  318. package/dist/lib/reliability/react-state-order.js +2 -2
  319. package/dist/lib/reliability/react-state-paths.js +2 -2
  320. package/dist/lib/reliability/react-state-setter.js +5 -11
  321. package/dist/lib/reliability/react-state-walker.js +3 -3
  322. package/dist/lib/reliability/required-member.js +19 -0
  323. package/dist/lib/reliability/resource-leak-intervals.js +4 -7
  324. package/dist/lib/reliability/resource-leaks.js +4 -7
  325. package/dist/lib/reliability/rule-ids.js +70 -1
  326. package/dist/lib/reliability/same-file-io.js +135 -0
  327. package/dist/lib/reliability/short-write.js +220 -0
  328. package/dist/lib/reliability/site-fixes/crlf-line-split.js +71 -0
  329. package/dist/lib/reliability/site-fixes/error-values.js +40 -0
  330. package/dist/lib/reliability/site-fixes/pool-timeout.js +51 -0
  331. package/dist/lib/reliability/source-helpers.js +18 -8
  332. package/dist/lib/reliability/standalone-sources.js +8 -6
  333. package/dist/lib/reliability/suspicious-logic.js +6 -8
  334. package/dist/lib/reliability/swallowed-errors.js +3 -7
  335. package/dist/lib/reliability/switch-exhaustive.js +195 -5
  336. package/dist/lib/reliability/test-cleanup-after-await.js +2 -2
  337. package/dist/lib/reliability/throw-string-plan.js +121 -0
  338. package/dist/lib/reliability/uncaught-exception.js +2 -7
  339. package/dist/lib/reliability/usage.js +1 -1
  340. package/dist/lib/reliability/working-directory.js +101 -0
  341. package/dist/lib/security/analyze.js +2 -0
  342. package/dist/lib/security/auth-crypto/hashing.js +21 -4
  343. package/dist/lib/security/auth-crypto/index.js +6 -1
  344. package/dist/lib/security/auth-crypto/jwt-decode-helpers.js +163 -0
  345. package/dist/lib/security/auth-crypto/jwt.js +52 -36
  346. package/dist/lib/security/auth-crypto/plaintext-password.js +2 -1
  347. package/dist/lib/security/auth-crypto/random.js +2 -1
  348. package/dist/lib/security/auth-crypto/rate-limits.js +79 -8
  349. package/dist/lib/security/auth-crypto/rule-ids.js +2 -0
  350. package/dist/lib/security/auth-crypto/secrets.js +11 -3
  351. package/dist/lib/security/auth-crypto/shared.js +1 -4
  352. package/dist/lib/security/auth-crypto/signature-verification.js +29 -0
  353. package/dist/lib/security/auth-crypto/transport-and-ciphers.js +43 -3
  354. package/dist/lib/security/auth-crypto/weak-hash.js +183 -0
  355. package/dist/lib/security/bindings.js +41 -9
  356. package/dist/lib/security/cli.js +83 -26
  357. package/dist/lib/security/cookie-csrf.js +316 -7
  358. package/dist/lib/security/deps/cargo-lock.js +78 -0
  359. package/dist/lib/security/deps/cli.js +4 -4
  360. package/dist/lib/security/deps/fixed-version.js +2 -2
  361. package/dist/lib/security/deps/lockfiles.js +204 -16
  362. package/dist/lib/security/deps/osv.js +190 -59
  363. package/dist/lib/security/deps/scan.js +87 -19
  364. package/dist/lib/security/examples/{auth-crypto.cjs → auth-crypto.js} +11 -5
  365. package/dist/lib/security/examples/{deps.cjs → deps.js} +1 -3
  366. package/dist/lib/security/examples/{exposure.cjs → exposure.js} +17 -3
  367. package/dist/lib/security/examples/{files.cjs → files.js} +9 -3
  368. package/dist/lib/security/examples/{injection.cjs → injection.js} +13 -3
  369. package/dist/lib/security/examples/{moved.cjs → moved.js} +1 -3
  370. package/dist/lib/security/examples/{request-forgery.cjs → request-forgery.js} +1 -3
  371. package/dist/lib/security/exposure/backend-security-mastery.js +2 -1
  372. package/dist/lib/security/exposure/client-env.js +2 -1
  373. package/dist/lib/security/exposure/content-disposition.js +71 -0
  374. package/dist/lib/security/exposure/cookies.js +200 -1
  375. package/dist/lib/security/exposure/cors.js +63 -4
  376. package/dist/lib/security/exposure/frontend-security.js +7 -60
  377. package/dist/lib/security/exposure/index.js +9 -0
  378. package/dist/lib/security/exposure/js-yaml.js +203 -0
  379. package/dist/lib/security/exposure/message-effects.js +266 -0
  380. package/dist/lib/security/exposure/package-manifest.js +2 -2
  381. package/dist/lib/security/exposure/prototype-pollution.js +26 -1
  382. package/dist/lib/security/exposure/reflected-xss.js +47 -12
  383. package/dist/lib/security/exposure/response-content-type.js +181 -0
  384. package/dist/lib/security/exposure/rule-ids.js +4 -0
  385. package/dist/lib/security/exposure/trust-boundary.js +142 -0
  386. package/dist/lib/security/exposure/url-secrets.js +38 -2
  387. package/dist/lib/security/exposure/webhook-verification.js +231 -0
  388. package/dist/lib/security/express-registration.js +45 -0
  389. package/dist/lib/security/express-router-factories.js +118 -0
  390. package/dist/lib/security/files/component-markup.js +66 -0
  391. package/dist/lib/security/files/compose.js +2 -1
  392. package/dist/lib/security/files/index.js +121 -27
  393. package/dist/lib/security/files/kubernetes.js +136 -0
  394. package/dist/lib/security/files/project-files.js +98 -31
  395. package/dist/lib/security/files/rule-ids.js +2 -0
  396. package/dist/lib/security/files/secrets.js +9 -5
  397. package/dist/lib/security/injection/code.js +33 -5
  398. package/dist/lib/security/injection/command.js +51 -4
  399. package/dist/lib/security/injection/escape-preserving.js +219 -0
  400. package/dist/lib/security/injection/escape-replace.js +174 -2
  401. package/dist/lib/security/injection/index.js +5 -1
  402. package/dist/lib/security/injection/nosql.js +1 -1
  403. package/dist/lib/security/injection/redos.js +25 -4
  404. package/dist/lib/security/injection/rule-ids.js +3 -0
  405. package/dist/lib/security/injection/shell-output-guard.js +97 -0
  406. package/dist/lib/security/injection/sql.js +51 -0
  407. package/dist/lib/security/injection/xpath.js +35 -0
  408. package/dist/lib/security/pg-identifier-guards.js +58 -6
  409. package/dist/lib/security/phase5-rules.js +1 -0
  410. package/dist/lib/security/polyglot.js +35 -3
  411. package/dist/lib/security/provider-credentials.js +29 -0
  412. package/dist/lib/security/redirect-settings.js +131 -6
  413. package/dist/lib/security/request-forgery/contained-helper.js +75 -0
  414. package/dist/lib/security/request-forgery/open-redirect-query.js +2 -1
  415. package/dist/lib/security/request-forgery/open-redirect.js +25 -2
  416. package/dist/lib/security/request-forgery/parsed-host-guard.js +213 -0
  417. package/dist/lib/security/request-forgery/path-traversal.js +36 -1
  418. package/dist/lib/security/request-forgery/shared.js +187 -27
  419. package/dist/lib/security/request-forgery/ssrf.js +145 -1
  420. package/dist/lib/security/rule-descriptions.js +17 -1
  421. package/dist/lib/security/rule-ids.js +21 -0
  422. package/dist/lib/security/scope/drizzle-policy.js +2 -1
  423. package/dist/lib/security/scope/kysely-policy.js +173 -0
  424. package/dist/lib/security/site-fixes/auth-crypto.js +3 -1
  425. package/dist/lib/security/taint/accessors.js +364 -0
  426. package/dist/lib/security/taint/array-writes.js +139 -0
  427. package/dist/lib/security/taint/binding-inputs.js +4 -3
  428. package/dist/lib/security/taint/field-access.js +80 -0
  429. package/dist/lib/security/taint/filename-guard.js +81 -6
  430. package/dist/lib/security/taint/guards.js +150 -17
  431. package/dist/lib/security/taint/index.js +41 -116
  432. package/dist/lib/security/taint/propagate.js +5 -6
  433. package/dist/lib/security/taint/resolution-cache.js +10 -1
  434. package/dist/lib/security/taint/sanitizers.js +5 -5
  435. package/dist/lib/security/taint/shape-flows.js +128 -0
  436. package/dist/lib/security/taint/sink-alphabets.js +237 -0
  437. package/dist/lib/security/taint/sources.js +151 -8
  438. package/dist/lib/security/taint/trace-nodes.js +35 -2
  439. package/dist/lib/security/taint/validators.js +58 -19
  440. package/dist/lib/security/trusted-bindings.js +44 -0
  441. package/dist/lib/shared/agent/agent-init.js +84 -9
  442. package/dist/lib/shared/agent/agent-integrations.js +626 -0
  443. package/dist/lib/shared/agent/agent-prompt.js +2 -1
  444. package/dist/lib/shared/agent/agent-session.js +1 -1
  445. package/dist/lib/shared/agent/agent-toml.js +98 -0
  446. package/dist/lib/shared/agent/agent-verify.js +21 -3
  447. package/dist/lib/shared/agent/git-hook.js +31 -4
  448. package/dist/lib/shared/agent/notify-editor.js +2 -1
  449. package/dist/lib/shared/agent/review-mcp.js +67 -13
  450. package/dist/lib/shared/agent/review-request.js +4 -0
  451. package/dist/lib/shared/analysis/ast-helpers.js +50 -0
  452. package/dist/lib/shared/analysis/ast-semantics.js +7 -1
  453. package/dist/lib/shared/analysis/binding-names.js +13 -0
  454. package/dist/lib/shared/analysis/execution-context.js +49 -9
  455. package/dist/lib/shared/analysis/polyglot-compatibility.js +102 -23
  456. package/dist/lib/shared/analysis/scan-cache-storage.js +180 -0
  457. package/dist/lib/shared/analysis/scan-cache.js +342 -119
  458. package/dist/lib/shared/analysis/valid-javascript.js +118 -0
  459. package/dist/lib/shared/changed-lines.js +129 -0
  460. package/dist/lib/shared/check-options.js +63 -0
  461. package/dist/lib/shared/check-watch-inputs.js +152 -0
  462. package/dist/lib/shared/check-watch-process.js +57 -0
  463. package/dist/lib/shared/check-watch.js +136 -0
  464. package/dist/lib/shared/check.js +73 -37
  465. package/dist/lib/shared/completion-shells.js +127 -0
  466. package/dist/lib/shared/completion.js +124 -0
  467. package/dist/lib/shared/config-rule-validation.js +135 -0
  468. package/dist/lib/shared/config.js +330 -163
  469. package/dist/lib/shared/declarative-rule-packs.js +173 -0
  470. package/dist/lib/shared/explain.js +47 -9
  471. package/dist/lib/shared/fix/fix-convergence.js +45 -128
  472. package/dist/lib/shared/fix/fix-history.js +130 -26
  473. package/dist/lib/shared/fix/fix-interactive.js +78 -0
  474. package/dist/lib/shared/fix/fix-patch.js +89 -0
  475. package/dist/lib/shared/fix/fix-polyglot-preview.js +166 -0
  476. package/dist/lib/shared/fix/fix-presentation-biome.js +120 -0
  477. package/dist/lib/shared/fix/fix-presentation-prettier.js +27 -10
  478. package/dist/lib/shared/fix/fix-presentation-rows.js +5 -1
  479. package/dist/lib/shared/fix/fix-presentation.js +22 -15
  480. package/dist/lib/shared/fix/fix-project-membership.js +79 -0
  481. package/dist/lib/shared/fix/fix-reversal-proof.js +107 -0
  482. package/dist/lib/shared/fix/fix-reverse.js +37 -0
  483. package/dist/lib/shared/fix/fix-safety.js +4 -4
  484. package/dist/lib/shared/fix/fix-scope.js +13 -9
  485. package/dist/lib/shared/fix/fix-source-snapshot.js +92 -0
  486. package/dist/lib/shared/fix/fix-staging.js +129 -0
  487. package/dist/lib/shared/fix/fix-terminal.js +34 -9
  488. package/dist/lib/shared/fix/fix-typecheck.js +21 -8
  489. package/dist/lib/shared/fix/project-file-access.js +44 -11
  490. package/dist/lib/shared/fix/read-fix-text.js +23 -0
  491. package/dist/lib/shared/fix/reversal-lock.js +37 -0
  492. package/dist/lib/shared/fix/review-fix-mode.js +9 -0
  493. package/dist/lib/shared/fix.js +162 -26
  494. package/dist/lib/shared/formats/ci-consumers.js +84 -0
  495. package/dist/lib/shared/formats/finding-location.js +52 -3
  496. package/dist/lib/shared/formats/github.js +22 -7
  497. package/dist/lib/shared/formats/index.js +21 -5
  498. package/dist/lib/shared/formats/readable.js +63 -0
  499. package/dist/lib/shared/formats/report-rows.js +38 -0
  500. package/dist/lib/shared/formats/sarif-fixes.js +261 -0
  501. package/dist/lib/shared/formats/sarif.js +175 -33
  502. package/dist/lib/shared/formats/security-cwe.js +113 -0
  503. package/dist/lib/shared/node-scan.js +64 -0
  504. package/dist/lib/shared/package-root.js +2 -0
  505. package/dist/lib/shared/project-root.js +27 -1
  506. package/dist/lib/shared/reporting/action-summary.js +31 -0
  507. package/dist/lib/shared/reporting/baseline.js +12 -12
  508. package/dist/lib/shared/reporting/finding-id-hash.js +7 -0
  509. package/dist/lib/shared/reporting/impact-levels.js +1 -1
  510. package/dist/lib/shared/reporting/pillar-rules.js +13 -1
  511. package/dist/lib/shared/reporting/pillars.js +37 -19
  512. package/dist/lib/shared/reporting/rule-docs.js +2 -2
  513. package/dist/lib/shared/reporting/rule-pack-fingerprint.js +21 -0
  514. package/dist/lib/shared/reporting/source-report.js +16 -2
  515. package/dist/lib/shared/reporting/stray-console-methods.js +1 -0
  516. package/dist/lib/shared/rule-registry.js +6 -1
  517. package/dist/lib/shared/system/atomic-write.js +12 -6
  518. package/dist/lib/shared/system/component-source.js +28 -0
  519. package/dist/lib/shared/system/environment.js +12 -0
  520. package/dist/lib/shared/system/file-key.js +8 -0
  521. package/dist/lib/shared/system/git.js +47 -0
  522. package/dist/lib/shared/system/glob.js +92 -14
  523. package/dist/lib/shared/system/jsonc-config.js +63 -0
  524. package/dist/lib/shared/system/path-inside.js +19 -0
  525. package/dist/lib/shared/system/posix-path.js +22 -0
  526. package/dist/lib/shared/system/read-json.js +10 -0
  527. package/dist/lib/shared/system/sentry.js +6 -3
  528. package/dist/lib/shared/system/text-helpers.js +40 -0
  529. package/dist/lib/shared/system/windows-orphans-script.js +75 -0
  530. package/dist/lib/shared/system/windows-orphans.js +28 -0
  531. package/dist/lib/shared/types/changed-lines.js +1 -0
  532. package/dist/lib/shared/types/completion.js +1 -0
  533. package/dist/lib/shared/workspace-selection.js +67 -0
  534. package/dist/lib/shared/workspaces.js +210 -68
  535. package/dist/polyglot/maintainability/rules.js +119 -3
  536. package/examples/README.md +45 -0
  537. package/examples/clean/avatar.html +1 -0
  538. package/examples/clean/source.ts +10 -0
  539. package/examples/clean/tsconfig.json +4 -0
  540. package/examples/findings/avatar.html +1 -0
  541. package/examples/findings/source.ts +11 -0
  542. package/examples/findings/tsconfig.json +4 -0
  543. package/examples/labels-clean.py +5 -0
  544. package/integrations/zed/Cargo.lock +1 -1
  545. package/integrations/zed/Cargo.toml +1 -1
  546. package/integrations/zed/LICENSE +201 -0
  547. package/integrations/zed/extension.toml +3 -3
  548. package/integrations/zed/extension.wasm +0 -0
  549. package/integrations/zed/src/lib.rs +108 -8
  550. package/package.json +25 -14
  551. package/polyglot/performance/rules/csharp.yml +173 -10
  552. package/polyglot/performance/rules/go.yml +15 -7
  553. package/polyglot/performance/rules/input.yml +12 -0
  554. package/polyglot/performance/rules/java.yml +52 -1
  555. package/polyglot/performance/rules/php.yml +146 -0
  556. package/polyglot/performance/rules/python.yml +7 -3
  557. package/polyglot/performance/rules/ruby.yml +81 -0
  558. package/polyglot/performance/sgconfig.yml +2 -0
  559. package/polyglot/reliability/rules/csharp.yml +105 -0
  560. package/polyglot/reliability/rules/go.yml +339 -0
  561. package/polyglot/reliability/rules/input.yml +6 -0
  562. package/polyglot/reliability/rules/java.yml +218 -0
  563. package/polyglot/reliability/rules/kotlin.yml +49 -0
  564. package/polyglot/reliability/rules/python.yml +288 -0
  565. package/polyglot/reliability/rules/rust.yml +83 -0
  566. package/polyglot/reliability/sgconfig.yml +1 -0
  567. package/polyglot/security/rules/csharp.yml +143 -3
  568. package/polyglot/security/rules/go.yml +59 -4
  569. package/polyglot/security/rules/java.yml +103 -0
  570. package/polyglot/security/rules/python.yml +413 -21
  571. package/polyglot/security/rules/rust.yml +176 -3
  572. package/polyglot/security/sgconfig.yml +2 -0
  573. package/polyglot/security/utils/java-imported-jca-cipher.yml +32 -0
  574. package/polyglot/security/utils/java-unshadowed-javax.yml +29 -0
  575. package/schema/loadwise.config.schema.json +1051 -600
  576. package/schema/loadwise.outcomes.schema.json +43 -0
  577. package/types/scan.d.ts +53 -0
  578. package/dist/lib/maintainability/site-fixes/exports.js +0 -25
  579. package/docs/assets/cli-workflow.gif +0 -0
  580. package/plugin/.claude-plugin/plugin.json +0 -9
  581. package/plugin/commands/loadwise.md +0 -29
  582. package/plugin/hooks/check-edited-file.mjs +0 -173
  583. package/plugin/hooks/hooks.json +0 -17
  584. /package/dist/lib/{maintainability/types/changed-lines.js → editor/types/workspace-fix.js} +0 -0
@@ -2,7 +2,9 @@
2
2
  import { ts } from '../../performance/engine/compiler.js';
3
3
  import { classifyExecutionContext } from '../../shared/analysis/execution-context.js';
4
4
  import { constInitializer, effectiveProperty, staticNullish, unwrapExpression, } from '../../shared/analysis/ast-semantics.js';
5
+ import { isReassigned } from '../taint/guards.js';
5
6
  import { strip, isResponseReceiver, hopReason, isContainedPath, isProjectValidated } from './shared.js';
7
+ import { isContainedByHelper } from './contained-helper.js';
6
8
  const ruleId = 'path-traversal';
7
9
  const message = (label) => `This file path includes \`${label}\`. Check that its resolved location stays inside the intended directory, or validate the entire filename against the application's allowed format before opening it.`;
8
10
  const uploadNameReason = 'The path uses an uploaded file name; multer (busboy) strips directories from it, so confirm the upload parser does.';
@@ -163,12 +165,45 @@ function pathArguments(call, context) {
163
165
  return call.arguments.slice(0, 2);
164
166
  return [];
165
167
  }
168
+ // A local const copy holds the same path string as its source. The containment matcher still
169
+ // proves that the source came from resolve/join and that its directory guard dominates the sink.
170
+ function localPathCopySource(argument, sink, checker) {
171
+ const target = strip(argument);
172
+ if (!ts.isIdentifier(target))
173
+ return argument;
174
+ const binding = checker.getSymbolAtLocation(target);
175
+ const declaration = binding?.valueDeclaration;
176
+ if (!binding ||
177
+ !declaration ||
178
+ !ts.isVariableDeclaration(declaration) ||
179
+ !(declaration.parent.flags & ts.NodeFlags.Const) ||
180
+ declaration.end > target.pos)
181
+ return argument;
182
+ const source = strip(declaration.initializer);
183
+ if (!source || !ts.isIdentifier(source))
184
+ return argument;
185
+ const sourceDeclaration = checker.getSymbolAtLocation(source)?.valueDeclaration;
186
+ const owner = ts.findAncestor(sink, ts.isFunctionLike);
187
+ if (!sourceDeclaration ||
188
+ sourceDeclaration.end > source.pos ||
189
+ !owner ||
190
+ !('body' in owner) ||
191
+ !owner.body ||
192
+ ts.findAncestor(declaration, ts.isFunctionLike) !== owner ||
193
+ ts.findAncestor(sourceDeclaration, ts.isFunctionLike) !== owner ||
194
+ isReassigned(owner.body, binding, checker))
195
+ return argument;
196
+ return source;
197
+ }
166
198
  function checkFilePath(call, context) {
167
199
  for (const argument of pathArguments(call, context)) {
168
200
  const trace = context.taint.trace(argument, 'path');
169
201
  if (!trace)
170
202
  continue;
171
- if (isContainedPath(call, argument, context) || isProjectValidated(call, argument, validatedKinds, context))
203
+ const containmentTarget = localPathCopySource(argument, call, context.checker);
204
+ if (isContainedPath(call, containmentTarget, context) ||
205
+ isContainedByHelper(call, argument, context) ||
206
+ isProjectValidated(call, argument, validatedKinds, context))
172
207
  continue;
173
208
  const runtime = classifyExecutionContext(context.sourceFile).runtime;
174
209
  const reason = (runtime === 'cli-tooling' ? 'Runs in CLI or developer tooling rather than a server request path.' : undefined) ??
@@ -1,6 +1,7 @@
1
1
  // Helpers shared by the request-forgery rules: argument and option lookup, response receivers, hop
2
2
  // tiering, and the validation evidence that keeps a traced value quiet.
3
3
  import { ts } from '../../performance/engine/compiler.js';
4
+ import { isUnshadowedGlobal } from '../../shared/analysis/ast-semantics.js';
4
5
  import { importedFrom, stripExpression as strip } from '../bindings.js';
5
6
  import { isLiteralList } from '../pg-identifier-guards.js';
6
7
  import { isGuardedByCondition, isReassigned } from '../taint/guards.js';
@@ -50,11 +51,6 @@ function isResponseReceiver(expression) {
50
51
  receiver.expression.kind === ts.SyntaxKind.ThisKeyword &&
51
52
  responseNames.has(receiver.name.text));
52
53
  }
53
- // An identifier that is not declared by the project: a global such as `fetch` or `Response`.
54
- function isGlobalIdentifier(identifier, checker) {
55
- const declaration = checker.getSymbolAtLocation(identifier)?.declarations?.[0];
56
- return !declaration || declaration.getSourceFile().isDeclarationFile;
57
- }
58
54
  function isHostHeader(trace) {
59
55
  return hostHeaderLabel.test(trace.label);
60
56
  }
@@ -80,8 +76,20 @@ function stableIdentifier(node, sink, checker, properties = false) {
80
76
  const declaration = symbol?.valueDeclaration;
81
77
  if (!symbol || !declaration || !(ts.isParameter(declaration) || constantDeclaration(value, checker)))
82
78
  return;
83
- if (!isReassigned(scopeOf(sink), symbol, checker, properties))
79
+ const sinkScope = scopeOf(sink);
80
+ const readScope = scopeOf(value);
81
+ const declarationScope = scopeOf(declaration);
82
+ const reassignedAfter = (scope, capture) => ts.isBlock(scope) || ts.isSourceFile(scope)
83
+ ? scope.statements.some((statement) => statement.end > capture.getStart() && isReassigned(statement, symbol, checker, properties))
84
+ : isReassigned(scope, symbol, checker, properties);
85
+ if (!isReassigned(sinkScope, symbol, checker, properties) &&
86
+ (readScope === sinkScope ||
87
+ (!reassignedAfter(readScope, value) &&
88
+ (declarationScope === readScope ||
89
+ declarationScope === sinkScope ||
90
+ !reassignedAfter(declarationScope, readScope))))) {
84
91
  return value;
92
+ }
85
93
  }
86
94
  function sameValue(node, reference, checker) {
87
95
  const value = strip(node);
@@ -118,15 +126,32 @@ function isPathSeparator(node, checker) {
118
126
  value.name.text === 'sep' &&
119
127
  importedFrom(strip(value.expression), checker)?.module === 'path');
120
128
  }
121
- const separators = /[\\/]+/g;
122
- // `'/srv/'` for `path.resolve('/srv', name)`: the literal root plus one trailing separator.
123
- // resolve() output is normalized, so a prefix in the other platform's separator style never matches
124
- // and fails closed.
129
+ // A forward slash literal establishes a boundary on POSIX and cannot match native Windows output.
130
+ // A root written only with backslashes, checked against itself plus a backslash, is the Windows
131
+ // boundary; on POSIX the resolved path starts with '/' and never passes it, so the check fails
132
+ // closed. A backslash can be part of a POSIX filename, so a root that mixes both separators is
133
+ // not a boundary. Use the separate path.sep proof for native separators.
125
134
  function isRootWithSeparator(prefixText, root) {
126
- if (!ts.isStringLiteralLike(root) || !/[\\/]$/.test(prefixText))
135
+ if (!ts.isStringLiteralLike(root))
136
+ return false;
137
+ const windowsRoot = root.text.includes('\\');
138
+ if (windowsRoot && root.text.includes('/'))
127
139
  return false;
128
- const directory = root.text.replaceAll(separators, '/').replace(/\/$/, '');
129
- return directory !== '' && prefixText.replaceAll(separators, '/') === `${directory}/`;
140
+ const separator = windowsRoot ? '\\' : '/';
141
+ const directory = windowsRoot
142
+ ? root.text.replaceAll(/\\+/g, '\\').replace(/\\$/, '')
143
+ : root.text.replaceAll(/\/+/g, '/').replace(/\/$/, '');
144
+ return directory !== '' && prefixText === `${directory}${separator}`;
145
+ }
146
+ // `left + right` or the template `${left}${right}`.
147
+ function prefixOperands(prefix) {
148
+ if (ts.isBinaryExpression(prefix)) {
149
+ return prefix.operatorToken.kind === ts.SyntaxKind.PlusToken ? [prefix.left, prefix.right] : undefined;
150
+ }
151
+ if (!ts.isTemplateExpression(prefix) || prefix.head.text !== '' || prefix.templateSpans.length !== 2)
152
+ return;
153
+ const [first, second] = prefix.templateSpans;
154
+ return first.literal.text === '' && second.literal.text === '' ? [first.expression, second.expression] : undefined;
130
155
  }
131
156
  // A path starts inside the resolved root only after the directory boundary, or when its relative
132
157
  // path is neither an upward traversal nor an absolute path (which can happen across Windows
@@ -157,19 +182,35 @@ function isContainedPath(sink, expression, context) {
157
182
  const found = methodCall(condition, 'startsWith');
158
183
  if (!truth || !found || !sameValue(found.receiver, target, checker))
159
184
  return false;
160
- const prefix = strip(found.call.arguments[0]);
185
+ const prefix = prefixValue(found.call.arguments[0]);
161
186
  if (prefix && ts.isStringLiteralLike(prefix))
162
187
  return isRootWithSeparator(prefix.text, root);
163
- const resolvedLeft = prefix !== undefined && ts.isBinaryExpression(prefix) ? strip(prefix.left) : undefined;
164
- return (prefix !== undefined &&
165
- ts.isBinaryExpression(prefix) &&
166
- prefix.operatorToken.kind === ts.SyntaxKind.PlusToken &&
167
- (sameValue(prefix.left, root, checker) ||
168
- (pathCall(resolvedLeft, 'resolve', context) &&
169
- resolvedLeft.arguments.length === 1 &&
170
- sameValue(resolvedLeft.arguments[0], root, checker))) &&
171
- isPathSeparator(prefix.right, checker));
188
+ const operands = prefix && prefixOperands(prefix);
189
+ if (!operands)
190
+ return false;
191
+ const [left, right] = operands;
192
+ const resolvedLeft = strip(left);
193
+ return ((sameValue(left, root, checker) ||
194
+ (pathCall(resolvedLeft, 'resolve', context) &&
195
+ resolvedLeft.arguments.length === 1 &&
196
+ sameValue(resolvedLeft.arguments[0], root, checker))) &&
197
+ isPathSeparator(right, checker));
172
198
  };
199
+ // The prefix expression, followed through a const name and through
200
+ // `root.endsWith(sep) ? root : <root + sep>`, whose true branch already ends in the separator.
201
+ function prefixValue(node) {
202
+ let value = strip(node);
203
+ const alias = value && ts.isIdentifier(value) && constantDeclaration(value, checker);
204
+ if (alias)
205
+ value = strip(alias.initializer);
206
+ if (!value || !ts.isConditionalExpression(value))
207
+ return value;
208
+ const endsWithSeparator = methodCall(strip(value.condition), 'endsWith');
209
+ const separatorChecked = endsWithSeparator !== undefined &&
210
+ sameValue(endsWithSeparator.receiver, root, checker) &&
211
+ isPathSeparator(endsWithSeparator.call.arguments[0], checker);
212
+ return separatorChecked && sameValue(value.whenTrue, root, checker) ? strip(value.whenFalse) : undefined;
213
+ }
173
214
  const rejectsParent = (condition, truth) => {
174
215
  const found = methodCall(condition, 'startsWith');
175
216
  if (truth || !found)
@@ -271,6 +312,26 @@ function isProjectValidated(sink, expression, kinds, context) {
271
312
  }
272
313
  const hostFields = new Set(['hostname', 'host', 'origin']);
273
314
  const urlValueProperties = new Set([...hostFields, 'href', 'protocol', 'port', 'pathname', 'search', 'hash']);
315
+ function isNonEscapingUrlRead(node, checker) {
316
+ const parent = node.parent;
317
+ if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
318
+ if (urlValueProperties.has(parent.name.text))
319
+ return true;
320
+ const call = parent.parent;
321
+ return (parent.name.text === 'toString' &&
322
+ ts.isCallExpression(call) &&
323
+ call.expression === parent &&
324
+ call.arguments.length === 0);
325
+ }
326
+ if (ts.isCallExpression(parent) &&
327
+ parent.arguments.length === 1 &&
328
+ parent.arguments[0] === node &&
329
+ isUnshadowedGlobal(strip(parent.expression), 'String', checker))
330
+ return true;
331
+ if (ts.isTemplateSpan(parent) && parent.expression === node)
332
+ return true;
333
+ return false;
334
+ }
274
335
  function urlReferenceEscapes(sink, target, checker) {
275
336
  const scope = scopeOf(sink);
276
337
  const declaration = checker.getSymbolAtLocation(target)?.valueDeclaration;
@@ -284,15 +345,32 @@ function urlReferenceEscapes(sink, target, checker) {
284
345
  if (node.getStart() >= sinkStart)
285
346
  return false;
286
347
  if (node !== declaredName && ts.isIdentifier(node) && sameValue(node, target, checker)) {
287
- const parent = node.parent;
288
- return !ts.isPropertyAccessExpression(parent) || !urlValueProperties.has(parent.name.text);
348
+ return !isNonEscapingUrlRead(node, checker);
289
349
  }
290
350
  return ts.forEachChild(node, visit);
291
351
  })(scope));
292
352
  }
353
+ function unwrapUrlString(expression, checker) {
354
+ const value = strip(expression);
355
+ if (ts.isPropertyAccessExpression(value) && value.name.text === 'href')
356
+ return value.expression;
357
+ if (ts.isCallExpression(value)) {
358
+ const callee = strip(value.expression);
359
+ if (value.arguments.length === 0 && ts.isPropertyAccessExpression(callee) && callee.name.text === 'toString')
360
+ return callee.expression;
361
+ if (value.arguments.length === 1 && isUnshadowedGlobal(callee, 'String', checker))
362
+ return value.arguments[0];
363
+ }
364
+ if (ts.isTemplateExpression(value) &&
365
+ value.head.text === '' &&
366
+ value.templateSpans.length === 1 &&
367
+ value.templateSpans[0].literal.text === '')
368
+ return value.templateSpans[0].expression;
369
+ return expression;
370
+ }
293
371
  function isAllowedHost(sink, expression, context, hostOnly, acceptsCollection) {
294
372
  const { checker } = context;
295
- const target = stableIdentifier(expression, sink, checker, !hostOnly);
373
+ const target = stableIdentifier(hostOnly ? expression : unwrapUrlString(expression, checker), sink, checker, !hostOnly);
296
374
  if (!target)
297
375
  return false;
298
376
  if (!hostOnly) {
@@ -318,6 +396,88 @@ function isAllowedHost(sink, expression, context, hostOnly, acceptsCollection) {
318
396
  return checkedAgainstLiteral(condition, truth, matches, checker);
319
397
  });
320
398
  }
399
+ function isHttpsOriginList(expression) {
400
+ const list = strip(expression);
401
+ if (!ts.isArrayLiteralExpression(list) || !list.elements.length)
402
+ return false;
403
+ return list.elements.every((entry) => {
404
+ if (!ts.isStringLiteralLike(entry))
405
+ return false;
406
+ const url = URL.parse(entry.text);
407
+ return url?.protocol === 'https:' && url.origin === entry.text;
408
+ });
409
+ }
410
+ function localOriginPredicate(condition, target, checker) {
411
+ const callee = strip(condition.expression);
412
+ if (!ts.isIdentifier(callee) || !sameValue(condition.arguments[0], target, checker))
413
+ return false;
414
+ const symbol = checker.getSymbolAtLocation(callee);
415
+ const helper = symbol?.valueDeclaration;
416
+ if (!symbol || !helper || !ts.isFunctionDeclaration(helper) || helper.parameters.length !== 1 || !helper.body)
417
+ return false;
418
+ if (helper.asteriskToken || ts.getCombinedModifierFlags(helper) & ts.ModifierFlags.Async)
419
+ return false;
420
+ if (isReassigned(condition.getSourceFile(), symbol, checker))
421
+ return false;
422
+ const parameter = helper.parameters[0].name;
423
+ if (!ts.isIdentifier(parameter))
424
+ return false;
425
+ const statements = helper.body.statements;
426
+ const returned = statements.at(-1);
427
+ if (!returned || !ts.isReturnStatement(returned))
428
+ return false;
429
+ const membership = methodCall(strip(returned.expression), 'includes');
430
+ if (!membership || !sameValue(membership.call.arguments[0], parameter, checker))
431
+ return false;
432
+ if (statements.length === 1)
433
+ return isHttpsOriginList(membership.receiver);
434
+ const first = statements[0];
435
+ if (statements.length !== 2 || !ts.isVariableStatement(first))
436
+ return false;
437
+ const receiver = strip(membership.receiver);
438
+ if (!ts.isIdentifier(receiver))
439
+ return false;
440
+ const declaration = constantDeclaration(receiver, checker);
441
+ return (!!declaration?.initializer &&
442
+ first.declarationList.declarations.length === 1 &&
443
+ first.declarationList.declarations[0] === declaration &&
444
+ isHttpsOriginList(declaration.initializer));
445
+ }
446
+ function isAllowedOriginPrefix(sink, expression, checker) {
447
+ const resolved = strip(expression);
448
+ const target = ts.isIdentifier(resolved) ? strip(constantDeclaration(resolved, checker)?.initializer) : resolved;
449
+ if (!target || !ts.isTemplateExpression(target) || target.head.text !== '' || target.templateSpans.length !== 1)
450
+ return false;
451
+ const [span] = target.templateSpans;
452
+ if (!span.literal.text.startsWith('/'))
453
+ return false;
454
+ const originValue = strip(span.expression);
455
+ if (!ts.isIdentifier(originValue))
456
+ return false;
457
+ const originSymbol = checker.getSymbolAtLocation(originValue);
458
+ const originDeclaration = originSymbol?.valueDeclaration;
459
+ const binding = originDeclaration && ts.isBindingElement(originDeclaration)
460
+ ? ts.findAncestor(originDeclaration, ts.isVariableDeclaration)
461
+ : undefined;
462
+ const originScope = originDeclaration ? scopeOf(originDeclaration) : undefined;
463
+ const sinkScope = scopeOf(sink);
464
+ const origin = stableIdentifier(originValue, sink, checker) ??
465
+ (originSymbol &&
466
+ binding &&
467
+ binding.parent.flags & ts.NodeFlags.Const &&
468
+ !isReassigned(sinkScope, originSymbol, checker) &&
469
+ (!originScope || originScope === sinkScope || !isReassigned(originScope, originSymbol, checker))
470
+ ? originValue
471
+ : undefined);
472
+ return (!!origin &&
473
+ isGuardedByCondition(sink, (condition, truth) => {
474
+ if (!truth || !ts.isCallExpression(condition) || condition.arguments.length !== 1)
475
+ return false;
476
+ const list = methodCall(condition, 'includes');
477
+ return ((!!list && sameValue(condition.arguments[0], origin, checker) && isHttpsOriginList(list.receiver)) ||
478
+ localOriginPredicate(condition, origin, checker));
479
+ }));
480
+ }
321
481
  // Reject characters the URL parser treats as alternate separators or removes before interpreting
322
482
  // the path.
323
483
  const redirectSeparators = /[\\\t\r\n]/;
@@ -350,4 +510,4 @@ function isRelativeRedirect(sink, expression, context) {
350
510
  isGuardedByCondition(sink, (condition, truth) => !truth && prefix(condition, '//')) &&
351
511
  isGuardedByCondition(sink, (condition, truth) => !truth && unsafeSeparator(condition)));
352
512
  }
353
- export { strip, scopeOf, nameText, propertyValue, calleeName, isResponseReceiver, isGlobalIdentifier, hopReason, isHostHeader, constantDeclaration, stableIdentifier, sameValue, checkedAgainstLiteral, urlReferenceEscapes, isContainedPath, isAllowedHost, isRelativeRedirect, isProjectValidated, };
513
+ export { strip, scopeOf, nameText, propertyValue, calleeName, isResponseReceiver, hopReason, isHostHeader, constantDeclaration, stableIdentifier, sameValue, checkedAgainstLiteral, urlReferenceEscapes, isContainedPath, isAllowedHost, isAllowedOriginPrefix, isRelativeRedirect, isProjectValidated, };
@@ -2,7 +2,9 @@
2
2
  import { ts } from '../../performance/engine/compiler.js';
3
3
  import { constInitializer, effectiveProperty, unwrapExpression } from '../../shared/analysis/ast-semantics.js';
4
4
  import { importedFrom } from '../bindings.js';
5
- import { strip, propertyValue, isGlobalIdentifier, hopReason, isAllowedHost, isHostHeader } from './shared.js';
5
+ import { strip, propertyValue, hopReason, isAllowedHost, isAllowedOriginPrefix, isHostHeader, scopeOf, } from './shared.js';
6
+ import { isParsedHostAllowlisted } from './parsed-host-guard.js';
7
+ import { isGlobalIdentifier } from '../../shared/analysis/ast-helpers.js';
6
8
  const ruleId = 'ssrf-request-url';
7
9
  const message = (label) => `The request URL host comes from \`${label}\`, so a caller can make this server reach internal addresses. Parse it with \`new URL()\` and allow only known hosts, or build the URL from a fixed origin.`;
8
10
  const hostHeaderReason = 'The host comes from the Host header; a reverse proxy that accepts only known hosts makes this unreachable.';
@@ -96,9 +98,140 @@ function urlArguments(call, client) {
96
98
  }
97
99
  return found;
98
100
  }
101
+ // Options the filtering-agent proof reads, including got's `agent: { http, https }` object. A write
102
+ // to another field, such as `headers` or `timeout`, cannot replace the agent.
103
+ const transportOptionNames = new Set(['agent', 'httpAgent', 'httpsAgent', 'dispatcher', 'http', 'https']);
104
+ function writesTransportOption(access) {
105
+ if (ts.isPropertyAccessExpression(access))
106
+ return transportOptionNames.has(access.name.text);
107
+ const key = unwrapExpression(access.argumentExpression);
108
+ // A computed key can name any field.
109
+ return !key || !ts.isStringLiteralLike(key) || transportOptionNames.has(key.text);
110
+ }
111
+ function isMutatedPropertyAccess(access) {
112
+ const parent = access.parent;
113
+ if (ts.isDeleteExpression(parent))
114
+ return true;
115
+ if ((ts.isPrefixUnaryExpression(parent) || ts.isPostfixUnaryExpression(parent)) &&
116
+ (parent.operator === ts.SyntaxKind.PlusPlusToken || parent.operator === ts.SyntaxKind.MinusMinusToken))
117
+ return true;
118
+ return (ts.isBinaryExpression(parent) &&
119
+ parent.left === access &&
120
+ parent.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
121
+ parent.operatorToken.kind <= ts.SyntaxKind.LastAssignment);
122
+ }
123
+ // Calls that read an options object without keeping or changing it.
124
+ const readOnlyCallees = new Set([
125
+ 'JSON.stringify',
126
+ 'Object.keys',
127
+ 'Object.values',
128
+ 'Object.entries',
129
+ 'structuredClone',
130
+ ]);
131
+ const mutatingCallees = new Set(['Object.assign', 'Object.defineProperty', 'Object.defineProperties']);
132
+ const hazardsByDeclaration = new WeakMap();
133
+ function isWrapperNode(node) {
134
+ return (ts.isParenthesizedExpression(node) ||
135
+ ts.isAsExpression(node) ||
136
+ ts.isNonNullExpression(node) ||
137
+ ts.isSatisfiesExpression(node) ||
138
+ ts.isTypeAssertionExpression(node));
139
+ }
140
+ function isHazardousReference(reference, context) {
141
+ let child = reference;
142
+ while (isWrapperNode(child.parent))
143
+ child = child.parent;
144
+ const parent = child.parent;
145
+ if ((ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) && parent.expression === child)
146
+ return isMutatedPropertyAccess(parent) && writesTransportOption(parent);
147
+ if (ts.isCallExpression(parent) || ts.isNewExpression(parent)) {
148
+ if (!parent.arguments?.some((argument) => argument === child))
149
+ return false;
150
+ if (ts.isNewExpression(parent))
151
+ return true;
152
+ const calleeText = parent.expression.getText();
153
+ if (mutatingCallees.has(calleeText))
154
+ return parent.arguments[0] === child;
155
+ if (readOnlyCallees.has(calleeText) || calleeText.startsWith('console.'))
156
+ return false;
157
+ return !clientCall(parent, context);
158
+ }
159
+ if (ts.isVariableDeclaration(parent))
160
+ return parent.initializer === child && ts.isIdentifier(parent.name);
161
+ if (ts.isBinaryExpression(parent))
162
+ return (parent.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
163
+ parent.operatorToken.kind <= ts.SyntaxKind.LastAssignment);
164
+ return (ts.isShorthandPropertyAssignment(parent) ||
165
+ ts.isPropertyAssignment(parent) ||
166
+ ts.isReturnStatement(parent) ||
167
+ ts.isArrayLiteralExpression(parent) ||
168
+ ts.isArrowFunction(parent) ||
169
+ ts.isExportAssignment(parent) ||
170
+ ts.isYieldExpression(parent));
171
+ }
172
+ // Every hazardous reference to the options object, found once per declaration.
173
+ function optionsHazards(declaration, symbol, context) {
174
+ const cached = hazardsByDeclaration.get(declaration);
175
+ if (cached)
176
+ return cached;
177
+ const declarationScope = scopeOf(declaration);
178
+ const hazards = [];
179
+ const referencesOptions = (identifier) => {
180
+ const parent = identifier.parent;
181
+ // `typeof options` names the variable in a type; it reads no runtime value.
182
+ if (ts.isTypeQueryNode(parent))
183
+ return false;
184
+ const referenced = ts.isShorthandPropertyAssignment(parent) && parent.name === identifier
185
+ ? context.checker.getShorthandAssignmentValueSymbol(parent)
186
+ : context.checker.getSymbolAtLocation(identifier);
187
+ return referenced === symbol;
188
+ };
189
+ (function visit(node) {
190
+ if (ts.isIdentifier(node) &&
191
+ node !== declaration.name &&
192
+ referencesOptions(node) &&
193
+ isHazardousReference(node, context))
194
+ hazards.push({ node, inNestedFunction: scopeOf(node) !== declarationScope });
195
+ ts.forEachChild(node, visit);
196
+ })(declarationScope);
197
+ hazardsByDeclaration.set(declaration, hazards);
198
+ return hazards;
199
+ }
200
+ // The loops around `use` inside its function: a later statement in a loop runs before the next pass.
201
+ function enclosingLoops(use) {
202
+ const loops = [];
203
+ for (let node = use.parent; node && !ts.isFunctionLike(node); node = node.parent)
204
+ if (ts.isIterationStatement(node, false))
205
+ loops.push(node);
206
+ return loops;
207
+ }
208
+ // True when the options object may change, or be reached through another name, before `use` reads it.
209
+ function optionsMutatedOrEscaped(use, declaration, context) {
210
+ const symbol = context.checker.getSymbolAtLocation(declaration.name);
211
+ if (!symbol)
212
+ return true;
213
+ if (ts.getCombinedModifierFlags(declaration) & ts.ModifierFlags.Export)
214
+ return true;
215
+ const hazards = optionsHazards(declaration, symbol, context);
216
+ if (!hazards.length)
217
+ return false;
218
+ if (scopeOf(declaration) !== scopeOf(use))
219
+ return true;
220
+ const useStart = use.getStart();
221
+ // A loop body that also declares the options builds a fresh object each pass; a `for` initializer runs once, so that loop carries it.
222
+ const loops = enclosingLoops(use).filter((loop) => declaration.getStart() < loop.getStart() ||
223
+ declaration.getEnd() > loop.getEnd() ||
224
+ (ts.isForStatement(loop) && loop.initializer === declaration.parent));
225
+ return hazards.some(({ node, inNestedFunction }) => inNestedFunction ||
226
+ node.getStart() < useStart ||
227
+ loops.some((loop) => node.getStart() >= loop.getStart() && node.getEnd() <= loop.getEnd()));
228
+ }
99
229
  function optionsObject(expression, context) {
100
230
  let current = unwrapExpression(expression);
101
231
  for (let depth = 0; depth < 4 && ts.isIdentifier(current); depth++) {
232
+ const declaration = context.checker.getSymbolAtLocation(current)?.valueDeclaration;
233
+ if (declaration && ts.isVariableDeclaration(declaration) && optionsMutatedOrEscaped(current, declaration, context))
234
+ return;
102
235
  const initializer = constInitializer(current, context.checker);
103
236
  if (!initializer)
104
237
  return;
@@ -278,8 +411,12 @@ function checkRequestUrl(call, context) {
278
411
  const control = hostOnly ? hostControl(expression, context) : context.taint.urlControl(expression);
279
412
  if (!control || (control.part === 'path' && !control.rawPathname))
280
413
  continue;
414
+ if (!hostOnly && isAllowedOriginPrefix(call, expression, context.checker))
415
+ continue;
281
416
  if (isAllowedHost(call, expression, context, hostOnly))
282
417
  continue;
418
+ if (!hostOnly && isParsedHostAllowlisted(call, optionsUrl(expression, context), context.checker))
419
+ continue;
283
420
  const { trace } = control;
284
421
  const reason = (control.part === 'path' ? 'The host is fixed; only the URL path is derived from input.' : undefined) ??
285
422
  hopReason(trace) ??
@@ -288,6 +425,13 @@ function checkRequestUrl(call, context) {
288
425
  return;
289
426
  }
290
427
  }
428
+ // The `url` of a named options object (`axios.request(options)`) when no other field picks the host.
429
+ function optionsUrl(expression, context) {
430
+ const options = ts.isIdentifier(unwrapExpression(expression)) && optionsObject(expression, context);
431
+ if (!options || ['baseURL', 'prefixUrl', 'origin', 'hostname', 'host'].some((name) => propertyValue(options, name)))
432
+ return expression;
433
+ return effectiveOption(options, 'url', context) ?? expression;
434
+ }
291
435
  function hostControl(expression, context) {
292
436
  const trace = context.taint.trace(expression, 'url');
293
437
  return trace && { part: 'host', trace };
@@ -11,10 +11,12 @@ const descriptionByRule = {
11
11
  'cookie-missing-security-flags': 'A sensitive cookie is set without the expected security attributes.',
12
12
  'cors-credentials-any-origin': 'A credentialed CORS response allows arbitrary origins.',
13
13
  'cors-origin-regex-unanchored': 'A CORS origin regex also accepts look-alike hosts.',
14
+ 'csharp-binaryformatter-request-deserialization': 'Legacy BinaryFormatter.Deserialize consumes an ASP.NET Core request stream.',
14
15
  'csharp-ef-from-sql-raw': 'FromSqlRaw or ExecuteSqlRaw receives a concatenated or interpolated string, risking SQL injection.',
15
16
  'csharp-process-start': 'Process.Start launches an external process and risks command injection with untrusted arguments.',
16
17
  'database-error-in-response': 'An HTTP response includes a raw database error message.',
17
18
  'dependency-known-vulnerability': 'A resolved dependency version is listed in a published vulnerability advisory.',
19
+ 'discarded-signature-verification-result': 'A standalone call discards the result of Node.js synchronous signature verification.',
18
20
  'dockerfile-add-remote-url': 'A Dockerfile ADD instruction retrieves a resource from a remote URL.',
19
21
  'dockerfile-runs-as-root': 'The final image selects root or inherits an unverified base-image user.',
20
22
  'dockerfile-secret-in-build': 'A Dockerfile exposes a secret through a build argument or environment variable.',
@@ -35,9 +37,13 @@ const descriptionByRule = {
35
37
  'graphql-query-depth-unbounded': 'A GraphQL server accepts queries of any depth.',
36
38
  'hardcoded-secret': 'The source supplies a literal credential or cryptographic secret.',
37
39
  'insecure-cipher': 'A cryptographic operation selects an insecure cipher or mode.',
40
+ 'insecure-deserialization': 'Request data is deserialized by a library that can rebuild and run functions from it.',
38
41
  'insecure-random-for-secret': 'A sensitive token or secret uses a non-cryptographic random source.',
42
+ 'java-des-cipher': 'A JCA Cipher factory explicitly selects DES.',
43
+ 'java-objectinputstream-request-deserialization': 'Java ObjectInputStream.readObject consumes a servlet request body.',
39
44
  'java-runtime-exec': 'Runtime.getRuntime().exec runs an OS command and risks command injection with untrusted arguments.',
40
45
  'java-sql-string-concat': 'A SQL query built by string concatenation risks SQL injection.',
46
+ 'js-yaml-unsafe-schema': 'A resolved js-yaml loader enables JavaScript-specific YAML constructors.',
41
47
  'jsx-javascript-url': 'In React 18 and older or Preact, a URL search parameter or location hash starts a JSX href, action or iframe src (javascript: XSS).',
42
48
  'jwt-decode-for-auth': 'Authentication uses decoded JWT claims without verifying the token signature.',
43
49
  'jwt-none-algorithm': 'JWT signing or verification allows an unsigned token.',
@@ -45,6 +51,8 @@ const descriptionByRule = {
45
51
  'jwt-verify-without-algorithms': 'JWT verification does not restrict the accepted signing algorithms.',
46
52
  'jwt-weak-secret-literal': 'JWT signing or verification uses a short (< 32 chars) or weak literal secret susceptible to brute-force forgery.',
47
53
  'knex-raw-dynamic-text': 'A dynamic SQL fragment reaches Knex without parameter binding.',
54
+ 'kubernetes-privileged-container': 'A Kubernetes workload explicitly requests a privileged container.',
55
+ 'kysely-scope-unverified': 'A Kysely read lacks the row scope required by the declared policy.',
48
56
  'ldap-filter-injection': 'Request data reaches an LDAP search filter without RFC 4515 filter escaping or a filter builder.',
49
57
  'mass-assignment': 'An unfiltered request body reaches a persistence operation.',
50
58
  'mysql-dynamic-query-text': 'Dynamic SQL text reaches a MySQL client without parameter binding.',
@@ -62,12 +70,15 @@ const descriptionByRule = {
62
70
  'prototype-pollution': 'Request data can supply keys to a write or merge that can modify an object prototype.',
63
71
  'python-insecure-deserialization': 'pickle or marshal deserialization of untrusted data can execute arbitrary code.',
64
72
  'python-requests-tls-verify-disabled': 'Calling Python requests with verify=False disables TLS certificate verification.',
73
+ 'python-sqlite-unbound-value': 'A Python sqlite3 query inserts a value into SQL text instead of binding it.',
65
74
  'python-subprocess-shell-true': 'subprocess with shell=True or os.system passes input through a shell, risking command injection.',
66
- 'python-unsafe-yaml-load': 'yaml.load or yaml.load_all without SafeLoader can construct arbitrary Python objects.',
75
+ 'python-unsafe-yaml-load': 'yaml.load or yaml.load_all without SafeLoader or BaseLoader can construct arbitrary Python objects.',
76
+ 'raw-content-disposition-filename': 'Request data is interpolated into a raw Content-Disposition filename parameter.',
67
77
  'react-dangerously-set-inner-html': 'dangerouslySetInnerHTML receives HTML that is not a constant or sanitized.',
68
78
  'reflected-xss-response': 'An HTML response reflects request data without recognized escaping.',
69
79
  'regex-catastrophic-backtracking': 'A regular expression that can backtrack exponentially or in polynomial time runs on request input.',
70
80
  'regex-from-input': 'Request input supplies a regular expression pattern without recognized escaping.',
81
+ 'request-selected-executable': 'Request input selects the program at a resolved process-launch API.',
71
82
  'rust-command-shell': 'Command::new("sh") or Command::new("bash") spawns a shell and risks command injection.',
72
83
  'rust-reqwest-danger-accept-invalid-certs': 'Calling danger_accept_invalid_certs(true) on a reqwest client disables TLS certificate verification.',
73
84
  'rust-unsafe-raw-pointer-deref': 'A raw pointer dereference in an unsafe block bypasses Rust memory safety guarantees.',
@@ -81,13 +92,18 @@ const descriptionByRule = {
81
92
  'storage-object-public-acl': 'A storage upload makes the object publicly readable.',
82
93
  'template-autoescape-disabled': 'A template engine is configured to render values without HTML escaping.',
83
94
  'template-injection': 'Request data is interpreted as template source rather than a template value.',
95
+ 'template-raw-html-binding': 'A Vue or Svelte template inserts a dynamic value as raw HTML.',
84
96
  'tls-verification-disabled': 'A TLS client skips certificate or server hostname verification.',
97
+ 'trust-boundary-violation': 'Request data is stored in application-wide state that later requests trust.',
85
98
  'typeorm-dynamic-query-text': 'A dynamic SQL fragment reaches TypeORM without parameter binding.',
86
99
  'upload-client-filename': 'A file upload is stored under the original name supplied by the client.',
87
100
  'vm-sandbox-escape': 'Node `vm` or `vm2` executes dynamic code or an untrusted context, risking sandbox escape and host RCE.',
88
101
  'vue-v-html-unsanitized': 'A Vue render function binds unsanitized dynamic HTML to innerHTML.',
102
+ 'weak-hash': 'A request credential is hashed with MD5 or SHA-1.',
89
103
  'weak-password-hash': 'A password is hashed with an algorithm unsuitable for password storage.',
104
+ 'webhook-body-without-verification': 'A Stripe webhook writes request-body data before visible signature verification.',
90
105
  'xml-external-entities': 'An XML parser allows processing of external entities.',
106
+ 'xpath-injection': 'Request data is concatenated into an XPath expression.',
91
107
  'zip-slip-extraction': 'An archive entry controls an extraction path without a recognized containment check.',
92
108
  };
93
109
  export { descriptionByRule };