cfsolve 0.1.2 → 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 (368) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/THIRD_PARTY_LICENSES/README.md +71 -254
  4. data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
  5. data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
  6. data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
  7. data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
  8. data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
  9. data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
  10. data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
  11. data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
  12. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
  13. data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
  14. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
  15. data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
  16. data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
  17. data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
  18. data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
  19. data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
  20. data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
  21. data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
  22. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
  23. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
  24. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
  25. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
  26. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
  27. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
  28. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
  29. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
  30. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
  31. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
  32. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
  33. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
  34. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
  35. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
  36. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
  37. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
  38. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
  39. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
  40. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
  41. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
  42. data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
  43. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
  44. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
  45. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
  46. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
  47. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
  48. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
  49. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
  50. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
  51. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
  52. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
  53. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
  54. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
  55. data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
  56. data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
  57. data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
  58. data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
  59. data/UPSTREAM.md +7 -5
  60. data/ext/cfsolve/Cargo.lock +534 -1727
  61. data/ext/cfsolve/Cargo.toml +4 -0
  62. data/ext/cfsolve/src/main.rs +1 -1
  63. data/lib/cfsolve/profiles/safari-26-ios/answers.json +266 -265
  64. data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
  65. data/lib/cfsolve/profiles/safari-26-ios.json +106 -152
  66. data/lib/cfsolve/version.rb +2 -2
  67. data/vendor/cfsolve/Cargo.lock +561 -1729
  68. data/vendor/cfsolve/Cargo.toml +26 -8
  69. data/vendor/cfsolve/README.md +4 -0
  70. data/vendor/cfsolve/examples/check_answers.rs +2 -2
  71. data/vendor/cfsolve/examples/compare_session.rs +1 -2
  72. data/vendor/cfsolve/examples/solver_profile.rs +84 -0
  73. data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
  74. data/vendor/cfsolve/examples/stage2_snapshot.rs +2 -2
  75. data/vendor/cfsolve/examples/tls_echo.rs +3 -3
  76. data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
  77. data/vendor/cfsolve/profiles/safari-26-ios/answers.json +266 -265
  78. data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
  79. data/vendor/cfsolve/profiles/safari-26-ios.json +106 -152
  80. data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
  81. data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
  82. data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
  83. data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
  84. data/vendor/cfsolve/src/capture/proxy.rs +44 -13
  85. data/vendor/cfsolve/src/capture/sessions.rs +4 -3
  86. data/vendor/cfsolve/src/capture/upstream.rs +1 -1
  87. data/vendor/cfsolve/src/challenge/codec.rs +4 -2
  88. data/vendor/cfsolve/src/challenge/expression.rs +161 -117
  89. data/vendor/cfsolve/src/challenge/installed/audit.rs +11 -10
  90. data/vendor/cfsolve/src/challenge/installed.rs +13 -6
  91. data/vendor/cfsolve/src/challenge/merge.rs +120 -80
  92. data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
  93. data/vendor/cfsolve/src/challenge/payload.rs +69 -31
  94. data/vendor/cfsolve/src/challenge/program.rs +197 -178
  95. data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
  96. data/vendor/cfsolve/src/challenge/source.rs +151 -96
  97. data/vendor/cfsolve/src/challenge/state.rs +180 -148
  98. data/vendor/cfsolve/src/challenge/tally.rs +64 -50
  99. data/vendor/cfsolve/src/challenge.rs +1 -0
  100. data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
  101. data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
  102. data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
  103. data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
  104. data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
  105. data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
  106. data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
  107. data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
  108. data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
  109. data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
  110. data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
  111. data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
  112. data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
  113. data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
  114. data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
  115. data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
  116. data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
  117. data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +198 -203
  118. data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
  119. data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +338 -513
  120. data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
  121. data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
  122. data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
  123. data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
  124. data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
  125. data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
  126. data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
  127. data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +353 -327
  128. data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
  129. data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
  130. data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
  131. data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
  132. data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
  133. data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
  134. data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
  135. data/vendor/cfsolve/src/deobfuscate.rs +15 -11
  136. data/vendor/cfsolve/src/embedding_page/extra_params.rs +23 -18
  137. data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
  138. data/vendor/cfsolve/src/error.rs +40 -5
  139. data/vendor/cfsolve/src/fingerprint.rs +8 -2
  140. data/vendor/cfsolve/src/http/client.rs +7 -10
  141. data/vendor/cfsolve/src/http/requests.rs +2 -2
  142. data/vendor/cfsolve/src/js/ast.rs +479 -263
  143. data/vendor/cfsolve/src/lib.rs +1 -0
  144. data/vendor/cfsolve/src/listing/fold.rs +19 -9
  145. data/vendor/cfsolve/src/listing/query.rs +1 -47
  146. data/vendor/cfsolve/src/performance_clock.rs +20 -1
  147. data/vendor/cfsolve/src/profiling.rs +49 -0
  148. data/vendor/cfsolve/src/script.rs +35 -24
  149. data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
  150. data/vendor/cfsolve/src/session/channel.rs +2 -2
  151. data/vendor/cfsolve/src/session/initial.rs +5 -5
  152. data/vendor/cfsolve/src/session/sink.rs +26 -1
  153. data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
  154. data/vendor/cfsolve/src/session.rs +1 -1
  155. data/vendor/cfsolve/src/solver.rs +3 -1
  156. data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
  157. data/vendor/cfsolve/src/stage2/analysis/envelope.rs +2 -1
  158. data/vendor/cfsolve/src/stage2/audit_globals.rs +142 -74
  159. data/vendor/cfsolve/src/stage2/benchmark.rs +62 -31
  160. data/vendor/cfsolve/src/stage2/call_stack.rs +1415 -1025
  161. data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
  162. data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
  163. data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
  164. data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -4
  165. data/vendor/cfsolve/src/stage2/payload/recover.rs +2 -2
  166. data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
  167. data/vendor/cfsolve/src/stage2/probes/performance.rs +12 -8
  168. data/vendor/cfsolve/src/stage2/queries.rs +50 -0
  169. data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
  170. data/vendor/cfsolve/src/stage2/trace.rs +134 -108
  171. data/vendor/cfsolve/src/stage2/vocabulary.rs +1 -11
  172. data/vendor/cfsolve/src/stage2.rs +2 -0
  173. data/vendor/cfsolve/src/vm/disassemble.rs +7 -3
  174. data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
  175. data/vendor/cfsolve/src/vm/extract.rs +347 -250
  176. data/vendor/cfsolve/src/vm/interpret/access.rs +63 -48
  177. data/vendor/cfsolve/src/vm/interpret/builtin.rs +10 -10
  178. data/vendor/cfsolve/src/vm/interpret/call.rs +116 -52
  179. data/vendor/cfsolve/src/vm/interpret/compile.rs +79 -62
  180. data/vendor/cfsolve/src/vm/interpret/copies.rs +2 -2
  181. data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +63 -42
  182. data/vendor/cfsolve/src/vm/interpret/evaluate.rs +65 -575
  183. data/vendor/cfsolve/src/vm/interpret/explore.rs +7 -10
  184. data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
  185. data/vendor/cfsolve/src/vm/interpret/frozen.rs +3 -5
  186. data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +123 -59
  187. data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
  188. data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
  189. data/vendor/cfsolve/src/vm/interpret/pattern.rs +1736 -0
  190. data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
  191. data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
  192. data/vendor/cfsolve/src/vm/interpret/run.rs +116 -45
  193. data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
  194. data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
  195. data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
  196. data/vendor/cfsolve/src/vm/interpret.rs +9 -1
  197. data/vendor/cfsolve/src/vm/machine.rs +56 -49
  198. data/vendor/cfsolve/src/vm/output.rs +13 -5
  199. data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
  200. data/vendor/cfsolve/src/vm/session.rs +185 -120
  201. data/vendor/cfsolve/src/vm/value.rs +22 -19
  202. data/vendor/cfsolve/src/vm.rs +2 -1
  203. data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
  204. data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
  205. metadata +94 -178
  206. data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
  207. data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
  208. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
  209. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
  210. data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
  211. data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
  212. data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
  213. data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
  214. data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
  215. data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
  216. data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
  217. data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
  218. data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
  219. data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
  220. data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
  221. data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
  222. data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
  223. data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
  224. data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
  225. data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
  226. data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
  227. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
  228. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
  229. data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
  230. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
  231. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
  232. data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
  233. data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
  234. data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
  235. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
  236. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
  237. data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
  238. data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
  239. data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
  240. data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
  241. data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
  242. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
  243. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
  244. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
  245. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
  246. data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
  247. data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
  248. data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
  249. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
  250. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
  251. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
  252. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
  253. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
  254. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
  255. data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
  256. data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
  257. data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
  258. data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
  259. data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
  260. data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
  261. data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
  262. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
  263. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
  264. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
  265. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
  266. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
  267. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
  268. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
  269. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
  270. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
  271. data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
  272. data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
  273. data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
  274. data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
  275. data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
  276. data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
  277. data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
  278. data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
  279. data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
  280. data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
  281. data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
  282. data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
  283. data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
  284. data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
  285. data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
  286. data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
  287. data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
  288. data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
  289. data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
  290. data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
  291. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
  292. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
  293. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
  294. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
  295. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
  296. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
  297. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
  298. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
  299. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
  300. data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
  301. data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
  302. data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
  303. data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
  304. data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
  305. data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
  306. data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
  307. data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
  308. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
  309. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
  310. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
  311. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
  312. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
  313. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
  314. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
  315. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
  316. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
  317. data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
  318. data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
  319. data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
  320. data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
  321. data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
  322. data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
  323. data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
  324. data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
  325. data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
  326. data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
  327. data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
  328. data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
  329. data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
  330. data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
  331. data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
  332. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
  333. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
  334. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
  335. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
  336. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
  337. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
  338. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
  339. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
  340. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
  341. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
  342. data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
  343. data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
  344. data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
  345. /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
  346. /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
  347. /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
  348. /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
  349. /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
  350. /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
  351. /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
  352. /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
  353. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
  354. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
  355. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
  356. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
  357. /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
  358. /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
  359. /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
  360. /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
  361. /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
  362. /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
  363. /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
  364. /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
  365. /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
  366. /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
  367. /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
  368. /data/THIRD_PARTY_LICENSES/{cargo-platform-0.1.9 → zmij_ecma-1.0.23}/LICENSE-MIT +0 -0
