cfsolve 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +10 -9
- 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 +10 -8
- 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 +2570 -1894
- data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +1867 -1192
- data/lib/cfsolve/profiles/safari-26-ios.json +102 -156
- 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 -35
- data/vendor/cfsolve/examples/build_profile.rs +17 -15
- data/vendor/cfsolve/examples/capture_session.rs +37 -0
- data/vendor/cfsolve/examples/check_answers.rs +66 -0
- data/vendor/cfsolve/examples/compare_session.rs +189 -0
- 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 +6 -3
- 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 +2570 -1894
- data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +1867 -1192
- data/vendor/cfsolve/profiles/safari-26-ios.json +102 -156
- data/vendor/cfsolve/scripts/capture_cssom.mjs +42 -0
- data/vendor/cfsolve/scripts/serve_cssom.py +111 -0
- 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/profile.rs +7 -18
- data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
- data/vendor/cfsolve/src/capture/proxy.rs +44 -13
- data/vendor/cfsolve/src/capture/recorded.rs +42 -7
- 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 +132 -0
- data/vendor/cfsolve/src/challenge/installed.rs +127 -269
- 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 +175 -35
- 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 +236 -122
- 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 +201 -205
- data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
- data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +346 -536
- 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 +361 -322
- 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 -32
- data/vendor/cfsolve/src/embedding_page/page.rs +28 -2
- 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 +9 -1
- data/vendor/cfsolve/src/http/requests.rs +2 -2
- data/vendor/cfsolve/src/js/ast.rs +479 -254
- data/vendor/cfsolve/src/js/objects.rs +9 -2
- data/vendor/cfsolve/src/lib.rs +1 -0
- data/vendor/cfsolve/src/listing/fold.rs +19 -92
- data/vendor/cfsolve/src/listing/query.rs +26 -291
- data/vendor/cfsolve/src/listing.rs +0 -1
- 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 +19 -10
- data/vendor/cfsolve/src/session/probes.rs +160 -125
- 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/timing.rs +58 -53
- data/vendor/cfsolve/src/session/widget.rs +5 -6
- data/vendor/cfsolve/src/session.rs +1 -1
- data/vendor/cfsolve/src/solver.rs +3 -1
- data/vendor/cfsolve/src/stage2/analysis/analyze.rs +50 -33
- data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
- data/vendor/cfsolve/src/stage2/analysis/discovery.rs +61 -66
- data/vendor/cfsolve/src/stage2/analysis/envelope.rs +33 -22
- data/vendor/cfsolve/src/stage2/analysis/recognize.rs +3 -5
- data/vendor/cfsolve/src/stage2/analysis.rs +0 -1
- data/vendor/cfsolve/src/stage2/audit_globals.rs +378 -0
- data/vendor/cfsolve/src/stage2/benchmark.rs +66 -38
- data/vendor/cfsolve/src/stage2/call_stack.rs +1463 -1017
- 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/native.rs +2 -1
- data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -7
- data/vendor/cfsolve/src/stage2/payload/recover.rs +56 -25
- data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
- data/vendor/cfsolve/src/stage2/probes/ice.rs +11 -10
- data/vendor/cfsolve/src/stage2/probes/media.rs +47 -33
- data/vendor/cfsolve/src/stage2/probes/performance.rs +13 -8
- data/vendor/cfsolve/src/stage2/probes/rects.rs +12 -17
- data/vendor/cfsolve/src/stage2/probes/stack.rs +50 -103
- data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +17 -86
- data/vendor/cfsolve/src/stage2/probes.rs +0 -1
- data/vendor/cfsolve/src/stage2/queries.rs +50 -0
- data/vendor/cfsolve/src/stage2/records.rs +4 -13
- data/vendor/cfsolve/src/stage2/reference.json +1 -1
- data/vendor/cfsolve/src/stage2/reference.rs +98 -100
- data/vendor/cfsolve/src/stage2/registry.rs +41 -34
- data/vendor/cfsolve/src/stage2/replay.rs +182 -254
- data/vendor/cfsolve/src/stage2/stylesheets.rs +176 -0
- data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
- data/vendor/cfsolve/src/stage2/trace.rs +152 -108
- data/vendor/cfsolve/src/stage2/vocabulary.rs +103 -403
- data/vendor/cfsolve/src/stage2.rs +4 -1
- data/vendor/cfsolve/src/vm/disassemble.rs +46 -13
- 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 +67 -68
- data/vendor/cfsolve/src/vm/interpret/builtin.rs +16 -63
- data/vendor/cfsolve/src/vm/interpret/call.rs +192 -51
- data/vendor/cfsolve/src/vm/interpret/compile.rs +643 -0
- data/vendor/cfsolve/src/vm/interpret/copies.rs +232 -120
- data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +149 -40
- data/vendor/cfsolve/src/vm/interpret/evaluate.rs +189 -572
- data/vendor/cfsolve/src/vm/interpret/explore.rs +159 -46
- data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
- data/vendor/cfsolve/src/vm/interpret/frozen.rs +169 -0
- data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +414 -0
- 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 +605 -330
- data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
- data/vendor/cfsolve/src/vm/interpret/run.rs +314 -54
- 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 +16 -3
- data/vendor/cfsolve/src/vm/machine.rs +58 -47
- data/vendor/cfsolve/src/vm/output.rs +13 -5
- data/vendor/cfsolve/src/vm/packed_names.rs +311 -0
- data/vendor/cfsolve/src/vm/session.rs +197 -110
- data/vendor/cfsolve/src/vm/value.rs +35 -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
- data/vendor/cfsolve/vendor/btls-sys/src/lib.rs +3 -0
- metadata +106 -183
- 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/vendor/cfsolve/src/listing/normalize.rs +0 -264
- data/vendor/cfsolve/src/stage2/analysis/outputs.rs +0 -327
- data/vendor/cfsolve/src/stage2/probes/stylesheets.rs +0 -249
- data/vendor/cfsolve/src/stage2/reference-expanded.json +0 -42
- data/vendor/cfsolve/src/stage2/session_names.rs +0 -470
- /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,23 +2,26 @@
|
|
|
2
2
|
//! tally ([`super::tally`]), the sender's additions and POST log, and the resource timing
|
|
3
3
|
//! format ([`super::reduced_timing`]).
|
|
4
4
|
|
|
5
|
-
use std::collections::BTreeMap;
|
|
5
|
+
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
|
|
|
@@ -36,11 +39,21 @@ pub struct ScriptState {
|
|
|
36
39
|
/// Options copied into the payload under their original names at send time.
|
|
37
40
|
pub forwarded: Vec<String>,
|
|
38
41
|
pub timing: Option<ResourceTiming>,
|
|
39
|
-
/// Functions on the script's namespace,
|
|
40
|
-
pub getters: BTreeMap<String,
|
|
42
|
+
/// Functions on the script's namespace, by name.
|
|
43
|
+
pub getters: BTreeMap<String, Getter>,
|
|
41
44
|
pub post_log: Option<PostLog>,
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
/// A function on the script's namespace that returns an option.
|
|
48
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
49
|
+
pub struct Getter {
|
|
50
|
+
pub option: String,
|
|
51
|
+
/// The option holding the page origin, when the getter passes each render sample's stack
|
|
52
|
+
/// through a helper that replaces URLs on that origin with indices (see
|
|
53
|
+
/// `crate::challenge::payload::split_page_urls`).
|
|
54
|
+
pub page_origin: Option<String>,
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
/// Log of challenge POSTs. Each payload includes the log so far. The sender then adds an entry for
|
|
45
58
|
/// the current POST and records its response time when the response arrives.
|
|
46
59
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
@@ -155,22 +168,23 @@ fn unsigned<'de, D: Deserializer<'de>>(deserializer: D) -> Result<i64, D::Error>
|
|
|
155
168
|
impl ScriptState {
|
|
156
169
|
#[cfg(test)]
|
|
157
170
|
pub(crate) fn from_javascript(javascript: &str) -> Result<Self> {
|
|
158
|
-
let parsed = ast::
|
|
159
|
-
|
|
171
|
+
let parsed = ast::ParsedScript::parse("t", javascript)?;
|
|
172
|
+
let script = parsed.script();
|
|
173
|
+
Self::from_script(script, &source::bootstrap_options(script))
|
|
160
174
|
}
|
|
161
175
|
|
|
162
176
|
/// Recovers the state of a parsed script, using bootstrap options to identify its payload
|
|
163
177
|
/// template.
|
|
164
|
-
pub(crate) fn
|
|
165
|
-
let script = &parsed.script;
|
|
178
|
+
pub(crate) fn from_script(script: Script<'_>, options: &Options) -> Result<Self> {
|
|
166
179
|
let mut scopes = Scopes {
|
|
180
|
+
script,
|
|
167
181
|
options,
|
|
168
182
|
stack: Vec::new(),
|
|
169
183
|
found: Vec::new(),
|
|
170
184
|
};
|
|
171
|
-
script.
|
|
172
|
-
let mut sender = Sender::
|
|
173
|
-
script.
|
|
185
|
+
scopes.visit_program(script.program);
|
|
186
|
+
let mut sender = Sender::new(script);
|
|
187
|
+
sender.visit_program(script.program);
|
|
174
188
|
let post_log = sender.post_log()?;
|
|
175
189
|
let elapsed = candidates::at_most_one_distinct(sender.elapsed, "elapsed-time field")?;
|
|
176
190
|
let sender_scope = elapsed.as_ref().map(|(scope, _)| *scope);
|
|
@@ -184,14 +198,14 @@ impl ScriptState {
|
|
|
184
198
|
collected.into_iter().map(|(_, key)| key),
|
|
185
199
|
"collected resource timing option",
|
|
186
200
|
)?;
|
|
187
|
-
let tallies =
|
|
188
|
-
tally::published_tally(function.
|
|
201
|
+
let tallies = script.in_declared_functions(|function| {
|
|
202
|
+
tally::published_tally(script, function.body.as_ref()?)
|
|
189
203
|
});
|
|
190
204
|
let counters = candidates::at_most_one_distinct(tallies, "interaction tally")?;
|
|
191
205
|
let timing = match collected {
|
|
192
206
|
Some(option) => {
|
|
193
|
-
let reductions =
|
|
194
|
-
reduced_timing::reduction(function.
|
|
207
|
+
let reductions = script.in_declared_functions(|function| {
|
|
208
|
+
reduced_timing::reduction(script, function.body.as_ref()?)
|
|
195
209
|
});
|
|
196
210
|
candidates::at_most_one_distinct(reductions, "resource timing reducer")?
|
|
197
211
|
.map(|fields| ResourceTiming { option, fields })
|
|
@@ -208,7 +222,7 @@ impl ScriptState {
|
|
|
208
222
|
elapsed: elapsed.map(|(_, elapsed)| elapsed),
|
|
209
223
|
forwarded: forwarded.into_iter().map(|(_, key)| key).collect(),
|
|
210
224
|
timing,
|
|
211
|
-
getters: distinct_getters(sender.getters)?,
|
|
225
|
+
getters: distinct_getters(script, sender.getters, &sender.helpers)?,
|
|
212
226
|
post_log,
|
|
213
227
|
})
|
|
214
228
|
}
|
|
@@ -223,22 +237,19 @@ impl ScriptState {
|
|
|
223
237
|
bail!("could not recover the iframe's input event counters: {reason}")
|
|
224
238
|
}
|
|
225
239
|
|
|
226
|
-
fn builds_payload(&self, option: &str) -> bool {
|
|
227
|
-
self.marks
|
|
228
|
-
.iter()
|
|
229
|
-
.any(|mark| mark.option == option && mark.in_builder)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
240
|
/// Identifies the interval measured by `difference`, using `merged` as the marked option.
|
|
233
241
|
/// Returns no interval if the script never marks the later timestamp.
|
|
234
242
|
fn span(&self, difference: &Difference, merged: Option<&str>) -> Option<Span> {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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 {
|
|
240
251
|
Span::Collect
|
|
241
|
-
} else if Some(earlier.as_str()) == merged {
|
|
252
|
+
} else if Some(difference.earlier.as_str()) == merged {
|
|
242
253
|
Span::Handoff
|
|
243
254
|
} else {
|
|
244
255
|
Span::Initialise
|
|
@@ -331,7 +342,8 @@ enum Span {
|
|
|
331
342
|
/// Groups timestamps by their innermost function and finds the function containing the payload
|
|
332
343
|
/// template. A template in a nested callback may subtract timestamps set by different
|
|
333
344
|
/// functions.
|
|
334
|
-
struct Scopes<'options> {
|
|
345
|
+
struct Scopes<'options, 'a> {
|
|
346
|
+
script: Script<'a>,
|
|
335
347
|
options: &'options Options,
|
|
336
348
|
/// The enclosing functions, innermost last.
|
|
337
349
|
stack: Vec<Scope>,
|
|
@@ -345,10 +357,10 @@ struct Scope {
|
|
|
345
357
|
builds_payload: bool,
|
|
346
358
|
}
|
|
347
359
|
|
|
348
|
-
impl Scopes<'_> {
|
|
349
|
-
fn within
|
|
360
|
+
impl Scopes<'_, '_> {
|
|
361
|
+
fn within(&mut self, walk: impl FnOnce(&mut Self)) {
|
|
350
362
|
self.stack.push(Scope::default());
|
|
351
|
-
|
|
363
|
+
walk(self);
|
|
352
364
|
let scope = self.stack.pop().expect("entered a scope first");
|
|
353
365
|
let marks = scope.marks.into_iter().map(|option| Mark {
|
|
354
366
|
option,
|
|
@@ -358,77 +370,136 @@ impl Scopes<'_> {
|
|
|
358
370
|
}
|
|
359
371
|
}
|
|
360
372
|
|
|
361
|
-
impl Visit for Scopes<'_> {
|
|
362
|
-
fn visit_function(&mut self, function: &Function) {
|
|
363
|
-
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));
|
|
364
376
|
}
|
|
365
377
|
|
|
366
|
-
fn
|
|
367
|
-
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));
|
|
368
380
|
}
|
|
369
381
|
|
|
370
|
-
fn
|
|
382
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
371
383
|
if let Some(option) = expression::option_assignment(&assignment.left)
|
|
372
|
-
&&
|
|
384
|
+
&& self.script.is_date_now(&assignment.right)
|
|
373
385
|
&& let Some(scope) = self.stack.last_mut()
|
|
374
386
|
{
|
|
375
387
|
scope.marks.push(option.to_owned());
|
|
376
388
|
}
|
|
377
|
-
|
|
389
|
+
walk::walk_assignment_expression(self, assignment);
|
|
378
390
|
}
|
|
379
391
|
|
|
380
|
-
fn
|
|
392
|
+
fn visit_if_statement(&mut self, conditional: &IfStatement<'a>) {
|
|
381
393
|
let options = self.options;
|
|
382
394
|
source::visit_taken_branches(self, conditional, options);
|
|
383
395
|
}
|
|
384
396
|
|
|
385
|
-
fn
|
|
397
|
+
fn visit_object_expression(&mut self, object: &ObjectExpression<'a>) {
|
|
386
398
|
if source::is_payload_template(object, self.options)
|
|
387
399
|
&& let Some(scope) = self.stack.last_mut()
|
|
388
400
|
{
|
|
389
401
|
scope.builds_payload = true;
|
|
390
402
|
}
|
|
391
|
-
|
|
403
|
+
walk::walk_object_expression(self, object);
|
|
392
404
|
}
|
|
393
405
|
}
|
|
394
406
|
|
|
395
407
|
/// Finds property writes that add payload fields or install namespace getters. Records the
|
|
396
408
|
/// enclosing function for each write.
|
|
397
|
-
|
|
398
|
-
|
|
409
|
+
struct Sender<'a> {
|
|
410
|
+
script: Script<'a>,
|
|
399
411
|
entered: usize,
|
|
400
412
|
scopes: Vec<usize>,
|
|
401
413
|
elapsed: Vec<(usize, Elapsed)>,
|
|
402
414
|
copies: Vec<(usize, String)>,
|
|
403
|
-
getters: Vec<
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
415
|
+
getters: Vec<FoundGetter<'a>>,
|
|
416
|
+
/// The first option each declared function reads, by binding.
|
|
417
|
+
helpers: HashMap<SymbolId, String>,
|
|
418
|
+
pushes: Vec<Push<'a>>,
|
|
419
|
+
entries: Vec<LogEntry<'a>>,
|
|
420
|
+
stamps: Vec<Stamp<'a>>,
|
|
407
421
|
}
|
|
408
422
|
|
|
409
|
-
/// A namespace getter named `function` that returns the option `option
|
|
410
|
-
|
|
423
|
+
/// A namespace getter named `function` that returns the option `option`, rewriting each
|
|
424
|
+
/// sample's stack with the declared function `rewrite`, if any.
|
|
425
|
+
struct FoundGetter<'a> {
|
|
411
426
|
function: String,
|
|
412
427
|
option: String,
|
|
428
|
+
rewrite: Option<Binding<'a>>,
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/// Finds `<sample>.s = <helper>(<sample>.s)`.
|
|
432
|
+
struct StackRewrite<'a> {
|
|
433
|
+
script: Script<'a>,
|
|
434
|
+
helper: Option<Binding<'a>>,
|
|
435
|
+
}
|
|
436
|
+
|
|
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()
|
|
440
|
+
&& ast::ident_property(target) == Some("s")
|
|
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)
|
|
447
|
+
&& ast::ident_property(read) == Some("s")
|
|
448
|
+
{
|
|
449
|
+
self.helper = Some(self.script.binding(helper));
|
|
450
|
+
}
|
|
451
|
+
walk::walk_assignment_expression(self, assignment);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/// The first option a function reads.
|
|
456
|
+
#[derive(Default)]
|
|
457
|
+
struct OptionRead(Option<String>);
|
|
458
|
+
|
|
459
|
+
impl<'a> Visit<'a> for OptionRead {
|
|
460
|
+
fn visit_member_expression(&mut self, member: &MemberExpression<'a>) {
|
|
461
|
+
if self.0.is_none()
|
|
462
|
+
&& expression::is_options(member.object())
|
|
463
|
+
&& let Some(option) = ast::member_str(member)
|
|
464
|
+
{
|
|
465
|
+
self.0 = Some(option.to_owned());
|
|
466
|
+
}
|
|
467
|
+
walk::walk_member_expression(self, member);
|
|
468
|
+
}
|
|
413
469
|
}
|
|
414
470
|
|
|
415
471
|
/// Matches `_cf_chl_opt.<log>.push(<local>)`.
|
|
416
|
-
struct Push {
|
|
472
|
+
struct Push<'a> {
|
|
417
473
|
log: String,
|
|
418
|
-
local:
|
|
474
|
+
local: Binding<'a>,
|
|
419
475
|
}
|
|
420
476
|
|
|
421
477
|
/// Matches `<local>.<key> = <clock>()`.
|
|
422
|
-
struct Stamp {
|
|
423
|
-
local:
|
|
478
|
+
struct Stamp<'a> {
|
|
479
|
+
local: Binding<'a>,
|
|
424
480
|
key: String,
|
|
425
481
|
}
|
|
426
482
|
|
|
427
|
-
impl Sender {
|
|
428
|
-
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)) {
|
|
429
500
|
self.entered += 1;
|
|
430
501
|
self.scopes.push(self.entered);
|
|
431
|
-
|
|
502
|
+
walk(self);
|
|
432
503
|
self.scopes.pop();
|
|
433
504
|
}
|
|
434
505
|
|
|
@@ -456,98 +527,114 @@ impl Sender {
|
|
|
456
527
|
|
|
457
528
|
/// Finds a local initialized with a POST log entry: `{ url: new URL(...).href, count:
|
|
458
529
|
/// _cf_chl_opt.<counter>, sent: clock() }`.
|
|
459
|
-
struct LogEntry {
|
|
460
|
-
local:
|
|
530
|
+
struct LogEntry<'a> {
|
|
531
|
+
local: Binding<'a>,
|
|
461
532
|
fields: Vec<(String, Logged)>,
|
|
462
533
|
counter: String,
|
|
463
534
|
}
|
|
464
535
|
|
|
465
|
-
impl LogEntry {
|
|
466
|
-
fn read(local:
|
|
467
|
-
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 {
|
|
468
539
|
return None;
|
|
469
540
|
};
|
|
470
541
|
let mut fields = Vec::new();
|
|
471
542
|
let mut counter = None;
|
|
472
543
|
for property in ast::key_values(object) {
|
|
473
|
-
let value = property.value.
|
|
544
|
+
let value = property.value.without_parentheses();
|
|
474
545
|
let logged = if let Some(option) = expression::option_key(value) {
|
|
475
546
|
counter = Some(option.to_owned());
|
|
476
547
|
Logged::Count
|
|
477
|
-
} else if value
|
|
548
|
+
} else if matches!(value, Expression::CallExpression(call) if call.arguments.is_empty())
|
|
549
|
+
{
|
|
478
550
|
Logged::Sent
|
|
479
|
-
} else if let
|
|
480
|
-
&& ast::member_str(
|
|
481
|
-
&&
|
|
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
|
+
)
|
|
482
557
|
{
|
|
483
558
|
Logged::Url
|
|
484
559
|
} else {
|
|
485
560
|
return None;
|
|
486
561
|
};
|
|
487
|
-
fields.push((
|
|
562
|
+
fields.push((
|
|
563
|
+
ast::key_str(&property.key, property.computed)?.to_owned(),
|
|
564
|
+
logged,
|
|
565
|
+
));
|
|
488
566
|
}
|
|
489
567
|
let complete = fields.len() == 3
|
|
490
568
|
&& [Logged::Url, Logged::Count, Logged::Sent]
|
|
491
569
|
.iter()
|
|
492
570
|
.all(|logged| fields.iter().any(|(_, field)| field == logged));
|
|
493
571
|
complete.then_some(Self {
|
|
494
|
-
local
|
|
572
|
+
local,
|
|
495
573
|
fields,
|
|
496
574
|
counter: counter?,
|
|
497
575
|
})
|
|
498
576
|
}
|
|
499
577
|
}
|
|
500
578
|
|
|
501
|
-
impl Visit for Sender {
|
|
502
|
-
fn visit_function(&mut self, function: &Function) {
|
|
503
|
-
|
|
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
|
+
}
|
|
589
|
+
}
|
|
590
|
+
self.within(|sender| walk::walk_function(sender, function, flags));
|
|
504
591
|
}
|
|
505
592
|
|
|
506
|
-
fn
|
|
507
|
-
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));
|
|
508
595
|
}
|
|
509
596
|
|
|
510
|
-
fn
|
|
511
|
-
if let
|
|
597
|
+
fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
|
|
598
|
+
if let BindingPattern::BindingIdentifier(local) = &declarator.id
|
|
512
599
|
&& let Some(init) = &declarator.init
|
|
513
|
-
&& let Some(entry) = LogEntry::read(
|
|
600
|
+
&& let Some(entry) = LogEntry::read(Binding::Symbol(local.symbol_id()), init)
|
|
514
601
|
{
|
|
515
602
|
self.entries.push(entry);
|
|
516
603
|
}
|
|
517
|
-
|
|
604
|
+
walk::walk_variable_declarator(self, declarator);
|
|
518
605
|
}
|
|
519
606
|
|
|
520
|
-
fn
|
|
607
|
+
fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
|
|
521
608
|
// `_cf_chl_opt.<log>.push(<entry>)`
|
|
522
|
-
if let Some(callee) = call.callee.
|
|
523
|
-
&& ast::member_str(
|
|
524
|
-
&& let Some(option) = expression::option_key(
|
|
525
|
-
&& let [entry] = &call.
|
|
526
|
-
&& 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()
|
|
527
614
|
{
|
|
528
615
|
self.pushes.push(Push {
|
|
529
616
|
log: option.to_owned(),
|
|
530
|
-
local:
|
|
617
|
+
local: self.script.binding(local),
|
|
531
618
|
});
|
|
532
619
|
}
|
|
533
|
-
|
|
620
|
+
walk::walk_call_expression(self, call);
|
|
534
621
|
}
|
|
535
622
|
|
|
536
|
-
fn
|
|
623
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
537
624
|
let scope = self.scopes.last().copied().unwrap_or_default();
|
|
538
|
-
if let
|
|
539
|
-
&& 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)
|
|
540
627
|
{
|
|
541
628
|
self.entries.push(entry);
|
|
542
629
|
}
|
|
543
|
-
if let
|
|
630
|
+
if let Some(target) = assignment.left.as_member_expression()
|
|
544
631
|
&& let Some(key) = ast::ident_property(target)
|
|
545
632
|
{
|
|
546
|
-
match
|
|
633
|
+
match &assignment.right {
|
|
547
634
|
// `payload.<key> = Date.now() - _cf_chl_opt.<mark>`
|
|
548
|
-
|
|
549
|
-
if binary.
|
|
550
|
-
&&
|
|
635
|
+
Expression::BinaryExpression(binary)
|
|
636
|
+
if binary.operator == BinaryOperator::Subtraction
|
|
637
|
+
&& self.script.is_date_now(&binary.left)
|
|
551
638
|
&& let Some(mark) = expression::option_key(&binary.right) =>
|
|
552
639
|
{
|
|
553
640
|
let elapsed = Elapsed {
|
|
@@ -557,15 +644,24 @@ impl Visit for Sender {
|
|
|
557
644
|
self.elapsed.push((scope, elapsed));
|
|
558
645
|
}
|
|
559
646
|
// `<namespace>.<key> = function () { var ...; local = _cf_chl_opt.<option>; ... }`
|
|
560
|
-
|
|
561
|
-
if let Some(body) = &getter.
|
|
562
|
-
&& let Some(first) =
|
|
563
|
-
|
|
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
|
|
564
654
|
&& let Some(option) = expression::option_key(&first.right) =>
|
|
565
655
|
{
|
|
566
|
-
|
|
656
|
+
let mut rewrite = StackRewrite {
|
|
657
|
+
script: self.script,
|
|
658
|
+
helper: None,
|
|
659
|
+
};
|
|
660
|
+
rewrite.visit_function(getter, ScopeFlags::Function);
|
|
661
|
+
self.getters.push(FoundGetter {
|
|
567
662
|
function: key.to_owned(),
|
|
568
663
|
option: option.to_owned(),
|
|
664
|
+
rewrite: rewrite.helper,
|
|
569
665
|
});
|
|
570
666
|
}
|
|
571
667
|
// `payload.<key> = _cf_chl_opt.<key>`
|
|
@@ -573,30 +669,53 @@ impl Visit for Sender {
|
|
|
573
669
|
self.copies.push((scope, key.to_owned()));
|
|
574
670
|
}
|
|
575
671
|
// `entry.<key> = clock()`
|
|
576
|
-
|
|
577
|
-
if call.
|
|
578
|
-
&& let
|
|
672
|
+
Expression::CallExpression(call)
|
|
673
|
+
if call.arguments.is_empty()
|
|
674
|
+
&& let Expression::Identifier(local) = target.object() =>
|
|
579
675
|
{
|
|
580
676
|
self.stamps.push(Stamp {
|
|
581
|
-
local:
|
|
677
|
+
local: self.script.binding(local),
|
|
582
678
|
key: key.to_owned(),
|
|
583
679
|
});
|
|
584
680
|
}
|
|
585
681
|
_ => {}
|
|
586
682
|
}
|
|
587
683
|
}
|
|
588
|
-
|
|
684
|
+
walk::walk_assignment_expression(self, assignment);
|
|
589
685
|
}
|
|
590
686
|
}
|
|
591
687
|
|
|
592
|
-
///
|
|
593
|
-
|
|
688
|
+
/// Resolves each getter's stack rewrite to the option its helper reads. Rejects a getter name
|
|
689
|
+
/// that returns different options.
|
|
690
|
+
fn distinct_getters(
|
|
691
|
+
script: Script<'_>,
|
|
692
|
+
getters: Vec<FoundGetter<'_>>,
|
|
693
|
+
helpers: &HashMap<SymbolId, String>,
|
|
694
|
+
) -> Result<BTreeMap<String, Getter>> {
|
|
594
695
|
let mut distinct = BTreeMap::new();
|
|
595
|
-
for
|
|
596
|
-
let
|
|
696
|
+
for found in getters {
|
|
697
|
+
let function = found.function;
|
|
698
|
+
let page_origin = found
|
|
699
|
+
.rewrite
|
|
700
|
+
.map(|helper| {
|
|
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}")
|
|
708
|
+
})
|
|
709
|
+
})
|
|
710
|
+
.transpose()?;
|
|
711
|
+
let getter = Getter {
|
|
712
|
+
option: found.option,
|
|
713
|
+
page_origin,
|
|
714
|
+
};
|
|
715
|
+
let previous = distinct.entry(function.clone()).or_insert(getter.clone());
|
|
597
716
|
ensure!(
|
|
598
|
-
*previous ==
|
|
599
|
-
"getter {function} reads both {previous} and {
|
|
717
|
+
*previous == getter,
|
|
718
|
+
"getter {function} reads both {previous:?} and {getter:?}"
|
|
600
719
|
);
|
|
601
720
|
}
|
|
602
721
|
Ok(distinct)
|
|
@@ -715,12 +834,7 @@ mod tests {
|
|
|
715
834
|
.enumerate()
|
|
716
835
|
.map(|(index, (later, earlier))| {
|
|
717
836
|
let text = format!("e._cf_chl_opt.{later} - e._cf_chl_opt.{earlier}");
|
|
718
|
-
Field
|
|
719
|
-
name: format!("f{index}"),
|
|
720
|
-
expression: ast::parse_expression("t", &text).unwrap(),
|
|
721
|
-
text,
|
|
722
|
-
bootstrap_value: None,
|
|
723
|
-
}
|
|
837
|
+
Field::parse(format!("f{index}"), text, None).unwrap()
|
|
724
838
|
})
|
|
725
839
|
.collect();
|
|
726
840
|
let intervals = &Intervals {
|