cfsolve 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/THIRD_PARTY_LICENSES/README.md +71 -254
- data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
- data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
- data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
- data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
- data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
- data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
- data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
- data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
- data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
- data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
- data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
- data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
- data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
- data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
- data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
- data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
- data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
- data/UPSTREAM.md +7 -5
- data/ext/cfsolve/Cargo.lock +534 -1727
- data/ext/cfsolve/Cargo.toml +4 -0
- data/ext/cfsolve/src/main.rs +1 -1
- data/lib/cfsolve/profiles/safari-26-ios/answers.json +266 -265
- data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
- data/lib/cfsolve/profiles/safari-26-ios.json +106 -152
- data/lib/cfsolve/version.rb +2 -2
- data/vendor/cfsolve/Cargo.lock +561 -1729
- data/vendor/cfsolve/Cargo.toml +26 -8
- data/vendor/cfsolve/README.md +4 -0
- data/vendor/cfsolve/examples/check_answers.rs +2 -2
- data/vendor/cfsolve/examples/compare_session.rs +1 -2
- data/vendor/cfsolve/examples/solver_profile.rs +84 -0
- data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
- data/vendor/cfsolve/examples/stage2_snapshot.rs +2 -2
- data/vendor/cfsolve/examples/tls_echo.rs +3 -3
- data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
- data/vendor/cfsolve/profiles/safari-26-ios/answers.json +266 -265
- data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
- data/vendor/cfsolve/profiles/safari-26-ios.json +106 -152
- data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
- data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
- data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
- data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
- data/vendor/cfsolve/src/capture/proxy.rs +44 -13
- data/vendor/cfsolve/src/capture/sessions.rs +4 -3
- data/vendor/cfsolve/src/capture/upstream.rs +1 -1
- data/vendor/cfsolve/src/challenge/codec.rs +4 -2
- data/vendor/cfsolve/src/challenge/expression.rs +161 -117
- data/vendor/cfsolve/src/challenge/installed/audit.rs +11 -10
- data/vendor/cfsolve/src/challenge/installed.rs +13 -6
- data/vendor/cfsolve/src/challenge/merge.rs +120 -80
- data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
- data/vendor/cfsolve/src/challenge/payload.rs +69 -31
- data/vendor/cfsolve/src/challenge/program.rs +197 -178
- data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
- data/vendor/cfsolve/src/challenge/source.rs +151 -96
- data/vendor/cfsolve/src/challenge/state.rs +180 -148
- data/vendor/cfsolve/src/challenge/tally.rs +64 -50
- data/vendor/cfsolve/src/challenge.rs +1 -0
- data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
- data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
- data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
- data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
- data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
- data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
- data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
- data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
- data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
- data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
- data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
- data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
- data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
- data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
- data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
- data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
- data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
- data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +198 -203
- data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
- data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +338 -513
- data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
- data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
- data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
- data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
- data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
- data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
- data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
- data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +353 -327
- data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
- data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
- data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
- data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
- data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
- data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
- data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
- data/vendor/cfsolve/src/deobfuscate.rs +15 -11
- data/vendor/cfsolve/src/embedding_page/extra_params.rs +23 -18
- data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
- data/vendor/cfsolve/src/error.rs +40 -5
- data/vendor/cfsolve/src/fingerprint.rs +8 -2
- data/vendor/cfsolve/src/http/client.rs +7 -10
- data/vendor/cfsolve/src/http/requests.rs +2 -2
- data/vendor/cfsolve/src/js/ast.rs +479 -263
- data/vendor/cfsolve/src/lib.rs +1 -0
- data/vendor/cfsolve/src/listing/fold.rs +19 -9
- data/vendor/cfsolve/src/listing/query.rs +1 -47
- data/vendor/cfsolve/src/performance_clock.rs +20 -1
- data/vendor/cfsolve/src/profiling.rs +49 -0
- data/vendor/cfsolve/src/script.rs +35 -24
- data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
- data/vendor/cfsolve/src/session/channel.rs +2 -2
- data/vendor/cfsolve/src/session/initial.rs +5 -5
- data/vendor/cfsolve/src/session/sink.rs +26 -1
- data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
- data/vendor/cfsolve/src/session.rs +1 -1
- data/vendor/cfsolve/src/solver.rs +3 -1
- data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
- data/vendor/cfsolve/src/stage2/analysis/envelope.rs +2 -1
- data/vendor/cfsolve/src/stage2/audit_globals.rs +142 -74
- data/vendor/cfsolve/src/stage2/benchmark.rs +62 -31
- data/vendor/cfsolve/src/stage2/call_stack.rs +1415 -1025
- data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
- data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
- data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
- data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -4
- data/vendor/cfsolve/src/stage2/payload/recover.rs +2 -2
- data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
- data/vendor/cfsolve/src/stage2/probes/performance.rs +12 -8
- data/vendor/cfsolve/src/stage2/queries.rs +50 -0
- data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
- data/vendor/cfsolve/src/stage2/trace.rs +134 -108
- data/vendor/cfsolve/src/stage2/vocabulary.rs +1 -11
- data/vendor/cfsolve/src/stage2.rs +2 -0
- data/vendor/cfsolve/src/vm/disassemble.rs +7 -3
- data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
- data/vendor/cfsolve/src/vm/extract.rs +347 -250
- data/vendor/cfsolve/src/vm/interpret/access.rs +63 -48
- data/vendor/cfsolve/src/vm/interpret/builtin.rs +10 -10
- data/vendor/cfsolve/src/vm/interpret/call.rs +116 -52
- data/vendor/cfsolve/src/vm/interpret/compile.rs +79 -62
- data/vendor/cfsolve/src/vm/interpret/copies.rs +2 -2
- data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +63 -42
- data/vendor/cfsolve/src/vm/interpret/evaluate.rs +65 -575
- data/vendor/cfsolve/src/vm/interpret/explore.rs +7 -10
- data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
- data/vendor/cfsolve/src/vm/interpret/frozen.rs +3 -5
- data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +123 -59
- data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
- data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
- data/vendor/cfsolve/src/vm/interpret/pattern.rs +1736 -0
- data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
- data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
- data/vendor/cfsolve/src/vm/interpret/run.rs +116 -45
- data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
- data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
- data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
- data/vendor/cfsolve/src/vm/interpret.rs +9 -1
- data/vendor/cfsolve/src/vm/machine.rs +56 -49
- data/vendor/cfsolve/src/vm/output.rs +13 -5
- data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
- data/vendor/cfsolve/src/vm/session.rs +185 -120
- data/vendor/cfsolve/src/vm/value.rs +22 -19
- data/vendor/cfsolve/src/vm.rs +2 -1
- data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
- data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
- metadata +94 -178
- data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
- data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
- data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
- data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
- data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
- data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
- data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
- data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
- data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
- data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
- data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
- data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
- data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
- data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
- data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
- data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
- data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
- data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
- data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
- data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
- data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
- data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
- data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
- /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
- /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
- /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{cargo-platform-0.1.9 → zmij_ecma-1.0.23}/LICENSE-MIT +0 -0
|
@@ -1,242 +1,235 @@
|
|
|
1
|
-
//! Counts binding
|
|
2
|
-
//! single assignments and follow copies to their source.
|
|
1
|
+
//! Counts binding writes and reads in the current tree.
|
|
3
2
|
|
|
4
3
|
use std::mem;
|
|
5
4
|
|
|
6
|
-
use
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
use oxc::ast::ast::{
|
|
6
|
+
AssignmentExpression, AssignmentTarget, BindingPattern, Class, ClassType, Expression,
|
|
7
|
+
ForStatementLeft, FormalParameters, Function, FunctionType, IdentifierReference,
|
|
8
|
+
MemberExpression, Program, SimpleAssignmentTarget, UpdateExpression, VariableDeclarator,
|
|
9
9
|
};
|
|
10
|
-
use
|
|
11
|
-
use
|
|
10
|
+
use oxc::ast_visit::{Visit, walk};
|
|
11
|
+
use oxc::semantic::Scoping;
|
|
12
|
+
use oxc::syntax::operator::AssignmentOperator;
|
|
13
|
+
use oxc::syntax::scope::ScopeFlags;
|
|
12
14
|
|
|
13
|
-
use
|
|
15
|
+
use super::Id;
|
|
16
|
+
use crate::deobfuscate::{HashMap, HashSet, ast};
|
|
14
17
|
|
|
15
|
-
///
|
|
16
|
-
///
|
|
18
|
+
/// Writes and value reads by binding identity, since spelling alone does not identify a local
|
|
19
|
+
/// across scopes.
|
|
17
20
|
///
|
|
18
|
-
/// Writes include assignments, updates, initialized declarations, `for-in` and `for-of`
|
|
19
|
-
///
|
|
20
|
-
/// helpers may use parameter slots whose incoming values are never read.
|
|
21
|
-
/// be used for substitution only when its binding has exactly one write.
|
|
21
|
+
/// Writes include assignments, updates, initialized declarations, `for-in` and `for-of` targets,
|
|
22
|
+
/// and function or class declarations. Parameters and catch bindings do not count as writes:
|
|
23
|
+
/// helpers may use parameter slots whose incoming values are never read.
|
|
22
24
|
#[derive(Default)]
|
|
23
|
-
pub(crate) struct Bindings {
|
|
24
|
-
writes: HashMap<Id,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
pub(in crate::deobfuscate) struct Bindings {
|
|
26
|
+
writes: HashMap<Id, usize>,
|
|
27
|
+
/// Counted from reference flags, including the object read in `binding.property`.
|
|
28
|
+
reads: HashMap<Id, usize>,
|
|
29
|
+
/// The source of each plain copy assignment `target = source`.
|
|
30
|
+
copies: HashMap<Id, Id>,
|
|
31
|
+
/// Function and arrow parameters, including bindings inside destructuring patterns.
|
|
29
32
|
parameters: HashSet<Id>,
|
|
30
|
-
/// Parameters of functions that use `arguments`.
|
|
33
|
+
/// Parameters of functions that use `arguments`. In sloppy mode, `arguments[i]` can observe
|
|
34
|
+
/// parameter writes, so passes must preserve those stores and parameter bindings.
|
|
31
35
|
mapped: HashSet<Id>,
|
|
32
|
-
/// Whether the function being visited refers to its `arguments`.
|
|
33
|
-
uses_arguments: bool,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/// One write, and the assigned value when analysis can follow it.
|
|
37
|
-
enum Write {
|
|
38
|
-
/// `binding = other` or `var binding = other`.
|
|
39
|
-
Copy(Id),
|
|
40
|
-
Other,
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
impl Bindings {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
pub(super) fn collect(program: &Program<'_>, scoping: &Scoping) -> Self {
|
|
40
|
+
let mut collect = Collect {
|
|
41
|
+
scoping,
|
|
42
|
+
bindings: Self::default(),
|
|
43
|
+
arguments: false,
|
|
44
|
+
};
|
|
45
|
+
collect.visit_program(program);
|
|
46
|
+
collect.bindings
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
self.writes.get(id).map_or(0, Vec::len)
|
|
49
|
+
pub(in crate::deobfuscate) fn write_count(&self, id: &Id) -> usize {
|
|
50
|
+
self.writes.get(id).copied().unwrap_or(0)
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
pub(in crate::deobfuscate) fn references(&self, id: &Id) -> usize {
|
|
54
|
+
self.reads.get(id).copied().unwrap_or(0)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
pub(in crate::deobfuscate) fn is_written_once(&self, id: &Id) -> bool {
|
|
59
58
|
self.write_count(id) == 1
|
|
60
59
|
}
|
|
61
60
|
|
|
62
|
-
///
|
|
63
|
-
|
|
64
|
-
pub(crate) fn
|
|
65
|
-
|
|
61
|
+
/// Checks for a local binding that is never assigned and that `arguments` does not alias, so
|
|
62
|
+
/// every read sees the value it was declared or called with.
|
|
63
|
+
pub(in crate::deobfuscate) fn is_never_written(&self, id: &Id) -> bool {
|
|
64
|
+
!id.is_global() && self.write_count(id) == 0 && !self.is_mapped_parameter(id)
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
#[must_use]
|
|
70
|
-
pub(crate) fn is_parameter(&self, id: &Id) -> bool {
|
|
67
|
+
pub(in crate::deobfuscate) fn is_parameter(&self, id: &Id) -> bool {
|
|
71
68
|
self.parameters.contains(id)
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
/// `arguments[i]` can observe parameter writes and changes to the parameter list.
|
|
76
|
-
#[must_use]
|
|
77
|
-
pub(crate) fn is_mapped_parameter(&self, id: &Id) -> bool {
|
|
71
|
+
pub(in crate::deobfuscate) fn is_mapped_parameter(&self, id: &Id) -> bool {
|
|
78
72
|
self.mapped.contains(id)
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
/// Returns the source
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
match self.writes.get(id)?.as_slice() {
|
|
85
|
-
[Write::Copy(source)] => Some(source),
|
|
86
|
-
_ => None,
|
|
87
|
-
}
|
|
75
|
+
/// Returns the source of a plain copy assignment if it is the binding's only write.
|
|
76
|
+
pub(in crate::deobfuscate) fn copy_source(&self, id: &Id) -> Option<&Id> {
|
|
77
|
+
self.copies.get(id).filter(|_| self.is_written_once(id))
|
|
88
78
|
}
|
|
89
79
|
|
|
90
|
-
///
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
80
|
+
/// Checks whether another single-write binding copies this binding's value.
|
|
81
|
+
pub(in crate::deobfuscate) fn is_copied(&self, id: &Id) -> bool {
|
|
82
|
+
self.copies
|
|
83
|
+
.iter()
|
|
84
|
+
.any(|(alias, source)| source == id && self.is_written_once(alias))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// Follows single-write copies to their original binding, stopping at cycles.
|
|
88
|
+
pub(in crate::deobfuscate) fn root(&self, id: &Id) -> Id {
|
|
89
|
+
let mut id = *id;
|
|
95
90
|
let mut seen = HashSet::default();
|
|
96
|
-
while let Some(
|
|
97
|
-
if !seen.insert(
|
|
91
|
+
while let Some(&next) = self.copy_source(&id) {
|
|
92
|
+
if !seen.insert(id) {
|
|
98
93
|
break;
|
|
99
94
|
}
|
|
100
|
-
|
|
95
|
+
id = next
|
|
101
96
|
}
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/// The [`Self::root`] of every binding that has a copy source.
|
|
106
|
-
#[must_use]
|
|
107
|
-
pub(crate) fn roots(&self) -> HashMap<Id, Id> {
|
|
108
|
-
let copies = self
|
|
109
|
-
.writes
|
|
110
|
-
.keys()
|
|
111
|
-
.filter(|id| self.copy_source(id).is_some());
|
|
112
|
-
copies.map(|id| (id.clone(), self.root(id))).collect()
|
|
97
|
+
id
|
|
113
98
|
}
|
|
99
|
+
}
|
|
114
100
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
101
|
+
struct Collect<'s> {
|
|
102
|
+
scoping: &'s Scoping,
|
|
103
|
+
bindings: Bindings,
|
|
104
|
+
/// Whether the current function mentions `arguments`.
|
|
105
|
+
arguments: bool,
|
|
106
|
+
}
|
|
122
107
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
108
|
+
impl Collect<'_> {
|
|
109
|
+
fn write(&mut self, id: Id, value: Option<&Expression<'_>>) {
|
|
110
|
+
*self.bindings.writes.entry(id).or_default() += 1;
|
|
111
|
+
let source = value
|
|
112
|
+
.and_then(Expression::get_identifier_reference)
|
|
113
|
+
.and_then(|reference| Id::of(reference, self.scoping));
|
|
114
|
+
if let Some(source) = source {
|
|
115
|
+
self.bindings.copies.insert(id, source);
|
|
126
116
|
}
|
|
127
117
|
}
|
|
128
118
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.entry(source.to_id())
|
|
134
|
-
.or_default()
|
|
135
|
-
.push(id.clone());
|
|
136
|
-
Write::Copy(source.to_id())
|
|
137
|
-
} else {
|
|
138
|
-
Write::Other
|
|
139
|
-
};
|
|
140
|
-
self.writes.entry(id).or_default().push(write);
|
|
119
|
+
fn write_pattern(&mut self, pattern: &BindingPattern<'_>) {
|
|
120
|
+
for id in pattern_ids(pattern) {
|
|
121
|
+
self.write(id, None)
|
|
122
|
+
}
|
|
141
123
|
}
|
|
124
|
+
}
|
|
142
125
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
126
|
+
fn pattern_ids(pattern: &BindingPattern<'_>) -> impl Iterator<Item = Id> {
|
|
127
|
+
let bindings = pattern.get_binding_identifiers().into_iter();
|
|
128
|
+
bindings.filter_map(|binding| binding.symbol_id.get().map(Id::Local))
|
|
146
129
|
}
|
|
147
130
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
match assignment.left.as_ident() {
|
|
151
|
-
Some(target) if assignment.op == AssignOp::Assign => {
|
|
152
|
-
self.write_value(target.to_id(), &assignment.right);
|
|
153
|
-
}
|
|
154
|
-
_ => self.write(&assignment.left),
|
|
155
|
-
}
|
|
156
|
-
assignment.visit_children_with(self);
|
|
157
|
-
}
|
|
131
|
+
/// Visits only target bindings; computed member operands and default values execute separately.
|
|
132
|
+
struct Targets<'b, 's>(&'b mut Collect<'s>);
|
|
158
133
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
134
|
+
impl<'a> Visit<'a> for Targets<'_, '_> {
|
|
135
|
+
fn visit_identifier_reference(&mut self, reference: &IdentifierReference<'a>) {
|
|
136
|
+
if let Some(id) = Id::of(reference, self.0.scoping) {
|
|
137
|
+
self.0.write(id, None)
|
|
162
138
|
}
|
|
163
|
-
update.visit_children_with(self);
|
|
164
139
|
}
|
|
165
140
|
|
|
166
|
-
fn
|
|
167
|
-
if let Some(init) = &declarator.init {
|
|
168
|
-
match declarator.name.as_ident() {
|
|
169
|
-
Some(name) => self.write_value(name.to_id(), init),
|
|
170
|
-
None => self.write(&declarator.name),
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
declarator.visit_children_with(self);
|
|
174
|
-
}
|
|
141
|
+
fn visit_member_expression(&mut self, _: &MemberExpression<'a>) {}
|
|
175
142
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
self.write(head);
|
|
179
|
-
head.visit_children_with(self);
|
|
180
|
-
}
|
|
143
|
+
fn visit_expression(&mut self, _: &Expression<'a>) {}
|
|
144
|
+
}
|
|
181
145
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
146
|
+
impl<'a> Visit<'a> for Collect<'_> {
|
|
147
|
+
fn visit_identifier_reference(&mut self, reference: &IdentifierReference<'a>) {
|
|
148
|
+
self.arguments |= ast::is_arguments(reference);
|
|
149
|
+
if let Some(id) = Id::of(reference, self.scoping) {
|
|
150
|
+
let reference_id = reference.reference_id.get().expect("resolved reference");
|
|
151
|
+
if self.scoping.get_reference(reference_id).is_read() {
|
|
152
|
+
*self.bindings.reads.entry(id).or_default() += 1
|
|
153
|
+
}
|
|
154
|
+
}
|
|
185
155
|
}
|
|
186
156
|
|
|
187
|
-
fn
|
|
188
|
-
|
|
189
|
-
|
|
157
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
158
|
+
if let AssignmentTarget::AssignmentTargetIdentifier(target) = &assignment.left {
|
|
159
|
+
if let Some(id) = Id::of(target, self.scoping) {
|
|
160
|
+
let copied = assignment.operator == AssignmentOperator::Assign;
|
|
161
|
+
self.write(id, copied.then_some(&assignment.right))
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
Targets(self).visit_assignment_target(&assignment.left);
|
|
165
|
+
}
|
|
166
|
+
walk::walk_assignment_expression(self, assignment)
|
|
190
167
|
}
|
|
191
168
|
|
|
192
|
-
fn
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
self.mapped.extend(
|
|
198
|
-
function
|
|
199
|
-
.params
|
|
200
|
-
.iter()
|
|
201
|
-
.flat_map(|param| swc_ecma_utils::find_pat_ids::<_, Id>(¶m.pat)),
|
|
202
|
-
);
|
|
169
|
+
fn visit_update_expression(&mut self, update: &UpdateExpression<'a>) {
|
|
170
|
+
if let SimpleAssignmentTarget::AssignmentTargetIdentifier(target) = &update.argument
|
|
171
|
+
&& let Some(id) = Id::of(target, self.scoping)
|
|
172
|
+
{
|
|
173
|
+
self.write(id, None)
|
|
203
174
|
}
|
|
175
|
+
walk::walk_update_expression(self, update)
|
|
204
176
|
}
|
|
205
177
|
|
|
206
|
-
fn
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
178
|
+
fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
|
|
179
|
+
if let Some(value) = &declarator.init {
|
|
180
|
+
match ast::pattern_id(&declarator.id) {
|
|
181
|
+
Some(id) => self.write(id, Some(value)),
|
|
182
|
+
None => self.write_pattern(&declarator.id),
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
walk::walk_variable_declarator(self, declarator)
|
|
210
186
|
}
|
|
211
187
|
|
|
212
|
-
fn
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
188
|
+
fn visit_for_statement_left(&mut self, left: &ForStatementLeft<'a>) {
|
|
189
|
+
if let ForStatementLeft::VariableDeclaration(declaration) = left {
|
|
190
|
+
for declarator in &declaration.declarations {
|
|
191
|
+
self.write_pattern(&declarator.id)
|
|
192
|
+
}
|
|
193
|
+
} else if let Some(target) = left.as_assignment_target() {
|
|
194
|
+
Targets(self).visit_assignment_target(target)
|
|
195
|
+
}
|
|
196
|
+
walk::walk_for_statement_left(self, left)
|
|
216
197
|
}
|
|
217
198
|
|
|
218
|
-
fn
|
|
219
|
-
|
|
199
|
+
fn visit_function(&mut self, function: &Function<'a>, flags: ScopeFlags) {
|
|
200
|
+
if function.r#type == FunctionType::FunctionDeclaration
|
|
201
|
+
&& let Some(id) = ast::function_id(function)
|
|
202
|
+
{
|
|
203
|
+
self.write(id, None)
|
|
204
|
+
}
|
|
205
|
+
let outer = mem::take(&mut self.arguments);
|
|
206
|
+
walk::walk_function(self, function, flags);
|
|
207
|
+
if mem::replace(&mut self.arguments, outer) {
|
|
208
|
+
for parameter in &function.params.items {
|
|
209
|
+
self.bindings.mapped.extend(pattern_ids(¶meter.pattern));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
220
212
|
}
|
|
221
213
|
|
|
222
|
-
fn
|
|
223
|
-
if
|
|
224
|
-
|
|
214
|
+
fn visit_class(&mut self, class: &Class<'a>) {
|
|
215
|
+
if class.r#type == ClassType::ClassDeclaration
|
|
216
|
+
&& let Some(symbol) = class.id.as_ref().and_then(|id| id.symbol_id.get())
|
|
217
|
+
{
|
|
218
|
+
self.write(Id::Local(symbol), None)
|
|
225
219
|
}
|
|
226
|
-
|
|
220
|
+
walk::walk_class(self, class)
|
|
227
221
|
}
|
|
228
222
|
|
|
229
|
-
fn
|
|
230
|
-
|
|
231
|
-
self.
|
|
223
|
+
fn visit_formal_parameters(&mut self, parameters: &FormalParameters<'a>) {
|
|
224
|
+
for pattern in parameters.iter_bindings() {
|
|
225
|
+
self.bindings.parameters.extend(pattern_ids(pattern));
|
|
232
226
|
}
|
|
233
|
-
|
|
227
|
+
walk::walk_formal_parameters(self, parameters)
|
|
234
228
|
}
|
|
235
229
|
}
|
|
236
230
|
|
|
237
231
|
#[cfg(test)]
|
|
238
232
|
mod tests {
|
|
239
|
-
use super::Bindings;
|
|
240
233
|
use crate::deobfuscate::testing;
|
|
241
234
|
|
|
242
235
|
#[test]
|
|
@@ -249,20 +242,29 @@ mod tests {
|
|
|
249
242
|
for (const [a, b] of list) {}
|
|
250
243
|
return once.x + escaped.y + m.z + m[\"w\"] + mutated.x + { param };
|
|
251
244
|
}",
|
|
252
|
-
|
|
|
253
|
-
let
|
|
254
|
-
assert!(
|
|
255
|
-
assert!(!
|
|
256
|
-
assert!(
|
|
257
|
-
assert!(!
|
|
258
|
-
assert!(
|
|
259
|
-
assert!(
|
|
260
|
-
assert!(
|
|
261
|
-
assert!(!
|
|
262
|
-
assert_eq!(
|
|
263
|
-
assert_eq!(
|
|
264
|
-
assert_eq!(
|
|
265
|
-
assert_eq!(
|
|
245
|
+
|_, analysis, id| {
|
|
246
|
+
let bindings = &analysis.bindings;
|
|
247
|
+
assert!(bindings.is_written_once(&id("once")));
|
|
248
|
+
assert!(!bindings.is_written_once(&id("twice")));
|
|
249
|
+
assert!(bindings.is_written_once(&id("escaped")));
|
|
250
|
+
assert!(!bindings.is_written_once(&id("counted")));
|
|
251
|
+
assert!(bindings.is_written_once(&id("declared")));
|
|
252
|
+
assert!(bindings.is_written_once(&id("g")));
|
|
253
|
+
assert!(bindings.is_written_once(&id("a")));
|
|
254
|
+
assert!(!bindings.is_written_once(&id("m")));
|
|
255
|
+
assert_eq!(bindings.references(&id("m")), 3);
|
|
256
|
+
assert_eq!(bindings.references(&id("escaped")), 2);
|
|
257
|
+
assert_eq!(bindings.references(&id("param")), 1);
|
|
258
|
+
assert_eq!(bindings.references(&id("mutated")), 2);
|
|
259
|
+
},
|
|
260
|
+
);
|
|
261
|
+
// Compound assignments and destructuring loop heads are writes.
|
|
262
|
+
testing::check(
|
|
263
|
+
"function f(a,b,c){a+=b;c=1;for([c] of list){}}",
|
|
264
|
+
|_, analysis, id| {
|
|
265
|
+
assert_eq!(analysis.bindings.copy_source(&id("a")), None);
|
|
266
|
+
assert_eq!(analysis.bindings.write_count(&id("a")), 1);
|
|
267
|
+
assert_eq!(analysis.bindings.write_count(&id("c")), 2);
|
|
266
268
|
},
|
|
267
269
|
);
|
|
268
270
|
}
|
|
@@ -276,8 +278,8 @@ mod tests {
|
|
|
276
278
|
h = {}; p = h; var q = p;
|
|
277
279
|
return late;
|
|
278
280
|
}",
|
|
279
|
-
|
|
|
280
|
-
let bindings =
|
|
281
|
+
|_, analysis, id| {
|
|
282
|
+
let bindings = &analysis.bindings;
|
|
281
283
|
assert_eq!(bindings.root(&id("q")), id("h"));
|
|
282
284
|
assert_eq!(bindings.root(&id("late")), id("d"));
|
|
283
285
|
assert_eq!(bindings.root(&id("mixed")), id("mixed"));
|
|
@@ -286,8 +288,8 @@ mod tests {
|
|
|
286
288
|
testing::check(
|
|
287
289
|
"function f(a, [b]) { return () => arguments[0]; }
|
|
288
290
|
function g(c) { return function () { return arguments; }; }",
|
|
289
|
-
|
|
|
290
|
-
let bindings =
|
|
291
|
+
|_, analysis, id| {
|
|
292
|
+
let bindings = &analysis.bindings;
|
|
291
293
|
assert!(bindings.is_mapped_parameter(&id("a")));
|
|
292
294
|
assert!(bindings.is_mapped_parameter(&id("b")));
|
|
293
295
|
assert!(!bindings.is_mapped_parameter(&id("c")));
|
|
@@ -1,75 +1,66 @@
|
|
|
1
|
-
//! Tracks
|
|
1
|
+
//! Tracks the bindings an expression reads and writes.
|
|
2
2
|
|
|
3
|
-
use
|
|
4
|
-
use
|
|
5
|
-
use
|
|
3
|
+
use oxc::ast::ast::{ArrowFunctionExpression, Expression, Function, IdentifierReference};
|
|
4
|
+
use oxc::ast_visit::{Visit, walk};
|
|
5
|
+
use oxc::syntax::scope::ScopeFlags;
|
|
6
6
|
|
|
7
|
-
use super::
|
|
7
|
+
use super::{Analysis, Id};
|
|
8
8
|
use crate::deobfuscate::HashSet;
|
|
9
9
|
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
///
|
|
13
|
-
/// a known browser global without a getter, such as `Math` or `undefined`. Other globals may
|
|
14
|
-
/// throw `ReferenceError` or invoke a getter.
|
|
15
|
-
#[must_use]
|
|
16
|
-
pub(crate) fn may_have_effects(expression: &Expr, globals: Globals) -> bool {
|
|
17
|
-
use swc_ecma_utils::ExprExt;
|
|
18
|
-
|
|
19
|
-
expression.may_have_side_effects(ExprCtx {
|
|
20
|
-
unresolved_ctxt: globals.unresolved,
|
|
21
|
-
is_unresolved_ref_safe: false,
|
|
22
|
-
in_strict: false,
|
|
23
|
-
remaining_depth: 4,
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/// Tracks binding reads and writes outside function bodies. Creating a closure does not execute
|
|
28
|
-
/// its body. Does not analyze the effects of calls, `new`, tagged templates, `await`, or
|
|
29
|
-
/// `yield`.
|
|
10
|
+
/// Binding reads and writes outside function bodies, since creating a closure does not run its
|
|
11
|
+
/// body. Calls, construction, tagged templates, `await`, and `yield` are opaque: they may change
|
|
12
|
+
/// a binding through code that this local scan cannot analyze.
|
|
30
13
|
#[derive(Default)]
|
|
31
|
-
pub(crate) struct Effects {
|
|
14
|
+
pub(in crate::deobfuscate) struct Effects {
|
|
32
15
|
pub reads: HashSet<Id>,
|
|
33
16
|
pub writes: HashSet<Id>,
|
|
34
17
|
pub opaque: bool,
|
|
35
18
|
}
|
|
36
19
|
|
|
37
20
|
impl Effects {
|
|
38
|
-
|
|
39
|
-
pub(crate) fn
|
|
40
|
-
let mut
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
/// Uses reference flags, so writes include destructuring targets.
|
|
22
|
+
pub(crate) fn expression(expression: &Expression<'_>, analysis: &Analysis<'_>) -> Self {
|
|
23
|
+
let mut uses = Uses {
|
|
24
|
+
analysis,
|
|
25
|
+
effects: Self::default(),
|
|
26
|
+
};
|
|
27
|
+
uses.visit_expression(expression);
|
|
28
|
+
uses.effects
|
|
43
29
|
}
|
|
44
30
|
}
|
|
45
31
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
fn visit_assign_expr(&mut self, assignment: &AssignExpr) {
|
|
52
|
-
self.writes
|
|
53
|
-
.extend(swc_ecma_utils::find_pat_ids::<_, Id>(&assignment.left));
|
|
54
|
-
assignment.visit_children_with(self);
|
|
55
|
-
}
|
|
32
|
+
struct Uses<'b, 'a> {
|
|
33
|
+
analysis: &'b Analysis<'a>,
|
|
34
|
+
effects: Effects,
|
|
35
|
+
}
|
|
56
36
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
impl<'a> Visit<'a> for Uses<'_, 'a> {
|
|
38
|
+
fn visit_identifier_reference(&mut self, reference: &IdentifierReference<'a>) {
|
|
39
|
+
if let Some(id) = self.analysis.id(reference) {
|
|
40
|
+
let reference_id = reference.reference_id.get().expect("resolved reference");
|
|
41
|
+
let flags = self.analysis.scoping.get_reference(reference_id).flags();
|
|
42
|
+
if flags.is_read() {
|
|
43
|
+
self.effects.reads.insert(id);
|
|
44
|
+
}
|
|
45
|
+
if flags.is_write() {
|
|
46
|
+
self.effects.writes.insert(id);
|
|
47
|
+
}
|
|
60
48
|
}
|
|
61
|
-
update.arg.visit_with(self);
|
|
62
49
|
}
|
|
63
50
|
|
|
64
|
-
fn
|
|
65
|
-
self.opaque |= matches!(
|
|
51
|
+
fn visit_expression(&mut self, expression: &Expression<'a>) {
|
|
52
|
+
self.effects.opaque |= matches!(
|
|
66
53
|
expression,
|
|
67
|
-
|
|
54
|
+
Expression::CallExpression(_)
|
|
55
|
+
| Expression::NewExpression(_)
|
|
56
|
+
| Expression::TaggedTemplateExpression(_)
|
|
57
|
+
| Expression::AwaitExpression(_)
|
|
58
|
+
| Expression::YieldExpression(_)
|
|
68
59
|
);
|
|
69
|
-
|
|
60
|
+
walk::walk_expression(self, expression)
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
fn visit_function(&mut self, _: &Function) {}
|
|
63
|
+
fn visit_function(&mut self, _: &Function<'a>, _: ScopeFlags) {}
|
|
73
64
|
|
|
74
|
-
fn
|
|
65
|
+
fn visit_arrow_function_expression(&mut self, _: &ArrowFunctionExpression<'a>) {}
|
|
75
66
|
}
|