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
@@ -15,18 +15,20 @@ use std::collections::{HashMap, HashSet};
15
15
  use std::mem;
16
16
 
17
17
  use anyhow::{Context, Result};
18
- use swc_core::atoms::Atom;
19
- use swc_core::common::BytePos;
20
- use swc_core::ecma::ast::{
21
- BinaryOp, CallExpr, Callee, CondExpr, Expr, FnDecl, Function, KeyValueProp, Lit, MemberExpr,
22
- MemberProp, Pat, PropName, ReturnStmt, TryStmt, UnaryOp, VarDeclarator,
18
+ use oxc::ast::ast::{
19
+ Argument, BindingPattern, CallExpression, ConditionalExpression, Expression, Function,
20
+ MemberExpression, ObjectPropertyKind, PropertyKey, ReturnStatement, TryStatement,
21
+ VariableDeclarator,
23
22
  };
24
- use swc_core::ecma::visit::{Visit, VisitWith};
23
+ use oxc::ast_visit::{Visit, walk};
24
+ use oxc::semantic::{ScopeFlags, SymbolId};
25
+ use oxc::span::GetSpan;
26
+ use oxc::syntax::operator::{BinaryOperator, UnaryOperator};
25
27
  use url::Url;
26
28
 
27
29
  use crate::candidates;
28
30
  use crate::engine::{Engine, StackFrame, V8_STACK_LIMIT};
29
- use crate::js::ast::{self, ParsedScript};
31
+ use crate::js::ast::{self, Binding, ParsedScript, Script};
30
32
 
31
33
  /// The loader's entry point for widgets declared in markup.
32
34
  const IMPLICIT_RENDER: &str = "runImplicitRender";
@@ -42,10 +44,10 @@ pub(crate) struct RenderSample {
42
44
  }
43
45
 
44
46
  impl RenderSample {
45
- /// Rebuilds the stack for markup-triggered rendering from `parsed`, using `engine`'s format
47
+ /// Rebuilds the stack for markup-triggered rendering from `script`, using `engine`'s format
46
48
  /// and `url` as the script name.
47
- pub(crate) fn from_parsed(parsed: &ParsedScript, url: &Url, engine: Engine) -> Result<Self> {
48
- let loader = Loader::read(parsed);
49
+ pub(crate) fn from_script(script: Script<'_>, url: &Url, engine: Engine) -> Result<Self> {
50
+ let loader = Loader::read(script);
49
51
  let (method, mut frames) = loader.sampled(IMPLICIT_RENDER, engine)?;
50
52
  // The outer frames cover queue insertion and the DOM-ready handler draining that queue.
51
53
  let queued = candidates::at_most_one_distinct(
@@ -58,13 +60,13 @@ impl RenderSample {
58
60
  let drained = loader
59
61
  .calls
60
62
  .iter()
61
- .find(|call| call.scope.as_ref() == Some(ready))
63
+ .find(|call| call.scope.map(Binding::Symbol) == Some(*ready))
62
64
  .context("the ready handler calls nothing it queued")?;
63
- frames.push((queued.function.to_string(), &queued.site));
64
- frames.push((ready.to_string(), &drained.site));
65
+ frames.push((loader.name(queued.function).to_owned(), &queued.site));
66
+ frames.push((script.name(*ready).to_owned(), &drained.site));
65
67
  Ok(Self {
66
68
  method,
67
- stack: engine.error_stack(placed(parsed, url, &frames, engine)),
69
+ stack: engine.error_stack(placed(script, url, &frames, engine)),
68
70
  })
69
71
  }
70
72
 
@@ -78,11 +80,12 @@ impl RenderSample {
78
80
  caller: impl IntoIterator<Item = StackFrame<'caller>>,
79
81
  engine: Engine,
80
82
  ) -> Result<Self> {
81
- let parsed = ast::parse_javascript("the Turnstile loader", source)?;
82
- let loader = Loader::read(&parsed);
83
+ let parsed = ParsedScript::parse("the Turnstile loader", source)?;
84
+ let script = parsed.script();
85
+ let loader = Loader::read(script);
83
86
  let (method, frames) = loader.sampled(EXPLICIT_RENDER, engine)?;
84
87
  let caller = caller.into_iter().map(|frame| StackFrame { ..frame });
85
- let frames = placed(&parsed, url, &frames, engine)
88
+ let frames = placed(script, url, &frames, engine)
86
89
  .into_iter()
87
90
  .chain(caller);
88
91
  let stack = match engine {
@@ -94,7 +97,7 @@ impl RenderSample {
94
97
  )?
95
98
  .context("loader never calls an onload callback")?;
96
99
  let timer = [(String::new(), onload)];
97
- engine.error_stack(frames.chain(placed(&parsed, url, &timer, engine)))
100
+ engine.error_stack(frames.chain(placed(script, url, &timer, engine)))
98
101
  }
99
102
  };
100
103
  Ok(Self { method, stack })
@@ -104,7 +107,7 @@ impl RenderSample {
104
107
  /// Places loader frames for `engine`, leaving out the frames JavaScriptCore's tail calls
105
108
  /// replace.
106
109
  fn placed<'a>(
107
- parsed: &ParsedScript,
110
+ script: Script<'_>,
108
111
  url: &'a Url,
109
112
  frames: &'a [(String, &Site)],
110
113
  engine: Engine,
@@ -116,7 +119,7 @@ fn placed<'a>(
116
119
  Engine::WebKit if site.tail => continue,
117
120
  Engine::WebKit => site.jsc,
118
121
  };
119
- let (line, column) = parsed.position(at);
122
+ let (line, column) = script.position(at);
120
123
  surviving.push(StackFrame {
121
124
  function,
122
125
  url: url.as_str(),
@@ -127,13 +130,13 @@ fn placed<'a>(
127
130
  surviving
128
131
  }
129
132
 
130
- /// Engine-specific source positions for a call frame.
133
+ /// Engine-specific source offsets for a call frame.
131
134
  #[derive(Debug, PartialEq)]
132
135
  struct Site {
133
136
  /// The start of the callee, V8's position.
134
- v8: BytePos,
137
+ v8: u32,
135
138
  /// The opening argument parenthesis, used by JavaScriptCore.
136
- jsc: BytePos,
139
+ jsc: u32,
137
140
  /// Whether this call is directly returned and therefore eligible for JavaScriptCore
138
141
  /// tail-call replacement.
139
142
  tail: bool,
@@ -141,39 +144,42 @@ struct Site {
141
144
 
142
145
  /// A call through a plain identifier.
143
146
  #[derive(Debug, PartialEq)]
144
- struct Call {
145
- scope: Option<Atom>,
146
- callee: Atom,
147
+ struct Call<'a> {
148
+ /// The named function containing the call.
149
+ scope: Option<SymbolId>,
150
+ callee: Binding<'a>,
147
151
  site: Site,
148
- first: Option<Atom>,
152
+ /// The first argument, when it is a plain identifier.
153
+ first: Option<Binding<'a>>,
149
154
  }
150
155
 
151
156
  /// A frame position inside the named function `function`.
152
157
  #[derive(Debug, PartialEq)]
153
158
  struct FunctionSite {
154
- function: Atom,
159
+ function: SymbolId,
155
160
  site: Site,
156
161
  }
157
162
 
158
163
  /// Finds the functions and calls involved in stack sampling.
159
- #[derive(Default)]
160
- struct Loader {
161
- scope: Option<Atom>,
164
+ struct Loader<'a> {
165
+ script: Script<'a>,
166
+ /// The named function being visited.
167
+ scope: Option<SymbolId>,
162
168
  /// `new Error().stack` reads, at the error's construction site.
163
169
  samples: Vec<FunctionSite>,
164
- calls: Vec<Call>,
170
+ calls: Vec<Call<'a>>,
165
171
  /// `runImplicitRender` property calls.
166
172
  implicit_calls: Vec<FunctionSite>,
167
- /// Calls returned directly outside `try` blocks.
168
- tail_calls: HashSet<BytePos>,
173
+ /// Starts of calls returned directly outside `try` blocks.
174
+ tail_calls: HashSet<u32>,
169
175
  /// Whether the visit is inside a `try` block of the current function.
170
176
  in_try: bool,
171
177
  /// `key: function` in object literals.
172
- properties: HashMap<Atom, Atom>,
178
+ properties: HashMap<&'a str, Binding<'a>>,
173
179
  /// Variables initialised to a number.
174
- numbers: HashMap<Atom, f64>,
180
+ numbers: HashMap<SymbolId, f64>,
175
181
  /// The functions handed to `addEventListener("DOMContentLoaded", ...)`.
176
- ready: Vec<Atom>,
182
+ ready: Vec<Binding<'a>>,
177
183
  /// Delay of the timer whose callback is currently being visited.
178
184
  timer_delay: Option<f64>,
179
185
  /// Calls to the page's defined `onload` callback from a timer with no delay. Another timer
@@ -181,13 +187,31 @@ struct Loader {
181
187
  onload_calls: Vec<Site>,
182
188
  }
183
189
 
184
- impl Loader {
185
- fn read(parsed: &ParsedScript) -> Self {
186
- let mut loader = Self::default();
187
- parsed.script.visit_with(&mut loader);
190
+ impl<'a> Loader<'a> {
191
+ fn read(script: Script<'a>) -> Self {
192
+ let mut loader = Self {
193
+ script,
194
+ scope: None,
195
+ samples: Vec::new(),
196
+ calls: Vec::new(),
197
+ implicit_calls: Vec::new(),
198
+ tail_calls: HashSet::new(),
199
+ in_try: false,
200
+ properties: HashMap::new(),
201
+ numbers: HashMap::new(),
202
+ ready: Vec::new(),
203
+ timer_delay: None,
204
+ onload_calls: Vec::new(),
205
+ };
206
+ loader.visit_program(script.program);
188
207
  loader
189
208
  }
190
209
 
210
+ /// The declared name of the function `symbol` binds.
211
+ fn name(&self, symbol: SymbolId) -> &'a str {
212
+ self.script.scoping.symbol_name(symbol)
213
+ }
214
+
191
215
  /// Returns the sampling method code for loader export `property` and its frames, innermost
192
216
  /// first: sampler, timing wrapper, and export. Fails if any step is ambiguous.
193
217
  fn sampled(&self, property: &str, engine: Engine) -> Result<(f64, Vec<(String, &Site)>)> {
@@ -196,196 +220,209 @@ impl Loader {
196
220
  let wrapper = candidates::at_most_one_distinct(
197
221
  self.calls
198
222
  .iter()
199
- .filter(|call| call.callee == sample.function),
223
+ .filter(|call| call.callee == Binding::Symbol(sample.function)),
200
224
  "calls of the stack sampler",
201
225
  )?
202
226
  .context("loader never calls its stack sampler")?;
203
227
  let measured = wrapper
204
228
  .scope
205
- .as_ref()
206
229
  .context("the stack sampler is called from an anonymous function")?;
207
- let exported = self
230
+ let exported = *self
208
231
  .properties
209
- .get(&Atom::from(property))
232
+ .get(property)
210
233
  .with_context(|| format!("loader exports no {property}"))?;
211
234
  let call = candidates::at_most_one_distinct(
212
- self.calls
213
- .iter()
214
- .filter(|call| call.scope.as_ref() == Some(exported) && call.callee == *measured),
235
+ self.calls.iter().filter(|call| {
236
+ call.scope.map(Binding::Symbol) == Some(exported)
237
+ && call.callee == Binding::Symbol(measured)
238
+ }),
215
239
  "stack samples in the exported render",
216
240
  )?
217
241
  .with_context(|| format!("the loader's {property} takes no stack sample"))?;
218
- let method = call
219
- .first
220
- .as_ref()
221
- .and_then(|code| self.numbers.get(code))
222
- .with_context(|| format!("the loader's {property} has no constant method code"))?;
242
+ let method = match call.first {
243
+ Some(Binding::Symbol(code)) => self.numbers.get(&code),
244
+ _ => None,
245
+ }
246
+ .with_context(|| format!("the loader's {property} has no constant method code"))?;
247
+ let exported = self.script.name(exported);
223
248
  let exported = match engine {
224
249
  Engine::Chromium => format!("Object.{exported} [as {property}]"),
225
- Engine::WebKit => exported.to_string(),
250
+ Engine::WebKit => exported.to_owned(),
226
251
  };
227
252
  Ok((
228
253
  *method,
229
254
  vec![
230
- (sample.function.to_string(), &sample.site),
231
- (measured.to_string(), &wrapper.site),
255
+ (self.name(sample.function).to_owned(), &sample.site),
256
+ (self.name(measured).to_owned(), &wrapper.site),
232
257
  (exported, &call.site),
233
258
  ],
234
259
  ))
235
260
  }
236
261
 
237
- fn within(&mut self, name: Option<Atom>, function: &Function) {
262
+ /// Visits `function` as the body of the function `name` binds, or of an anonymous one.
263
+ fn within(&mut self, name: Option<SymbolId>, function: &Function<'a>, flags: ScopeFlags) {
238
264
  let previous = mem::replace(&mut self.scope, name);
239
265
  let in_try = mem::take(&mut self.in_try);
240
- function.visit_children_with(self);
266
+ walk::walk_function(self, function, flags);
241
267
  self.scope = previous;
242
268
  self.in_try = in_try;
243
269
  }
244
270
 
245
- fn site(&self, call: &CallExpr, v8: BytePos, jsc: BytePos) -> Site {
271
+ fn site(&self, call: &CallExpression<'_>, v8: u32, jsc: u32) -> Site {
246
272
  Site {
247
273
  v8,
248
274
  jsc,
249
- tail: self.tail_calls.contains(&call.span.lo),
275
+ tail: self.tail_calls.contains(&call.span.start),
250
276
  }
251
277
  }
252
278
  }
253
279
 
254
- impl Visit for Loader {
255
- fn visit_fn_decl(&mut self, declaration: &FnDecl) {
256
- self.within(Some(declaration.ident.sym.clone()), &declaration.function);
257
- }
258
-
259
- fn visit_function(&mut self, function: &Function) {
260
- self.within(None, function);
280
+ impl<'a> Visit<'a> for Loader<'a> {
281
+ /// Declared functions are named by their binding; expressions are anonymous unless a
282
+ /// variable names them.
283
+ fn visit_function(&mut self, function: &Function<'a>, flags: ScopeFlags) {
284
+ let name = function
285
+ .id
286
+ .as_ref()
287
+ .filter(|_| function.is_declaration())
288
+ .map(|id| id.symbol_id());
289
+ self.within(name, function, flags);
261
290
  }
262
291
 
263
292
  /// V8 names a function expression after the variable it initialises.
264
- fn visit_var_declarator(&mut self, declarator: &VarDeclarator) {
265
- if let Pat::Ident(name) = &declarator.name {
266
- match declarator.init.as_deref() {
267
- Some(Expr::Fn(function)) => {
268
- self.within(Some(name.id.sym.clone()), &function.function);
293
+ fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
294
+ if let BindingPattern::BindingIdentifier(name) = &declarator.id {
295
+ match &declarator.init {
296
+ Some(Expression::FunctionExpression(function)) => {
297
+ self.within(Some(name.symbol_id()), function, ScopeFlags::Function);
269
298
  return;
270
299
  }
271
- Some(Expr::Lit(Lit::Num(number))) => {
272
- self.numbers.insert(name.id.sym.clone(), number.value);
300
+ Some(Expression::NumericLiteral(number)) => {
301
+ self.numbers.insert(name.symbol_id(), number.value);
273
302
  }
274
303
  _ => {}
275
304
  }
276
305
  }
277
- declarator.visit_children_with(self);
306
+ walk::walk_variable_declarator(self, declarator);
278
307
  }
279
308
 
280
- fn visit_member_expr(&mut self, member: &MemberExpr) {
281
- if ast::member_str(&member.prop) == Some("stack")
282
- && let Expr::New(error) = &*member.obj
283
- && let Expr::Ident(callee) = &*error.callee
284
- && callee.sym == "Error"
285
- && let Some(function) = self.scope.clone()
309
+ fn visit_member_expression(&mut self, member: &MemberExpression<'a>) {
310
+ if ast::member_str(member) == Some("stack")
311
+ && let Expression::NewExpression(error) = member.object()
312
+ && self.script.is_global(&error.callee, "Error")
313
+ && let Some(function) = self.scope
286
314
  {
287
315
  self.samples.push(FunctionSite {
288
316
  function,
289
317
  site: Site {
290
- v8: error.span.lo,
291
- jsc: callee.span.hi,
318
+ v8: error.span.start,
319
+ jsc: error.callee.span().end,
292
320
  tail: false,
293
321
  },
294
322
  });
295
323
  }
296
- member.visit_children_with(self);
324
+ walk::walk_member_expression(self, member);
297
325
  }
298
326
 
299
327
  /// `found === void 0 ? report() : found()`: the call of a callback once it is defined.
300
- fn visit_cond_expr(&mut self, conditional: &CondExpr) {
328
+ fn visit_conditional_expression(&mut self, conditional: &ConditionalExpression<'a>) {
301
329
  if self.timer_delay == Some(0.0)
302
- && let Expr::Bin(test) = &*conditional.test
303
- && test.op == BinaryOp::EqEqEq
304
- && let Expr::Ident(tested) = &*test.left
305
- && matches!(&*test.right, Expr::Unary(unary) if unary.op == UnaryOp::Void)
306
- && let Expr::Call(call) = &*conditional.alt
307
- && call.args.is_empty()
308
- && let Callee::Expr(callee) = &call.callee
309
- && let Expr::Ident(callee) = &**callee
310
- && callee.sym == tested.sym
330
+ && let Expression::BinaryExpression(test) = &conditional.test
331
+ && test.operator == BinaryOperator::StrictEquality
332
+ && let Expression::Identifier(tested) = &test.left
333
+ && matches!(&test.right, Expression::UnaryExpression(unary)
334
+ if unary.operator == UnaryOperator::Void)
335
+ && let Expression::CallExpression(call) = &conditional.alternate
336
+ && call.arguments.is_empty()
337
+ && let Expression::Identifier(callee) = &call.callee
338
+ && self.script.binding(callee) == self.script.binding(tested)
311
339
  {
312
- let site = self.site(call, callee.span.lo, callee.span.hi);
340
+ let site = self.site(call, callee.span.start, callee.span.end);
313
341
  self.onload_calls.push(site);
314
342
  }
315
- conditional.visit_children_with(self);
343
+ walk::walk_conditional_expression(self, conditional);
316
344
  }
317
345
 
318
- fn visit_call_expr(&mut self, call: &CallExpr) {
346
+ fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
319
347
  let outer_delay = self.timer_delay;
320
- if let Callee::Expr(callee) = &call.callee {
321
- match &**callee {
322
- Expr::Ident(callee) => {
323
- // `setTimeout(function () { ... }, delay)`: the callback runs from a timer.
324
- if callee.sym == "setTimeout"
325
- && let [callback, delay] = &call.args[..]
326
- && callback.expr.is_fn_expr()
327
- {
328
- self.timer_delay = ast::number(&delay.expr);
329
- }
330
- self.calls.push(Call {
331
- scope: self.scope.clone(),
332
- callee: callee.sym.clone(),
333
- site: self.site(call, callee.span.lo, callee.span.hi),
334
- first: call
335
- .args
336
- .first()
337
- .and_then(|argument| Some(argument.expr.as_ident()?.sym.clone())),
338
- });
348
+ match &call.callee {
349
+ Expression::Identifier(callee) => {
350
+ // `setTimeout(function () { ... }, delay)`: the callback runs from a timer.
351
+ if self.script.is_global(&call.callee, "setTimeout")
352
+ && let [callback, delay] = &call.arguments[..]
353
+ && matches!(
354
+ callback.as_expression(),
355
+ Some(Expression::FunctionExpression(_))
356
+ )
357
+ {
358
+ self.timer_delay = delay.as_expression().and_then(ast::number);
359
+ }
360
+ self.calls.push(Call {
361
+ scope: self.scope,
362
+ callee: self.script.binding(callee),
363
+ site: self.site(call, callee.span.start, callee.span.end),
364
+ first: match call.arguments.first().and_then(Argument::as_expression) {
365
+ Some(Expression::Identifier(first)) => Some(self.script.binding(first)),
366
+ _ => None,
367
+ },
368
+ });
369
+ }
370
+ callee => {
371
+ if let Expression::StaticMemberExpression(member) = callee
372
+ && member.property.name == IMPLICIT_RENDER
373
+ && let Some(function) = self.scope
374
+ {
375
+ let property = member.property.span;
376
+ let site = self.site(call, property.start, property.end);
377
+ self.implicit_calls.push(FunctionSite { function, site });
339
378
  }
340
- Expr::Member(member) => {
341
- if let MemberProp::Ident(property) = &member.prop
342
- && property.sym == IMPLICIT_RENDER
343
- && let Some(function) = self.scope.clone()
344
- {
345
- let site = self.site(call, property.span.lo, property.span.hi);
346
- self.implicit_calls.push(FunctionSite { function, site });
347
- }
348
- if ast::member_str(&member.prop) == Some("addEventListener")
349
- && let [event, listener, ..] = &call.args[..]
350
- && matches!(&*event.expr, Expr::Lit(Lit::Str(_)))
351
- && ast::static_str(&event.expr) == Some("DOMContentLoaded")
352
- && let Expr::Ident(listener) = &*listener.expr
353
- {
354
- self.ready.push(listener.sym.clone());
355
- }
379
+ if let Some(member) = callee.as_member_expression()
380
+ && ast::member_str(member) == Some("addEventListener")
381
+ && let [event, listener, ..] = &call.arguments[..]
382
+ && let Some(event @ Expression::StringLiteral(_)) = event.as_expression()
383
+ && ast::static_str(event) == Some("DOMContentLoaded")
384
+ && let Some(Expression::Identifier(listener)) = listener.as_expression()
385
+ {
386
+ self.ready.push(self.script.binding(listener));
356
387
  }
357
- _ => {}
358
388
  }
359
389
  }
360
- call.visit_children_with(self);
390
+ walk::walk_call_expression(self, call);
361
391
  self.timer_delay = outer_delay;
362
392
  }
363
393
 
364
394
  /// A directly returned call is in tail position unless an enclosing `try` requires work
365
395
  /// after it returns.
366
- fn visit_return_stmt(&mut self, statement: &ReturnStmt) {
396
+ fn visit_return_statement(&mut self, statement: &ReturnStatement<'a>) {
367
397
  if !self.in_try
368
- && let Some(Expr::Call(call)) = statement.arg.as_deref()
398
+ && let Some(Expression::CallExpression(call)) = &statement.argument
369
399
  {
370
- self.tail_calls.insert(call.span.lo);
400
+ self.tail_calls.insert(call.span.start);
371
401
  }
372
- statement.visit_children_with(self);
402
+ walk::walk_return_statement(self, statement);
373
403
  }
374
404
 
375
- fn visit_try_stmt(&mut self, statement: &TryStmt) {
405
+ fn visit_try_statement(&mut self, statement: &TryStatement<'a>) {
376
406
  let outer = mem::replace(&mut self.in_try, true);
377
- statement.block.visit_with(self);
407
+ self.visit_block_statement(&statement.block);
378
408
  self.in_try = outer;
379
- statement.handler.visit_with(self);
380
- statement.finalizer.visit_with(self);
409
+ if let Some(handler) = &statement.handler {
410
+ self.visit_catch_clause(handler);
411
+ }
412
+ if let Some(finalizer) = &statement.finalizer {
413
+ self.visit_block_statement(finalizer);
414
+ }
381
415
  }
382
416
 
383
- fn visit_key_value_prop(&mut self, property: &KeyValueProp) {
384
- if let PropName::Ident(key) = &property.key
385
- && let Expr::Ident(value) = &*property.value
417
+ fn visit_object_property_kind(&mut self, property: &ObjectPropertyKind<'a>) {
418
+ if let Some(entry) = ast::key_value(property)
419
+ && !entry.computed
420
+ && let PropertyKey::StaticIdentifier(key) = &entry.key
421
+ && let Expression::Identifier(value) = &entry.value
386
422
  {
387
- self.properties.insert(key.sym.clone(), value.sym.clone());
423
+ self.properties
424
+ .insert(key.name.as_str(), self.script.binding(value));
388
425
  }
389
- property.visit_children_with(self);
426
+ walk::walk_object_property_kind(self, property);
390
427
  }
391
428
  }
@@ -2,11 +2,11 @@
2
2
  //! retains the details.
3
3
 
4
4
  use std::error::Error as StdError;
5
- use std::fmt;
5
+ use std::{fmt, io};
6
6
 
7
7
  use wreq::StatusCode;
8
8
 
9
- use crate::session::Stage;
9
+ use crate::session::{SinkFailed, Stage};
10
10
 
11
11
  /// A failed solve, or a profile that cannot solve.
12
12
  #[derive(Debug)]
@@ -36,24 +36,35 @@ pub enum Error {
36
36
  /// Rejection details, including request context.
37
37
  error: anyhow::Error,
38
38
  },
39
+ /// The [`Sink`](crate::Sink) failed to save an artifact, so the solve stopped rather than
40
+ /// lose its diagnostics.
41
+ Sink(anyhow::Error),
39
42
  /// The solver cannot handle this page or challenge, for example because it uses a new
40
43
  /// challenge build. Retrying will not help.
41
44
  Unsupported(anyhow::Error),
42
45
  }
43
46
 
44
47
  impl Error {
45
- /// Classifies a failure using a wrapped `Error`, if present, or the first recognized marker
46
- /// or network error in the chain.
48
+ /// Classifies a failure using a wrapped `Error`, if present, a sink failure, or the first
49
+ /// recognized marker or transport error in the chain. Other failures are [`Unsupported`].
50
+ ///
51
+ /// I/O errors count as network failures: once the sink's own failures are set apart, they
52
+ /// come from reading response bodies, such as a truncated compressed body.
53
+ ///
54
+ /// [`Unsupported`]: Self::Unsupported
47
55
  pub(crate) fn classify(error: anyhow::Error) -> Self {
48
56
  let error = match error.downcast::<Self>() {
49
57
  Ok(error) => return error,
50
58
  Err(error) => error,
51
59
  };
60
+ if error.downcast_ref::<SinkFailed>().is_some() {
61
+ return Self::Sink(error);
62
+ }
52
63
  for cause in error.chain() {
53
64
  if let Some(&Refused { stage, .. }) = cause.downcast_ref() {
54
65
  return Self::Rejected { stage, error };
55
66
  }
56
- if cause.is::<wreq::Error>() {
67
+ if cause.is::<wreq::Error>() || cause.is::<io::Error>() {
57
68
  return Self::Network(error);
58
69
  }
59
70
  }
@@ -67,6 +78,7 @@ impl fmt::Display for Error {
67
78
  Self::Config(error)
68
79
  | Self::Network(error)
69
80
  | Self::Rejected { error, .. }
81
+ | Self::Sink(error)
70
82
  | Self::Unsupported(error) => fmt::Display::fmt(error, formatter),
71
83
  Self::Blocked { status } => write!(formatter, "the page answered HTTP {status}"),
72
84
  Self::Challenged { status } => write!(
@@ -87,6 +99,7 @@ impl StdError for Error {
87
99
  Self::Config(error)
88
100
  | Self::Network(error)
89
101
  | Self::Rejected { error, .. }
102
+ | Self::Sink(error)
90
103
  | Self::Unsupported(error) => error.source(),
91
104
  Self::Blocked { .. } | Self::Challenged { .. } | Self::NotChallenged => None,
92
105
  }
@@ -139,4 +152,26 @@ mod tests {
139
152
  let unknown = Error::classify(anyhow::anyhow!("no orchestrator path"));
140
153
  assert!(matches!(unknown, Error::Unsupported(_)));
141
154
  }
155
+
156
+ #[test]
157
+ fn sets_apart_sink_and_transport_failures() {
158
+ struct Full;
159
+ impl crate::Sink for Full {
160
+ fn artifact(&self, _: &str, _: &[u8]) -> anyhow::Result<()> {
161
+ Err(io::Error::from(io::ErrorKind::StorageFull).into())
162
+ }
163
+ fn progress(&self, _: &str) {}
164
+ }
165
+ let sink: &dyn crate::Sink = &Full;
166
+ let failed = sink
167
+ .save("page.html", b"")
168
+ .unwrap_err()
169
+ .context("loading the page");
170
+ let failed = Error::classify(failed);
171
+ assert!(matches!(failed, Error::Sink(_)));
172
+ assert!(failed.to_string().starts_with("loading the page"));
173
+ let truncated = anyhow::Error::new(io::Error::from(io::ErrorKind::UnexpectedEof))
174
+ .context("decoding the response body");
175
+ assert!(matches!(Error::classify(truncated), Error::Network(_)));
176
+ }
142
177
  }
@@ -78,8 +78,13 @@ impl Transport {
78
78
  })
79
79
  }
80
80
 
81
- /// Creates a client with this transport, optionally using `proxy`.
82
- pub fn client(&self, proxy: Option<&str>) -> Result<BrowserClient> {
81
+ /// Creates a client with this transport, optionally using `proxy` and trusting only the PEM
82
+ /// certificate `trusted_root`.
83
+ pub fn client(
84
+ &self,
85
+ proxy: Option<&str>,
86
+ trusted_root: Option<&[u8]>,
87
+ ) -> Result<BrowserClient> {
83
88
  BrowserClient::try_new(
84
89
  self.profile,
85
90
  self.platform,
@@ -88,6 +93,7 @@ impl Transport {
88
93
  self.requests.clone(),
89
94
  self.engine,
90
95
  proxy,
96
+ trusted_root,
91
97
  )
92
98
  }
93
99
  }