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
@@ -44,6 +44,7 @@ mod engine;
44
44
  mod error;
45
45
  mod listing;
46
46
  mod performance_clock;
47
+ mod profiling;
47
48
  mod random_id;
48
49
  mod resource_timing;
49
50
  mod session;
@@ -12,7 +12,7 @@
12
12
  use std::collections::BTreeMap;
13
13
  use std::convert::Infallible;
14
14
 
15
- use swc_core::ecma::ast::{BinaryOp, UnaryOp};
15
+ use oxc::syntax::operator::{BinaryOperator, UnaryOperator};
16
16
 
17
17
  use crate::js::{JsValue, json};
18
18
  use crate::vm::dataflow::Facts;
@@ -200,14 +200,18 @@ pub(crate) fn feasible<X>(path: &Path, resolve: impl Fn(&Term) -> Option<Known<X
200
200
  /// known values count as defined, and comparisons between them stay undecided.
201
201
  fn truth<X>(condition: &Term, resolve: &impl Fn(&Term) -> Option<Known<X>>) -> Option<bool> {
202
202
  match condition {
203
- Term::Unary(UnaryOp::Bang, inner) => truth(inner, resolve).map(|value| !value),
204
- Term::Binary(operator @ (BinaryOp::EqEqEq | BinaryOp::NotEqEq), left, right) => {
203
+ Term::Unary(UnaryOperator::LogicalNot, inner) => truth(inner, resolve).map(|value| !value),
204
+ Term::Binary(
205
+ operator @ (BinaryOperator::StrictEquality | BinaryOperator::StrictInequality),
206
+ left,
207
+ right,
208
+ ) => {
205
209
  let equal = match (resolve(left)?, resolve(right)?) {
206
210
  (Known::Undefined, Known::Undefined) => true,
207
211
  (Known::Undefined, _) | (_, Known::Undefined) => false,
208
212
  _ => return None,
209
213
  };
210
- Some(equal == (*operator == BinaryOp::EqEqEq))
214
+ Some(equal == (*operator == BinaryOperator::StrictEquality))
211
215
  }
212
216
  _ => None,
213
217
  }
@@ -218,7 +222,7 @@ mod tests {
218
222
  use super::*;
219
223
  use crate::vm::Exit;
220
224
 
221
- fn strict(operator: BinaryOp, left: Term, right: Term) -> Term {
225
+ fn strict(operator: BinaryOperator, left: Term, right: Term) -> Term {
222
226
  Term::Binary(operator, Box::new(left), Box::new(right))
223
227
  }
224
228
 
@@ -312,13 +316,19 @@ mod tests {
312
316
  frame.set(2, Some(Known::Decoder));
313
317
  frame.set(3, Some(Known::Literal(json!("a"))));
314
318
  let undefined = || Term::Const(Constant::Undefined);
315
- let is_undefined = |register| strict(BinaryOp::EqEqEq, Term::Reg(register), undefined());
319
+ let is_undefined = |register| {
320
+ strict(
321
+ BinaryOperator::StrictEquality,
322
+ Term::Reg(register),
323
+ undefined(),
324
+ )
325
+ };
316
326
  let a = Term::Const(Constant::String("a".into()));
317
327
  let same_as_a = Term::Unary(
318
- UnaryOp::Bang,
319
- Box::new(strict(BinaryOp::NotEqEq, Term::Reg(3), a)),
328
+ UnaryOperator::LogicalNot,
329
+ Box::new(strict(BinaryOperator::StrictInequality, Term::Reg(3), a)),
320
330
  );
321
- let loose = strict(BinaryOp::EqEq, Term::Reg(1), undefined());
331
+ let loose = strict(BinaryOperator::Equality, Term::Reg(1), undefined());
322
332
  // A condition, the outcome the path requires, and whether the path stays feasible.
323
333
  let cases = [
324
334
  // An undefined receiver selects the call without one and rules out the call with one.
@@ -1,5 +1,4 @@
1
- //! Queries value sources, function reachability, and common program reads such as `Date.now()`,
2
- //! challenge options, and record timestamps.
1
+ //! Queries value sources, function reachability, and common program reads such as `Date.now()`.
3
2
  //!
4
3
  //! [`Index::register_before`] finds the nearest earlier instruction assigning a register and
5
4
  //! returns the first write from any of its paths. [`Index::assignment`] resolves each write
@@ -7,11 +6,7 @@
7
6
 
8
7
  use std::collections::{BTreeMap, BTreeSet};
9
8
 
10
- use anyhow::{Context, Result, ensure};
11
- use swc_core::ecma::ast::BinaryOp;
12
-
13
9
  use super::Index;
14
- use crate::candidates;
15
10
  use crate::vm::{Constant, Effect, Instruction, Listing, Term};
16
11
 
17
12
  /// A property write, `object.key = value` or `object[key] = value`. Dynamic keys resolve to the
@@ -234,45 +229,4 @@ impl Index<'_> {
234
229
  && self.method(member.pc, &member.object).as_deref() == Some("Date")
235
230
  })
236
231
  }
237
-
238
- /// The challenge option `term` reads at `pc`: `name` in `window._cf_chl_opt[name]`.
239
- #[must_use]
240
- pub(crate) fn option_read(&self, pc: u32, term: &Term) -> Option<String> {
241
- let option = self.member(pc, term)?;
242
- let options = self.member(option.pc, &option.object)?;
243
- (options.key == "_cf_chl_opt").then_some(option.key)
244
- }
245
-
246
- /// Finds a record's start, finish, and duration stores. Uses the first `finished - started`
247
- /// store in program order and the stores supplying its operands.
248
- pub(crate) fn clock_marks<'s>(&self, stores: &[&'s Store]) -> Result<[&'s Store; 3]> {
249
- // Where a value comes from, or the value itself when its assignment is unknown.
250
- let source = |pc: u32, term: &Term| match self.dereference(pc, term) {
251
- Some((at, term)) => (Some(at), term),
252
- None => (None, term.clone()),
253
- };
254
- let (duration, finished, started) = stores
255
- .iter()
256
- .find_map(|store| match source(store.pc, &store.value) {
257
- (Some(at), Term::Binary(BinaryOp::Sub, finished, started)) => {
258
- Some((*store, source(at, &finished), source(at, &started)))
259
- }
260
- _ => None,
261
- })
262
- .context("record duration field not found")?;
263
- let writing = |operand: (Option<u32>, Term)| -> Vec<&'s Store> {
264
- stores
265
- .iter()
266
- .copied()
267
- .filter(|store| source(store.pc, &store.value) == operand)
268
- .collect()
269
- };
270
- let started = candidates::exactly_one(writing(started), "record start mark")?;
271
- let finished = candidates::exactly_one(writing(finished), "record finish mark")?;
272
- ensure!(
273
- started.key != finished.key,
274
- "record needs two wall-clock marks"
275
- );
276
- Ok([started, finished, duration])
277
- }
278
232
  }
