cfsolve 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- 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 +7 -5
- 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/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/vendor/cfsolve/Cargo.lock +561 -1729
- data/vendor/cfsolve/Cargo.toml +26 -8
- data/vendor/cfsolve/README.md +4 -0
- 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/vm_snapshot.rs +32 -33
- 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 +23 -18
- 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 +5 -5
- 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/audit.rs +4 -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 +62 -31
- data/vendor/cfsolve/src/stage2/call_stack.rs +1415 -1025
- data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
- 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/performance.rs +12 -8
- data/vendor/cfsolve/src/stage2/queries.rs +50 -0
- data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
- data/vendor/cfsolve/src/stage2/trace.rs +134 -108
- data/vendor/cfsolve/src/stage2/vocabulary.rs +1 -11
- data/vendor/cfsolve/src/stage2.rs +2 -0
- data/vendor/cfsolve/src/vm/disassemble.rs +7 -3
- data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
- data/vendor/cfsolve/src/vm/extract.rs +347 -250
- data/vendor/cfsolve/src/vm/interpret/access.rs +63 -48
- 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 +123 -59
- 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 +1736 -0
- data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
- data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
- data/vendor/cfsolve/src/vm/interpret/run.rs +116 -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 +56 -49
- data/vendor/cfsolve/src/vm/output.rs +13 -5
- data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
- data/vendor/cfsolve/src/vm/session.rs +185 -120
- data/vendor/cfsolve/src/vm/value.rs +22 -19
- data/vendor/cfsolve/src/vm.rs +2 -1
- data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
- data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
- metadata +94 -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
|
@@ -6,19 +6,22 @@ use std::collections::{BTreeMap, HashMap};
|
|
|
6
6
|
|
|
7
7
|
use anyhow::{Context, Result, bail, ensure};
|
|
8
8
|
use indexmap::IndexMap;
|
|
9
|
-
use
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
use oxc::ast::ast::{
|
|
10
|
+
ArrowFunctionExpression, AssignmentExpression, AssignmentTarget, BindingPattern,
|
|
11
|
+
CallExpression, Expression, Function, IfStatement, MemberExpression, ObjectExpression,
|
|
12
|
+
Statement, VariableDeclarator,
|
|
13
13
|
};
|
|
14
|
-
use
|
|
14
|
+
use oxc::ast_visit::{Visit, walk};
|
|
15
|
+
use oxc::semantic::{ScopeFlags, SymbolId};
|
|
16
|
+
use oxc::syntax::operator::BinaryOperator;
|
|
17
|
+
use serde::{Deserialize, Deserializer, Serialize};
|
|
15
18
|
|
|
16
19
|
use crate::candidates;
|
|
17
20
|
use crate::challenge::payload::Field;
|
|
18
21
|
use crate::challenge::reduced_timing::{self, ResourceTiming};
|
|
19
22
|
use crate::challenge::tally::{self, CounterEvents, Tally};
|
|
20
23
|
use crate::challenge::{expression, source};
|
|
21
|
-
use crate::js::ast::{self,
|
|
24
|
+
use crate::js::ast::{self, Binding, Script};
|
|
22
25
|
use crate::js::{JsObject, JsValue, Options, Payload, json};
|
|
23
26
|
use crate::resource_timing::LoadTiming;
|
|
24
27
|
|
|
@@ -47,7 +50,7 @@ pub struct Getter {
|
|
|
47
50
|
pub option: String,
|
|
48
51
|
/// The option holding the page origin, when the getter passes each render sample's stack
|
|
49
52
|
/// through a helper that replaces URLs on that origin with indices (see
|
|
50
|
-
///
|
|
53
|
+
/// `crate::challenge::payload::split_page_urls`).
|
|
51
54
|
pub page_origin: Option<String>,
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -165,22 +168,23 @@ fn unsigned<'de, D: Deserializer<'de>>(deserializer: D) -> Result<i64, D::Error>
|
|
|
165
168
|
impl ScriptState {
|
|
166
169
|
#[cfg(test)]
|
|
167
170
|
pub(crate) fn from_javascript(javascript: &str) -> Result<Self> {
|
|
168
|
-
let parsed = ast::
|
|
169
|
-
|
|
171
|
+
let parsed = ast::ParsedScript::parse("t", javascript)?;
|
|
172
|
+
let script = parsed.script();
|
|
173
|
+
Self::from_script(script, &source::bootstrap_options(script))
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
/// Recovers the state of a parsed script, using bootstrap options to identify its payload
|
|
173
177
|
/// template.
|
|
174
|
-
pub(crate) fn
|
|
175
|
-
let script = &parsed.script;
|
|
178
|
+
pub(crate) fn from_script(script: Script<'_>, options: &Options) -> Result<Self> {
|
|
176
179
|
let mut scopes = Scopes {
|
|
180
|
+
script,
|
|
177
181
|
options,
|
|
178
182
|
stack: Vec::new(),
|
|
179
183
|
found: Vec::new(),
|
|
180
184
|
};
|
|
181
|
-
script.
|
|
182
|
-
let mut sender = Sender::
|
|
183
|
-
script.
|
|
185
|
+
scopes.visit_program(script.program);
|
|
186
|
+
let mut sender = Sender::new(script);
|
|
187
|
+
sender.visit_program(script.program);
|
|
184
188
|
let post_log = sender.post_log()?;
|
|
185
189
|
let elapsed = candidates::at_most_one_distinct(sender.elapsed, "elapsed-time field")?;
|
|
186
190
|
let sender_scope = elapsed.as_ref().map(|(scope, _)| *scope);
|
|
@@ -194,14 +198,14 @@ impl ScriptState {
|
|
|
194
198
|
collected.into_iter().map(|(_, key)| key),
|
|
195
199
|
"collected resource timing option",
|
|
196
200
|
)?;
|
|
197
|
-
let tallies =
|
|
198
|
-
tally::published_tally(function.
|
|
201
|
+
let tallies = script.in_declared_functions(|function| {
|
|
202
|
+
tally::published_tally(script, function.body.as_ref()?)
|
|
199
203
|
});
|
|
200
204
|
let counters = candidates::at_most_one_distinct(tallies, "interaction tally")?;
|
|
201
205
|
let timing = match collected {
|
|
202
206
|
Some(option) => {
|
|
203
|
-
let reductions =
|
|
204
|
-
reduced_timing::reduction(function.
|
|
207
|
+
let reductions = script.in_declared_functions(|function| {
|
|
208
|
+
reduced_timing::reduction(script, function.body.as_ref()?)
|
|
205
209
|
});
|
|
206
210
|
candidates::at_most_one_distinct(reductions, "resource timing reducer")?
|
|
207
211
|
.map(|fields| ResourceTiming { option, fields })
|
|
@@ -218,7 +222,7 @@ impl ScriptState {
|
|
|
218
222
|
elapsed: elapsed.map(|(_, elapsed)| elapsed),
|
|
219
223
|
forwarded: forwarded.into_iter().map(|(_, key)| key).collect(),
|
|
220
224
|
timing,
|
|
221
|
-
getters: distinct_getters(sender.getters, &sender.helpers)?,
|
|
225
|
+
getters: distinct_getters(script, sender.getters, &sender.helpers)?,
|
|
222
226
|
post_log,
|
|
223
227
|
})
|
|
224
228
|
}
|
|
@@ -233,22 +237,19 @@ impl ScriptState {
|
|
|
233
237
|
bail!("could not recover the iframe's input event counters: {reason}")
|
|
234
238
|
}
|
|
235
239
|
|
|
236
|
-
fn builds_payload(&self, option: &str) -> bool {
|
|
237
|
-
self.marks
|
|
238
|
-
.iter()
|
|
239
|
-
.any(|mark| mark.option == option && mark.in_builder)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
240
|
/// Identifies the interval measured by `difference`, using `merged` as the marked option.
|
|
243
241
|
/// Returns no interval if the script never marks the later timestamp.
|
|
244
242
|
fn span(&self, difference: &Difference, merged: Option<&str>) -> Option<Span> {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
// Whether any mark of the later timestamp is in the builder; `None` if it is never marked.
|
|
244
|
+
let in_builder = self
|
|
245
|
+
.marks
|
|
246
|
+
.iter()
|
|
247
|
+
.filter(|mark| mark.option == difference.later)
|
|
248
|
+
.map(|mark| mark.in_builder)
|
|
249
|
+
.max()?;
|
|
250
|
+
Some(if in_builder {
|
|
250
251
|
Span::Collect
|
|
251
|
-
} else if Some(earlier.as_str()) == merged {
|
|
252
|
+
} else if Some(difference.earlier.as_str()) == merged {
|
|
252
253
|
Span::Handoff
|
|
253
254
|
} else {
|
|
254
255
|
Span::Initialise
|
|
@@ -341,7 +342,8 @@ enum Span {
|
|
|
341
342
|
/// Groups timestamps by their innermost function and finds the function containing the payload
|
|
342
343
|
/// template. A template in a nested callback may subtract timestamps set by different
|
|
343
344
|
/// functions.
|
|
344
|
-
struct Scopes<'options> {
|
|
345
|
+
struct Scopes<'options, 'a> {
|
|
346
|
+
script: Script<'a>,
|
|
345
347
|
options: &'options Options,
|
|
346
348
|
/// The enclosing functions, innermost last.
|
|
347
349
|
stack: Vec<Scope>,
|
|
@@ -355,10 +357,10 @@ struct Scope {
|
|
|
355
357
|
builds_payload: bool,
|
|
356
358
|
}
|
|
357
359
|
|
|
358
|
-
impl Scopes<'_> {
|
|
359
|
-
fn within
|
|
360
|
+
impl Scopes<'_, '_> {
|
|
361
|
+
fn within(&mut self, walk: impl FnOnce(&mut Self)) {
|
|
360
362
|
self.stack.push(Scope::default());
|
|
361
|
-
|
|
363
|
+
walk(self);
|
|
362
364
|
let scope = self.stack.pop().expect("entered a scope first");
|
|
363
365
|
let marks = scope.marks.into_iter().map(|option| Mark {
|
|
364
366
|
option,
|
|
@@ -368,81 +370,85 @@ impl Scopes<'_> {
|
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
372
|
|
|
371
|
-
impl Visit for Scopes<'_> {
|
|
372
|
-
fn visit_function(&mut self, function: &Function) {
|
|
373
|
-
self.within(function);
|
|
373
|
+
impl<'a> Visit<'a> for Scopes<'_, 'a> {
|
|
374
|
+
fn visit_function(&mut self, function: &Function<'a>, flags: ScopeFlags) {
|
|
375
|
+
self.within(|scopes| walk::walk_function(scopes, function, flags));
|
|
374
376
|
}
|
|
375
377
|
|
|
376
|
-
fn
|
|
377
|
-
self.within(arrow);
|
|
378
|
+
fn visit_arrow_function_expression(&mut self, arrow: &ArrowFunctionExpression<'a>) {
|
|
379
|
+
self.within(|scopes| walk::walk_arrow_function_expression(scopes, arrow));
|
|
378
380
|
}
|
|
379
381
|
|
|
380
|
-
fn
|
|
382
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
381
383
|
if let Some(option) = expression::option_assignment(&assignment.left)
|
|
382
|
-
&&
|
|
384
|
+
&& self.script.is_date_now(&assignment.right)
|
|
383
385
|
&& let Some(scope) = self.stack.last_mut()
|
|
384
386
|
{
|
|
385
387
|
scope.marks.push(option.to_owned());
|
|
386
388
|
}
|
|
387
|
-
|
|
389
|
+
walk::walk_assignment_expression(self, assignment);
|
|
388
390
|
}
|
|
389
391
|
|
|
390
|
-
fn
|
|
392
|
+
fn visit_if_statement(&mut self, conditional: &IfStatement<'a>) {
|
|
391
393
|
let options = self.options;
|
|
392
394
|
source::visit_taken_branches(self, conditional, options);
|
|
393
395
|
}
|
|
394
396
|
|
|
395
|
-
fn
|
|
397
|
+
fn visit_object_expression(&mut self, object: &ObjectExpression<'a>) {
|
|
396
398
|
if source::is_payload_template(object, self.options)
|
|
397
399
|
&& let Some(scope) = self.stack.last_mut()
|
|
398
400
|
{
|
|
399
401
|
scope.builds_payload = true;
|
|
400
402
|
}
|
|
401
|
-
|
|
403
|
+
walk::walk_object_expression(self, object);
|
|
402
404
|
}
|
|
403
405
|
}
|
|
404
406
|
|
|
405
407
|
/// Finds property writes that add payload fields or install namespace getters. Records the
|
|
406
408
|
/// enclosing function for each write.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
+
struct Sender<'a> {
|
|
410
|
+
script: Script<'a>,
|
|
409
411
|
entered: usize,
|
|
410
412
|
scopes: Vec<usize>,
|
|
411
413
|
elapsed: Vec<(usize, Elapsed)>,
|
|
412
414
|
copies: Vec<(usize, String)>,
|
|
413
|
-
getters: Vec<FoundGetter
|
|
415
|
+
getters: Vec<FoundGetter<'a>>,
|
|
414
416
|
/// The first option each declared function reads, by binding.
|
|
415
|
-
helpers: HashMap<
|
|
416
|
-
pushes: Vec<Push
|
|
417
|
-
entries: Vec<LogEntry
|
|
418
|
-
stamps: Vec<Stamp
|
|
417
|
+
helpers: HashMap<SymbolId, String>,
|
|
418
|
+
pushes: Vec<Push<'a>>,
|
|
419
|
+
entries: Vec<LogEntry<'a>>,
|
|
420
|
+
stamps: Vec<Stamp<'a>>,
|
|
419
421
|
}
|
|
420
422
|
|
|
421
423
|
/// A namespace getter named `function` that returns the option `option`, rewriting each
|
|
422
424
|
/// sample's stack with the declared function `rewrite`, if any.
|
|
423
|
-
struct FoundGetter {
|
|
425
|
+
struct FoundGetter<'a> {
|
|
424
426
|
function: String,
|
|
425
427
|
option: String,
|
|
426
|
-
rewrite: Option<
|
|
428
|
+
rewrite: Option<Binding<'a>>,
|
|
427
429
|
}
|
|
428
430
|
|
|
429
431
|
/// Finds `<sample>.s = <helper>(<sample>.s)`.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
+
struct StackRewrite<'a> {
|
|
433
|
+
script: Script<'a>,
|
|
434
|
+
helper: Option<Binding<'a>>,
|
|
435
|
+
}
|
|
432
436
|
|
|
433
|
-
impl Visit for StackRewrite {
|
|
434
|
-
fn
|
|
435
|
-
if let
|
|
437
|
+
impl<'a> Visit<'a> for StackRewrite<'a> {
|
|
438
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
439
|
+
if let Some(target) = assignment.left.as_member_expression()
|
|
436
440
|
&& ast::ident_property(target) == Some("s")
|
|
437
|
-
&& let
|
|
438
|
-
&& let
|
|
439
|
-
&& let [argument] = &call.
|
|
440
|
-
&& let Some(read) = argument
|
|
441
|
+
&& let Expression::CallExpression(call) = &assignment.right
|
|
442
|
+
&& let Expression::Identifier(helper) = &call.callee
|
|
443
|
+
&& let [argument] = &call.arguments[..]
|
|
444
|
+
&& let Some(read) = argument
|
|
445
|
+
.as_expression()
|
|
446
|
+
.and_then(Expression::as_member_expression)
|
|
441
447
|
&& ast::ident_property(read) == Some("s")
|
|
442
448
|
{
|
|
443
|
-
self.
|
|
449
|
+
self.helper = Some(self.script.binding(helper));
|
|
444
450
|
}
|
|
445
|
-
|
|
451
|
+
walk::walk_assignment_expression(self, assignment);
|
|
446
452
|
}
|
|
447
453
|
}
|
|
448
454
|
|
|
@@ -450,35 +456,50 @@ impl Visit for StackRewrite {
|
|
|
450
456
|
#[derive(Default)]
|
|
451
457
|
struct OptionRead(Option<String>);
|
|
452
458
|
|
|
453
|
-
impl Visit for OptionRead {
|
|
454
|
-
fn
|
|
459
|
+
impl<'a> Visit<'a> for OptionRead {
|
|
460
|
+
fn visit_member_expression(&mut self, member: &MemberExpression<'a>) {
|
|
455
461
|
if self.0.is_none()
|
|
456
|
-
&& expression::is_options(
|
|
457
|
-
&& let Some(option) = ast::member_str(
|
|
462
|
+
&& expression::is_options(member.object())
|
|
463
|
+
&& let Some(option) = ast::member_str(member)
|
|
458
464
|
{
|
|
459
465
|
self.0 = Some(option.to_owned());
|
|
460
466
|
}
|
|
461
|
-
|
|
467
|
+
walk::walk_member_expression(self, member);
|
|
462
468
|
}
|
|
463
469
|
}
|
|
464
470
|
|
|
465
471
|
/// Matches `_cf_chl_opt.<log>.push(<local>)`.
|
|
466
|
-
struct Push {
|
|
472
|
+
struct Push<'a> {
|
|
467
473
|
log: String,
|
|
468
|
-
local:
|
|
474
|
+
local: Binding<'a>,
|
|
469
475
|
}
|
|
470
476
|
|
|
471
477
|
/// Matches `<local>.<key> = <clock>()`.
|
|
472
|
-
struct Stamp {
|
|
473
|
-
local:
|
|
478
|
+
struct Stamp<'a> {
|
|
479
|
+
local: Binding<'a>,
|
|
474
480
|
key: String,
|
|
475
481
|
}
|
|
476
482
|
|
|
477
|
-
impl Sender {
|
|
478
|
-
fn
|
|
483
|
+
impl<'a> Sender<'a> {
|
|
484
|
+
fn new(script: Script<'a>) -> Self {
|
|
485
|
+
Self {
|
|
486
|
+
script,
|
|
487
|
+
entered: 0,
|
|
488
|
+
scopes: Vec::new(),
|
|
489
|
+
elapsed: Vec::new(),
|
|
490
|
+
copies: Vec::new(),
|
|
491
|
+
getters: Vec::new(),
|
|
492
|
+
helpers: HashMap::new(),
|
|
493
|
+
pushes: Vec::new(),
|
|
494
|
+
entries: Vec::new(),
|
|
495
|
+
stamps: Vec::new(),
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
fn within(&mut self, walk: impl FnOnce(&mut Self)) {
|
|
479
500
|
self.entered += 1;
|
|
480
501
|
self.scopes.push(self.entered);
|
|
481
|
-
|
|
502
|
+
walk(self);
|
|
482
503
|
self.scopes.pop();
|
|
483
504
|
}
|
|
484
505
|
|
|
@@ -506,107 +527,114 @@ impl Sender {
|
|
|
506
527
|
|
|
507
528
|
/// Finds a local initialized with a POST log entry: `{ url: new URL(...).href, count:
|
|
508
529
|
/// _cf_chl_opt.<counter>, sent: clock() }`.
|
|
509
|
-
struct LogEntry {
|
|
510
|
-
local:
|
|
530
|
+
struct LogEntry<'a> {
|
|
531
|
+
local: Binding<'a>,
|
|
511
532
|
fields: Vec<(String, Logged)>,
|
|
512
533
|
counter: String,
|
|
513
534
|
}
|
|
514
535
|
|
|
515
|
-
impl LogEntry {
|
|
516
|
-
fn read(local:
|
|
517
|
-
let
|
|
536
|
+
impl<'a> LogEntry<'a> {
|
|
537
|
+
fn read(local: Binding<'a>, value: &Expression<'_>) -> Option<Self> {
|
|
538
|
+
let Expression::ObjectExpression(object) = value.without_parentheses() else {
|
|
518
539
|
return None;
|
|
519
540
|
};
|
|
520
541
|
let mut fields = Vec::new();
|
|
521
542
|
let mut counter = None;
|
|
522
543
|
for property in ast::key_values(object) {
|
|
523
|
-
let value = property.value.
|
|
544
|
+
let value = property.value.without_parentheses();
|
|
524
545
|
let logged = if let Some(option) = expression::option_key(value) {
|
|
525
546
|
counter = Some(option.to_owned());
|
|
526
547
|
Logged::Count
|
|
527
|
-
} else if value
|
|
548
|
+
} else if matches!(value, Expression::CallExpression(call) if call.arguments.is_empty())
|
|
549
|
+
{
|
|
528
550
|
Logged::Sent
|
|
529
|
-
} else if let
|
|
530
|
-
&& ast::member_str(
|
|
531
|
-
&&
|
|
551
|
+
} else if let Some(member) = value.as_member_expression()
|
|
552
|
+
&& ast::member_str(member) == Some("href")
|
|
553
|
+
&& matches!(
|
|
554
|
+
member.object().without_parentheses(),
|
|
555
|
+
Expression::NewExpression(_)
|
|
556
|
+
)
|
|
532
557
|
{
|
|
533
558
|
Logged::Url
|
|
534
559
|
} else {
|
|
535
560
|
return None;
|
|
536
561
|
};
|
|
537
|
-
fields.push((
|
|
562
|
+
fields.push((
|
|
563
|
+
ast::key_str(&property.key, property.computed)?.to_owned(),
|
|
564
|
+
logged,
|
|
565
|
+
));
|
|
538
566
|
}
|
|
539
567
|
let complete = fields.len() == 3
|
|
540
568
|
&& [Logged::Url, Logged::Count, Logged::Sent]
|
|
541
569
|
.iter()
|
|
542
570
|
.all(|logged| fields.iter().any(|(_, field)| field == logged));
|
|
543
571
|
complete.then_some(Self {
|
|
544
|
-
local
|
|
572
|
+
local,
|
|
545
573
|
fields,
|
|
546
574
|
counter: counter?,
|
|
547
575
|
})
|
|
548
576
|
}
|
|
549
577
|
}
|
|
550
578
|
|
|
551
|
-
impl Visit for Sender {
|
|
552
|
-
fn visit_function(&mut self, function: &Function) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
579
|
+
impl<'a> Visit<'a> for Sender<'a> {
|
|
580
|
+
fn visit_function(&mut self, function: &Function<'a>, flags: ScopeFlags) {
|
|
581
|
+
if function.is_declaration()
|
|
582
|
+
&& let Some(name) = &function.id
|
|
583
|
+
{
|
|
584
|
+
let mut read = OptionRead::default();
|
|
585
|
+
read.visit_function(function, flags);
|
|
586
|
+
if let Some(option) = read.0 {
|
|
587
|
+
self.helpers.insert(name.symbol_id(), option);
|
|
588
|
+
}
|
|
561
589
|
}
|
|
562
|
-
|
|
590
|
+
self.within(|sender| walk::walk_function(sender, function, flags));
|
|
563
591
|
}
|
|
564
592
|
|
|
565
|
-
fn
|
|
566
|
-
self.within(arrow);
|
|
593
|
+
fn visit_arrow_function_expression(&mut self, arrow: &ArrowFunctionExpression<'a>) {
|
|
594
|
+
self.within(|sender| walk::walk_arrow_function_expression(sender, arrow));
|
|
567
595
|
}
|
|
568
596
|
|
|
569
|
-
fn
|
|
570
|
-
if let
|
|
597
|
+
fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
|
|
598
|
+
if let BindingPattern::BindingIdentifier(local) = &declarator.id
|
|
571
599
|
&& let Some(init) = &declarator.init
|
|
572
|
-
&& let Some(entry) = LogEntry::read(
|
|
600
|
+
&& let Some(entry) = LogEntry::read(Binding::Symbol(local.symbol_id()), init)
|
|
573
601
|
{
|
|
574
602
|
self.entries.push(entry);
|
|
575
603
|
}
|
|
576
|
-
|
|
604
|
+
walk::walk_variable_declarator(self, declarator);
|
|
577
605
|
}
|
|
578
606
|
|
|
579
|
-
fn
|
|
607
|
+
fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
|
|
580
608
|
// `_cf_chl_opt.<log>.push(<entry>)`
|
|
581
|
-
if let Some(callee) = call.callee.
|
|
582
|
-
&& ast::member_str(
|
|
583
|
-
&& let Some(option) = expression::option_key(
|
|
584
|
-
&& let [entry] = &call.
|
|
585
|
-
&& let Some(local) = entry.
|
|
609
|
+
if let Some(callee) = call.callee.as_member_expression()
|
|
610
|
+
&& ast::member_str(callee) == Some("push")
|
|
611
|
+
&& let Some(option) = expression::option_key(callee.object())
|
|
612
|
+
&& let [entry] = &call.arguments[..]
|
|
613
|
+
&& let Some(Expression::Identifier(local)) = entry.as_expression()
|
|
586
614
|
{
|
|
587
615
|
self.pushes.push(Push {
|
|
588
616
|
log: option.to_owned(),
|
|
589
|
-
local:
|
|
617
|
+
local: self.script.binding(local),
|
|
590
618
|
});
|
|
591
619
|
}
|
|
592
|
-
|
|
620
|
+
walk::walk_call_expression(self, call);
|
|
593
621
|
}
|
|
594
622
|
|
|
595
|
-
fn
|
|
623
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
596
624
|
let scope = self.scopes.last().copied().unwrap_or_default();
|
|
597
|
-
if let
|
|
598
|
-
&& let Some(entry) = LogEntry::read(
|
|
625
|
+
if let AssignmentTarget::AssignmentTargetIdentifier(local) = &assignment.left
|
|
626
|
+
&& let Some(entry) = LogEntry::read(self.script.binding(local), &assignment.right)
|
|
599
627
|
{
|
|
600
628
|
self.entries.push(entry);
|
|
601
629
|
}
|
|
602
|
-
if let
|
|
630
|
+
if let Some(target) = assignment.left.as_member_expression()
|
|
603
631
|
&& let Some(key) = ast::ident_property(target)
|
|
604
632
|
{
|
|
605
|
-
match
|
|
633
|
+
match &assignment.right {
|
|
606
634
|
// `payload.<key> = Date.now() - _cf_chl_opt.<mark>`
|
|
607
|
-
|
|
608
|
-
if binary.
|
|
609
|
-
&&
|
|
635
|
+
Expression::BinaryExpression(binary)
|
|
636
|
+
if binary.operator == BinaryOperator::Subtraction
|
|
637
|
+
&& self.script.is_date_now(&binary.left)
|
|
610
638
|
&& let Some(mark) = expression::option_key(&binary.right) =>
|
|
611
639
|
{
|
|
612
640
|
let elapsed = Elapsed {
|
|
@@ -616,18 +644,24 @@ impl Visit for Sender {
|
|
|
616
644
|
self.elapsed.push((scope, elapsed));
|
|
617
645
|
}
|
|
618
646
|
// `<namespace>.<key> = function () { var ...; local = _cf_chl_opt.<option>; ... }`
|
|
619
|
-
|
|
620
|
-
if let Some(body) = &getter.
|
|
621
|
-
&& let Some(first) =
|
|
622
|
-
|
|
647
|
+
Expression::FunctionExpression(getter)
|
|
648
|
+
if let Some(body) = &getter.body
|
|
649
|
+
&& let Some(Statement::ExpressionStatement(first)) =
|
|
650
|
+
body.statements.iter().find(|statement| {
|
|
651
|
+
matches!(statement, Statement::ExpressionStatement(_))
|
|
652
|
+
})
|
|
653
|
+
&& let Expression::AssignmentExpression(first) = &first.expression
|
|
623
654
|
&& let Some(option) = expression::option_key(&first.right) =>
|
|
624
655
|
{
|
|
625
|
-
let mut rewrite = StackRewrite
|
|
626
|
-
|
|
656
|
+
let mut rewrite = StackRewrite {
|
|
657
|
+
script: self.script,
|
|
658
|
+
helper: None,
|
|
659
|
+
};
|
|
660
|
+
rewrite.visit_function(getter, ScopeFlags::Function);
|
|
627
661
|
self.getters.push(FoundGetter {
|
|
628
662
|
function: key.to_owned(),
|
|
629
663
|
option: option.to_owned(),
|
|
630
|
-
rewrite: rewrite.
|
|
664
|
+
rewrite: rewrite.helper,
|
|
631
665
|
});
|
|
632
666
|
}
|
|
633
667
|
// `payload.<key> = _cf_chl_opt.<key>`
|
|
@@ -635,27 +669,28 @@ impl Visit for Sender {
|
|
|
635
669
|
self.copies.push((scope, key.to_owned()));
|
|
636
670
|
}
|
|
637
671
|
// `entry.<key> = clock()`
|
|
638
|
-
|
|
639
|
-
if call.
|
|
640
|
-
&& let
|
|
672
|
+
Expression::CallExpression(call)
|
|
673
|
+
if call.arguments.is_empty()
|
|
674
|
+
&& let Expression::Identifier(local) = target.object() =>
|
|
641
675
|
{
|
|
642
676
|
self.stamps.push(Stamp {
|
|
643
|
-
local:
|
|
677
|
+
local: self.script.binding(local),
|
|
644
678
|
key: key.to_owned(),
|
|
645
679
|
});
|
|
646
680
|
}
|
|
647
681
|
_ => {}
|
|
648
682
|
}
|
|
649
683
|
}
|
|
650
|
-
|
|
684
|
+
walk::walk_assignment_expression(self, assignment);
|
|
651
685
|
}
|
|
652
686
|
}
|
|
653
687
|
|
|
654
688
|
/// Resolves each getter's stack rewrite to the option its helper reads. Rejects a getter name
|
|
655
689
|
/// that returns different options.
|
|
656
690
|
fn distinct_getters(
|
|
657
|
-
|
|
658
|
-
|
|
691
|
+
script: Script<'_>,
|
|
692
|
+
getters: Vec<FoundGetter<'_>>,
|
|
693
|
+
helpers: &HashMap<SymbolId, String>,
|
|
659
694
|
) -> Result<BTreeMap<String, Getter>> {
|
|
660
695
|
let mut distinct = BTreeMap::new();
|
|
661
696
|
for found in getters {
|
|
@@ -663,11 +698,13 @@ fn distinct_getters(
|
|
|
663
698
|
let page_origin = found
|
|
664
699
|
.rewrite
|
|
665
700
|
.map(|helper| {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
701
|
+
let declared = match helper {
|
|
702
|
+
Binding::Symbol(symbol) => helpers.get(&symbol),
|
|
703
|
+
Binding::Global(_) => None,
|
|
704
|
+
};
|
|
705
|
+
declared.cloned().with_context(|| {
|
|
706
|
+
let name = script.name(helper);
|
|
707
|
+
format!("getter {function} rewrites stacks with unknown helper {name}")
|
|
671
708
|
})
|
|
672
709
|
})
|
|
673
710
|
.transpose()?;
|
|
@@ -797,12 +834,7 @@ mod tests {
|
|
|
797
834
|
.enumerate()
|
|
798
835
|
.map(|(index, (later, earlier))| {
|
|
799
836
|
let text = format!("e._cf_chl_opt.{later} - e._cf_chl_opt.{earlier}");
|
|
800
|
-
Field
|
|
801
|
-
name: format!("f{index}"),
|
|
802
|
-
expression: ast::parse_expression("t", &text).unwrap(),
|
|
803
|
-
text,
|
|
804
|
-
bootstrap_value: None,
|
|
805
|
-
}
|
|
837
|
+
Field::parse(format!("f{index}"), text, None).unwrap()
|
|
806
838
|
})
|
|
807
839
|
.collect();
|
|
808
840
|
let intervals = &Intervals {
|