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,30 +2,35 @@
|
|
|
2
2
|
//! hashes, objects built in a block, and expressions used to construct options and payloads.
|
|
3
3
|
|
|
4
4
|
use anyhow::{Context, Result, bail, ensure};
|
|
5
|
-
use
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
use oxc::ast::ast::{
|
|
6
|
+
ArrayExpressionElement, AssignmentExpression, AssignmentTarget, BinaryExpression, Expression,
|
|
7
|
+
FunctionBody, MemberExpression, Statement,
|
|
8
8
|
};
|
|
9
|
+
use oxc::syntax::operator::{BinaryOperator, LogicalOperator, UnaryOperator};
|
|
9
10
|
|
|
10
|
-
use crate::js::{self,
|
|
11
|
+
use crate::js::ast::{self, Binding, Script};
|
|
12
|
+
use crate::js::{self, JsValue, Options, Window};
|
|
11
13
|
|
|
12
14
|
/// Reads the build hash from `"0…0" + <number>.toString(16)`. The zero literal sets the
|
|
13
15
|
/// hexadecimal width. Requires an integer literal that fits without truncation; accepts any
|
|
14
16
|
/// numeric base and ignores surrounding parentheses.
|
|
15
17
|
#[must_use]
|
|
16
|
-
pub(crate) fn padded_build(sum: &
|
|
18
|
+
pub(crate) fn padded_build(sum: &BinaryExpression<'_>) -> Option<String> {
|
|
17
19
|
let zeros = ast::static_str(&sum.left)?;
|
|
18
|
-
let call = sum.right.
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
let Expression::CallExpression(call) = sum.right.without_parentheses() else {
|
|
21
|
+
return None;
|
|
22
|
+
};
|
|
23
|
+
let member = call.callee.without_parentheses().as_member_expression()?;
|
|
24
|
+
let (Expression::NumericLiteral(number), [radix]) =
|
|
25
|
+
(member.object().without_parentheses(), &call.arguments[..])
|
|
21
26
|
else {
|
|
22
27
|
return None;
|
|
23
28
|
};
|
|
24
|
-
let padded =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
&& ast::index_literal
|
|
29
|
+
let padded = sum.operator == BinaryOperator::Addition
|
|
30
|
+
&& !zeros.is_empty()
|
|
31
|
+
&& zeros.bytes().all(|byte| byte == b'0');
|
|
32
|
+
let hexadecimal = ast::member_str(member) == Some("toString")
|
|
33
|
+
&& radix.as_expression().and_then(ast::index_literal) == Some(16);
|
|
29
34
|
let (number, width) = (number.value, zeros.len());
|
|
30
35
|
// For padding wider than sixteen hex digits, the `u64` range limits the value.
|
|
31
36
|
let limit = 16f64.powi(i32::try_from(width).ok()?).min(2f64.powi(64));
|
|
@@ -33,153 +38,187 @@ pub(crate) fn padded_build(sum: &BinExpr) -> Option<String> {
|
|
|
33
38
|
.then(|| format!("{:0width$x}", number as u64))
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
/// Resolves a static expression using known options (see [`evaluate`]). Unknown
|
|
37
|
-
/// static value.
|
|
41
|
+
/// Resolves a static expression in `script` using known options (see [`evaluate`]). Unknown
|
|
42
|
+
/// options have no static value.
|
|
38
43
|
#[must_use]
|
|
39
|
-
pub(crate) fn static_value(
|
|
40
|
-
|
|
44
|
+
pub(crate) fn static_value(
|
|
45
|
+
script: Script<'_>,
|
|
46
|
+
expression: &Expression<'_>,
|
|
47
|
+
options: &Options,
|
|
48
|
+
) -> Option<JsValue> {
|
|
49
|
+
evaluate(script, expression, options, &Window::new()).ok()?
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
/// The `_cf_chl_opt` property read by `<global>._cf_chl_opt.<name>`.
|
|
44
53
|
#[must_use]
|
|
45
|
-
pub(crate) fn option_key(expression: &
|
|
46
|
-
|
|
47
|
-
ast::member_str(&member.prop).filter(|_| is_options(&member.obj))
|
|
54
|
+
pub(crate) fn option_key<'a>(expression: &Expression<'a>) -> Option<&'a str> {
|
|
55
|
+
options_member(expression.as_member_expression()?)
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
/// The option assigned by `_cf_chl_opt.<name> = ...`.
|
|
51
59
|
#[must_use]
|
|
52
|
-
pub(crate) fn option_assignment(target: &
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
pub(crate) fn option_assignment<'a>(target: &AssignmentTarget<'a>) -> Option<&'a str> {
|
|
61
|
+
options_member(target.as_member_expression()?)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// The option `member` names, if it is a property of `_cf_chl_opt`.
|
|
65
|
+
fn options_member<'a>(member: &MemberExpression<'a>) -> Option<&'a str> {
|
|
66
|
+
ast::member_str(member).filter(|_| is_options(member.object()))
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
/// Returns the assignment contained in an expression statement.
|
|
58
|
-
pub(crate) fn assignment
|
|
59
|
-
statement
|
|
70
|
+
pub(crate) fn assignment<'b, 'a>(
|
|
71
|
+
statement: &'b Statement<'a>,
|
|
72
|
+
) -> Option<&'b AssignmentExpression<'a>> {
|
|
73
|
+
match statement {
|
|
74
|
+
Statement::ExpressionStatement(statement) => match &statement.expression {
|
|
75
|
+
Expression::AssignmentExpression(assignment) => Some(assignment),
|
|
76
|
+
_ => None,
|
|
77
|
+
},
|
|
78
|
+
_ => None,
|
|
79
|
+
}
|
|
60
80
|
}
|
|
61
81
|
|
|
62
82
|
/// Finds standalone assignment statements in `body`.
|
|
63
|
-
pub(crate) fn assignments
|
|
64
|
-
body
|
|
83
|
+
pub(crate) fn assignments<'b, 'a>(
|
|
84
|
+
body: &'b FunctionBody<'a>,
|
|
85
|
+
) -> impl Iterator<Item = &'b AssignmentExpression<'a>> {
|
|
86
|
+
body.statements.iter().filter_map(assignment)
|
|
65
87
|
}
|
|
66
88
|
|
|
67
89
|
/// An object held by a local variable in a block.
|
|
68
|
-
pub(crate) struct BuiltObject<'
|
|
69
|
-
pub local:
|
|
70
|
-
pub fields: Vec<ObjectField<'
|
|
90
|
+
pub(crate) struct BuiltObject<'b, 'a> {
|
|
91
|
+
pub local: Binding<'a>,
|
|
92
|
+
pub fields: Vec<ObjectField<'b, 'a>>,
|
|
71
93
|
}
|
|
72
94
|
|
|
73
95
|
/// One field of an object, as `key: value` or `<local>.<key> = <value>`.
|
|
74
|
-
pub(crate) struct ObjectField<'
|
|
75
|
-
pub key: &'
|
|
76
|
-
pub value: &'
|
|
96
|
+
pub(crate) struct ObjectField<'b, 'a> {
|
|
97
|
+
pub key: &'a str,
|
|
98
|
+
pub value: &'b Expression<'a>,
|
|
77
99
|
}
|
|
78
100
|
|
|
79
101
|
/// Records an object assigned to a local, or a property write to one, in `built`. Returns
|
|
80
102
|
/// whether it matched. The deobfuscator may emit a literal, or an empty object followed by
|
|
81
103
|
/// property writes.
|
|
82
|
-
pub(crate) fn track<'
|
|
83
|
-
|
|
84
|
-
|
|
104
|
+
pub(crate) fn track<'b, 'a>(
|
|
105
|
+
script: Script<'a>,
|
|
106
|
+
built: &mut Vec<BuiltObject<'b, 'a>>,
|
|
107
|
+
assignment: &'b AssignmentExpression<'a>,
|
|
85
108
|
) -> bool {
|
|
86
|
-
let value =
|
|
87
|
-
|
|
88
|
-
Some(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
_ => return false,
|
|
109
|
+
let value = &assignment.right;
|
|
110
|
+
if let AssignmentTarget::AssignmentTargetIdentifier(local) = &assignment.left {
|
|
111
|
+
let Some(fields) = object_fields(value) else {
|
|
112
|
+
return false;
|
|
113
|
+
};
|
|
114
|
+
built.push(BuiltObject {
|
|
115
|
+
local: script.binding(local),
|
|
116
|
+
fields,
|
|
117
|
+
});
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
let Some(member) = assignment.left.as_member_expression() else {
|
|
121
|
+
return false;
|
|
122
|
+
};
|
|
123
|
+
let Expression::Identifier(object) = member.object() else {
|
|
124
|
+
return false;
|
|
125
|
+
};
|
|
126
|
+
let object = script.binding(object);
|
|
127
|
+
let target = built.iter_mut().rfind(|target| target.local == object);
|
|
128
|
+
let (Some(key), Some(target)) = (ast::member_str(member), target) else {
|
|
129
|
+
return false;
|
|
130
|
+
};
|
|
131
|
+
match target.fields.iter_mut().find(|field| field.key == key) {
|
|
132
|
+
Some(field) => field.value = value,
|
|
133
|
+
None => target.fields.push(ObjectField { key, value }),
|
|
113
134
|
}
|
|
114
135
|
true
|
|
115
136
|
}
|
|
116
137
|
|
|
117
138
|
/// The fields of an object literal whose keys are all names.
|
|
118
|
-
pub(crate) fn object_fields
|
|
119
|
-
|
|
139
|
+
pub(crate) fn object_fields<'b, 'a>(
|
|
140
|
+
expression: &'b Expression<'a>,
|
|
141
|
+
) -> Option<Vec<ObjectField<'b, 'a>>> {
|
|
142
|
+
let Expression::ObjectExpression(object) = expression else {
|
|
143
|
+
return None;
|
|
144
|
+
};
|
|
145
|
+
let fields = object.properties.iter().map(|property| {
|
|
120
146
|
let property = ast::key_value(property)?;
|
|
121
147
|
Some(ObjectField {
|
|
122
|
-
key: ast::key_str(&property.key)?,
|
|
148
|
+
key: ast::key_str(&property.key, property.computed)?,
|
|
123
149
|
value: &property.value,
|
|
124
150
|
})
|
|
125
151
|
});
|
|
126
152
|
fields.collect()
|
|
127
153
|
}
|
|
128
154
|
|
|
129
|
-
/// Evaluates expressions used to build options and payloads. Supports literals,
|
|
130
|
-
/// arrays, objects, `!`, `||`, `+`, `-`, `===`, `!==`, and `JSON.stringify`. Reads
|
|
131
|
-
/// `<global>._cf_chl_opt.<key>` and globals from `<global>.<key>`, including getters
|
|
132
|
-
/// without arguments.
|
|
155
|
+
/// Evaluates expressions in `script` used to build options and payloads. Supports literals,
|
|
156
|
+
/// `undefined`, arrays, objects, `!`, `||`, `+`, `-`, `===`, `!==`, and `JSON.stringify`. Reads
|
|
157
|
+
/// options from `<global>._cf_chl_opt.<key>` and globals from `<global>.<key>`, including getters
|
|
158
|
+
/// called without arguments.
|
|
133
159
|
///
|
|
134
160
|
/// Objects keep static properties and omit callbacks, matching `JSON.stringify`. `None`
|
|
135
161
|
/// represents `undefined`. Unsupported expressions return errors.
|
|
136
162
|
pub(crate) fn evaluate(
|
|
137
|
-
|
|
163
|
+
script: Script<'_>,
|
|
164
|
+
expression: &Expression<'_>,
|
|
138
165
|
options: &Options,
|
|
139
166
|
globals: &Window,
|
|
140
167
|
) -> Result<Option<JsValue>> {
|
|
141
|
-
let evaluate = |expression: &
|
|
168
|
+
let evaluate = |expression: &Expression<'_>| evaluate(script, expression, options, globals);
|
|
142
169
|
Ok(match expression {
|
|
143
|
-
|
|
144
|
-
|
|
170
|
+
Expression::ParenthesizedExpression(paren) => evaluate(&paren.expression)?,
|
|
171
|
+
Expression::StringLiteral(_) | Expression::TemplateLiteral(_) => Some(JsValue::from(
|
|
145
172
|
ast::static_str(expression).context("unsupported template or string literal")?,
|
|
146
173
|
)),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
Expression::NumericLiteral(number) => Some(JsValue::Number(number.value)),
|
|
175
|
+
Expression::BooleanLiteral(value) => Some(JsValue::Bool(value.value)),
|
|
176
|
+
Expression::NullLiteral(_) => Some(JsValue::Null),
|
|
177
|
+
Expression::Identifier(_) if script.is_global(expression, "undefined") => None,
|
|
151
178
|
// `JSON.stringify` writes an undefined element as `null`.
|
|
152
|
-
|
|
153
|
-
let mut elements = Vec::with_capacity(array.
|
|
154
|
-
for element in &array.
|
|
155
|
-
let element = element
|
|
156
|
-
|
|
157
|
-
|
|
179
|
+
Expression::ArrayExpression(array) => {
|
|
180
|
+
let mut elements = Vec::with_capacity(array.elements.len());
|
|
181
|
+
for element in &array.elements {
|
|
182
|
+
let element = match element {
|
|
183
|
+
ArrayExpressionElement::Elision(_) => bail!("unsupported array hole"),
|
|
184
|
+
ArrayExpressionElement::SpreadElement(_) => bail!("unsupported spread element"),
|
|
185
|
+
element => element.to_expression(),
|
|
186
|
+
};
|
|
187
|
+
elements.push(evaluate(element)?.unwrap_or(JsValue::Null));
|
|
158
188
|
}
|
|
159
189
|
Some(JsValue::Array(elements))
|
|
160
190
|
}
|
|
161
|
-
|
|
191
|
+
Expression::ObjectExpression(object) => Some(JsValue::Object(
|
|
162
192
|
ast::key_values(object)
|
|
163
193
|
.filter_map(|property| {
|
|
164
194
|
let value = evaluate(&property.value).ok()??;
|
|
165
|
-
Some((
|
|
195
|
+
Some((
|
|
196
|
+
ast::key_str(&property.key, property.computed)?.to_owned(),
|
|
197
|
+
value,
|
|
198
|
+
))
|
|
166
199
|
})
|
|
167
200
|
.collect(),
|
|
168
201
|
)),
|
|
169
202
|
// `!x` is always a boolean; an unset option is `undefined`, so falsy.
|
|
170
|
-
|
|
171
|
-
!evaluate(&unary.
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
let left = evaluate(&
|
|
175
|
-
match
|
|
203
|
+
Expression::UnaryExpression(unary) if unary.operator == UnaryOperator::LogicalNot => Some(
|
|
204
|
+
JsValue::Bool(!evaluate(&unary.argument)?.as_ref().is_some_and(js::truthy)),
|
|
205
|
+
),
|
|
206
|
+
Expression::LogicalExpression(logical) => {
|
|
207
|
+
let left = evaluate(&logical.left)?;
|
|
208
|
+
match logical.operator {
|
|
176
209
|
// The right-hand side runs only when the left is falsy.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
210
|
+
LogicalOperator::Or if left.as_ref().is_some_and(js::truthy) => left,
|
|
211
|
+
LogicalOperator::Or => evaluate(&logical.right)?,
|
|
212
|
+
operator => bail!("unsupported operator {}", operator.as_str()),
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
Expression::BinaryExpression(binary) => {
|
|
216
|
+
let left = evaluate(&binary.left)?;
|
|
217
|
+
match binary.operator {
|
|
218
|
+
BinaryOperator::Subtraction => Some(JsValue::Number(
|
|
180
219
|
js::number(left.as_ref()) - js::number(evaluate(&binary.right)?.as_ref()),
|
|
181
220
|
)),
|
|
182
|
-
|
|
221
|
+
BinaryOperator::Addition => {
|
|
183
222
|
let right = evaluate(&binary.right)?;
|
|
184
223
|
// Strings, arrays, and objects trigger string concatenation; other values
|
|
185
224
|
// use numeric addition.
|
|
@@ -196,7 +235,7 @@ pub(crate) fn evaluate(
|
|
|
196
235
|
JsValue::Number(js::number(left) + js::number(right))
|
|
197
236
|
})
|
|
198
237
|
}
|
|
199
|
-
|
|
238
|
+
BinaryOperator::StrictEquality | BinaryOperator::StrictInequality => {
|
|
200
239
|
let [left, right] = [left, evaluate(&binary.right)?]
|
|
201
240
|
.map(|value| value.unwrap_or(JsValue::Undefined));
|
|
202
241
|
// `JsValue` equality implements `===` for primitive values. Copies of
|
|
@@ -208,17 +247,20 @@ pub(crate) fn evaluate(
|
|
|
208
247
|
"unsupported identity comparison of an object"
|
|
209
248
|
);
|
|
210
249
|
Some(JsValue::Bool(
|
|
211
|
-
(left == right) == (binary.
|
|
250
|
+
(left == right) == (binary.operator == BinaryOperator::StrictEquality),
|
|
212
251
|
))
|
|
213
252
|
}
|
|
214
|
-
operator => bail!("unsupported operator {
|
|
253
|
+
operator => bail!("unsupported operator {}", operator.as_str()),
|
|
215
254
|
}
|
|
216
255
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
256
|
+
Expression::StaticMemberExpression(_)
|
|
257
|
+
| Expression::ComputedMemberExpression(_)
|
|
258
|
+
| Expression::PrivateFieldExpression(_) => {
|
|
259
|
+
let member = expression.to_member_expression();
|
|
260
|
+
let key = ast::member_str(member).context("unsupported computed property")?;
|
|
261
|
+
match member.object() {
|
|
220
262
|
object if is_options(object) => options.get(key).cloned(),
|
|
221
|
-
|
|
263
|
+
Expression::Identifier(_) => globals.get(key).cloned(),
|
|
222
264
|
object => match evaluate(object)? {
|
|
223
265
|
Some(JsValue::Object(object)) => object.get(key).cloned(),
|
|
224
266
|
None | Some(JsValue::Undefined) => bail!("reads {key} of undefined"),
|
|
@@ -226,25 +268,28 @@ pub(crate) fn evaluate(
|
|
|
226
268
|
},
|
|
227
269
|
}
|
|
228
270
|
}
|
|
229
|
-
|
|
271
|
+
Expression::CallExpression(call) => {
|
|
230
272
|
let member = call
|
|
231
273
|
.callee
|
|
232
|
-
.
|
|
233
|
-
.and_then(|callee| callee.as_member())
|
|
274
|
+
.as_member_expression()
|
|
234
275
|
.context("unsupported call")?;
|
|
235
|
-
if
|
|
236
|
-
let [argument] = &call.
|
|
276
|
+
if script.is_method_of(member, "JSON", "stringify") {
|
|
277
|
+
let [argument] = &call.arguments[..] else {
|
|
237
278
|
bail!("unsupported JSON.stringify arguments");
|
|
238
279
|
};
|
|
239
|
-
|
|
280
|
+
let argument = argument
|
|
281
|
+
.as_expression()
|
|
282
|
+
.context("unsupported spread argument")?;
|
|
240
283
|
// `JSON.stringify(undefined)` is itself `undefined`.
|
|
241
|
-
evaluate(
|
|
284
|
+
evaluate(argument)?
|
|
242
285
|
.and_then(|value| value.stringify())
|
|
243
286
|
.map(JsValue::String)
|
|
244
|
-
} else if matches!(
|
|
287
|
+
} else if matches!(member.object(), Expression::Identifier(_))
|
|
288
|
+
&& call.arguments.is_empty()
|
|
289
|
+
{
|
|
245
290
|
// Use the getter's collected value instead of running the call.
|
|
246
291
|
globals
|
|
247
|
-
.get(ast::member_str(
|
|
292
|
+
.get(ast::member_str(member).context("unsupported computed getter")?)
|
|
248
293
|
.cloned()
|
|
249
294
|
} else {
|
|
250
295
|
bail!("unsupported call")
|
|
@@ -256,9 +301,8 @@ pub(crate) fn evaluate(
|
|
|
256
301
|
|
|
257
302
|
/// Whether an expression is the `_cf_chl_opt` object itself, rather than one of its properties.
|
|
258
303
|
#[must_use]
|
|
259
|
-
pub(crate) fn is_options(expression: &
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
)
|
|
304
|
+
pub(crate) fn is_options(expression: &Expression<'_>) -> bool {
|
|
305
|
+
expression
|
|
306
|
+
.as_member_expression()
|
|
307
|
+
.is_some_and(|member| ast::member_str(member) == Some("_cf_chl_opt"))
|
|
264
308
|
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
//! Audit-only recovery includes initialization's timer callbacks. It does not change the
|
|
2
|
+
//! options, key material, or globals used by the payload encoder.
|
|
3
|
+
|
|
4
|
+
use std::rc::Rc;
|
|
5
|
+
|
|
6
|
+
use oxc::syntax::operator::BinaryOperator;
|
|
7
|
+
|
|
8
|
+
use super::{Held, Installed};
|
|
9
|
+
use crate::challenge;
|
|
10
|
+
use crate::js::{JsValue, json};
|
|
11
|
+
use crate::listing::fold::{Frame, Known};
|
|
12
|
+
use crate::vm::{Effect, Listing, Term};
|
|
13
|
+
|
|
14
|
+
pub(super) fn read(listing: &Listing, installed: &mut Installed) {
|
|
15
|
+
let mut frame = Frame::<Held>::default();
|
|
16
|
+
for (&pc, instruction) in &listing.instructions {
|
|
17
|
+
for path in &instruction.paths {
|
|
18
|
+
frame.begin();
|
|
19
|
+
frame.follow(pc, &path.effects, evaluate, |frame, effect| {
|
|
20
|
+
// The key factory is declared by evaluating a literal function definition,
|
|
21
|
+
// after a Trusted Types wrapper has returned that same source string.
|
|
22
|
+
for argument in effect.call().map_or(&[][..], |(_, arguments)| arguments) {
|
|
23
|
+
if let Some(known) = frame.resolve(argument)
|
|
24
|
+
&& let Some(text) = known.text()
|
|
25
|
+
&& let Some(function) = text.strip_prefix("function ")
|
|
26
|
+
&& let Some((name, _)) = function.split_once('(')
|
|
27
|
+
&& challenge::is_hex_name(name)
|
|
28
|
+
{
|
|
29
|
+
installed.audit.insert(name.into(), "N".into());
|
|
30
|
+
installed
|
|
31
|
+
.audit_roles
|
|
32
|
+
.insert(name.into(), "function-factory".into());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
let Effect::SetProperty { object, key, value } = effect else {
|
|
36
|
+
return;
|
|
37
|
+
};
|
|
38
|
+
let (Some(object), Some(key)) = (frame.resolve(object), frame.resolve(key)) else {
|
|
39
|
+
return;
|
|
40
|
+
};
|
|
41
|
+
let value = frame.resolve(value);
|
|
42
|
+
if let Known::Ext(Held::AuditArray(array)) = &object
|
|
43
|
+
&& let Known::Literal(JsValue::Number(index)) = &key
|
|
44
|
+
&& *index >= 0.0
|
|
45
|
+
&& index.fract() == 0.0
|
|
46
|
+
{
|
|
47
|
+
let native = match &value {
|
|
48
|
+
Some(Known::Ext(Held::NativeFunction(name))) => {
|
|
49
|
+
Some(format!("function {name}() {{ [native code] }}"))
|
|
50
|
+
}
|
|
51
|
+
_ => None,
|
|
52
|
+
};
|
|
53
|
+
array.borrow_mut().insert(*index as usize, native);
|
|
54
|
+
}
|
|
55
|
+
if !matches!(object, Known::Ext(Held::Window)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let Some(name) = key.text().filter(|name| challenge::is_hex_name(name)) else {
|
|
59
|
+
return;
|
|
60
|
+
};
|
|
61
|
+
let (role, audit) = match value {
|
|
62
|
+
Some(Known::Ext(Held::AuditArray(array))) => {
|
|
63
|
+
let members: Option<Vec<String>> =
|
|
64
|
+
array.borrow().values().cloned().collect();
|
|
65
|
+
let Some(members) = members else {
|
|
66
|
+
return;
|
|
67
|
+
};
|
|
68
|
+
let role = if members.is_empty() {
|
|
69
|
+
"empty-array"
|
|
70
|
+
} else {
|
|
71
|
+
"native-array"
|
|
72
|
+
};
|
|
73
|
+
(role, members.join(","))
|
|
74
|
+
}
|
|
75
|
+
Some(Known::Ext(Held::GpuPromise)) => ("gpu-adapter", "o".into()),
|
|
76
|
+
Some(Known::Ext(Held::ClockDelta)) => ("clock-delta", String::new()),
|
|
77
|
+
_ => return,
|
|
78
|
+
};
|
|
79
|
+
installed.audit.insert(name.into(), audit);
|
|
80
|
+
installed.audit_roles.insert(name.into(), role.into());
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fn evaluate(frame: &Frame<Held>, value: &Term) -> Option<Known<Held>> {
|
|
87
|
+
let string = |term: &Term| match frame.resolve(term) {
|
|
88
|
+
Some(Known::Literal(JsValue::String(text))) => Some(text),
|
|
89
|
+
_ => None,
|
|
90
|
+
};
|
|
91
|
+
match value {
|
|
92
|
+
Term::Array(elements) if elements.is_empty() => {
|
|
93
|
+
return Some(Known::Ext(Held::AuditArray(Rc::default())));
|
|
94
|
+
}
|
|
95
|
+
Term::Get(_, key) => {
|
|
96
|
+
if let Some(name @ ("querySelector" | "querySelectorAll")) =
|
|
97
|
+
frame.resolve(key).as_ref().and_then(Known::text)
|
|
98
|
+
{
|
|
99
|
+
return Some(Known::Ext(Held::NativeFunction(name.into())));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
Term::Call {
|
|
103
|
+
callee, arguments, ..
|
|
104
|
+
} => {
|
|
105
|
+
if let Term::Get(_, method) = &**callee {
|
|
106
|
+
match frame.resolve(method).as_ref().and_then(Known::text) {
|
|
107
|
+
Some("now") => return Some(Known::Ext(Held::Clock)),
|
|
108
|
+
Some("requestAdapter") => return Some(Known::Ext(Held::GpuPromise)),
|
|
109
|
+
_ => {}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if let [argument] = arguments.as_slice()
|
|
113
|
+
&& let Some(text) = string(argument)
|
|
114
|
+
&& text.starts_with("function ")
|
|
115
|
+
{
|
|
116
|
+
return Some(Known::Literal(json!(text)));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
Term::Binary(BinaryOperator::Subtraction, _, right)
|
|
120
|
+
if matches!(frame.resolve(right), Some(Known::Ext(Held::Clock))) =>
|
|
121
|
+
{
|
|
122
|
+
return Some(Known::Ext(Held::ClockDelta));
|
|
123
|
+
}
|
|
124
|
+
Term::Binary(BinaryOperator::Addition, left, right) => {
|
|
125
|
+
if let (Some(left), Some(right)) = (string(left), string(right)) {
|
|
126
|
+
return Some(Known::Literal(json!(format!("{left}{right}"))));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
_ => {}
|
|
130
|
+
}
|
|
131
|
+
super::evaluate(frame, value)
|
|
132
|
+
}
|