cfsolve 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +10 -9
  4. data/THIRD_PARTY_LICENSES/README.md +71 -254
  5. data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
  6. data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
  7. data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
  8. data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
  9. data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
  10. data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
  11. data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
  12. data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
  13. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
  14. data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
  15. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
  16. data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
  17. data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
  18. data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
  19. data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
  20. data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
  21. data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
  22. data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
  23. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
  24. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
  25. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
  26. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
  27. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
  28. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
  29. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
  30. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
  31. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
  32. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
  33. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
  34. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
  35. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
  36. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
  37. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
  38. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
  39. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
  40. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
  41. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
  42. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
  43. data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
  44. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
  45. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
  46. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
  47. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
  48. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
  49. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
  50. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
  51. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
  52. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
  53. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
  54. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
  55. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
  56. data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
  57. data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
  58. data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
  59. data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
  60. data/UPSTREAM.md +10 -8
  61. data/ext/cfsolve/Cargo.lock +534 -1727
  62. data/ext/cfsolve/Cargo.toml +4 -0
  63. data/ext/cfsolve/src/main.rs +1 -1
  64. data/lib/cfsolve/profiles/safari-26-ios/answers.json +2570 -1894
  65. data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +1867 -1192
  66. data/lib/cfsolve/profiles/safari-26-ios.json +102 -156
  67. data/lib/cfsolve/version.rb +2 -2
  68. data/vendor/cfsolve/Cargo.lock +561 -1729
  69. data/vendor/cfsolve/Cargo.toml +26 -8
  70. data/vendor/cfsolve/README.md +4 -35
  71. data/vendor/cfsolve/examples/build_profile.rs +17 -15
  72. data/vendor/cfsolve/examples/capture_session.rs +37 -0
  73. data/vendor/cfsolve/examples/check_answers.rs +66 -0
  74. data/vendor/cfsolve/examples/compare_session.rs +189 -0
  75. data/vendor/cfsolve/examples/solver_profile.rs +84 -0
  76. data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
  77. data/vendor/cfsolve/examples/stage2_snapshot.rs +6 -3
  78. data/vendor/cfsolve/examples/tls_echo.rs +3 -3
  79. data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
  80. data/vendor/cfsolve/profiles/safari-26-ios/answers.json +2570 -1894
  81. data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +1867 -1192
  82. data/vendor/cfsolve/profiles/safari-26-ios.json +102 -156
  83. data/vendor/cfsolve/scripts/capture_cssom.mjs +42 -0
  84. data/vendor/cfsolve/scripts/serve_cssom.py +111 -0
  85. data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
  86. data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
  87. data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
  88. data/vendor/cfsolve/src/capture/profile.rs +7 -18
  89. data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
  90. data/vendor/cfsolve/src/capture/proxy.rs +44 -13
  91. data/vendor/cfsolve/src/capture/recorded.rs +42 -7
  92. data/vendor/cfsolve/src/capture/sessions.rs +4 -3
  93. data/vendor/cfsolve/src/capture/upstream.rs +1 -1
  94. data/vendor/cfsolve/src/challenge/codec.rs +4 -2
  95. data/vendor/cfsolve/src/challenge/expression.rs +161 -117
  96. data/vendor/cfsolve/src/challenge/installed/audit.rs +132 -0
  97. data/vendor/cfsolve/src/challenge/installed.rs +127 -269
  98. data/vendor/cfsolve/src/challenge/merge.rs +120 -80
  99. data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
  100. data/vendor/cfsolve/src/challenge/payload.rs +175 -35
  101. data/vendor/cfsolve/src/challenge/program.rs +197 -178
  102. data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
  103. data/vendor/cfsolve/src/challenge/source.rs +151 -96
  104. data/vendor/cfsolve/src/challenge/state.rs +236 -122
  105. data/vendor/cfsolve/src/challenge/tally.rs +64 -50
  106. data/vendor/cfsolve/src/challenge.rs +1 -0
  107. data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
  108. data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
  109. data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
  110. data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
  111. data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
  112. data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
  113. data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
  114. data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
  115. data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
  116. data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
  117. data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
  118. data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
  119. data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
  120. data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
  121. data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
  122. data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
  123. data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
  124. data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +201 -205
  125. data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
  126. data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +346 -536
  127. data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
  128. data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
  129. data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
  130. data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
  131. data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
  132. data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
  133. data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
  134. data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +361 -322
  135. data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
  136. data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
  137. data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
  138. data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
  139. data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
  140. data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
  141. data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
  142. data/vendor/cfsolve/src/deobfuscate.rs +15 -11
  143. data/vendor/cfsolve/src/embedding_page/extra_params.rs +23 -32
  144. data/vendor/cfsolve/src/embedding_page/page.rs +28 -2
  145. data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
  146. data/vendor/cfsolve/src/error.rs +40 -5
  147. data/vendor/cfsolve/src/fingerprint.rs +8 -2
  148. data/vendor/cfsolve/src/http/client.rs +9 -1
  149. data/vendor/cfsolve/src/http/requests.rs +2 -2
  150. data/vendor/cfsolve/src/js/ast.rs +479 -254
  151. data/vendor/cfsolve/src/js/objects.rs +9 -2
  152. data/vendor/cfsolve/src/lib.rs +1 -0
  153. data/vendor/cfsolve/src/listing/fold.rs +19 -92
  154. data/vendor/cfsolve/src/listing/query.rs +26 -291
  155. data/vendor/cfsolve/src/listing.rs +0 -1
  156. data/vendor/cfsolve/src/performance_clock.rs +20 -1
  157. data/vendor/cfsolve/src/profiling.rs +49 -0
  158. data/vendor/cfsolve/src/script.rs +35 -24
  159. data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
  160. data/vendor/cfsolve/src/session/channel.rs +2 -2
  161. data/vendor/cfsolve/src/session/initial.rs +19 -10
  162. data/vendor/cfsolve/src/session/probes.rs +160 -125
  163. data/vendor/cfsolve/src/session/sink.rs +26 -1
  164. data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
  165. data/vendor/cfsolve/src/session/timing.rs +58 -53
  166. data/vendor/cfsolve/src/session/widget.rs +5 -6
  167. data/vendor/cfsolve/src/session.rs +1 -1
  168. data/vendor/cfsolve/src/solver.rs +3 -1
  169. data/vendor/cfsolve/src/stage2/analysis/analyze.rs +50 -33
  170. data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
  171. data/vendor/cfsolve/src/stage2/analysis/discovery.rs +61 -66
  172. data/vendor/cfsolve/src/stage2/analysis/envelope.rs +33 -22
  173. data/vendor/cfsolve/src/stage2/analysis/recognize.rs +3 -5
  174. data/vendor/cfsolve/src/stage2/analysis.rs +0 -1
  175. data/vendor/cfsolve/src/stage2/audit_globals.rs +378 -0
  176. data/vendor/cfsolve/src/stage2/benchmark.rs +66 -38
  177. data/vendor/cfsolve/src/stage2/call_stack.rs +1463 -1017
  178. data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
  179. data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
  180. data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
  181. data/vendor/cfsolve/src/stage2/interaction/native.rs +2 -1
  182. data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -7
  183. data/vendor/cfsolve/src/stage2/payload/recover.rs +56 -25
  184. data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
  185. data/vendor/cfsolve/src/stage2/probes/ice.rs +11 -10
  186. data/vendor/cfsolve/src/stage2/probes/media.rs +47 -33
  187. data/vendor/cfsolve/src/stage2/probes/performance.rs +13 -8
  188. data/vendor/cfsolve/src/stage2/probes/rects.rs +12 -17
  189. data/vendor/cfsolve/src/stage2/probes/stack.rs +50 -103
  190. data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +17 -86
  191. data/vendor/cfsolve/src/stage2/probes.rs +0 -1
  192. data/vendor/cfsolve/src/stage2/queries.rs +50 -0
  193. data/vendor/cfsolve/src/stage2/records.rs +4 -13
  194. data/vendor/cfsolve/src/stage2/reference.json +1 -1
  195. data/vendor/cfsolve/src/stage2/reference.rs +98 -100
  196. data/vendor/cfsolve/src/stage2/registry.rs +41 -34
  197. data/vendor/cfsolve/src/stage2/replay.rs +182 -254
  198. data/vendor/cfsolve/src/stage2/stylesheets.rs +176 -0
  199. data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
  200. data/vendor/cfsolve/src/stage2/trace.rs +152 -108
  201. data/vendor/cfsolve/src/stage2/vocabulary.rs +103 -403
  202. data/vendor/cfsolve/src/stage2.rs +4 -1
  203. data/vendor/cfsolve/src/vm/disassemble.rs +46 -13
  204. data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
  205. data/vendor/cfsolve/src/vm/extract.rs +347 -250
  206. data/vendor/cfsolve/src/vm/interpret/access.rs +67 -68
  207. data/vendor/cfsolve/src/vm/interpret/builtin.rs +16 -63
  208. data/vendor/cfsolve/src/vm/interpret/call.rs +192 -51
  209. data/vendor/cfsolve/src/vm/interpret/compile.rs +643 -0
  210. data/vendor/cfsolve/src/vm/interpret/copies.rs +232 -120
  211. data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +149 -40
  212. data/vendor/cfsolve/src/vm/interpret/evaluate.rs +189 -572
  213. data/vendor/cfsolve/src/vm/interpret/explore.rs +159 -46
  214. data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
  215. data/vendor/cfsolve/src/vm/interpret/frozen.rs +169 -0
  216. data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +414 -0
  217. data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
  218. data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
  219. data/vendor/cfsolve/src/vm/interpret/pattern.rs +1736 -0
  220. data/vendor/cfsolve/src/vm/interpret/plan.rs +605 -330
  221. data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
  222. data/vendor/cfsolve/src/vm/interpret/run.rs +314 -54
  223. data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
  224. data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
  225. data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
  226. data/vendor/cfsolve/src/vm/interpret.rs +16 -3
  227. data/vendor/cfsolve/src/vm/machine.rs +58 -47
  228. data/vendor/cfsolve/src/vm/output.rs +13 -5
  229. data/vendor/cfsolve/src/vm/packed_names.rs +311 -0
  230. data/vendor/cfsolve/src/vm/session.rs +197 -110
  231. data/vendor/cfsolve/src/vm/value.rs +35 -19
  232. data/vendor/cfsolve/src/vm.rs +3 -1
  233. data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
  234. data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
  235. data/vendor/cfsolve/vendor/btls-sys/src/lib.rs +3 -0
  236. metadata +106 -183
  237. data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
  238. data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
  239. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
  240. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
  241. data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
  242. data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
  243. data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
  244. data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
  245. data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
  246. data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
  247. data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
  248. data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
  249. data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
  250. data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
  251. data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
  252. data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
  253. data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
  254. data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
  255. data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
  256. data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
  257. data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
  258. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
  259. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
  260. data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
  261. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
  262. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
  263. data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
  264. data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
  265. data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
  266. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
  267. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
  268. data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
  269. data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
  270. data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
  271. data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
  272. data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
  273. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
  274. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
  275. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
  276. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
  277. data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
  278. data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
  279. data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
  280. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
  281. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
  282. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
  283. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
  284. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
  285. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
  286. data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
  287. data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
  288. data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
  289. data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
  290. data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
  291. data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
  292. data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
  293. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
  294. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
  295. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
  296. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
  297. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
  298. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
  299. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
  300. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
  301. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
  302. data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
  303. data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
  304. data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
  305. data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
  306. data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
  307. data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
  308. data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
  309. data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
  310. data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
  311. data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
  312. data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
  313. data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
  314. data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
  315. data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
  316. data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
  317. data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
  318. data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
  319. data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
  320. data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
  321. data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
  322. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
  323. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
  324. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
  325. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
  326. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
  327. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
  328. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
  329. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
  330. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
  331. data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
  332. data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
  333. data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
  334. data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
  335. data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
  336. data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
  337. data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
  338. data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
  339. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
  340. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
  341. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
  342. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
  343. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
  344. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
  345. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
  346. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
  347. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
  348. data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
  349. data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
  350. data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
  351. data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
  352. data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
  353. data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
  354. data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
  355. data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
  356. data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
  357. data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
  358. data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
  359. data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
  360. data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
  361. data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
  362. data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
  363. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
  364. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
  365. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
  366. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
  367. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
  368. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
  369. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
  370. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
  371. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
  372. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
  373. data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
  374. data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
  375. data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
  376. data/vendor/cfsolve/src/listing/normalize.rs +0 -264
  377. data/vendor/cfsolve/src/stage2/analysis/outputs.rs +0 -327
  378. data/vendor/cfsolve/src/stage2/probes/stylesheets.rs +0 -249
  379. data/vendor/cfsolve/src/stage2/reference-expanded.json +0 -42
  380. data/vendor/cfsolve/src/stage2/session_names.rs +0 -470
  381. /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
  382. /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
  383. /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
  384. /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
  385. /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
  386. /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
  387. /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
  388. /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
  389. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
  390. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
  391. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
  392. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
  393. /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
  394. /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
  395. /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
  396. /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
  397. /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
  398. /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
  399. /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
  400. /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
  401. /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
  402. /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
  403. /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
  404. /data/THIRD_PARTY_LICENSES/{cargo-platform-0.1.9 → zmij_ecma-1.0.23}/LICENSE-MIT +0 -0
