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,13 +2,16 @@
|
|
|
2
2
|
//! randomly named `_cf_chl_opt` options.
|
|
3
3
|
|
|
4
4
|
use anyhow::{Context, Result};
|
|
5
|
-
use
|
|
6
|
-
|
|
5
|
+
use oxc::ast::ast::{
|
|
6
|
+
AssignmentTarget, BindingPattern, CallExpression, Expression, FormalParameter, Function,
|
|
7
|
+
IdentifierReference, Statement,
|
|
7
8
|
};
|
|
8
|
-
use
|
|
9
|
+
use oxc::ast_visit::{Visit, walk};
|
|
10
|
+
use oxc::semantic::SymbolId;
|
|
11
|
+
use oxc::syntax::operator::{LogicalOperator, UnaryOperator};
|
|
9
12
|
|
|
10
13
|
use crate::challenge::expression;
|
|
11
|
-
use crate::js::ast::{self,
|
|
14
|
+
use crate::js::ast::{self, Binding, Script};
|
|
12
15
|
use crate::js::{JsValue, Options, json};
|
|
13
16
|
use crate::{candidates, js};
|
|
14
17
|
|
|
@@ -48,18 +51,19 @@ pub struct Mapping(pub Vec<OptionEntry>);
|
|
|
48
51
|
impl Mapping {
|
|
49
52
|
#[cfg(test)]
|
|
50
53
|
pub(crate) fn from_javascript(source: &str) -> Result<Self> {
|
|
51
|
-
Self::
|
|
54
|
+
Self::from_script(ast::ParsedScript::parse("t", source)?.script())
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
pub(crate) fn
|
|
55
|
-
let merges =
|
|
57
|
+
pub(crate) fn from_script(script: Script<'_>) -> Result<Self> {
|
|
58
|
+
let merges = script.in_declared_functions(|function| merge_function(script, function));
|
|
56
59
|
let merge =
|
|
57
60
|
candidates::exactly_one(merges, "function merging the embedding page's parameters")?;
|
|
58
61
|
let mut calls = Calls {
|
|
62
|
+
script,
|
|
59
63
|
merge: &merge,
|
|
60
64
|
roles: Vec::new(),
|
|
61
65
|
};
|
|
62
|
-
|
|
66
|
+
calls.visit_program(script.program);
|
|
63
67
|
let roles = candidates::at_most_one_distinct(calls.roles, "merge call arguments")?
|
|
64
68
|
.context("could not find where the merge is called")?;
|
|
65
69
|
let entries = merge.writes.into_iter().map(|write| write.entry(&roles));
|
|
@@ -199,20 +203,23 @@ enum Role {
|
|
|
199
203
|
|
|
200
204
|
/// A candidate merge function.
|
|
201
205
|
struct Merge {
|
|
202
|
-
|
|
206
|
+
function: SymbolId,
|
|
203
207
|
arity: usize,
|
|
204
208
|
writes: Vec<OptionWrite>,
|
|
205
209
|
}
|
|
206
210
|
|
|
207
211
|
/// A function declaration that writes enough options from parameter fields to be the merge.
|
|
208
|
-
fn merge_function(function: &
|
|
209
|
-
let writes = writes(function);
|
|
212
|
+
fn merge_function(script: Script<'_>, function: &Function<'_>) -> Option<Merge> {
|
|
213
|
+
let writes = writes(script, function);
|
|
210
214
|
let fields = writes
|
|
211
215
|
.iter()
|
|
212
216
|
.filter(|write| matches!(write.value, Written::Field { key: Some(_), .. }));
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
if fields.count() < MINIMUM_FIELDS {
|
|
218
|
+
return None;
|
|
219
|
+
}
|
|
220
|
+
Some(Merge {
|
|
221
|
+
function: function.id.as_ref()?.symbol_id(),
|
|
222
|
+
arity: function.params.parameters_count(),
|
|
216
223
|
writes,
|
|
217
224
|
})
|
|
218
225
|
}
|
|
@@ -220,22 +227,25 @@ fn merge_function(function: &FnDecl) -> Option<Merge> {
|
|
|
220
227
|
/// Identifies arguments in merge calls that pass the message exactly once and have no unknown
|
|
221
228
|
/// arguments. Calls that deliver the message also pass its origin. Other calls use stored local
|
|
222
229
|
/// variables; treating them as message delivery would produce incorrect field mappings.
|
|
223
|
-
struct Calls<'merge> {
|
|
230
|
+
struct Calls<'merge, 'a> {
|
|
231
|
+
script: Script<'a>,
|
|
224
232
|
merge: &'merge Merge,
|
|
225
233
|
roles: Vec<Vec<Role>>,
|
|
226
234
|
}
|
|
227
235
|
|
|
228
|
-
impl Visit for Calls<'_> {
|
|
229
|
-
fn
|
|
230
|
-
if
|
|
231
|
-
&&
|
|
232
|
-
&& ident.sym == *self.merge.name
|
|
233
|
-
&& call.args.len() == self.merge.arity
|
|
236
|
+
impl<'a> Visit<'a> for Calls<'_, 'a> {
|
|
237
|
+
fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
|
|
238
|
+
if self.script.refers_to(&call.callee, self.merge.function)
|
|
239
|
+
&& call.arguments.len() == self.merge.arity
|
|
234
240
|
{
|
|
235
241
|
let roles: Vec<Role> = call
|
|
236
|
-
.
|
|
242
|
+
.arguments
|
|
237
243
|
.iter()
|
|
238
|
-
.map(|argument|
|
|
244
|
+
.map(|argument| {
|
|
245
|
+
argument
|
|
246
|
+
.as_expression()
|
|
247
|
+
.map_or(Role::Unknown, |argument| role(self.script, argument))
|
|
248
|
+
})
|
|
239
249
|
.collect();
|
|
240
250
|
if roles.iter().filter(|role| **role == Role::Message).count() == 1
|
|
241
251
|
&& !roles.contains(&Role::Unknown)
|
|
@@ -243,21 +253,26 @@ impl Visit for Calls<'_> {
|
|
|
243
253
|
self.roles.push(roles);
|
|
244
254
|
}
|
|
245
255
|
}
|
|
246
|
-
|
|
256
|
+
walk::walk_call_expression(self, call);
|
|
247
257
|
}
|
|
248
258
|
}
|
|
249
259
|
|
|
250
|
-
fn role(expression: &
|
|
260
|
+
fn role(script: Script<'_>, expression: &Expression<'_>) -> Role {
|
|
251
261
|
match expression {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
key,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
262
|
+
Expression::Identifier(_) => Role::Message,
|
|
263
|
+
Expression::LogicalExpression(logical) if logical.operator == LogicalOperator::Or => {
|
|
264
|
+
match role(script, &logical.left) {
|
|
265
|
+
Role::Field { key, .. } => Role::Field {
|
|
266
|
+
key,
|
|
267
|
+
fallback: expression::static_value(script, &logical.right, &Options::new()),
|
|
268
|
+
},
|
|
269
|
+
other => other,
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
_ => match expression
|
|
273
|
+
.as_member_expression()
|
|
274
|
+
.and_then(ast::ident_property)
|
|
275
|
+
{
|
|
261
276
|
Some("origin") => Role::Origin,
|
|
262
277
|
Some(key) => Role::Field {
|
|
263
278
|
key: key.to_owned(),
|
|
@@ -269,48 +284,58 @@ fn role(expression: &Expr) -> Role {
|
|
|
269
284
|
}
|
|
270
285
|
|
|
271
286
|
/// Every `_cf_chl_opt.<name> = ...` in a function's own body.
|
|
272
|
-
fn writes(function: &
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
287
|
+
fn writes(script: Script<'_>, function: &Function<'_>) -> Vec<OptionWrite> {
|
|
288
|
+
// Destructured, defaulted, and rest parameters have no single binding.
|
|
289
|
+
let plain = |parameter: &FormalParameter<'_>| match ¶meter.pattern {
|
|
290
|
+
BindingPattern::BindingIdentifier(name) if parameter.initializer.is_none() => {
|
|
291
|
+
Some(name.symbol_id())
|
|
292
|
+
}
|
|
293
|
+
_ => None,
|
|
294
|
+
};
|
|
295
|
+
let mut parameters: Vec<Option<SymbolId>> = function.params.items.iter().map(plain).collect();
|
|
296
|
+
if function.params.rest.is_some() {
|
|
297
|
+
parameters.push(None);
|
|
298
|
+
}
|
|
299
|
+
let Some(body) = &function.body else {
|
|
280
300
|
return Vec::new();
|
|
281
301
|
};
|
|
282
302
|
// Some options pass through a local so stored browser state can override them before they
|
|
283
303
|
// are written back.
|
|
284
|
-
let mut staged: Vec<(
|
|
304
|
+
let mut staged: Vec<(Binding, &str)> = Vec::new();
|
|
285
305
|
let mut writes = Vec::new();
|
|
286
|
-
for statement in &body.
|
|
287
|
-
if let Some(write) = sampled(statement, ¶meters) {
|
|
306
|
+
for statement in &body.statements {
|
|
307
|
+
if let Some(write) = sampled(script, statement, ¶meters) {
|
|
288
308
|
writes.push(write);
|
|
289
309
|
continue;
|
|
290
310
|
}
|
|
291
|
-
if let
|
|
292
|
-
staged.extend(declaration.
|
|
293
|
-
let local =
|
|
294
|
-
|
|
311
|
+
if let Statement::VariableDeclaration(declaration) = statement {
|
|
312
|
+
staged.extend(declaration.declarations.iter().filter_map(|declarator| {
|
|
313
|
+
let BindingPattern::BindingIdentifier(local) = &declarator.id else {
|
|
314
|
+
return None;
|
|
315
|
+
};
|
|
316
|
+
let option = expression::option_key(declarator.init.as_ref()?)?;
|
|
317
|
+
Some((Binding::Symbol(local.symbol_id()), option))
|
|
295
318
|
}));
|
|
296
319
|
continue;
|
|
297
320
|
}
|
|
298
321
|
let Some(assignment) = expression::assignment(statement) else {
|
|
299
322
|
continue;
|
|
300
323
|
};
|
|
301
|
-
if let
|
|
324
|
+
if let AssignmentTarget::AssignmentTargetIdentifier(local) = &assignment.left
|
|
302
325
|
&& let Some(option) = expression::option_key(&assignment.right)
|
|
303
326
|
{
|
|
304
|
-
staged.push((
|
|
327
|
+
staged.push((script.binding(local), option));
|
|
305
328
|
continue;
|
|
306
329
|
}
|
|
307
330
|
let Some(option) = expression::option_assignment(&assignment.left).map(str::to_owned)
|
|
308
331
|
else {
|
|
309
332
|
continue;
|
|
310
333
|
};
|
|
311
|
-
let (mut value, default) = read(&assignment.right, ¶meters);
|
|
312
|
-
if let (Written::Other,
|
|
313
|
-
&& let Some((_, from)) = staged
|
|
334
|
+
let (mut value, default) = read(script, &assignment.right, ¶meters);
|
|
335
|
+
if let (Written::Other, Expression::Identifier(ident)) = (&value, &assignment.right)
|
|
336
|
+
&& let Some((_, from)) = staged
|
|
337
|
+
.iter()
|
|
338
|
+
.rfind(|(local, _)| *local == script.binding(ident))
|
|
314
339
|
{
|
|
315
340
|
value = Written::Copied((*from).to_owned());
|
|
316
341
|
}
|
|
@@ -325,18 +350,23 @@ fn writes(function: &FnDecl) -> Vec<OptionWrite> {
|
|
|
325
350
|
|
|
326
351
|
/// Recognizes the first sample copy: `if (!_cf_chl_opt.<option>.length) {
|
|
327
352
|
/// copy(<parameter>.<key>); }`.
|
|
328
|
-
fn sampled(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
&& let
|
|
335
|
-
&&
|
|
336
|
-
&& let
|
|
337
|
-
&&
|
|
338
|
-
&& let
|
|
339
|
-
&& let (
|
|
353
|
+
fn sampled(
|
|
354
|
+
script: Script<'_>,
|
|
355
|
+
statement: &Statement<'_>,
|
|
356
|
+
parameters: &[Option<SymbolId>],
|
|
357
|
+
) -> Option<OptionWrite> {
|
|
358
|
+
if let Statement::IfStatement(branch) = statement
|
|
359
|
+
&& let Expression::UnaryExpression(test) = &branch.test
|
|
360
|
+
&& test.operator == UnaryOperator::LogicalNot
|
|
361
|
+
&& let Some(length) = test.argument.as_member_expression()
|
|
362
|
+
&& ast::member_str(length) == Some("length")
|
|
363
|
+
&& let Some(option) = expression::option_key(length.object())
|
|
364
|
+
&& let Statement::BlockStatement(block) = &branch.consequent
|
|
365
|
+
&& let [Statement::ExpressionStatement(copy)] = &block.body[..]
|
|
366
|
+
&& let Expression::CallExpression(copy) = ©.expression
|
|
367
|
+
&& let [argument] = ©.arguments[..]
|
|
368
|
+
&& let Some(argument) = argument.as_expression()
|
|
369
|
+
&& let (Written::Field { parameter, key }, _) = read(script, argument, parameters)
|
|
340
370
|
&& let Some(key) = key
|
|
341
371
|
{
|
|
342
372
|
Some(OptionWrite {
|
|
@@ -368,26 +398,36 @@ fn samples(entries: Option<&JsValue>) -> JsValue {
|
|
|
368
398
|
}
|
|
369
399
|
|
|
370
400
|
/// Resolves `expression` and its literal fallback for falsy values.
|
|
371
|
-
fn read(
|
|
372
|
-
|
|
373
|
-
|
|
401
|
+
fn read(
|
|
402
|
+
script: Script<'_>,
|
|
403
|
+
expression: &Expression<'_>,
|
|
404
|
+
parameters: &[Option<SymbolId>],
|
|
405
|
+
) -> (Written, Option<JsValue>) {
|
|
406
|
+
let field = |name: &IdentifierReference<'_>, key: Option<&str>| {
|
|
407
|
+
let symbol = script.symbol(name)?;
|
|
408
|
+
let parameter = parameters
|
|
409
|
+
.iter()
|
|
410
|
+
.position(|parameter| *parameter == Some(symbol))?;
|
|
374
411
|
let key = key.map(str::to_owned);
|
|
375
412
|
Some(Written::Field { parameter, key })
|
|
376
413
|
};
|
|
377
414
|
let written = match expression {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
415
|
+
Expression::ParenthesizedExpression(paren) => {
|
|
416
|
+
return read(script, &paren.expression, parameters);
|
|
417
|
+
}
|
|
418
|
+
Expression::LogicalExpression(logical) if logical.operator == LogicalOperator::Or => {
|
|
419
|
+
let (written, _) = read(script, &logical.left, parameters);
|
|
420
|
+
let fallback = expression::static_value(script, &logical.right, &Options::new());
|
|
382
421
|
return (written, fallback);
|
|
383
422
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
423
|
+
Expression::Identifier(ident) => field(ident, None),
|
|
424
|
+
Expression::CallExpression(_) if script.is_date_now(expression) => Some(Written::Now),
|
|
425
|
+
_ => expression.as_member_expression().and_then(|member| {
|
|
426
|
+
match (member.object(), ast::member_str(member)) {
|
|
427
|
+
(Expression::Identifier(object), Some(key)) => field(object, Some(key)),
|
|
428
|
+
_ => None,
|
|
429
|
+
}
|
|
430
|
+
}),
|
|
391
431
|
};
|
|
392
432
|
(written.unwrap_or(Written::Other), None)
|
|
393
433
|
}
|
|
@@ -8,13 +8,18 @@
|
|
|
8
8
|
use std::collections::BTreeSet;
|
|
9
9
|
|
|
10
10
|
use anyhow::{Context, Result};
|
|
11
|
-
use
|
|
12
|
-
|
|
11
|
+
use oxc::ast::ast::{
|
|
12
|
+
AssignmentExpression, BinaryExpression, CallExpression, Expression, MemberExpression,
|
|
13
|
+
};
|
|
14
|
+
use oxc::ast_visit::{Visit, walk};
|
|
15
|
+
use oxc::semantic::{ScopeFlags, SymbolId};
|
|
16
|
+
use oxc::syntax::operator::BinaryOperator;
|
|
13
17
|
use url::Url;
|
|
14
18
|
|
|
15
19
|
use crate::candidates;
|
|
16
20
|
use crate::challenge::{expression, source};
|
|
17
|
-
use crate::js::{
|
|
21
|
+
use crate::js::ast::{self, ParsedScript, Script};
|
|
22
|
+
use crate::js::{JsValue, Options};
|
|
18
23
|
use crate::script::Source;
|
|
19
24
|
|
|
20
25
|
/// The orchestrator is served from this path prefix of the challenge page's origin.
|
|
@@ -47,8 +52,9 @@ impl ChallengePage {
|
|
|
47
52
|
let Ok(inline) = source::inline_javascript(html) else {
|
|
48
53
|
return Ok(None);
|
|
49
54
|
};
|
|
50
|
-
let parsed =
|
|
51
|
-
let
|
|
55
|
+
let parsed = ParsedScript::parse("challenge page", &inline)?;
|
|
56
|
+
let script = parsed.script();
|
|
57
|
+
let literals = ast::string_literals(|literals| literals.visit_program(script.program));
|
|
52
58
|
let Some(orchestrator) = candidates::at_most_one_distinct(
|
|
53
59
|
literals.iter().filter(|text| {
|
|
54
60
|
text.starts_with("/cdn-cgi/challenge-platform/") && text.contains(ORCHESTRATOR)
|
|
@@ -63,7 +69,7 @@ impl ChallengePage {
|
|
|
63
69
|
"loading address",
|
|
64
70
|
)?
|
|
65
71
|
.context("challenge page shows no loading address")?;
|
|
66
|
-
let answered = source::bootstrap_options(
|
|
72
|
+
let answered = source::bootstrap_options(script)
|
|
67
73
|
.get(ANSWERED)
|
|
68
74
|
.and_then(JsValue::as_str)
|
|
69
75
|
.map(|address| url.join(address))
|
|
@@ -90,57 +96,65 @@ impl ChallengePage {
|
|
|
90
96
|
/// it. These checks are all false on a top-level challenge page.
|
|
91
97
|
#[must_use]
|
|
92
98
|
pub(crate) fn frame_options(source: &Source, options: &Options) -> Options {
|
|
93
|
-
let script =
|
|
94
|
-
let readers =
|
|
95
|
-
|
|
99
|
+
let script = source.script();
|
|
100
|
+
let readers = script.in_declared_functions(|function| {
|
|
101
|
+
let mut read = TopRead(false);
|
|
102
|
+
read.visit_function(function, ScopeFlags::Function);
|
|
103
|
+
function
|
|
104
|
+
.id
|
|
105
|
+
.as_ref()
|
|
106
|
+
.filter(|_| read.0)
|
|
107
|
+
.map(|id| id.symbol_id())
|
|
96
108
|
});
|
|
97
109
|
let mut framing = Framing {
|
|
110
|
+
script,
|
|
98
111
|
readers: &readers,
|
|
99
112
|
options,
|
|
100
113
|
found: Options::new(),
|
|
101
114
|
};
|
|
102
|
-
script.
|
|
115
|
+
framing.visit_program(script.program);
|
|
103
116
|
framing.found
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
/// Whether a node reads a `top` property.
|
|
107
|
-
fn reads_top(node: &impl VisitWith<TopRead>) -> bool {
|
|
108
|
-
let mut read = TopRead(false);
|
|
109
|
-
node.visit_with(&mut read);
|
|
110
|
-
read.0
|
|
111
|
-
}
|
|
112
|
-
|
|
113
120
|
struct TopRead(bool);
|
|
114
121
|
|
|
115
|
-
impl Visit for TopRead {
|
|
116
|
-
fn
|
|
117
|
-
self.0 |= ast::member_str(
|
|
118
|
-
|
|
122
|
+
impl<'a> Visit<'a> for TopRead {
|
|
123
|
+
fn visit_member_expression(&mut self, member: &MemberExpression<'a>) {
|
|
124
|
+
self.0 |= ast::member_str(member) == Some("top");
|
|
125
|
+
walk::walk_member_expression(self, member);
|
|
119
126
|
}
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
/// Assigns `false` to unset options whose value reads `top` or calls a declared function that
|
|
123
130
|
/// does.
|
|
124
|
-
struct Framing<'known> {
|
|
125
|
-
|
|
131
|
+
struct Framing<'known, 'a> {
|
|
132
|
+
script: Script<'a>,
|
|
133
|
+
readers: &'known [SymbolId],
|
|
126
134
|
options: &'known Options,
|
|
127
135
|
found: Options,
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
impl Visit for Framing<'_> {
|
|
131
|
-
fn
|
|
138
|
+
impl<'a> Visit<'a> for Framing<'_, 'a> {
|
|
139
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
132
140
|
if let Some(option) = expression::option_assignment(&assignment.left)
|
|
133
141
|
&& !self.options.contains_key(option)
|
|
134
142
|
{
|
|
135
|
-
let value = assignment.right.
|
|
143
|
+
let value = assignment.right.without_parentheses();
|
|
136
144
|
let calls_reader = ast::direct_call(value).is_some_and(|(name, arguments)| {
|
|
137
|
-
arguments.is_empty()
|
|
145
|
+
arguments.is_empty()
|
|
146
|
+
&& self
|
|
147
|
+
.script
|
|
148
|
+
.symbol(name)
|
|
149
|
+
.is_some_and(|reader| self.readers.contains(&reader))
|
|
138
150
|
});
|
|
139
|
-
|
|
151
|
+
let mut read = TopRead(false);
|
|
152
|
+
read.visit_expression(value);
|
|
153
|
+
if calls_reader || read.0 {
|
|
140
154
|
self.found.insert(option.to_owned(), JsValue::Bool(false));
|
|
141
155
|
}
|
|
142
156
|
}
|
|
143
|
-
|
|
157
|
+
walk::walk_assignment_expression(self, assignment);
|
|
144
158
|
}
|
|
145
159
|
}
|
|
146
160
|
|
|
@@ -153,7 +167,7 @@ pub(crate) fn loader_url(source: &Source, options: &Options) -> Result<Url> {
|
|
|
153
167
|
paths: Vec::new(),
|
|
154
168
|
hosts: BTreeSet::new(),
|
|
155
169
|
};
|
|
156
|
-
|
|
170
|
+
found.visit_program(source.script().program);
|
|
157
171
|
let build = candidates::exactly_one(found.builds, "loader build")?;
|
|
158
172
|
let host = candidates::exactly_one(found.hosts, "loader host")?;
|
|
159
173
|
let paths: BTreeSet<String> = found
|
|
@@ -182,9 +196,9 @@ struct Loader<'options> {
|
|
|
182
196
|
|
|
183
197
|
impl Loader<'_> {
|
|
184
198
|
/// Returns the operands of a `+` chain from left to right.
|
|
185
|
-
fn operands<'e>(expression: &'e
|
|
186
|
-
match expression.
|
|
187
|
-
|
|
199
|
+
fn operands<'e, 'a>(expression: &'e Expression<'a>, out: &mut Vec<&'e Expression<'a>>) {
|
|
200
|
+
match expression.without_parentheses() {
|
|
201
|
+
Expression::BinaryExpression(binary) if binary.operator == BinaryOperator::Addition => {
|
|
188
202
|
Self::operands(&binary.left, out);
|
|
189
203
|
Self::operands(&binary.right, out);
|
|
190
204
|
}
|
|
@@ -192,7 +206,7 @@ impl Loader<'_> {
|
|
|
192
206
|
}
|
|
193
207
|
}
|
|
194
208
|
|
|
195
|
-
fn option(&self, operand: &
|
|
209
|
+
fn option(&self, operand: &Expression<'_>) -> Option<String> {
|
|
196
210
|
self.options
|
|
197
211
|
.get(expression::option_key(operand)?)?
|
|
198
212
|
.as_str()
|
|
@@ -200,22 +214,21 @@ impl Loader<'_> {
|
|
|
200
214
|
}
|
|
201
215
|
}
|
|
202
216
|
|
|
203
|
-
impl Visit for Loader<'_> {
|
|
204
|
-
fn
|
|
217
|
+
impl<'a> Visit<'a> for Loader<'_> {
|
|
218
|
+
fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
|
|
205
219
|
// `(zeros + number.toString(16)).slice(-width)`.
|
|
206
|
-
if let
|
|
207
|
-
&&
|
|
208
|
-
&&
|
|
209
|
-
&& let Expr::Bin(sum) = slice.obj.unwrap_parens()
|
|
220
|
+
if let Some(slice) = call.callee.without_parentheses().as_member_expression()
|
|
221
|
+
&& ast::member_str(slice) == Some("slice")
|
|
222
|
+
&& let Expression::BinaryExpression(sum) = slice.object().without_parentheses()
|
|
210
223
|
&& let Some(build) = expression::padded_build(sum)
|
|
211
224
|
{
|
|
212
225
|
self.builds.insert(build);
|
|
213
226
|
}
|
|
214
|
-
|
|
227
|
+
walk::walk_call_expression(self, call);
|
|
215
228
|
}
|
|
216
229
|
|
|
217
|
-
fn
|
|
218
|
-
if binary.
|
|
230
|
+
fn visit_binary_expression(&mut self, binary: &BinaryExpression<'a>) {
|
|
231
|
+
if binary.operator == BinaryOperator::Addition {
|
|
219
232
|
let mut operands = Vec::new();
|
|
220
233
|
Self::operands(&binary.left, &mut operands);
|
|
221
234
|
Self::operands(&binary.right, &mut operands);
|
|
@@ -228,7 +241,7 @@ impl Visit for Loader<'_> {
|
|
|
228
241
|
.iter()
|
|
229
242
|
.map(|operand| match (ast::static_str(operand), operand) {
|
|
230
243
|
(Some(text), _) => Some(Some(text.to_owned())),
|
|
231
|
-
(None,
|
|
244
|
+
(None, Expression::Identifier(_)) => Some(None),
|
|
232
245
|
(None, _) => self.option(operand).map(Some),
|
|
233
246
|
})
|
|
234
247
|
.collect();
|
|
@@ -246,7 +259,7 @@ impl Visit for Loader<'_> {
|
|
|
246
259
|
self.hosts.insert(host);
|
|
247
260
|
}
|
|
248
261
|
}
|
|
249
|
-
|
|
262
|
+
walk::walk_binary_expression(self, binary);
|
|
250
263
|
}
|
|
251
264
|
}
|
|
252
265
|
|