@@ -1,6 +1,7 @@
1
1
  //! Computes `performance.now()` using browser clock rules.
2
2
  //!
3
- //! On Linux, Chrome reads `CLOCK_MONOTONIC` through `base::TimeTicks`. It clamps the reading
3
+ //! On Linux, Chrome reads `CLOCK_MONOTONIC` through `base::TimeTicks`, and on Windows
4
+ //! `QueryPerformanceCounter`. It clamps the reading
4
5
  //! and time origin to 100 µs using jitter at each interval boundary, converts both to
5
6
  //! floating-point milliseconds, and subtracts. Conversion loses precision as uptime grows,
6
7
  //! producing values such as `23.300000000745058`. Use this module for all reported readings and
@@ -152,6 +153,7 @@ fn murmur3_fmix64(mut value: u64) -> u64 {
152
153
  value ^ (value >> 33)
153
154
  }
154
155
 
156
+ #[cfg(unix)]
155
157
  fn monotonic_us() -> i64 {
156
158
  let mut time = libc::timespec {
157
159
  tv_sec: 0,
@@ -167,6 +169,23 @@ fn monotonic_us() -> i64 {
167
169
  time.tv_sec * 1_000_000 + time.tv_nsec / 1000
168
170
  }
169
171
 
172
+ #[cfg(windows)]
173
+ fn monotonic_us() -> i64 {
174
+ use windows_sys::Win32::System::Performance::{
175
+ QueryPerformanceCounter, QueryPerformanceFrequency,
176
+ };
177
+
178
+ let (mut count, mut frequency) = (0, 0);
179
+ // SAFETY: both pointers are to live, writable, aligned `i64`s, which the calls only write
180
+ // through. Neither call fails on Windows XP or later.
181
+ unsafe {
182
+ QueryPerformanceCounter(&mut count);
183
+ QueryPerformanceFrequency(&mut frequency);
184
+ }
185
+ // As `base::TimeTicks` converts it, without overflowing at high frequencies.
186
+ (i128::from(count) * 1_000_000 / i128::from(frequency)) as i64
187
+ }
188
+
170
189
  #[cfg(test)]
171
190
  mod tests {
172
191
  use super::*;
@@ -0,0 +1,49 @@
1
+ //! CPU stage timings, printed when the `CFSOLVE_PROFILE` environment variable is set.
2
+
3
+ use std::cell::RefCell;
4
+ use std::cmp::Reverse;
5
+ use std::env;
6
+ use std::sync::LazyLock;
7
+ use std::time::{Duration, Instant};
8
+
9
+ use rustc_hash::FxHashMap;
10
+
11
+ #[derive(Default)]
12
+ struct Timing {
13
+ calls: usize,
14
+ total: Duration,
15
+ }
16
+
17
+ thread_local! {
18
+ static TIMINGS: RefCell<FxHashMap<String, Timing>> = RefCell::default();
19
+ }
20
+
21
+ /// Returns the current time if profiling is enabled.
22
+ pub(crate) fn start() -> Option<Instant> {
23
+ static ENABLED: LazyLock<bool> = LazyLock::new(|| env::var_os("CFSOLVE_PROFILE").is_some());
24
+ ENABLED.then(Instant::now)
25
+ }
26
+
27
+ /// Adds the time since `started` to `name`'s total. `name` is only called when profiling.
28
+ pub(crate) fn record(started: Option<Instant>, name: impl FnOnce() -> String) {
29
+ let Some(started) = started else {
30
+ return;
31
+ };
32
+ let elapsed = started.elapsed();
33
+ TIMINGS.with_borrow_mut(|timings| {
34
+ let timing = timings.entry(name()).or_default();
35
+ timing.calls += 1;
36
+ timing.total += elapsed;
37
+ });
38
+ }
39
+
40
+ /// Prints the slowest timings recorded on this thread for `stage`, then clears them.
41
+ pub(crate) fn report(stage: &str) {
42
+ let mut timings: Vec<(String, Timing)> =
43
+ TIMINGS.with_borrow_mut(|timings| timings.drain().collect());
44
+ timings.sort_unstable_by_key(|(_, timing)| Reverse(timing.total));
45
+ timings.truncate(30);
46
+ for (name, Timing { calls, total }) in timings {
47
+ eprintln!("{stage}: {name}: {calls} calls, {total:?}");
48
+ }
49
+ }
@@ -1,44 +1,55 @@
1
1
  //! One parsed, deobfuscated iframe or orchestrator script shared across session extractors.
2
2
 
3
- use std::sync::OnceLock;
3
+ use anyhow::{Result, anyhow};
4
+ use self_cell::self_cell;
4
5
 
5
- use anyhow::Result;
6
-
7
- use crate::js::ast::{self, ParsedScript};
6
+ use crate::js::ast::{ParsedScript, Script};
8
7
  use crate::vm::{Definition, Listing, Machine};
9
8
 
9
+ /// The VM a script defines, or why recovery failed. Recovery runs with the parse because the
10
+ /// definition borrows the tree; the error surfaces only when the VM is requested.
11
+ struct Recovered<'a>(Result<Definition<'a>>);
12
+
13
+ self_cell!(
14
+ struct Cell {
15
+ owner: ParsedScript,
16
+ #[covariant]
17
+ dependent: Recovered,
18
+ }
19
+ );
20
+
10
21
  /// A parsed iframe script shared by encoder extraction, parameter merging, scene recovery, and
11
22
  /// VM analysis. Rejects scripts with recoverable parse errors.
12
- pub struct Source {
13
- parsed: ParsedScript,
14
- /// Lazily recovered VM, needed only when the session analyzes a program.
15
- definition: OnceLock<Definition>,
16
- }
23
+ pub struct Source(Cell);
24
+
25
+ // SAFETY: The definition holds only shared references into the tree the `ParsedScript` owns, and
26
+ // plain data. `ParsedScript` is `Send` and `Sync` because the tree is immutable once built; see
27
+ // its implementations.
28
+ unsafe impl Send for Source {}
29
+ // SAFETY: See `Send` above.
30
+ unsafe impl Sync for Source {}
17
31
 
18
32
  impl Source {
19
- /// Parses `text`. Defers VM recovery and its possible errors until the VM is requested.
33
+ /// Parses `text` and recovers its VM. Errors from VM recovery are deferred until the VM is
34
+ /// requested.
20
35
  pub fn try_new(text: &str) -> Result<Self> {
21
- Ok(Self {
22
- parsed: ast::parse_iframe_javascript(text)?,
23
- definition: OnceLock::new(),
24
- })
36
+ let parsed = ParsedScript::parse("deobfuscated script", text)?;
37
+ Ok(Self(Cell::new(parsed, |parsed| {
38
+ Recovered(Definition::from_script(parsed.script()))
39
+ })))
25
40
  }
26
41
 
27
42
  #[must_use]
28
- pub(crate) fn parsed(&self) -> &ParsedScript {
29
- &self.parsed
43
+ pub(crate) fn script(&self) -> Script<'_> {
44
+ self.0.borrow_owner().script()
30
45
  }
31
46
 
32
47
  /// The VM the script defines, ready to decode one program.
33
48
  pub fn machine(&self) -> Result<Machine<'_>> {
34
- let definition = match self.definition.get() {
35
- Some(definition) => definition,
36
- None => {
37
- let definition = Definition::from_script(&self.parsed.script)?;
38
- self.definition.get_or_init(|| definition)
39
- }
40
- };
41
- Machine::try_new(definition)
49
+ match &self.0.borrow_dependent().0 {
50
+ Ok(definition) => Machine::try_new(definition),
51
+ Err(error) => Err(anyhow!("{error:#}")),
52
+ }
42
53
  }
43
54
 
44
55
  /// Disassembles `program` from its entry using [`Machine::disassemble`]. Probe analysis
@@ -5,6 +5,7 @@
5
5
  use anyhow::{Context, Result, bail};
6
6
  use serde::Serialize;
7
7
  use url::Url;
8
+ use wreq::StatusCode;
8
9
 
9
10
  use super::Sink;
10
11
  use super::channel::{Channel, Origin, Stage, Submission};
@@ -126,13 +127,13 @@ pub(crate) async fn begin(
126
127
  challenge: ChallengePage,
127
128
  referrer_policy: ReferrerPolicy,
128
129
  ) -> Result<(OrchestratorSession, EmbeddingPage)> {
129
- sink.artifact("page.html", challenge.html.as_bytes())?;
130
+ sink.save("page.html", challenge.html.as_bytes())?;
130
131
  let pacing = &page.orchestrator_pacing;
131
132
  let timer = Timer::start();
132
133
  let script =
133
134
  http::fetch_orchestrator(client, &challenge.orchestrator, &challenge.loading).await?;
134
135
  let script_fetch = timer.overall(challenge.orchestrator.as_str(), script.len() as u64);
135
- sink.artifact("orchestrator.js", script.as_bytes())?;
136
+ sink.save("orchestrator.js", script.as_bytes())?;
136
137
  // The orchestrator's header shows the site's icon as it starts. Deobfuscation runs on its
137
138
  // own thread meanwhile.
138
139
  let icon_url = challenge.url.join("/favicon.ico")?;
@@ -148,7 +149,7 @@ pub(crate) async fn begin(
148
149
  ));
149
150
  let ((text, cases), icon) =
150
151
  tokio::try_join!(initial::deobfuscate(sink, javascript.clone()), icon)?;
151
- sink.artifact("orchestrator.deobfuscated.js", text.as_bytes())?;
152
+ sink.save("orchestrator.deobfuscated.js", text.as_bytes())?;
152
153
  let source = Source::try_new(&text).context("parsing the deobfuscated orchestrator")?;
153
154
 
154
155
  let intervals = &pacing.intervals;
@@ -186,7 +187,7 @@ pub(crate) async fn begin(
186
187
  .context("the orchestrator's message table names no one language")?;
187
188
  let ray = first.program.request.ray()?;
188
189
  let rendered = embedding_page::challenge_page::render(&challenge, &loader, language, ray)?;
189
- sink.artifact("rendered-page.html", rendered.as_bytes())?;
190
+ sink.save("rendered-page.html", rendered.as_bytes())?;
190
191
  let rendered = RenderedPage::render_explicit(
191
192
  &rendered,
192
193
  challenge.url.clone(),
@@ -307,29 +308,20 @@ impl OrchestratorSession {
307
308
  .as_ref()
308
309
  .unwrap_or(&self.challenge.url);
309
310
  let cleared = http::submit_form(client, referer, &form.action, &form.fields).await?;
310
- sink.artifact("cleared.html", cleared.html.as_bytes())?;
311
- if !cleared.status.is_success()
312
- || ChallengePage::parse(&cleared.html, &cleared.url)?.is_some()
313
- {
314
- let message = format!(
315
- "the clearance form returned HTTP {} without the page",
316
- cleared.status
317
- );
318
- bail!(Refused::new(Stage::Clearance, message));
319
- }
311
+ sink.save("cleared.html", cleared.html.as_bytes())?;
312
+ let challenged = ChallengePage::parse(&cleared.html, &cleared.url)?.is_some();
313
+ let cookies = client.cookies(&cleared.url);
314
+ let clearance = cookies
315
+ .iter()
316
+ .find(|cookie| cookie.name() == "cf_clearance")
317
+ .map(|cookie| cookie.value().to_owned());
318
+ let clearance = accept_clearance(cleared.status, challenged, clearance)?;
320
319
  sink.progress(&format!(
321
320
  "Cleared the challenge: {} answered HTTP {} with the page ({} bytes)",
322
321
  cleared.url,
323
322
  cleared.status,
324
323
  cleared.html.len()
325
324
  ));
326
- let cookies = client.cookies(&cleared.url);
327
- let clearance = cookies
328
- .iter()
329
- .find(|cookie| cookie.name() == "cf_clearance")
330
- .context("the clearance form set no `cf_clearance` cookie")?
331
- .value()
332
- .to_owned();
333
325
  Ok(Clearance {
334
326
  clearance,
335
327
  cookies,
@@ -338,6 +330,34 @@ impl OrchestratorSession {
338
330
  }
339
331
  }
340
332
 
333
+ /// Decides whether the clearance form passed the challenge, from the response to the form:
334
+ /// its HTTP status, whether it is another challenge page, and the `cf_clearance` cookie it set,
335
+ /// if any. Returns the cookie's value.
336
+ ///
337
+ /// Cloudflare sets `cf_clearance` when the form passes. After that, the page behind the
338
+ /// challenge can still answer with an error status. For example, a site's waiting room can
339
+ /// answer HTTP 429 to the visitors it is queueing. So an error status with the cookie still
340
+ /// counts as a pass. Another challenge page, or an error status without the cookie, means
341
+ /// Cloudflare refused the answers.
342
+ pub(crate) fn accept_clearance(
343
+ status: StatusCode,
344
+ challenged: bool,
345
+ clearance: Option<String>,
346
+ ) -> Result<String> {
347
+ let refused = || {
348
+ let message = format!("the clearance form returned HTTP {status} without the page");
349
+ Refused::new(Stage::Clearance, message)
350
+ };
351
+ if challenged {
352
+ bail!(refused());
353
+ }
354
+ match clearance {
355
+ Some(clearance) => Ok(clearance),
356
+ None if !status.is_success() => bail!(refused()),
357
+ None => bail!("the clearance form set no `cf_clearance` cookie"),
358
+ }
359
+ }
360
+
341
361
  /// Builds two resource timing snapshots for the widget program. The first includes the
342
362
  /// unfinished navigation and later loads. The second includes the finished navigation, first
343
363
  /// POST, a second icon entry, and the widget iframe. Estimates unmeasured phases. Only the end
@@ -143,7 +143,7 @@ impl Channel<'_> {
143
143
  .context("reading challenge POST response")?;
144
144
  sink.json(&format!("{name}-network.json"), &network)?;
145
145
  let fetch = timer.phased(url.as_str(), waiting_ms, network.encoded_bytes);
146
- sink.artifact(&format!("{name}.bin"), &body)?;
146
+ sink.save(&format!("{name}.bin"), &body)?;
147
147
  sink.progress(&format!(
148
148
  "POST returned HTTP {status}; saved {} bytes",
149
149
  body.len()
@@ -155,7 +155,7 @@ impl Channel<'_> {
155
155
  ));
156
156
  }
157
157
  let text = codec::decode_response(&body, request.ray()?)?;
158
- sink.artifact(&format!("{name}.decoded.txt"), &text)?;
158
+ sink.save(&format!("{name}.decoded.txt"), &text)?;
159
159
  let received_ms = performance_clock::epoch_ms();
160
160
  let program = STANDARD.decode(text).with_context(|| {
161
161
  format!(
@@ -199,7 +199,7 @@ pub(crate) async fn render_page(
199
199
  document: PageDocument,
200
200
  widget: Option<&Widget>,
201
201
  ) -> Result<EmbeddingPage> {
202
- sink.artifact("page.html", document.html.as_bytes())?;
202
+ sink.save("page.html", document.html.as_bytes())?;
203
203
  let widget_id = extra_params::widget_id();
204
204
  let rendered = RenderedPage::render(&document.html, document.url.clone(), &widget_id, widget)?;
205
205
  // A page that renders its widget from script may load the loader from script too.
@@ -277,10 +277,10 @@ pub(super) async fn fetch(
277
277
  let timer = Timer::start();
278
278
  let iframe = http::fetch_iframe(client, iframe_url, referrer.as_deref()).await?;
279
279
  let navigation = timer.overall(iframe.url.as_str(), iframe.navigation.encoded_bytes);
280
- sink.artifact("iframe.html", iframe.html.as_bytes())?;
280
+ sink.save("iframe.html", iframe.html.as_bytes())?;
281
281
  let javascript = source::inline_javascript(&iframe.html)?;
282
- sink.artifact("iframe.js", javascript.as_bytes())?;
283
- sink.artifact("iframe-url.txt", iframe.url.as_str().as_bytes())?;
282
+ sink.save("iframe.js", javascript.as_bytes())?;
283
+ sink.save("iframe-url.txt", iframe.url.as_str().as_bytes())?;
284
284
  sink.json("iframe-network.json", &iframe.navigation)?;
285
285
  sink.progress(&format!(
286
286
  "Fetched {} bytes of HTML; deobfuscating {} bytes of JavaScript",
@@ -288,7 +288,7 @@ pub(super) async fn fetch(
288
288
  javascript.len()
289
289
  ));
290
290
  let (text, cases) = deobfuscate(sink, javascript.clone()).await?;
291
- sink.artifact("iframe.deobfuscated.js", text.as_bytes())?;
291
+ sink.save("iframe.deobfuscated.js", text.as_bytes())?;
292
292
  let source = Source::try_new(&text).context("parsing the deobfuscated iframe")?;
293
293
  Ok(Fetched {
294
294
  iframe,
@@ -1,5 +1,7 @@
1
1
  //! Session artifact storage and progress reporting.
2
2
 
3
+ use std::fmt;
4
+
3
5
  use anyhow::{Context, Result};
4
6
  use serde::Serialize;
5
7
 
@@ -21,11 +23,34 @@ impl Sink for Discard {
21
23
  fn progress(&self, _: &str) {}
22
24
  }
23
25
 
26
+ /// Marks a failure as the sink's own, so it is not mistaken for a challenge the solver cannot
27
+ /// handle.
28
+ #[derive(Debug)]
29
+ pub(crate) struct SinkFailed {
30
+ name: String,
31
+ }
32
+
33
+ impl fmt::Display for SinkFailed {
34
+ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
35
+ write!(formatter, "saving artifact {}", self.name)
36
+ }
37
+ }
38
+
24
39
  impl dyn Sink + '_ {
40
+ /// Saves `contents` under artifact `name` with [`Sink::artifact`], marking a failure with
41
+ /// [`SinkFailed`].
42
+ pub(crate) fn save(&self, name: &str, contents: &[u8]) -> Result<()> {
43
+ self.artifact(name, contents).map_err(|error| {
44
+ error.context(SinkFailed {
45
+ name: name.to_owned(),
46
+ })
47
+ })
48
+ }
49
+
25
50
  /// Saves `value` as pretty-printed JSON under artifact `name`.
26
51
  pub(crate) fn json(&self, name: &str, value: &impl Serialize) -> Result<()> {
27
52
  let json =
28
53
  serde_json::to_vec_pretty(value).with_context(|| format!("serializing {name}"))?;
29
- self.artifact(name, &json)
54
+ self.save(name, &json)
30
55
  }
31
56
  }
@@ -1,9 +1,12 @@
1
1
  //! Regression tests for a challenge-page session.
2
2
 
3
+ use wreq::StatusCode;
4
+
5
+ use crate::Error;
3
6
  use crate::challenge::reduced_timing::{Measure, ResourceTiming};
4
7
  use crate::js::json;
5
8
  use crate::resource_timing::{LoadTiming, Phases};
6
- use crate::session::challenge_page;
9
+ use crate::session::{Stage, challenge_page};
7
10
 
8
11
  /// A load measured only as a whole.
9
12
  fn fetch(url: &str, started_ms: i64, duration_ms: f64) -> LoadTiming {
@@ -61,3 +64,35 @@ fn the_pages_resource_timing_lists_both_of_the_widget_programs_reads() {
61
64
  ]
62
65
  );
63
66
  }
67
+
68
+ /// Whether a clearance form response refuses the answers, as a caller sees it.
69
+ fn refused(status: StatusCode, challenged: bool, clearance: Option<&str>) -> bool {
70
+ let error = challenge_page::accept_clearance(status, challenged, clearance.map(str::to_owned))
71
+ .expect_err("the response should not pass");
72
+ matches!(
73
+ Error::classify(error),
74
+ Error::Rejected {
75
+ stage: Stage::Clearance,
76
+ ..
77
+ }
78
+ )
79
+ }
80
+
81
+ /// A `cf_clearance` cookie is a pass whatever the status of the page behind the challenge,
82
+ /// such as a waiting room's HTTP 429. Another challenge page, or an error status without the
83
+ /// cookie, is a refusal. A success without the cookie is a failure the solver can't explain.
84
+ #[test]
85
+ fn the_clearance_form_passes_when_it_sets_the_cookie_whatever_the_pages_status() {
86
+ for status in [
87
+ StatusCode::OK,
88
+ StatusCode::TOO_MANY_REQUESTS,
89
+ StatusCode::NOT_FOUND,
90
+ ] {
91
+ let clearance = challenge_page::accept_clearance(status, false, Some("token".into()));
92
+ assert_eq!(clearance.unwrap(), "token", "HTTP {status}");
93
+ }
94
+ assert!(refused(StatusCode::OK, true, Some("token")));
95
+ assert!(refused(StatusCode::FORBIDDEN, true, Some("token")));
96
+ assert!(refused(StatusCode::TOO_MANY_REQUESTS, false, None));
97
+ assert!(!refused(StatusCode::OK, false, None));
98
+ }
@@ -16,8 +16,8 @@ mod timing;
16
16
  mod widget;
17
17
 
18
18
  pub use channel::Stage;
19
- pub(crate) use sink::Discard;
20
19
  pub use sink::Sink;
20
+ pub(crate) use sink::{Discard, SinkFailed};
21
21
  pub use widget::{Clearance, Outcome};
22
22
  pub(crate) use widget::{Expect, native, navigate, prepare, send_first_payload};
23
23
 
@@ -20,6 +20,8 @@ use crate::session::{self, Clearance, Discard, Expect, Outcome, Sink};
20
20
  pub struct Options {
21
21
  /// An `http://`, `https://`, `socks5://`, or `socks5h://` proxy for every request.
22
22
  pub proxy: Option<String>,
23
+ /// A PEM certificate to trust instead of the built-in roots, such as a recording proxy's CA.
24
+ pub trusted_root: Option<Vec<u8>>,
23
25
  /// Destination for artifacts and progress messages. Both are discarded if absent.
24
26
  pub sink: Option<Arc<dyn Sink>>,
25
27
  }
@@ -203,7 +205,7 @@ impl Browser {
203
205
 
204
206
  fn client(&self, options: &Options) -> Result<BrowserClient, Error> {
205
207
  self.transport
206
- .client(options.proxy.as_deref())
208
+ .client(options.proxy.as_deref(), options.trusted_root.as_deref())
207
209
  .map_err(Error::Config)
208
210
  }
209
211
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  use std::collections::{BTreeMap, BTreeSet};
8
8
 
9
- use swc_core::ecma::ast::BinaryOp;
9
+ use oxc::syntax::operator::BinaryOperator;
10
10
 
11
11
  use crate::candidates;
12
12
  use crate::listing::Index;
@@ -77,7 +77,9 @@ fn value_role(index: &Index<'_>, store: &Store) -> Option<&'static str> {
77
77
  }
78
78
  match index.dereference(pc, value)? {
79
79
  // The decoded size less a Server-Timing duration.
80
- (at, Term::Binary(BinaryOp::Sub, left, _)) if index.reads(at, &left, "decodedBodySize") => {
80
+ (at, Term::Binary(BinaryOperator::Subtraction, left, _))
81
+ if index.reads(at, &left, "decodedBodySize") =>
82
+ {
81
83
  Some(ENVIRONMENT_AUDIT_REDUCTION)
82
84
  }
83
85
  // A touch-support check given the probe frame's document.
@@ -9,6 +9,7 @@ use crate::listing::fold::{Frame, Known};
9
9
  use crate::listing::query::Store;
10
10
  use crate::listing::{Index, query};
11
11
  use crate::stage2::payload::RecordLiteral;
12
+ use crate::stage2::queries;
12
13
  use crate::stage2::records::{Completion, Envelope, INITIAL_STATUS, Probe};
13
14
  use crate::vm::{Effect, Term};
14
15
 
@@ -93,7 +94,7 @@ pub(super) fn recover(
93
94
  .iter()
94
95
  .filter(|store| finish.contains(&store.pc))
95
96
  .collect();
96
- let [started, finished, duration] = index.clock_marks(&finishing)?;
97
+ let [started, finished, duration] = queries::clock_marks(index, &finishing)?;
97
98
  Ok(Envelope {
98
99
  counter,
99
100
  token,