@@ -11,7 +11,7 @@ use url::Url;
11
11
  use wreq::ws::message::Message;
12
12
 
13
13
  use super::channel::Submission;
14
- use super::timing::{self, Schedule, Timer};
14
+ use super::timing::{self, Schedule, Timeline, Timer};
15
15
  use super::widget::{Embedding, WidgetSession};
16
16
  use crate::browser::{Profile, Solve};
17
17
  use crate::challenge::payload;
@@ -59,8 +59,14 @@ pub(crate) async fn prepare(session: &WidgetSession<'_>, solve: &Solve) -> Resul
59
59
  let engine = session.client.engine();
60
60
  let plan = session.analysis.plan();
61
61
  let mut options = session.request.options.clone();
62
- let (mut observed, fetches) = observe(session, plan, &options, profile).await?;
62
+ let mut observed = observe(session, plan, profile).await?;
63
63
  observed.page_signals = Some(merged.page_signals.clone());
64
+ let replay = answers.map(|answers| Replay::new(answers, plan));
65
+ let planned = durations(plan, &profile.durations, &observed, replay.as_ref());
66
+ // The stack is needed only for the records, so rebuild it while the probes run.
67
+ let probes = run_probes(session, plan, &options, profile, &mut observed, &planned);
68
+ let ((schedule, fetches), stack) = tokio::try_join!(probes, probe_stack(session, plan))?;
69
+ observed.stack = stack;
64
70
  // Resource timings now include the first POST and probe requests.
65
71
  if let Some(timing) = &merged.state.timing {
66
72
  let mut resources = merged.resources.clone();
@@ -82,17 +88,6 @@ pub(crate) async fn prepare(session: &WidgetSession<'_>, solve: &Solve) -> Resul
82
88
  }
83
89
  window.extend(profile.window.clone());
84
90
 
85
- let replay = answers
86
- .map(|answers| Replay::new(answers, plan, &session.fetched.source, &session.installed))
87
- .transpose()?;
88
- let pending_ms = i64::from(profile.pending_ms);
89
- let schedule = timing::schedule(
90
- &durations(plan, &profile.durations, &observed, replay.as_ref()),
91
- profile.startup_ms.into(),
92
- pending_ms,
93
- session.arrived_ms,
94
- performance_clock::epoch_ms(),
95
- );
96
91
  if let Some((probe, Operation::PerformanceEntries { fields })) =
97
92
  plan.operation(Kind::PerformanceEntries)
98
93
  {
@@ -107,15 +102,19 @@ pub(crate) async fn prepare(session: &WidgetSession<'_>, solve: &Solve) -> Resul
107
102
  engine,
108
103
  ));
109
104
  }
105
+ let mut globals = merged.audit_globals.0.clone();
106
+ globals.extend(replay::Globals::recover(&session.fetched.source).0);
107
+ let globals = replay::Globals(globals);
110
108
  let stored = replay::Session {
111
- iframe_url: session.fetched.iframe.url.as_str(),
112
109
  iframe_html: &session.fetched.iframe.html,
110
+ iframe_url: session.fetched.iframe.url.as_str(),
113
111
  modified: Local::now().format("%m/%d/%Y %H:%M:%S").to_string(),
114
112
  referrer: session.fetched.referrer.as_deref().unwrap_or_default(),
115
113
  navigation: &session.fetched.iframe.navigation,
116
114
  options: &options,
117
115
  trace: Trace::recover(&session.fetched.source),
118
116
  controller: plan.controller_trace.as_deref(),
117
+ globals: &globals,
119
118
  };
120
119
  let records = records(
121
120
  plan,
@@ -133,14 +132,14 @@ pub(crate) async fn prepare(session: &WidgetSession<'_>, solve: &Solve) -> Resul
133
132
  },
134
133
  records,
135
134
  &profile.document,
136
- pending_ms,
135
+ profile.pending_ms.into(),
137
136
  )?;
138
137
  ensure!(
139
138
  plaintext.len() > plan.probes().len(),
140
139
  "the assembled payload holds nothing besides records"
141
140
  );
142
141
  payload::append_send_time_at(&mut plaintext, &merged.state, &options, schedule.send_at);
143
- let geometry = window_geometry(replay.as_ref(), &plaintext);
142
+ let geometry = window_geometry(plan, replay.as_ref(), &plaintext);
144
143
  Ok(ProbeSubmission {
145
144
  payload: Submission {
146
145
  plaintext,
@@ -152,33 +151,28 @@ pub(crate) async fn prepare(session: &WidgetSession<'_>, solve: &Solve) -> Resul
152
151
  })
153
152
  }
154
153
 
155
- /// Collects native measurements, and the requests the iframe's resource timing lists. Runs
156
- /// requests and stack recovery concurrently.
154
+ /// Collects the measurements that make no requests, except the stack. Probes with requests make
155
+ /// them as they run; see [`run_probes`].
157
156
  async fn observe(
158
157
  session: &WidgetSession<'_>,
159
158
  plan: &ProbePlan,
160
- options: &Options,
161
159
  profile: &Profile,
162
- ) -> Result<(Observed, Vec<LoadTiming>)> {
160
+ ) -> Result<Observed> {
163
161
  let mut observed = Observed::default();
164
- let requests = requests(session, plan, options, profile, &mut observed);
165
- let stack = probe_stack(session, plan);
166
- let (fetches, stack) = tokio::try_join!(requests, stack)?;
167
- observed.stack = stack;
168
162
  let facts = &profile.facts;
169
163
  let resolution = session.clock_resolution();
170
- if let Some((probe, Operation::Benchmark { fields })) = plan.operation(Kind::Benchmark) {
171
- let measured = fields
172
- .measure(&facts.benchmark_worker, resolution)
173
- .with_context(|| format!("running probe {}'s benchmark", probe.index))?;
174
- observed.benchmark = Some(measured);
175
- }
176
164
  if let (Some((probe, _)), Some(previous)) = (plan.operation(Kind::Media), &facts.media) {
177
165
  let media = ice::refresh(previous.clone())
178
166
  .with_context(|| format!("refreshing probe {}'s media", probe.index))?;
179
167
  session.sink.json("media-measurement.json", &media)?;
180
168
  observed.media = Some(media);
181
169
  }
170
+ if let Some((probe, Operation::Benchmark { fields })) = plan.operation(Kind::Benchmark) {
171
+ let measured = fields
172
+ .measure(&facts.benchmark_worker, resolution)
173
+ .with_context(|| format!("running probe {}'s benchmark", probe.index))?;
174
+ observed.benchmark = Some(measured);
175
+ }
182
176
  // The worker compares 5000 consecutive clock-reading pairs. Chrome's call overhead usually
183
177
  // crosses a 100 µs boundary; faster native reads may miss all boundaries. Retry until a
184
178
  // pair crosses one.
@@ -190,7 +184,7 @@ async fn observe(
190
184
  .unwrap_or_else(|| worker.back_to_back(clock::PAIRS));
191
185
  observed.clock = Some(readings);
192
186
  }
193
- Ok((observed, fetches))
187
+ Ok(observed)
194
188
  }
195
189
 
196
190
  /// Runs the WebSocket echo exchange. After opening, sends `String(performance.now())` and sends a
@@ -278,7 +272,8 @@ async fn probe_stack(session: &WidgetSession<'_>, plan: &ProbePlan) -> Result<Op
278
272
  let origin = fetched.script_position()?;
279
273
  let engine = session.client.engine();
280
274
  let stack = task::spawn_blocking(move || {
281
- let geometry = call_stack::recover_probe(&javascript, &cases, calls)?;
275
+ let resumed = call_stack::Resumption::WorkerMessage;
276
+ let geometry = call_stack::recover_probe(&javascript, &cases, calls, resumed)?;
282
277
  anyhow::Ok(geometry.format(&origin, engine))
283
278
  })
284
279
  .await
@@ -310,109 +305,145 @@ fn durations(
310
305
  plan.probes().iter().map(duration).collect()
311
306
  }
312
307
 
313
- /// Makes probe requests as the iframe would and returns the loads included in resource timing.
314
- async fn requests(
308
+ /// Runs the probes in order from the end of startup, or now if later. A probe that makes
309
+ /// requests waits for its start and lasts at least until they end. Returns the probes' marks
310
+ /// and the loads resource timing lists.
311
+ async fn run_probes(
315
312
  session: &WidgetSession<'_>,
316
313
  plan: &ProbePlan,
317
314
  options: &Options,
318
315
  profile: &Profile,
319
316
  observed: &mut Observed,
320
- ) -> Result<Vec<LoadTiming>> {
321
- let (client, iframe) = (session.client, &session.fetched.iframe);
317
+ planned: &[i64],
318
+ ) -> Result<(Schedule, Vec<LoadTiming>)> {
319
+ let startup_end = session.arrived_ms + i64::from(profile.startup_ms);
320
+ let mut timeline = Timeline::starting(performance_clock::epoch_ms().max(startup_end));
322
321
  let mut fetches = Vec::new();
323
- for probe in plan.probes() {
324
- match &probe.operation {
325
- Some(Operation::PrivateToken { fields }) => {
326
- let url = fields.url(options, &probe.input, &iframe.url)?;
327
- let started_ms = performance_clock::epoch_ms();
328
- // The worker calls `r.text()` before posting results. Treat body-read failures
329
- // like fetch failures because both reject the promise chain.
330
- let fetched = http::fetch_from_worker(client, iframe, &url, FetchOptions::NoCache);
331
- let outcome = async {
332
- let response = fetched.await?;
333
- let status = response.status();
334
- anyhow::Ok(private_token::WorkerOutcome::Response {
335
- ok: status.is_success(),
336
- status: status.as_u16(),
337
- text: response.text().await?,
338
- })
339
- }
340
- .await
341
- .unwrap_or_else(|error| private_token::WorkerOutcome::Rejected {
342
- worker_error: error.to_string(),
343
- });
344
- observed.private_token = Some(private_token::Measurement {
345
- outcome,
346
- started_ms,
347
- finished_ms: performance_clock::epoch_ms(),
348
- });
349
- }
350
- Some(Operation::WorkerFetch { .. }) if profile.facts.worker_fetch_rejected => {
351
- observed.worker_fetch = Some(worker_fetch::Measurement::Rejected);
352
- }
353
- Some(Operation::HostReachability { fields }) => {
354
- // CORS rejects a response that does not allow the iframe's origin.
355
- let origin = iframe.url.origin().ascii_serialization();
356
- let mut outcomes = Vec::new();
357
- for url in &fields.urls {
358
- let url = Url::parse(url).context("parsing a host reachability URL")?;
359
- let timer = Timer::start();
360
- let options = FetchOptions::NoStoreWithoutCredentials;
361
- let fetched = http::fetch_from_worker(client, iframe, &url, options);
362
- outcomes.push(match time::timeout(REACHABILITY_TIMEOUT, fetched).await {
363
- Ok(Ok(response))
364
- if response
365
- .headers()
366
- .get("access-control-allow-origin")
367
- .and_then(|allowed| allowed.to_str().ok())
368
- .is_some_and(|allowed| allowed == "*" || allowed == origin) =>
369
- {
370
- host_reachability::Outcome::Answered {
371
- elapsed_ms: timer.elapsed_ms() as i64,
372
- }
373
- }
374
- _ => host_reachability::Outcome::Rejected,
375
- });
376
- }
377
- observed.host_reachability = Some(outcomes);
378
- }
379
- Some(Operation::WebSocketEcho { fields }) => {
380
- observed.websocket_echo = Some(echo_websocket(session, fields, options).await?);
322
+ for (probe, &planned_ms) in plan.probes().iter().zip(planned) {
323
+ let requests = matches!(
324
+ probe.operation,
325
+ Some(
326
+ Operation::PrivateToken { .. }
327
+ | Operation::WorkerFetch { .. }
328
+ | Operation::HostReachability { .. }
329
+ | Operation::WebSocketEcho { .. }
330
+ | Operation::Image { .. }
331
+ )
332
+ );
333
+ let finished = if requests {
334
+ timing::sleep_until(timeline.next_start).await;
335
+ request(session, probe, options, profile, observed, &mut fetches).await?;
336
+ Some(performance_clock::epoch_ms())
337
+ } else {
338
+ None
339
+ };
340
+ timeline.finish(planned_ms, finished);
341
+ }
342
+ Ok((timeline.schedule(profile.pending_ms.into()), fetches))
343
+ }
344
+
345
+ /// Makes `probe`'s requests as the iframe would. Records its measurement in `observed` and the
346
+ /// loads resource timing lists in `fetches`.
347
+ async fn request(
348
+ session: &WidgetSession<'_>,
349
+ probe: &Probe,
350
+ options: &Options,
351
+ profile: &Profile,
352
+ observed: &mut Observed,
353
+ fetches: &mut Vec<LoadTiming>,
354
+ ) -> Result<()> {
355
+ let (client, iframe) = (session.client, &session.fetched.iframe);
356
+ match &probe.operation {
357
+ Some(Operation::PrivateToken { fields }) => {
358
+ let url = fields.url(options, &probe.input, &iframe.url)?;
359
+ let started_ms = performance_clock::epoch_ms();
360
+ // The worker calls `r.text()` before posting results. Treat body-read failures
361
+ // like fetch failures because both reject the promise chain.
362
+ let fetched = http::fetch_from_worker(client, iframe, &url, FetchOptions::NoCache);
363
+ let outcome = async {
364
+ let response = fetched.await?;
365
+ let status = response.status();
366
+ anyhow::Ok(private_token::WorkerOutcome::Response {
367
+ ok: status.is_success(),
368
+ status: status.as_u16(),
369
+ text: response.text().await?,
370
+ })
381
371
  }
382
- Some(Operation::WorkerFetch { fields }) => {
383
- let url = fields.url(options)?;
372
+ .await
373
+ .unwrap_or_else(|error| private_token::WorkerOutcome::Rejected {
374
+ worker_error: error.to_string(),
375
+ });
376
+ observed.private_token = Some(private_token::Measurement {
377
+ outcome,
378
+ started_ms,
379
+ finished_ms: performance_clock::epoch_ms(),
380
+ });
381
+ }
382
+ Some(Operation::WorkerFetch { .. }) if profile.facts.worker_fetch_rejected => {
383
+ observed.worker_fetch = Some(worker_fetch::Measurement::Rejected);
384
+ }
385
+ Some(Operation::HostReachability { fields }) => {
386
+ // CORS rejects a response that does not allow the iframe's origin.
387
+ let origin = iframe.url.origin().ascii_serialization();
388
+ let mut outcomes = Vec::new();
389
+ for url in &fields.urls {
390
+ let url = Url::parse(url).context("parsing a host reachability URL")?;
391
+ let timer = Timer::start();
384
392
  let options = FetchOptions::NoStoreWithoutCredentials;
385
- let fetched = http::fetch_from_worker(client, iframe, &url, options).await;
386
- observed.worker_fetch = Some(match fetched {
387
- Ok(response) => worker_fetch::Measurement::Response {
388
- status: response.status().as_u16(),
389
- headers: http::text_headers(response.headers())
390
- .map(|(name, value)| (name.to_owned(), value))
391
- .collect(),
392
- },
393
- Err(_) => worker_fetch::Measurement::Rejected,
393
+ let fetched = http::fetch_from_worker(client, iframe, &url, options);
394
+ outcomes.push(match time::timeout(REACHABILITY_TIMEOUT, fetched).await {
395
+ Ok(Ok(response))
396
+ if response
397
+ .headers()
398
+ .get("access-control-allow-origin")
399
+ .and_then(|allowed| allowed.to_str().ok())
400
+ .is_some_and(|allowed| allowed == "*" || allowed == origin) =>
401
+ {
402
+ host_reachability::Outcome::Answered {
403
+ elapsed_ms: timer.elapsed_ms() as i64,
404
+ }
405
+ }
406
+ _ => host_reachability::Outcome::Rejected,
394
407
  });
395
408
  }
396
- Some(Operation::Image { fields }) => {
397
- let url = fields.url(options, &probe.input, &iframe.url)?;
398
- let timer = Timer::start();
399
- let response = http::fetch_image(client, iframe, &url).await?;
400
- let waiting_ms = timer.elapsed_ms();
401
- let ok = response.status().is_success();
402
- let (body, network) = http::read_encoded(response)
403
- .await
404
- .context("reading a challenge image")?;
405
- fetches.push(timer.phased(url.as_str(), waiting_ms, network.encoded_bytes));
406
- observed.image = Some(image::Measurement::loaded(
407
- ok.then_some(&body[..]),
408
- &profile.image.effective_type,
409
- profile.image.online,
410
- ));
411
- }
412
- _ => {}
409
+ observed.host_reachability = Some(outcomes);
413
410
  }
411
+ Some(Operation::WebSocketEcho { fields }) => {
412
+ observed.websocket_echo = Some(echo_websocket(session, fields, options).await?);
413
+ }
414
+ Some(Operation::WorkerFetch { fields }) => {
415
+ let url = fields.url(options)?;
416
+ let options = FetchOptions::NoStoreWithoutCredentials;
417
+ let fetched = http::fetch_from_worker(client, iframe, &url, options).await;
418
+ observed.worker_fetch = Some(match fetched {
419
+ Ok(response) => worker_fetch::Measurement::Response {
420
+ status: response.status().as_u16(),
421
+ headers: http::text_headers(response.headers())
422
+ .map(|(name, value)| (name.to_owned(), value))
423
+ .collect(),
424
+ },
425
+ Err(_) => worker_fetch::Measurement::Rejected,
426
+ });
427
+ }
428
+ Some(Operation::Image { fields }) => {
429
+ let url = fields.url(options, &probe.input, &iframe.url)?;
430
+ let timer = Timer::start();
431
+ let response = http::fetch_image(client, iframe, &url).await?;
432
+ let waiting_ms = timer.elapsed_ms();
433
+ let ok = response.status().is_success();
434
+ let (body, network) = http::read_encoded(response)
435
+ .await
436
+ .context("reading a challenge image")?;
437
+ fetches.push(timer.phased(url.as_str(), waiting_ms, network.encoded_bytes));
438
+ observed.image = Some(image::Measurement::loaded(
439
+ ok.then_some(&body[..]),
440
+ &profile.image.effective_type,
441
+ profile.image.online,
442
+ ));
443
+ }
444
+ _ => {}
414
445
  }
415
- Ok(fetches)
446
+ Ok(())
416
447
  }
417
448
 
418
449
  /// Builds probe records with scheduled timestamps. Stored answers use `stored` and preserve the
@@ -464,9 +495,13 @@ fn records(
464
495
  }
465
496
 
466
497
  /// Window dimensions and position already reported by the environment audit.
467
- fn window_geometry(replay: Option<&Replay<'_>>, payload: &Payload) -> BTreeMap<String, f64> {
498
+ fn window_geometry(
499
+ plan: &ProbePlan,
500
+ replay: Option<&Replay<'_>>,
501
+ payload: &Payload,
502
+ ) -> BTreeMap<String, f64> {
468
503
  let groups = replay
469
- .and_then(|replay| replay.audit_groups(payload))
504
+ .and_then(|replay| replay.audit_groups(plan, payload))
470
505
  .into_iter()
471
506
  .flatten();
472
507
  let mut geometry = BTreeMap::new();
@@ -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
+ }
@@ -79,32 +79,43 @@ pub(crate) struct Schedule {
79
79
  pub send_at: i64,
80
80
  }
81
81
 
82
- /// Schedules probes at least `startup_ms` after `arrived_ms`. Reserves one millisecond after
83
- /// each probe, then `pending_ms` before sending. The send time is no earlier than `now_ms`.
84
- /// Programs without probes wait only for startup. Uses signed durations to match record
85
- /// timestamp differences.
86
- pub(crate) fn schedule(
87
- durations: &[i64],
88
- startup_ms: i64,
89
- pending_ms: i64,
90
- arrived_ms: i64,
91
- now_ms: i64,
92
- ) -> Schedule {
93
- let span: i64 = durations.iter().map(|duration| duration + 1).sum();
94
- let busy = if durations.is_empty() {
95
- startup_ms
96
- } else {
97
- startup_ms + span + pending_ms
98
- };
99
- let send_at = now_ms.max(arrived_ms + busy);
100
- let mut start = send_at - pending_ms - span;
101
- let mut marks = Vec::with_capacity(durations.len());
102
- for &duration in durations {
103
- let end = start + duration;
104
- marks.push(ProbeMarks { start, end });
105
- start = end + 1;
82
+ /// Probe marks laid out as the probes run: in order, one millisecond apart. A probe lasts its
83
+ /// planned duration, or until the work it waits for, such as a request, ends.
84
+ pub(crate) struct Timeline {
85
+ /// When the next probe starts, in epoch milliseconds.
86
+ pub next_start: i64,
87
+ marks: Vec<ProbeMarks>,
88
+ }
89
+
90
+ impl Timeline {
91
+ #[must_use]
92
+ pub(crate) fn starting(next_start: i64) -> Self {
93
+ Self {
94
+ next_start,
95
+ marks: Vec::new(),
96
+ }
97
+ }
98
+
99
+ /// Ends the next probe `planned_ms` after it starts, or at `finished_ms` if its work ended
100
+ /// later.
101
+ pub(crate) fn finish(&mut self, planned_ms: i64, finished_ms: Option<i64>) {
102
+ let start = self.next_start;
103
+ let planned_end = start + planned_ms;
104
+ let end = finished_ms.map_or(planned_end, |finished| finished.max(planned_end));
105
+ self.marks.push(ProbeMarks { start, end });
106
+ self.next_start = end + 1;
107
+ }
108
+
109
+ /// Sends `pending_ms` after the last probe's next mark. Programs without probes send when
110
+ /// they start.
111
+ #[must_use]
112
+ pub(crate) fn schedule(self, pending_ms: i64) -> Schedule {
113
+ let pending_ms = if self.marks.is_empty() { 0 } else { pending_ms };
114
+ Schedule {
115
+ marks: self.marks,
116
+ send_at: self.next_start + pending_ms,
117
+ }
106
118
  }
107
- Schedule { marks, send_at }
108
119
  }
109
120
 
110
121
  #[cfg(test)]
@@ -112,13 +123,14 @@ mod tests {
112
123
  use super::*;
113
124
 
114
125
  #[test]
115
- fn probes_end_pending_ms_before_a_send_no_sooner_than_a_browser_could() {
116
- let schedule = schedule(&[3, 5], 400, 15, 1_000, 1_100);
117
- assert_eq!(
118
- schedule.send_at, 1_425,
119
- "400 ms startup, then 3 + 1 and 5 + 1 ms of probes, then 15 ms pending: a browser \
120
- could send 425 ms after the program arrived"
121
- );
126
+ fn probes_run_in_order_and_last_until_their_requests_end() {
127
+ let mut timeline = Timeline::starting(1_400);
128
+ timeline.finish(3, None);
129
+ // The request took longer than planned.
130
+ timeline.finish(5, Some(1_430));
131
+ // The request ended before the planned duration ran out.
132
+ timeline.finish(10, Some(1_433));
133
+ let schedule = timeline.schedule(15);
122
134
  assert_eq!(
123
135
  schedule.marks,
124
136
  [
@@ -128,35 +140,28 @@ mod tests {
128
140
  },
129
141
  ProbeMarks {
130
142
  start: 1_404,
131
- end: 1_409
143
+ end: 1_430
132
144
  },
133
- ],
134
- "the last probe's next mark is exactly `pending_ms` before sending"
145
+ ProbeMarks {
146
+ start: 1_431,
147
+ end: 1_441
148
+ },
149
+ ]
135
150
  );
136
-
137
- let late = super::schedule(&[3, 5], 400, 15, 1_000, 2_000);
138
- assert_eq!(late.send_at, 2_000);
139
151
  assert_eq!(
140
- late.marks[0].start, 1_975,
141
- "a late send moves every mark with it"
152
+ schedule.send_at, 1_457,
153
+ "the last probe's next mark is exactly `pending_ms` before sending"
142
154
  );
155
+ assert_eq!(Timeline::starting(900).schedule(15).send_at, 900);
143
156
  }
144
157
 
145
158
  #[test]
146
- fn a_program_without_probes_waits_for_its_startup_alone() {
147
- let schedule = schedule(&[], 400, 15, 1_000, 1_100);
159
+ fn signed_durations_are_kept() {
160
+ let mut timeline = Timeline::starting(0);
161
+ timeline.finish(-2, None);
148
162
  assert_eq!(
149
- schedule,
150
- Schedule {
151
- marks: Vec::new(),
152
- send_at: 1_400
153
- }
163
+ timeline.schedule(0).marks,
164
+ [ProbeMarks { start: 0, end: -2 }]
154
165
  );
155
166
  }
156
-
157
- #[test]
158
- fn signed_durations_are_kept() {
159
- let schedule = schedule(&[-2, 4], 0, 0, 0, 0);
160
- assert_eq!(schedule.marks[0].end - schedule.marks[0].start, -2);
161
- }
162
167
  }