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