cfsolve 0.1.1 → 0.1.3

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 (404) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +10 -9
  4. data/THIRD_PARTY_LICENSES/README.md +71 -254
  5. data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
  6. data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
  7. data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
  8. data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
  9. data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
  10. data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
  11. data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
  12. data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
  13. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
  14. data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
  15. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
  16. data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
  17. data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
  18. data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
  19. data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
  20. data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
  21. data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
  22. data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
  23. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
  24. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
  25. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
  26. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
  27. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
  28. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
  29. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
  30. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
  31. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
  32. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
  33. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
  34. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
  35. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
  36. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
  37. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
  38. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
  39. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
  40. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
  41. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
  42. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
  43. data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
  44. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
  45. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
  46. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
  47. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
  48. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
  49. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
  50. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
  51. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
  52. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
  53. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
  54. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
  55. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
  56. data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
  57. data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
  58. data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
  59. data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
  60. data/UPSTREAM.md +10 -8
  61. data/ext/cfsolve/Cargo.lock +534 -1727
  62. data/ext/cfsolve/Cargo.toml +4 -0
  63. data/ext/cfsolve/src/main.rs +1 -1
  64. data/lib/cfsolve/profiles/safari-26-ios/answers.json +2570 -1894
  65. data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +1867 -1192
  66. data/lib/cfsolve/profiles/safari-26-ios.json +102 -156
  67. data/lib/cfsolve/version.rb +2 -2
  68. data/vendor/cfsolve/Cargo.lock +561 -1729
  69. data/vendor/cfsolve/Cargo.toml +26 -8
  70. data/vendor/cfsolve/README.md +4 -35
  71. data/vendor/cfsolve/examples/build_profile.rs +17 -15
  72. data/vendor/cfsolve/examples/capture_session.rs +37 -0
  73. data/vendor/cfsolve/examples/check_answers.rs +66 -0
  74. data/vendor/cfsolve/examples/compare_session.rs +189 -0
  75. data/vendor/cfsolve/examples/solver_profile.rs +84 -0
  76. data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
  77. data/vendor/cfsolve/examples/stage2_snapshot.rs +6 -3
  78. data/vendor/cfsolve/examples/tls_echo.rs +3 -3
  79. data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
  80. data/vendor/cfsolve/profiles/safari-26-ios/answers.json +2570 -1894
  81. data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +1867 -1192
  82. data/vendor/cfsolve/profiles/safari-26-ios.json +102 -156
  83. data/vendor/cfsolve/scripts/capture_cssom.mjs +42 -0
  84. data/vendor/cfsolve/scripts/serve_cssom.py +111 -0
  85. data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
  86. data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
  87. data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
  88. data/vendor/cfsolve/src/capture/profile.rs +7 -18
  89. data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
  90. data/vendor/cfsolve/src/capture/proxy.rs +44 -13
  91. data/vendor/cfsolve/src/capture/recorded.rs +42 -7
  92. data/vendor/cfsolve/src/capture/sessions.rs +4 -3
  93. data/vendor/cfsolve/src/capture/upstream.rs +1 -1
  94. data/vendor/cfsolve/src/challenge/codec.rs +4 -2
  95. data/vendor/cfsolve/src/challenge/expression.rs +161 -117
  96. data/vendor/cfsolve/src/challenge/installed/audit.rs +132 -0
  97. data/vendor/cfsolve/src/challenge/installed.rs +127 -269
  98. data/vendor/cfsolve/src/challenge/merge.rs +120 -80
  99. data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
  100. data/vendor/cfsolve/src/challenge/payload.rs +175 -35
  101. data/vendor/cfsolve/src/challenge/program.rs +197 -178
  102. data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
  103. data/vendor/cfsolve/src/challenge/source.rs +151 -96
  104. data/vendor/cfsolve/src/challenge/state.rs +236 -122
  105. data/vendor/cfsolve/src/challenge/tally.rs +64 -50
  106. data/vendor/cfsolve/src/challenge.rs +1 -0
  107. data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
  108. data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
  109. data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
  110. data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
  111. data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
  112. data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
  113. data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
  114. data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
  115. data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
  116. data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
  117. data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
  118. data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
  119. data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
  120. data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
  121. data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
  122. data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
  123. data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
  124. data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +201 -205
  125. data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
  126. data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +346 -536
  127. data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
  128. data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
  129. data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
  130. data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
  131. data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
  132. data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
  133. data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
  134. data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +361 -322
  135. data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
  136. data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
  137. data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
  138. data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
  139. data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
  140. data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
  141. data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
  142. data/vendor/cfsolve/src/deobfuscate.rs +15 -11
  143. data/vendor/cfsolve/src/embedding_page/extra_params.rs +23 -32
  144. data/vendor/cfsolve/src/embedding_page/page.rs +28 -2
  145. data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
  146. data/vendor/cfsolve/src/error.rs +40 -5
  147. data/vendor/cfsolve/src/fingerprint.rs +8 -2
  148. data/vendor/cfsolve/src/http/client.rs +9 -1
  149. data/vendor/cfsolve/src/http/requests.rs +2 -2
  150. data/vendor/cfsolve/src/js/ast.rs +479 -254
  151. data/vendor/cfsolve/src/js/objects.rs +9 -2
  152. data/vendor/cfsolve/src/lib.rs +1 -0
  153. data/vendor/cfsolve/src/listing/fold.rs +19 -92
  154. data/vendor/cfsolve/src/listing/query.rs +26 -291
  155. data/vendor/cfsolve/src/listing.rs +0 -1
  156. data/vendor/cfsolve/src/performance_clock.rs +20 -1
  157. data/vendor/cfsolve/src/profiling.rs +49 -0
  158. data/vendor/cfsolve/src/script.rs +35 -24
  159. data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
  160. data/vendor/cfsolve/src/session/channel.rs +2 -2
  161. data/vendor/cfsolve/src/session/initial.rs +19 -10
  162. data/vendor/cfsolve/src/session/probes.rs +160 -125
  163. data/vendor/cfsolve/src/session/sink.rs +26 -1
  164. data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
  165. data/vendor/cfsolve/src/session/timing.rs +58 -53
  166. data/vendor/cfsolve/src/session/widget.rs +5 -6
  167. data/vendor/cfsolve/src/session.rs +1 -1
  168. data/vendor/cfsolve/src/solver.rs +3 -1
  169. data/vendor/cfsolve/src/stage2/analysis/analyze.rs +50 -33
  170. data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
  171. data/vendor/cfsolve/src/stage2/analysis/discovery.rs +61 -66
  172. data/vendor/cfsolve/src/stage2/analysis/envelope.rs +33 -22
  173. data/vendor/cfsolve/src/stage2/analysis/recognize.rs +3 -5
  174. data/vendor/cfsolve/src/stage2/analysis.rs +0 -1
  175. data/vendor/cfsolve/src/stage2/audit_globals.rs +378 -0
  176. data/vendor/cfsolve/src/stage2/benchmark.rs +66 -38
  177. data/vendor/cfsolve/src/stage2/call_stack.rs +1463 -1017
  178. data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
  179. data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
  180. data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
  181. data/vendor/cfsolve/src/stage2/interaction/native.rs +2 -1
  182. data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -7
  183. data/vendor/cfsolve/src/stage2/payload/recover.rs +56 -25
  184. data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
  185. data/vendor/cfsolve/src/stage2/probes/ice.rs +11 -10
  186. data/vendor/cfsolve/src/stage2/probes/media.rs +47 -33
  187. data/vendor/cfsolve/src/stage2/probes/performance.rs +13 -8
  188. data/vendor/cfsolve/src/stage2/probes/rects.rs +12 -17
  189. data/vendor/cfsolve/src/stage2/probes/stack.rs +50 -103
  190. data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +17 -86
  191. data/vendor/cfsolve/src/stage2/probes.rs +0 -1
  192. data/vendor/cfsolve/src/stage2/queries.rs +50 -0
  193. data/vendor/cfsolve/src/stage2/records.rs +4 -13
  194. data/vendor/cfsolve/src/stage2/reference.json +1 -1
  195. data/vendor/cfsolve/src/stage2/reference.rs +98 -100
  196. data/vendor/cfsolve/src/stage2/registry.rs +41 -34
  197. data/vendor/cfsolve/src/stage2/replay.rs +182 -254
  198. data/vendor/cfsolve/src/stage2/stylesheets.rs +176 -0
  199. data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
  200. data/vendor/cfsolve/src/stage2/trace.rs +152 -108
  201. data/vendor/cfsolve/src/stage2/vocabulary.rs +103 -403
  202. data/vendor/cfsolve/src/stage2.rs +4 -1
  203. data/vendor/cfsolve/src/vm/disassemble.rs +46 -13
  204. data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
  205. data/vendor/cfsolve/src/vm/extract.rs +347 -250
  206. data/vendor/cfsolve/src/vm/interpret/access.rs +67 -68
  207. data/vendor/cfsolve/src/vm/interpret/builtin.rs +16 -63
  208. data/vendor/cfsolve/src/vm/interpret/call.rs +192 -51
  209. data/vendor/cfsolve/src/vm/interpret/compile.rs +643 -0
  210. data/vendor/cfsolve/src/vm/interpret/copies.rs +232 -120
  211. data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +149 -40
  212. data/vendor/cfsolve/src/vm/interpret/evaluate.rs +189 -572
  213. data/vendor/cfsolve/src/vm/interpret/explore.rs +159 -46
  214. data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
  215. data/vendor/cfsolve/src/vm/interpret/frozen.rs +169 -0
  216. data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +414 -0
  217. data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
  218. data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
  219. data/vendor/cfsolve/src/vm/interpret/pattern.rs +1736 -0
  220. data/vendor/cfsolve/src/vm/interpret/plan.rs +605 -330
  221. data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
  222. data/vendor/cfsolve/src/vm/interpret/run.rs +314 -54
  223. data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
  224. data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
  225. data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
  226. data/vendor/cfsolve/src/vm/interpret.rs +16 -3
  227. data/vendor/cfsolve/src/vm/machine.rs +58 -47
  228. data/vendor/cfsolve/src/vm/output.rs +13 -5
  229. data/vendor/cfsolve/src/vm/packed_names.rs +311 -0
  230. data/vendor/cfsolve/src/vm/session.rs +197 -110
  231. data/vendor/cfsolve/src/vm/value.rs +35 -19
  232. data/vendor/cfsolve/src/vm.rs +3 -1
  233. data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
  234. data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
  235. data/vendor/cfsolve/vendor/btls-sys/src/lib.rs +3 -0
  236. metadata +106 -183
  237. data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
  238. data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
  239. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
  240. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
  241. data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
  242. data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
  243. data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
  244. data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
  245. data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
  246. data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
  247. data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
  248. data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
  249. data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
  250. data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
  251. data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
  252. data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
  253. data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
  254. data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
  255. data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
  256. data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
  257. data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
  258. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
  259. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
  260. data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
  261. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
  262. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
  263. data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
  264. data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
  265. data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
  266. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
  267. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
  268. data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
  269. data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
  270. data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
  271. data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
  272. data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
  273. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
  274. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
  275. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
  276. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
  277. data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
  278. data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
  279. data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
  280. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
  281. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
  282. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
  283. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
  284. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
  285. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
  286. data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
  287. data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
  288. data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
  289. data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
  290. data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
  291. data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
  292. data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
  293. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
  294. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
  295. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
  296. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
  297. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
  298. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
  299. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
  300. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
  301. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
  302. data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
  303. data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
  304. data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
  305. data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
  306. data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
  307. data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
  308. data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
  309. data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
  310. data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
  311. data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
  312. data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
  313. data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
  314. data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
  315. data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
  316. data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
  317. data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
  318. data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
  319. data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
  320. data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
  321. data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
  322. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
  323. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
  324. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
  325. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
  326. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
  327. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
  328. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
  329. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
  330. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
  331. data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
  332. data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
  333. data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
  334. data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
  335. data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
  336. data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
  337. data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
  338. data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
  339. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
  340. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
  341. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
  342. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
  343. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
  344. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
  345. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
  346. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
  347. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
  348. data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
  349. data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
  350. data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
  351. data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
  352. data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
  353. data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
  354. data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
  355. data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
  356. data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
  357. data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
  358. data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
  359. data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
  360. data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
  361. data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
  362. data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
  363. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
  364. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
  365. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
  366. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
  367. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
  368. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
  369. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
  370. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
  371. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
  372. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
  373. data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
  374. data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
  375. data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
  376. data/vendor/cfsolve/src/listing/normalize.rs +0 -264
  377. data/vendor/cfsolve/src/stage2/analysis/outputs.rs +0 -327
  378. data/vendor/cfsolve/src/stage2/probes/stylesheets.rs +0 -249
  379. data/vendor/cfsolve/src/stage2/reference-expanded.json +0 -42
  380. data/vendor/cfsolve/src/stage2/session_names.rs +0 -470
  381. /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
  382. /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
  383. /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
  384. /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
  385. /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
  386. /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
  387. /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
  388. /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
  389. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
  390. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
  391. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
  392. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
  393. /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
  394. /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
  395. /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
  396. /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
  397. /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
  398. /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
  399. /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
  400. /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
  401. /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
  402. /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
  403. /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
  404. /data/THIRD_PARTY_LICENSES/{cargo-platform-0.1.9 → zmij_ecma-1.0.23}/LICENSE-MIT +0 -0