@@ -2,10 +2,12 @@
2
2
  //! client's fetch measurements to that format. Depending on the build, entries contain rounded-down
3
3
  //! phase durations or the original timestamps.
4
4
 
5
- use swc_core::ecma::ast::{AssignTarget, BinaryOp, BlockStmt, Expr, SimpleAssignTarget};
5
+ use oxc::ast::ast::{AssignmentTarget, Expression, FunctionBody};
6
+ use oxc::syntax::operator::BinaryOperator;
6
7
 
7
8
  use crate::challenge::expression::{self, BuiltObject, ObjectField};
8
- use crate::js::{JsObject, JsValue, ast, json};
9
+ use crate::js::ast::{self, Binding, Script};
10
+ use crate::js::{JsObject, JsValue, json};
9
11
  use crate::resource_timing::{LoadTiming, Phases, ResourceMeasurement};
10
12
 
11
13
  /// The resource timing property represented by an output field.
@@ -108,45 +110,54 @@ impl ResourceTiming {
108
110
 
109
111
  /// Finds the first resource summary object in `body`, using the resource name and locals
110
112
  /// holding floored measurements.
111
- pub(super) fn reduction(body: &BlockStmt) -> Option<Vec<(String, Measure)>> {
112
- let mut measured: Vec<(&str, Measure)> = Vec::new();
113
+ pub(super) fn reduction<'a>(
114
+ script: Script<'a>,
115
+ body: &FunctionBody<'a>,
116
+ ) -> Option<Vec<(String, Measure)>> {
117
+ let mut measured: Vec<(Binding, Measure)> = Vec::new();
113
118
  let mut built: Vec<BuiltObject> = Vec::new();
114
119
  for assignment in expression::assignments(body) {
115
- if let AssignTarget::Simple(SimpleAssignTarget::Ident(local)) = &assignment.left
116
- && let Some(measure) = floored(&assignment.right)
120
+ if let AssignmentTarget::AssignmentTargetIdentifier(local) = &assignment.left
121
+ && let Some(measure) = floored(script, &assignment.right)
117
122
  {
118
- measured.push((&local.id.sym, measure));
123
+ measured.push((script.binding(local), measure));
119
124
  } else {
120
- expression::track(&mut built, assignment);
125
+ expression::track(script, &mut built, assignment);
121
126
  }
122
127
  }
123
128
  built
124
129
  .iter()
125
- .find_map(|object| reduced_fields(&object.fields, &measured))
130
+ .find_map(|object| reduced_fields(script, &object.fields, &measured))
126
131
  }
127
132
 
128
133
  /// Recognizes a reduced entry when it has enough fields, includes the resource name, and uses
129
134
  /// only properties of the entry itself or locals listed in `measured`.
130
- fn reduced_fields(
131
- fields: &[ObjectField<'_>],
132
- measured: &[(&str, Measure)],
135
+ fn reduced_fields<'a>(
136
+ script: Script<'a>,
137
+ fields: &[ObjectField<'_, 'a>],
138
+ measured: &[(Binding<'a>, Measure)],
133
139
  ) -> Option<Vec<(String, Measure)>> {
134
140
  let mut reduced = Vec::with_capacity(fields.len());
135
141
  for field in fields {
136
142
  let measure = match field.value {
137
- Expr::Member(member) => match ast::member_str(&member.prop)? {
138
- "name" => Measure::Name,
139
- "startTime" => Measure::Start,
140
- "requestStart" => Measure::RequestStart,
141
- "responseStart" => Measure::ResponseStart,
142
- "responseEnd" => Measure::ResponseEnd,
143
- "duration" => Measure::ExactDuration,
144
- "transferSize" => Measure::Transfer,
145
- "encodedBodySize" => Measure::Body,
146
- _ => return None,
147
- },
148
- Expr::Ident(ident) => {
149
- let (_, measure) = measured.iter().rfind(|(local, _)| *local == &*ident.sym)?;
143
+ Expression::StaticMemberExpression(_)
144
+ | Expression::ComputedMemberExpression(_)
145
+ | Expression::PrivateFieldExpression(_) => {
146
+ match ast::member_str(field.value.to_member_expression())? {
147
+ "name" => Measure::Name,
148
+ "startTime" => Measure::Start,
149
+ "requestStart" => Measure::RequestStart,
150
+ "responseStart" => Measure::ResponseStart,
151
+ "responseEnd" => Measure::ResponseEnd,
152
+ "duration" => Measure::ExactDuration,
153
+ "transferSize" => Measure::Transfer,
154
+ "encodedBodySize" => Measure::Body,
155
+ _ => return None,
156
+ }
157
+ }
158
+ Expression::Identifier(ident) => {
159
+ let local = script.binding(ident);
160
+ let (_, measure) = measured.iter().rfind(|(measured, _)| *measured == local)?;
150
161
  *measure
151
162
  }
152
163
  _ => return None,
@@ -158,17 +169,19 @@ fn reduced_fields(
158
169
  }
159
170
 
160
171
  /// `Math.floor(entry.a - entry.b)` or `Math.floor(entry.a)`.
161
- fn floored(expression: &Expr) -> Option<Measure> {
162
- let call = expression.as_call()?;
163
- let member = call.callee.as_expr()?.as_member()?;
164
- if !ast::is_method_of(member, "Math", "floor") {
172
+ fn floored(script: Script<'_>, expression: &Expression<'_>) -> Option<Measure> {
173
+ let Expression::CallExpression(call) = expression else {
174
+ return None;
175
+ };
176
+ let member = call.callee.as_member_expression()?;
177
+ if !script.is_method_of(member, "Math", "floor") {
165
178
  return None;
166
179
  }
167
- fn attribute(expression: &Expr) -> Option<&str> {
168
- ast::ident_property(expression.as_member()?)
180
+ fn attribute<'a>(expression: &Expression<'a>) -> Option<&'a str> {
181
+ ast::ident_property(expression.as_member_expression()?)
169
182
  }
170
- match &*call.args.first()?.expr {
171
- Expr::Bin(binary) if binary.op == BinaryOp::Sub => {
183
+ match call.arguments.first()?.as_expression()? {
184
+ Expression::BinaryExpression(binary) if binary.operator == BinaryOperator::Subtraction => {
172
185
  match (attribute(&binary.left)?, attribute(&binary.right)?) {
173
186
  ("responseEnd", "responseStart") => Some(Measure::Response),
174
187
  ("responseStart", "requestStart") => Some(Measure::Request),
@@ -186,7 +199,10 @@ fn floored(expression: &Expr) -> Option<Measure> {
186
199
 
187
200
  #[cfg(test)]
188
201
  mod tests {
202
+ use oxc::ast::ast::Statement;
203
+
189
204
  use super::*;
205
+ use crate::js::ast::ParsedScript;
190
206
 
191
207
  /// Uses a 137 ms navigation that iOS Safari reported as 124 ms receiving the response and
192
208
  /// zero time waiting for it.
@@ -225,19 +241,18 @@ mod tests {
225
241
  /// durations.
226
242
  #[test]
227
243
  fn summaries_may_copy_the_entrys_timestamps() {
228
- let parsed = ast::parse_javascript(
244
+ let parsed = ParsedScript::parse(
229
245
  "t.js",
230
246
  "function f(e) { var r; r = { a: e.name, b: e.startTime, c: e.requestStart, \
231
247
  d: e.responseStart, g: e.responseEnd, h: e.duration, i: e.transferSize, \
232
248
  j: e.encodedBodySize }; list.push(r); }",
233
249
  )
234
250
  .unwrap();
235
- let function = parsed.script.body[0]
236
- .as_decl()
237
- .unwrap()
238
- .as_fn_decl()
239
- .unwrap();
240
- let fields = reduction(function.function.body.as_ref().unwrap()).unwrap();
251
+ let script = parsed.script();
252
+ let Statement::FunctionDeclaration(function) = &script.program.body[0] else {
253
+ panic!("not a function declaration");
254
+ };
255
+ let fields = reduction(script, function.body.as_ref().unwrap()).unwrap();
241
256
  let measures: Vec<Measure> = fields.iter().map(|(_, measure)| *measure).collect();
242
257
  assert_eq!(
243
258
  measures,
@@ -3,20 +3,33 @@
3
3
  use std::collections::BTreeSet;
4
4
 
5
5
  use anyhow::{Context, Result, ensure};
6
- use scraper::{Html, Selector};
7
- use swc_core::ecma::ast::{
8
- AssignExpr, AssignOp, AssignTarget, BinExpr, BinaryOp, CallExpr, Callee, Expr, Function,
9
- IfStmt, Lit, ObjectLit, SimpleAssignTarget, UnaryExpr, UnaryOp,
6
+ use oxc::ast::ast::{
7
+ Argument, AssignmentExpression, BinaryExpression, CallExpression, Expression, Function,
8
+ IfStatement, ObjectExpression, UnaryExpression,
10
9
  };
11
- use swc_core::ecma::visit::{Visit, VisitWith};
10
+ use oxc::ast_visit::{Visit, walk};
11
+ use oxc::semantic::ScopeFlags;
12
+ use oxc::syntax::operator::{AssignmentOperator, LogicalOperator, UnaryOperator};
13
+ use scraper::{Html, Selector};
12
14
  use url::Url;
13
15
 
14
16
  use crate::candidates;
15
17
  use crate::challenge::expression;
16
- use crate::js::ast::{self, ParsedScript};
18
+ use crate::js::ast::{self, Script};
17
19
  use crate::js::{JsValue, Options};
18
20
  use crate::script::Source;
19
21
 
22
+ /// Whether `text` is a randomized name in the form newer builds use: `_` and 24 lowercase hex
23
+ /// digits, such as `_2b78d2cde0fa83bfaec4edae`.
24
+ pub(crate) fn is_hex_name(text: &str) -> bool {
25
+ text.strip_prefix('_').is_some_and(|hex| {
26
+ hex.len() == 24
27
+ && hex
28
+ .bytes()
29
+ .all(|byte| matches!(byte, b'0'..=b'9' | b'a'..=b'f'))
30
+ })
31
+ }
32
+
20
33
  /// Minimum property count distinguishing a payload template from an ordinary options object.
21
34
  const PAYLOAD_FIELDS: usize = 20;
22
35
  /// Stable prefix of the initial challenge type: `chl_api_m` for managed widgets or `chl_api_ni`
@@ -45,18 +58,19 @@ impl InitialRequest {
45
58
 
46
59
  #[cfg(test)]
47
60
  pub(crate) fn from_javascript(source: &str, iframe_url: &Url) -> Result<Self> {
48
- Self::from_parsed(&ast::parse_iframe_javascript(source)?, iframe_url)
61
+ Self::from_script(ast::ParsedScript::parse("t", source)?.script(), iframe_url)
49
62
  }
50
63
 
51
- pub(crate) fn from_parsed(parsed: &ParsedScript, iframe_url: &Url) -> Result<Self> {
52
- let options = bootstrap_options(parsed);
64
+ pub(crate) fn from_script(script: Script<'_>, iframe_url: &Url) -> Result<Self> {
65
+ let options = bootstrap_options(script);
53
66
  ensure!(!options.is_empty(), "missing _cf_chl_opt object");
54
67
  let mut request = Request {
68
+ script,
55
69
  options: &options,
56
70
  paths: BTreeSet::new(),
57
71
  tokens: BTreeSet::new(),
58
72
  };
59
- parsed.script.visit_with(&mut request);
73
+ request.visit_program(script.program);
60
74
  let token = candidates::exactly_one(request.tokens, "cf-chl token")?;
61
75
  let path = candidates::exactly_one(
62
76
  request
@@ -96,12 +110,15 @@ pub fn ray(url: &Url) -> Result<&str> {
96
110
  /// Reads bootstrap `_cf_chl_opt` values and later static assignments. Returns an empty map if
97
111
  /// the script installs no options.
98
112
  #[must_use]
99
- pub(crate) fn bootstrap_options(parsed: &ParsedScript) -> Options {
100
- let mut options = StaticOptions::default();
101
- parsed.script.visit_with(&mut options);
113
+ pub(crate) fn bootstrap_options(script: Script<'_>) -> Options {
114
+ let mut assigned = StaticOptions {
115
+ script,
116
+ options: Options::new(),
117
+ };
118
+ assigned.visit_program(script.program);
102
119
  let mut renames = Renames::default();
103
- parsed.script.visit_with(&mut renames);
104
- let StaticOptions(mut options) = options;
120
+ renames.visit_program(script.program);
121
+ let mut options = assigned.options;
105
122
  for (to, from) in renames.copies {
106
123
  if renames.deleted.contains(&from)
107
124
  && !options.contains_key(&to)
@@ -130,51 +147,53 @@ pub(crate) fn mode(options: &Options) -> Option<&str> {
130
147
  pub(crate) fn expected_build(source: &Source) -> Option<String> {
131
148
  #[derive(Default)]
132
149
  struct Builds(Vec<String>);
133
- impl Visit for Builds {
134
- fn visit_bin_expr(&mut self, binary: &BinExpr) {
150
+ impl<'a> Visit<'a> for Builds {
151
+ fn visit_binary_expression(&mut self, binary: &BinaryExpression<'a>) {
135
152
  if let Some(build) = expression::padded_build(binary).filter(|build| build.len() == 12)
136
153
  {
137
154
  self.0.push(build);
138
155
  }
139
- binary.visit_children_with(self);
156
+ walk::walk_binary_expression(self, binary);
140
157
  }
141
158
  }
142
159
  let mut builds = Builds::default();
143
- source.parsed().script.visit_with(&mut builds);
160
+ builds.visit_program(source.script().program);
144
161
  candidates::at_most_one_distinct(builds.0, "loader build").ok()?
145
162
  }
146
163
 
147
164
  /// Identifies a payload template by its size and a field that reads the initial challenge type
148
165
  /// option.
149
166
  #[must_use]
150
- pub(crate) fn is_payload_template(object: &ObjectLit, options: &Options) -> bool {
167
+ pub(crate) fn is_payload_template(object: &ObjectExpression<'_>, options: &Options) -> bool {
151
168
  let challenge = |value: &str| value.starts_with(INITIAL_CHALLENGE);
152
169
  let in_iframe = options
153
170
  .values()
154
171
  .any(|value| value.as_str().is_some_and(challenge));
155
172
  // The string values of the options the fields read.
156
173
  let mut read = ast::key_values(object).filter_map(|property| {
157
- let member = property.value.as_member()?;
158
- options.get(ast::member_str(&member.prop)?)?.as_str()
174
+ let member = property.value.as_member_expression()?;
175
+ options.get(ast::member_str(member)?)?.as_str()
159
176
  });
160
- object.props.len() > PAYLOAD_FIELDS
177
+ object.properties.len() > PAYLOAD_FIELDS
161
178
  && read.any(|value| challenge(value) || !in_iframe && PAGE_CHALLENGES.contains(&value))
162
179
  }
163
180
 
164
181
  /// Visits branches using known option values. For a condition guarded by an unset option,
165
182
  /// visits only `else`; otherwise visits both branches. This skips an unused second payload
166
183
  /// template in page orchestrators.
167
- pub(crate) fn visit_taken_branches<V: Visit>(
184
+ pub(crate) fn visit_taken_branches<'a, V: Visit<'a>>(
168
185
  visitor: &mut V,
169
- conditional: &IfStmt,
186
+ conditional: &IfStatement<'a>,
170
187
  options: &Options,
171
188
  ) {
172
- if expression::option_key(conditional.test.unwrap_parens())
189
+ if expression::option_key(conditional.test.without_parentheses())
173
190
  .is_some_and(|option| !options.contains_key(option))
174
191
  {
175
- conditional.alt.visit_with(visitor);
192
+ if let Some(alternate) = &conditional.alternate {
193
+ visitor.visit_statement(alternate);
194
+ }
176
195
  } else {
177
- conditional.visit_children_with(visitor);
196
+ walk::walk_if_statement(visitor, conditional);
178
197
  }
179
198
  }
180
199
 
@@ -188,107 +207,112 @@ struct Renames {
188
207
  deleted: Vec<String>,
189
208
  }
190
209
 
191
- impl Visit for Renames {
192
- fn visit_assign_expr(&mut self, assignment: &AssignExpr) {
193
- let source = match assignment.right.unwrap_parens() {
194
- Expr::Bin(BinExpr {
195
- op: BinaryOp::LogicalOr,
196
- right,
197
- ..
198
- }) => right.unwrap_parens(),
210
+ impl<'a> Visit<'a> for Renames {
211
+ fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
212
+ let source = match assignment.right.without_parentheses() {
213
+ Expression::LogicalExpression(logical) if logical.operator == LogicalOperator::Or => {
214
+ logical.right.without_parentheses()
215
+ }
199
216
  other => other,
200
217
  };
201
- if assignment.op == AssignOp::Assign
218
+ if assignment.operator == AssignmentOperator::Assign
202
219
  && let Some(to) = expression::option_assignment(&assignment.left)
203
220
  && let Some(from) = expression::option_key(source)
204
221
  {
205
222
  self.copies.push((to.to_owned(), from.to_owned()));
206
223
  }
207
- assignment.visit_children_with(self);
224
+ walk::walk_assignment_expression(self, assignment);
208
225
  }
209
226
 
210
- fn visit_unary_expr(&mut self, unary: &UnaryExpr) {
211
- if unary.op == UnaryOp::Delete
212
- && let Some(option) = expression::option_key(unary.arg.unwrap_parens())
227
+ fn visit_unary_expression(&mut self, unary: &UnaryExpression<'a>) {
228
+ if unary.operator == UnaryOperator::Delete
229
+ && let Some(option) = expression::option_key(unary.argument.without_parentheses())
213
230
  {
214
231
  self.deleted.push(option.to_owned());
215
232
  }
216
- unary.visit_children_with(self);
233
+ walk::walk_unary_expression(self, unary);
217
234
  }
218
235
  }
219
236
 
220
237
  /// The options the script assigns statically.
221
- #[derive(Default)]
222
- struct StaticOptions(Options);
238
+ struct StaticOptions<'a> {
239
+ script: Script<'a>,
240
+ options: Options,
241
+ }
223
242
 
224
- impl Visit for StaticOptions {
225
- fn visit_assign_expr(&mut self, assignment: &AssignExpr) {
226
- if let AssignTarget::Simple(SimpleAssignTarget::Member(member)) = &assignment.left {
227
- if ast::member_str(&member.prop) == Some("_cf_chl_opt") {
243
+ impl<'a> Visit<'a> for StaticOptions<'a> {
244
+ fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
245
+ if let Some(member) = assignment.left.as_member_expression() {
246
+ if ast::member_str(member) == Some("_cf_chl_opt") {
228
247
  if let Some(JsValue::Object(options)) =
229
- expression::static_value(&assignment.right, &Options::new())
248
+ expression::static_value(self.script, &assignment.right, &Options::new())
230
249
  {
231
- self.0 = Options::from(options);
250
+ self.options = Options::from(options);
232
251
  }
233
- } else if expression::is_options(&member.obj)
252
+ } else if expression::is_options(member.object())
234
253
  && let (Some(key), Some(value)) = (
235
- ast::member_str(&member.prop),
236
- expression::static_value(&assignment.right, &self.0),
254
+ ast::member_str(member),
255
+ expression::static_value(self.script, &assignment.right, &self.options),
237
256
  )
238
257
  {
239
- self.0.insert(key.to_owned(), value);
258
+ self.options.insert(key.to_owned(), value);
240
259
  }
241
260
  }
242
- assignment.visit_children_with(self);
261
+ walk::walk_assignment_expression(self, assignment);
243
262
  }
244
263
 
245
264
  // Only the bootstrap IIFE, entered below, runs now. Other functions mutate the options
246
265
  // later, and their writes must not overwrite the bootstrap values.
247
- fn visit_function(&mut self, _: &Function) {}
266
+ fn visit_function(&mut self, _: &Function<'a>, _: ScopeFlags) {}
248
267
 
249
- fn visit_call_expr(&mut self, call: &CallExpr) {
250
- if let Callee::Expr(callee) = &call.callee
251
- && let Expr::Fn(function) = callee.unwrap_parens()
252
- && let Some(body) = &function.function.body
268
+ fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
269
+ if let Expression::FunctionExpression(function) = call.callee.without_parentheses()
270
+ && let Some(body) = &function.body
253
271
  {
254
- body.visit_with(self);
272
+ self.visit_function_body(body);
255
273
  }
256
274
  }
257
275
  }
258
276
 
259
- struct Request<'options> {
277
+ struct Request<'options, 'a> {
278
+ script: Script<'a>,
260
279
  options: &'options Options,
261
280
  paths: BTreeSet<String>,
262
281
  tokens: BTreeSet<String>,
263
282
  }
264
283
 
265
- impl Visit for Request<'_> {
266
- fn visit_expr(&mut self, expression: &Expr) {
284
+ impl<'a> Visit<'a> for Request<'_, 'a> {
285
+ fn visit_expression(&mut self, expression: &Expression<'a>) {
267
286
  // Only inspect string concatenations, avoiding evaluation of complete
268
287
  // function bodies or the encoded VM program.
269
288
  if matches!(
270
289
  expression,
271
- Expr::Bin(_) | Expr::Tpl(_) | Expr::Lit(Lit::Str(_))
272
- ) && let Some(JsValue::String(path)) = expression::static_value(expression, self.options)
290
+ Expression::BinaryExpression(_)
291
+ | Expression::LogicalExpression(_)
292
+ | Expression::TemplateLiteral(_)
293
+ | Expression::StringLiteral(_)
294
+ ) && let Some(JsValue::String(path)) =
295
+ expression::static_value(self.script, expression, self.options)
273
296
  && is_post_path(&path)
274
297
  {
275
298
  self.paths.insert(path);
276
299
  }
277
- expression.visit_children_with(self);
300
+ walk::walk_expression(self, expression);
278
301
  }
279
302
 
280
303
  /// Finds arguments to `<request>.setRequestHeader('cf-chl', <token>)`, even when the method
281
304
  /// name comes from a variable.
282
- fn visit_call_expr(&mut self, call: &CallExpr) {
283
- if let [header, value] = &call.args[..]
284
- && expression::static_value(&header.expr, self.options)
285
- == Some(JsValue::String("cf-chl".into()))
286
- && let Some(JsValue::String(token)) =
287
- expression::static_value(&value.expr, self.options)
305
+ fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
306
+ let value = |argument: &Argument<'_>| {
307
+ expression::static_value(self.script, argument.as_expression()?, self.options)
308
+ };
309
+ if let [header, token] = &call.arguments[..]
310
+ && value(header) == Some(JsValue::String("cf-chl".into()))
311
+ && let Some(JsValue::String(token)) = value(token)
288
312
  {
289
313
  self.tokens.insert(token);
290
314
  }
291
- call.visit_children_with(self);
315
+ walk::walk_call_expression(self, call);
292
316
  }
293
317
  }
294
318
 
@@ -317,6 +341,35 @@ pub fn inline_javascript(html: &str) -> Result<String> {
317
341
  #[cfg(test)]
318
342
  mod tests {
319
343
  use super::*;
344
+ use crate::deobfuscate;
345
+
346
+ #[test]
347
+ fn extracts_requests_after_folding_parenthesized_helpers_and_cached_paths() {
348
+ let javascript = r#"window._cf_chl_opt = {variant:'g',ray:'ray-id',token:'session-token'};
349
+ (function(global) {
350
+ var prefix, path;
351
+ var options = function(value) { return value._cf_chl_opt; };
352
+ function send(xhr) {
353
+ xhr.setRequestHeader('cf-chl', (27253 ^ (36202 ^ 59167), options)(global).token);
354
+ xhr.open('POST', (prefix || (prefix = '/cdn-cgi/challenge-platform/h/'))
355
+ + global._cf_chl_opt.variant + (path || (path = '/fo/build/'))
356
+ + global._cf_chl_opt.ray + '/' + global._cf_chl_opt.token);
357
+ }
358
+ install(send);
359
+ })(window);"#;
360
+ let text = deobfuscate::deobfuscate(javascript.to_owned()).unwrap();
361
+ assert!(text.unconverged.is_none());
362
+ let request = InitialRequest::from_javascript(
363
+ &text.text,
364
+ &Url::parse("https://example.com/").unwrap(),
365
+ )
366
+ .unwrap_or_else(|error| panic!("{error:#}\n{}", text.text));
367
+ assert_eq!(request.cf_chl, "session-token");
368
+ assert_eq!(
369
+ request.url.path(),
370
+ "/cdn-cgi/challenge-platform/h/g/fo/build/ray-id/session-token"
371
+ );
372
+ }
320
373
 
321
374
  #[test]
322
375
  fn finds_session_parameters_with_different_randomized_names() {
@@ -355,28 +408,30 @@ mod tests {
355
408
  .map(|index| format!("f{index}: {index}, "))
356
409
  .collect();
357
410
  let template = format!("{{ {fields}kind: b._cf_chl_opt.mode }}");
358
- let Expr::Object(template) = ast::parse_expression("t", &template).unwrap() else {
359
- panic!("not an object");
360
- };
361
- // An iframe uses its `chl_api_` type. A page type is valid only for an orchestrator
362
- // with no `chl_api_` option.
363
- for (challenge, other, expected) in [
364
- ("chl_api_m", "x", true),
365
- ("chl_api_ni", "x", true),
366
- ("managed", "chl_api_m", false),
367
- ("managed", "x", true),
368
- ("unknown", "x", false),
369
- ] {
370
- let options = Options::from_iter([
371
- ("mode".to_owned(), JsValue::from(challenge)),
372
- ("other".to_owned(), JsValue::from(other)),
373
- ]);
374
- assert_eq!(
375
- is_payload_template(&template, &options),
376
- expected,
377
- "{challenge}"
378
- );
379
- }
411
+ ast::with_expression(&template, |_, template| {
412
+ let Expression::ObjectExpression(template) = template else {
413
+ panic!("not an object");
414
+ };
415
+ // An iframe uses its `chl_api_` type. A page type is valid only for an orchestrator
416
+ // with no `chl_api_` option.
417
+ for (challenge, other, expected) in [
418
+ ("chl_api_m", "x", true),
419
+ ("chl_api_ni", "x", true),
420
+ ("managed", "chl_api_m", false),
421
+ ("managed", "x", true),
422
+ ("unknown", "x", false),
423
+ ] {
424
+ let options = Options::from_iter([
425
+ ("mode".to_owned(), JsValue::from(challenge)),
426
+ ("other".to_owned(), JsValue::from(other)),
427
+ ]);
428
+ assert_eq!(
429
+ is_payload_template(template, &options),
430
+ expected,
431
+ "{challenge}"
432
+ );
433
+ }
434
+ });
380
435
  }
381
436
 
382
437
  #[test]