@@ -2,23 +2,26 @@
2
2
  //! tally ([`super::tally`]), the sender's additions and POST log, and the resource timing
3
3
  //! format ([`super::reduced_timing`]).
4
4
 
5
- use std::collections::BTreeMap;
5
+ use std::collections::{BTreeMap, HashMap};
6
6
 
7
7
  use anyhow::{Context, Result, bail, ensure};
8
8
  use indexmap::IndexMap;
9
- use serde::{Deserialize, Deserializer, Serialize};
10
- use swc_core::ecma::ast::{
11
- ArrowExpr, AssignExpr, AssignTarget, BinaryOp, CallExpr, Expr, Function, IfStmt, ObjectLit,
12
- SimpleAssignTarget, Stmt, VarDeclarator,
9
+ use oxc::ast::ast::{
10
+ ArrowFunctionExpression, AssignmentExpression, AssignmentTarget, BindingPattern,
11
+ CallExpression, Expression, Function, IfStatement, MemberExpression, ObjectExpression,
12
+ Statement, VariableDeclarator,
13
13
  };
14
- use swc_core::ecma::visit::{Visit, VisitWith};
14
+ use oxc::ast_visit::{Visit, walk};
15
+ use oxc::semantic::{ScopeFlags, SymbolId};
16
+ use oxc::syntax::operator::BinaryOperator;
17
+ use serde::{Deserialize, Deserializer, Serialize};
15
18
 
16
19
  use crate::candidates;
17
20
  use crate::challenge::payload::Field;
18
21
  use crate::challenge::reduced_timing::{self, ResourceTiming};
19
22
  use crate::challenge::tally::{self, CounterEvents, Tally};
20
23
  use crate::challenge::{expression, source};
21
- use crate::js::ast::{self, ParsedScript};
24
+ use crate::js::ast::{self, Binding, Script};
22
25
  use crate::js::{JsObject, JsValue, Options, Payload, json};
23
26
  use crate::resource_timing::LoadTiming;
24
27
 
@@ -36,11 +39,21 @@ pub struct ScriptState {
36
39
  /// Options copied into the payload under their original names at send time.
37
40
  pub forwarded: Vec<String>,
38
41
  pub timing: Option<ResourceTiming>,
39
- /// Functions on the script's namespace, mapped to the option each returns.
40
- pub getters: BTreeMap<String, String>,
42
+ /// Functions on the script's namespace, by name.
43
+ pub getters: BTreeMap<String, Getter>,
41
44
  pub post_log: Option<PostLog>,
42
45
  }
43
46
 
47
+ /// A function on the script's namespace that returns an option.
48
+ #[derive(Debug, Clone, PartialEq, Eq)]
49
+ pub struct Getter {
50
+ pub option: String,
51
+ /// The option holding the page origin, when the getter passes each render sample's stack
52
+ /// through a helper that replaces URLs on that origin with indices (see
53
+ /// `crate::challenge::payload::split_page_urls`).
54
+ pub page_origin: Option<String>,
55
+ }
56
+
44
57
  /// Log of challenge POSTs. Each payload includes the log so far. The sender then adds an entry for
45
58
  /// the current POST and records its response time when the response arrives.
46
59
  #[derive(Debug, Clone, PartialEq, Eq)]
@@ -155,22 +168,23 @@ fn unsigned<'de, D: Deserializer<'de>>(deserializer: D) -> Result<i64, D::Error>
155
168
  impl ScriptState {
156
169
  #[cfg(test)]
157
170
  pub(crate) fn from_javascript(javascript: &str) -> Result<Self> {
158
- let parsed = ast::parse_iframe_javascript(javascript)?;
159
- Self::from_parsed(&parsed, &source::bootstrap_options(&parsed))
171
+ let parsed = ast::ParsedScript::parse("t", javascript)?;
172
+ let script = parsed.script();
173
+ Self::from_script(script, &source::bootstrap_options(script))
160
174
  }
161
175
 
162
176
  /// Recovers the state of a parsed script, using bootstrap options to identify its payload
163
177
  /// template.
164
- pub(crate) fn from_parsed(parsed: &ParsedScript, options: &Options) -> Result<Self> {
165
- let script = &parsed.script;
178
+ pub(crate) fn from_script(script: Script<'_>, options: &Options) -> Result<Self> {
166
179
  let mut scopes = Scopes {
180
+ script,
167
181
  options,
168
182
  stack: Vec::new(),
169
183
  found: Vec::new(),
170
184
  };
171
- script.visit_with(&mut scopes);
172
- let mut sender = Sender::default();
173
- script.visit_with(&mut sender);
185
+ scopes.visit_program(script.program);
186
+ let mut sender = Sender::new(script);
187
+ sender.visit_program(script.program);
174
188
  let post_log = sender.post_log()?;
175
189
  let elapsed = candidates::at_most_one_distinct(sender.elapsed, "elapsed-time field")?;
176
190
  let sender_scope = elapsed.as_ref().map(|(scope, _)| *scope);
@@ -184,14 +198,14 @@ impl ScriptState {
184
198
  collected.into_iter().map(|(_, key)| key),
185
199
  "collected resource timing option",
186
200
  )?;
187
- let tallies = ast::in_declared_functions(script, |function| {
188
- tally::published_tally(function.function.body.as_ref()?)
201
+ let tallies = script.in_declared_functions(|function| {
202
+ tally::published_tally(script, function.body.as_ref()?)
189
203
  });
190
204
  let counters = candidates::at_most_one_distinct(tallies, "interaction tally")?;
191
205
  let timing = match collected {
192
206
  Some(option) => {
193
- let reductions = ast::in_declared_functions(script, |function| {
194
- reduced_timing::reduction(function.function.body.as_ref()?)
207
+ let reductions = script.in_declared_functions(|function| {
208
+ reduced_timing::reduction(script, function.body.as_ref()?)
195
209
  });
196
210
  candidates::at_most_one_distinct(reductions, "resource timing reducer")?
197
211
  .map(|fields| ResourceTiming { option, fields })
@@ -208,7 +222,7 @@ impl ScriptState {
208
222
  elapsed: elapsed.map(|(_, elapsed)| elapsed),
209
223
  forwarded: forwarded.into_iter().map(|(_, key)| key).collect(),
210
224
  timing,
211
- getters: distinct_getters(sender.getters)?,
225
+ getters: distinct_getters(script, sender.getters, &sender.helpers)?,
212
226
  post_log,
213
227
  })
214
228
  }
@@ -223,22 +237,19 @@ impl ScriptState {
223
237
  bail!("could not recover the iframe's input event counters: {reason}")
224
238
  }
225
239
 
226
- fn builds_payload(&self, option: &str) -> bool {
227
- self.marks
228
- .iter()
229
- .any(|mark| mark.option == option && mark.in_builder)
230
- }
231
-
232
240
  /// Identifies the interval measured by `difference`, using `merged` as the marked option.
233
241
  /// Returns no interval if the script never marks the later timestamp.
234
242
  fn span(&self, difference: &Difference, merged: Option<&str>) -> Option<Span> {
235
- let Difference { later, earlier } = difference;
236
- if !self.marks.iter().any(|mark| &mark.option == later) {
237
- return None;
238
- }
239
- Some(if self.builds_payload(later) {
243
+ // Whether any mark of the later timestamp is in the builder; `None` if it is never marked.
244
+ let in_builder = self
245
+ .marks
246
+ .iter()
247
+ .filter(|mark| mark.option == difference.later)
248
+ .map(|mark| mark.in_builder)
249
+ .max()?;
250
+ Some(if in_builder {
240
251
  Span::Collect
241
- } else if Some(earlier.as_str()) == merged {
252
+ } else if Some(difference.earlier.as_str()) == merged {
242
253
  Span::Handoff
243
254
  } else {
244
255
  Span::Initialise
@@ -331,7 +342,8 @@ enum Span {
331
342
  /// Groups timestamps by their innermost function and finds the function containing the payload
332
343
  /// template. A template in a nested callback may subtract timestamps set by different
333
344
  /// functions.
334
- struct Scopes<'options> {
345
+ struct Scopes<'options, 'a> {
346
+ script: Script<'a>,
335
347
  options: &'options Options,
336
348
  /// The enclosing functions, innermost last.
337
349
  stack: Vec<Scope>,
@@ -345,10 +357,10 @@ struct Scope {
345
357
  builds_payload: bool,
346
358
  }
347
359
 
348
- impl Scopes<'_> {
349
- fn within<N: VisitWith<Self>>(&mut self, node: &N) {
360
+ impl Scopes<'_, '_> {
361
+ fn within(&mut self, walk: impl FnOnce(&mut Self)) {
350
362
  self.stack.push(Scope::default());
351
- node.visit_children_with(self);
363
+ walk(self);
352
364
  let scope = self.stack.pop().expect("entered a scope first");
353
365
  let marks = scope.marks.into_iter().map(|option| Mark {
354
366
  option,
@@ -358,77 +370,136 @@ impl Scopes<'_> {
358
370
  }
359
371
  }
360
372
 
361
- impl Visit for Scopes<'_> {
362
- fn visit_function(&mut self, function: &Function) {
363
- self.within(function);
373
+ impl<'a> Visit<'a> for Scopes<'_, 'a> {
374
+ fn visit_function(&mut self, function: &Function<'a>, flags: ScopeFlags) {
375
+ self.within(|scopes| walk::walk_function(scopes, function, flags));
364
376
  }
365
377
 
366
- fn visit_arrow_expr(&mut self, arrow: &ArrowExpr) {
367
- self.within(arrow);
378
+ fn visit_arrow_function_expression(&mut self, arrow: &ArrowFunctionExpression<'a>) {
379
+ self.within(|scopes| walk::walk_arrow_function_expression(scopes, arrow));
368
380
  }
369
381
 
370
- fn visit_assign_expr(&mut self, assignment: &AssignExpr) {
382
+ fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
371
383
  if let Some(option) = expression::option_assignment(&assignment.left)
372
- && ast::is_date_now(&assignment.right)
384
+ && self.script.is_date_now(&assignment.right)
373
385
  && let Some(scope) = self.stack.last_mut()
374
386
  {
375
387
  scope.marks.push(option.to_owned());
376
388
  }
377
- assignment.visit_children_with(self);
389
+ walk::walk_assignment_expression(self, assignment);
378
390
  }
379
391
 
380
- fn visit_if_stmt(&mut self, conditional: &IfStmt) {
392
+ fn visit_if_statement(&mut self, conditional: &IfStatement<'a>) {
381
393
  let options = self.options;
382
394
  source::visit_taken_branches(self, conditional, options);
383
395
  }
384
396
 
385
- fn visit_object_lit(&mut self, object: &ObjectLit) {
397
+ fn visit_object_expression(&mut self, object: &ObjectExpression<'a>) {
386
398
  if source::is_payload_template(object, self.options)
387
399
  && let Some(scope) = self.stack.last_mut()
388
400
  {
389
401
  scope.builds_payload = true;
390
402
  }
391
- object.visit_children_with(self);
403
+ walk::walk_object_expression(self, object);
392
404
  }
393
405
  }
394
406
 
395
407
  /// Finds property writes that add payload fields or install namespace getters. Records the
396
408
  /// enclosing function for each write.
397
- #[derive(Default)]
398
- struct Sender {
409
+ struct Sender<'a> {
410
+ script: Script<'a>,
399
411
  entered: usize,
400
412
  scopes: Vec<usize>,
401
413
  elapsed: Vec<(usize, Elapsed)>,
402
414
  copies: Vec<(usize, String)>,
403
- getters: Vec<Getter>,
404
- pushes: Vec<Push>,
405
- entries: Vec<LogEntry>,
406
- stamps: Vec<Stamp>,
415
+ getters: Vec<FoundGetter<'a>>,
416
+ /// The first option each declared function reads, by binding.
417
+ helpers: HashMap<SymbolId, String>,
418
+ pushes: Vec<Push<'a>>,
419
+ entries: Vec<LogEntry<'a>>,
420
+ stamps: Vec<Stamp<'a>>,
407
421
  }
408
422
 
409
- /// A namespace getter named `function` that returns the option `option`.
410
- struct Getter {
423
+ /// A namespace getter named `function` that returns the option `option`, rewriting each
424
+ /// sample's stack with the declared function `rewrite`, if any.
425
+ struct FoundGetter<'a> {
411
426
  function: String,
412
427
  option: String,
428
+ rewrite: Option<Binding<'a>>,
429
+ }
430
+
431
+ /// Finds `<sample>.s = <helper>(<sample>.s)`.
432
+ struct StackRewrite<'a> {
433
+ script: Script<'a>,
434
+ helper: Option<Binding<'a>>,
435
+ }
436
+
437
+ impl<'a> Visit<'a> for StackRewrite<'a> {
438
+ fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
439
+ if let Some(target) = assignment.left.as_member_expression()
440
+ && ast::ident_property(target) == Some("s")
441
+ && let Expression::CallExpression(call) = &assignment.right
442
+ && let Expression::Identifier(helper) = &call.callee
443
+ && let [argument] = &call.arguments[..]
444
+ && let Some(read) = argument
445
+ .as_expression()
446
+ .and_then(Expression::as_member_expression)
447
+ && ast::ident_property(read) == Some("s")
448
+ {
449
+ self.helper = Some(self.script.binding(helper));
450
+ }
451
+ walk::walk_assignment_expression(self, assignment);
452
+ }
453
+ }
454
+
455
+ /// The first option a function reads.
456
+ #[derive(Default)]
457
+ struct OptionRead(Option<String>);
458
+
459
+ impl<'a> Visit<'a> for OptionRead {
460
+ fn visit_member_expression(&mut self, member: &MemberExpression<'a>) {
461
+ if self.0.is_none()
462
+ && expression::is_options(member.object())
463
+ && let Some(option) = ast::member_str(member)
464
+ {
465
+ self.0 = Some(option.to_owned());
466
+ }
467
+ walk::walk_member_expression(self, member);
468
+ }
413
469
  }
414
470
 
415
471
  /// Matches `_cf_chl_opt.<log>.push(<local>)`.
416
- struct Push {
472
+ struct Push<'a> {
417
473
  log: String,
418
- local: String,
474
+ local: Binding<'a>,
419
475
  }
420
476
 
421
477
  /// Matches `<local>.<key> = <clock>()`.
422
- struct Stamp {
423
- local: String,
478
+ struct Stamp<'a> {
479
+ local: Binding<'a>,
424
480
  key: String,
425
481
  }
426
482
 
427
- impl Sender {
428
- fn within<N: VisitWith<Self>>(&mut self, node: &N) {
483
+ impl<'a> Sender<'a> {
484
+ fn new(script: Script<'a>) -> Self {
485
+ Self {
486
+ script,
487
+ entered: 0,
488
+ scopes: Vec::new(),
489
+ elapsed: Vec::new(),
490
+ copies: Vec::new(),
491
+ getters: Vec::new(),
492
+ helpers: HashMap::new(),
493
+ pushes: Vec::new(),
494
+ entries: Vec::new(),
495
+ stamps: Vec::new(),
496
+ }
497
+ }
498
+
499
+ fn within(&mut self, walk: impl FnOnce(&mut Self)) {
429
500
  self.entered += 1;
430
501
  self.scopes.push(self.entered);
431
- node.visit_children_with(self);
502
+ walk(self);
432
503
  self.scopes.pop();
433
504
  }
434
505
 
@@ -456,98 +527,114 @@ impl Sender {
456
527
 
457
528
  /// Finds a local initialized with a POST log entry: `{ url: new URL(...).href, count:
458
529
  /// _cf_chl_opt.<counter>, sent: clock() }`.
459
- struct LogEntry {
460
- local: String,
530
+ struct LogEntry<'a> {
531
+ local: Binding<'a>,
461
532
  fields: Vec<(String, Logged)>,
462
533
  counter: String,
463
534
  }
464
535
 
465
- impl LogEntry {
466
- fn read(local: &str, value: &Expr) -> Option<Self> {
467
- let Expr::Object(object) = value.unwrap_parens() else {
536
+ impl<'a> LogEntry<'a> {
537
+ fn read(local: Binding<'a>, value: &Expression<'_>) -> Option<Self> {
538
+ let Expression::ObjectExpression(object) = value.without_parentheses() else {
468
539
  return None;
469
540
  };
470
541
  let mut fields = Vec::new();
471
542
  let mut counter = None;
472
543
  for property in ast::key_values(object) {
473
- let value = property.value.unwrap_parens();
544
+ let value = property.value.without_parentheses();
474
545
  let logged = if let Some(option) = expression::option_key(value) {
475
546
  counter = Some(option.to_owned());
476
547
  Logged::Count
477
- } else if value.as_call().is_some_and(|call| call.args.is_empty()) {
548
+ } else if matches!(value, Expression::CallExpression(call) if call.arguments.is_empty())
549
+ {
478
550
  Logged::Sent
479
- } else if let Expr::Member(member) = value
480
- && ast::member_str(&member.prop) == Some("href")
481
- && member.obj.unwrap_parens().is_new()
551
+ } else if let Some(member) = value.as_member_expression()
552
+ && ast::member_str(member) == Some("href")
553
+ && matches!(
554
+ member.object().without_parentheses(),
555
+ Expression::NewExpression(_)
556
+ )
482
557
  {
483
558
  Logged::Url
484
559
  } else {
485
560
  return None;
486
561
  };
487
- fields.push((ast::key_str(&property.key)?.to_owned(), logged));
562
+ fields.push((
563
+ ast::key_str(&property.key, property.computed)?.to_owned(),
564
+ logged,
565
+ ));
488
566
  }
489
567
  let complete = fields.len() == 3
490
568
  && [Logged::Url, Logged::Count, Logged::Sent]
491
569
  .iter()
492
570
  .all(|logged| fields.iter().any(|(_, field)| field == logged));
493
571
  complete.then_some(Self {
494
- local: local.to_owned(),
572
+ local,
495
573
  fields,
496
574
  counter: counter?,
497
575
  })
498
576
  }
499
577
  }
500
578
 
501
- impl Visit for Sender {
502
- fn visit_function(&mut self, function: &Function) {
503
- self.within(function);
579
+ impl<'a> Visit<'a> for Sender<'a> {
580
+ fn visit_function(&mut self, function: &Function<'a>, flags: ScopeFlags) {
581
+ if function.is_declaration()
582
+ && let Some(name) = &function.id
583
+ {
584
+ let mut read = OptionRead::default();
585
+ read.visit_function(function, flags);
586
+ if let Some(option) = read.0 {
587
+ self.helpers.insert(name.symbol_id(), option);
588
+ }
589
+ }
590
+ self.within(|sender| walk::walk_function(sender, function, flags));
504
591
  }
505
592
 
506
- fn visit_arrow_expr(&mut self, arrow: &ArrowExpr) {
507
- self.within(arrow);
593
+ fn visit_arrow_function_expression(&mut self, arrow: &ArrowFunctionExpression<'a>) {
594
+ self.within(|sender| walk::walk_arrow_function_expression(sender, arrow));
508
595
  }
509
596
 
510
- fn visit_var_declarator(&mut self, declarator: &VarDeclarator) {
511
- if let Some(local) = declarator.name.as_ident()
597
+ fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
598
+ if let BindingPattern::BindingIdentifier(local) = &declarator.id
512
599
  && let Some(init) = &declarator.init
513
- && let Some(entry) = LogEntry::read(&local.sym, init)
600
+ && let Some(entry) = LogEntry::read(Binding::Symbol(local.symbol_id()), init)
514
601
  {
515
602
  self.entries.push(entry);
516
603
  }
517
- declarator.visit_children_with(self);
604
+ walk::walk_variable_declarator(self, declarator);
518
605
  }
519
606
 
520
- fn visit_call_expr(&mut self, call: &CallExpr) {
607
+ fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
521
608
  // `_cf_chl_opt.<log>.push(<entry>)`
522
- if let Some(callee) = call.callee.as_expr().and_then(|callee| callee.as_member())
523
- && ast::member_str(&callee.prop) == Some("push")
524
- && let Some(option) = expression::option_key(&callee.obj)
525
- && let [entry] = &call.args[..]
526
- && let Some(local) = entry.expr.as_ident()
609
+ if let Some(callee) = call.callee.as_member_expression()
610
+ && ast::member_str(callee) == Some("push")
611
+ && let Some(option) = expression::option_key(callee.object())
612
+ && let [entry] = &call.arguments[..]
613
+ && let Some(Expression::Identifier(local)) = entry.as_expression()
527
614
  {
528
615
  self.pushes.push(Push {
529
616
  log: option.to_owned(),
530
- local: local.sym.to_string(),
617
+ local: self.script.binding(local),
531
618
  });
532
619
  }
533
- call.visit_children_with(self);
620
+ walk::walk_call_expression(self, call);
534
621
  }
535
622
 
536
- fn visit_assign_expr(&mut self, assignment: &AssignExpr) {
623
+ fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
537
624
  let scope = self.scopes.last().copied().unwrap_or_default();
538
- if let AssignTarget::Simple(SimpleAssignTarget::Ident(local)) = &assignment.left
539
- && let Some(entry) = LogEntry::read(&local.sym, &assignment.right)
625
+ if let AssignmentTarget::AssignmentTargetIdentifier(local) = &assignment.left
626
+ && let Some(entry) = LogEntry::read(self.script.binding(local), &assignment.right)
540
627
  {
541
628
  self.entries.push(entry);
542
629
  }
543
- if let AssignTarget::Simple(SimpleAssignTarget::Member(target)) = &assignment.left
630
+ if let Some(target) = assignment.left.as_member_expression()
544
631
  && let Some(key) = ast::ident_property(target)
545
632
  {
546
- match &*assignment.right {
633
+ match &assignment.right {
547
634
  // `payload.<key> = Date.now() - _cf_chl_opt.<mark>`
548
- Expr::Bin(binary)
549
- if binary.op == BinaryOp::Sub
550
- && ast::is_date_now(&binary.left)
635
+ Expression::BinaryExpression(binary)
636
+ if binary.operator == BinaryOperator::Subtraction
637
+ && self.script.is_date_now(&binary.left)
551
638
  && let Some(mark) = expression::option_key(&binary.right) =>
552
639
  {
553
640
  let elapsed = Elapsed {
@@ -557,15 +644,24 @@ impl Visit for Sender {
557
644
  self.elapsed.push((scope, elapsed));
558
645
  }
559
646
  // `<namespace>.<key> = function () { var ...; local = _cf_chl_opt.<option>; ... }`
560
- Expr::Fn(getter)
561
- if let Some(body) = &getter.function.body
562
- && let Some(first) = body.stmts.iter().find_map(Stmt::as_expr)
563
- && let Expr::Assign(first) = &*first.expr
647
+ Expression::FunctionExpression(getter)
648
+ if let Some(body) = &getter.body
649
+ && let Some(Statement::ExpressionStatement(first)) =
650
+ body.statements.iter().find(|statement| {
651
+ matches!(statement, Statement::ExpressionStatement(_))
652
+ })
653
+ && let Expression::AssignmentExpression(first) = &first.expression
564
654
  && let Some(option) = expression::option_key(&first.right) =>
565
655
  {
566
- self.getters.push(Getter {
656
+ let mut rewrite = StackRewrite {
657
+ script: self.script,
658
+ helper: None,
659
+ };
660
+ rewrite.visit_function(getter, ScopeFlags::Function);
661
+ self.getters.push(FoundGetter {
567
662
  function: key.to_owned(),
568
663
  option: option.to_owned(),
664
+ rewrite: rewrite.helper,
569
665
  });
570
666
  }
571
667
  // `payload.<key> = _cf_chl_opt.<key>`
@@ -573,30 +669,53 @@ impl Visit for Sender {
573
669
  self.copies.push((scope, key.to_owned()));
574
670
  }
575
671
  // `entry.<key> = clock()`
576
- Expr::Call(call)
577
- if call.args.is_empty()
578
- && let Some(local) = target.obj.as_ident() =>
672
+ Expression::CallExpression(call)
673
+ if call.arguments.is_empty()
674
+ && let Expression::Identifier(local) = target.object() =>
579
675
  {
580
676
  self.stamps.push(Stamp {
581
- local: local.sym.to_string(),
677
+ local: self.script.binding(local),
582
678
  key: key.to_owned(),
583
679
  });
584
680
  }
585
681
  _ => {}
586
682
  }
587
683
  }
588
- assignment.visit_children_with(self);
684
+ walk::walk_assignment_expression(self, assignment);
589
685
  }
590
686
  }
591
687
 
592
- /// Rejects a getter name that returns different options.
593
- fn distinct_getters(getters: Vec<Getter>) -> Result<BTreeMap<String, String>> {
688
+ /// Resolves each getter's stack rewrite to the option its helper reads. Rejects a getter name
689
+ /// that returns different options.
690
+ fn distinct_getters(
691
+ script: Script<'_>,
692
+ getters: Vec<FoundGetter<'_>>,
693
+ helpers: &HashMap<SymbolId, String>,
694
+ ) -> Result<BTreeMap<String, Getter>> {
594
695
  let mut distinct = BTreeMap::new();
595
- for Getter { function, option } in getters {
596
- let previous = distinct.entry(function.clone()).or_insert(option.clone());
696
+ for found in getters {
697
+ let function = found.function;
698
+ let page_origin = found
699
+ .rewrite
700
+ .map(|helper| {
701
+ let declared = match helper {
702
+ Binding::Symbol(symbol) => helpers.get(&symbol),
703
+ Binding::Global(_) => None,
704
+ };
705
+ declared.cloned().with_context(|| {
706
+ let name = script.name(helper);
707
+ format!("getter {function} rewrites stacks with unknown helper {name}")
708
+ })
709
+ })
710
+ .transpose()?;
711
+ let getter = Getter {
712
+ option: found.option,
713
+ page_origin,
714
+ };
715
+ let previous = distinct.entry(function.clone()).or_insert(getter.clone());
597
716
  ensure!(
598
- *previous == option,
599
- "getter {function} reads both {previous} and {option}"
717
+ *previous == getter,
718
+ "getter {function} reads both {previous:?} and {getter:?}"
600
719
  );
601
720
  }
602
721
  Ok(distinct)
@@ -715,12 +834,7 @@ mod tests {
715
834
  .enumerate()
716
835
  .map(|(index, (later, earlier))| {
717
836
  let text = format!("e._cf_chl_opt.{later} - e._cf_chl_opt.{earlier}");
718
- Field {
719
- name: format!("f{index}"),
720
- expression: ast::parse_expression("t", &text).unwrap(),
721
- text,
722
- bootstrap_value: None,
723
- }
837
+ Field::parse(format!("f{index}"), text, None).unwrap()
724
838
  })
725
839
  .collect();
726
840
  let intervals = &Intervals {