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
|
@@ -25,105 +25,56 @@
|
|
|
25
25
|
|
|
26
26
|
use std::iter;
|
|
27
27
|
|
|
28
|
-
use
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
use
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
use super::{
|
|
36
|
-
use
|
|
37
|
-
|
|
38
|
-
///
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Decoding,
|
|
43
|
-
/// Also includes direct calls and selection by any numeric argument.
|
|
44
|
-
All,
|
|
28
|
+
use oxc::allocator::{CloneIn, GetAllocator, Vec as ArenaVec};
|
|
29
|
+
use oxc::ast::ast::{Argument, Expression, Function, Program, Statement};
|
|
30
|
+
use oxc::ast_visit::{VisitMut, walk_mut};
|
|
31
|
+
use oxc::span::Span;
|
|
32
|
+
use oxc::syntax::operator::{BinaryOperator, UnaryOperator};
|
|
33
|
+
use oxc_ecmascript::side_effects::MayHaveSideEffects;
|
|
34
|
+
|
|
35
|
+
use super::analysis::{Analysis, Id};
|
|
36
|
+
use super::{HashMap, ast};
|
|
37
|
+
|
|
38
|
+
/// Inlines applications and operations selected by the first numeric argument, preserving
|
|
39
|
+
/// direct-call frames.
|
|
40
|
+
pub(super) fn run<'a>(program: &mut Program<'a>, analysis: &mut Analysis<'a>) -> bool {
|
|
41
|
+
inline(program, analysis, /* all= */ false)
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
/// Also inlines direct target calls and numeric selectors in later argument positions.
|
|
45
|
+
pub(super) fn run_all<'a>(program: &mut Program<'a>, analysis: &mut Analysis<'a>) -> bool {
|
|
46
|
+
inline(program, analysis, /* all= */ true)
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
let
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// The declaration or assignment that defines the function is its only write, so every call
|
|
61
|
-
// reaches this function.
|
|
62
|
-
functions.0.retain(|id, _| bindings.is_written_once(id));
|
|
63
|
-
if functions.0.is_empty() {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
let mut inline = InlineDispatchers {
|
|
67
|
-
functions: &functions.0,
|
|
68
|
-
globals,
|
|
69
|
-
reach,
|
|
49
|
+
fn inline<'a>(program: &mut Program<'a>, analysis: &Analysis<'a>, all: bool) -> bool {
|
|
50
|
+
let functions = ast::functions(program, analysis, &|function| {
|
|
51
|
+
let body = function.body.as_ref();
|
|
52
|
+
body.is_some_and(|body| may_select(&body.statements))
|
|
53
|
+
});
|
|
54
|
+
let mut inline = Inline {
|
|
55
|
+
analysis,
|
|
56
|
+
functions: &functions,
|
|
57
|
+
all,
|
|
70
58
|
changed: false,
|
|
71
59
|
};
|
|
72
|
-
|
|
60
|
+
inline.visit_program(program);
|
|
73
61
|
inline.changed
|
|
74
62
|
}
|
|
75
63
|
|
|
76
|
-
///
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
struct Candidate {
|
|
81
|
-
params: Vec<Id>,
|
|
82
|
-
body: Vec<Stmt>,
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
impl Candidate {
|
|
86
|
-
fn try_new(function: &Function) -> Option<Self> {
|
|
87
|
-
let params = names::parameter_ids(&function.params)?;
|
|
88
|
-
let body = &function.body.as_ref()?.stmts;
|
|
89
|
-
(!params.is_empty() && !function.is_async && !function.is_generator && may_select(body))
|
|
90
|
-
.then(|| Self {
|
|
91
|
-
params,
|
|
92
|
-
body: body.clone(),
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
impl Visit for Functions {
|
|
98
|
-
fn visit_expr(&mut self, expression: &Expr) {
|
|
99
|
-
if let Some((id, Expr::Fn(function))) = ast::assignment(expression)
|
|
100
|
-
&& let Some(candidate) = Candidate::try_new(&function.function)
|
|
101
|
-
{
|
|
102
|
-
self.0.insert(id, candidate);
|
|
103
|
-
}
|
|
104
|
-
expression.visit_children_with(self);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
fn visit_fn_decl(&mut self, declaration: &FnDecl) {
|
|
108
|
-
if let Some(candidate) = Candidate::try_new(&declaration.function) {
|
|
109
|
-
self.0.insert(declaration.ident.to_id(), candidate);
|
|
110
|
-
}
|
|
111
|
-
declaration.visit_children_with(self);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/// Checks whether some selector could reach `return value` through [`Path::run`]. Avoids
|
|
116
|
-
/// cloning large unrelated functions, such as VM helpers.
|
|
117
|
-
fn may_select<'a>(statements: impl IntoIterator<Item = &'a Stmt>) -> bool {
|
|
64
|
+
/// Rejects unrelated function bodies before taking an arena snapshot. A supported path must
|
|
65
|
+
/// reach a return through blocks, conditionals, or switches without executing other statements.
|
|
66
|
+
fn may_select<'b, 'a: 'b>(statements: impl IntoIterator<Item = &'b Statement<'a>>) -> bool {
|
|
118
67
|
for statement in statements {
|
|
119
68
|
let selects = match statement {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
may_select([
|
|
69
|
+
Statement::ReturnStatement(statement) => return statement.argument.is_some(),
|
|
70
|
+
Statement::BlockStatement(block) => may_select(&block.body),
|
|
71
|
+
Statement::EmptyStatement(_) => false,
|
|
72
|
+
Statement::IfStatement(branch) => {
|
|
73
|
+
may_select([&branch.consequent]) || may_select(branch.alternate.iter())
|
|
74
|
+
}
|
|
75
|
+
Statement::SwitchStatement(switch) => {
|
|
76
|
+
switch.cases.iter().any(|case| may_select(&case.consequent))
|
|
125
77
|
}
|
|
126
|
-
Stmt::Switch(switch) => switch.cases.iter().any(|case| may_select(&case.cons)),
|
|
127
78
|
_ => return false,
|
|
128
79
|
};
|
|
129
80
|
if selects {
|
|
@@ -133,51 +84,89 @@ fn may_select<'a>(statements: impl IntoIterator<Item = &'a Stmt>) -> bool {
|
|
|
133
84
|
false
|
|
134
85
|
}
|
|
135
86
|
|
|
136
|
-
/// Follows a
|
|
137
|
-
struct Path {
|
|
87
|
+
/// Follows a helper body using only the numeric parameter values known at this call.
|
|
88
|
+
struct Path<'b, 'a> {
|
|
138
89
|
values: HashMap<Id, f64>,
|
|
90
|
+
analysis: &'b Analysis<'a>,
|
|
139
91
|
}
|
|
140
92
|
|
|
141
|
-
impl Path {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
93
|
+
impl<'a> Path<'_, 'a> {
|
|
94
|
+
fn number(&self, expression: &Expression<'a>) -> Option<f64> {
|
|
95
|
+
ast::fold_number(expression, &|leaf| {
|
|
96
|
+
let id = self.analysis.expression_id(leaf)?;
|
|
97
|
+
self.values.get(&id).copied()
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fn truthy(&self, expression: &Expression<'a>) -> Option<bool> {
|
|
102
|
+
match expression.get_inner_expression() {
|
|
103
|
+
Expression::BooleanLiteral(literal) => Some(literal.value),
|
|
104
|
+
Expression::UnaryExpression(unary) if unary.operator == UnaryOperator::LogicalNot => {
|
|
105
|
+
Some(!self.truthy(&unary.argument)?)
|
|
106
|
+
}
|
|
107
|
+
Expression::BinaryExpression(binary) => {
|
|
108
|
+
let left = self.number(&binary.left)?;
|
|
109
|
+
let right = self.number(&binary.right)?;
|
|
110
|
+
Some(match binary.operator {
|
|
111
|
+
BinaryOperator::Equality | BinaryOperator::StrictEquality => left == right,
|
|
112
|
+
BinaryOperator::Inequality | BinaryOperator::StrictInequality => left != right,
|
|
113
|
+
BinaryOperator::LessThan => left < right,
|
|
114
|
+
BinaryOperator::LessEqualThan => left <= right,
|
|
115
|
+
BinaryOperator::GreaterThan => left > right,
|
|
116
|
+
BinaryOperator::GreaterEqualThan => left >= right,
|
|
117
|
+
_ => return None,
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
_ => None,
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// Returns `Some(Some(value))` for a reached value return, `Some(None)` for normal completion,
|
|
125
|
+
/// and `None` for an unsupported path. Switch selection follows fallthrough until a return;
|
|
126
|
+
/// paths with a `break` are left to other rewrites.
|
|
127
|
+
fn run<'c>(
|
|
145
128
|
&self,
|
|
146
|
-
statements: impl IntoIterator<Item = &'
|
|
147
|
-
) -> Option<Option<&'
|
|
129
|
+
statements: impl IntoIterator<Item = &'c Statement<'a>>,
|
|
130
|
+
) -> Option<Option<&'c Expression<'a>>>
|
|
131
|
+
where
|
|
132
|
+
'a: 'c,
|
|
133
|
+
{
|
|
148
134
|
for statement in statements {
|
|
149
135
|
let returned = match statement {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
136
|
+
Statement::ReturnStatement(statement) => {
|
|
137
|
+
return Some(Some(statement.argument.as_ref()?));
|
|
138
|
+
}
|
|
139
|
+
Statement::BlockStatement(block) => self.run(&block.body)?,
|
|
140
|
+
Statement::EmptyStatement(_) => None,
|
|
141
|
+
Statement::IfStatement(branch) => {
|
|
142
|
+
if self.truthy(&branch.test)? {
|
|
143
|
+
self.run([&branch.consequent])?
|
|
144
|
+
} else {
|
|
145
|
+
self.run(branch.alternate.iter())?
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
Statement::SwitchStatement(switch) => {
|
|
158
149
|
let value = self.number(&switch.discriminant)?;
|
|
159
|
-
let mut
|
|
150
|
+
let mut matched = None;
|
|
160
151
|
let mut default = None;
|
|
161
152
|
for (index, case) in switch.cases.iter().enumerate() {
|
|
162
|
-
let Some(test) = &case.test
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
153
|
+
if let Some(test) = &case.test {
|
|
154
|
+
if self.number(test)? == value {
|
|
155
|
+
matched.get_or_insert(index);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
default = Some(index)
|
|
168
159
|
}
|
|
169
160
|
}
|
|
170
|
-
let Some(start) =
|
|
161
|
+
let Some(start) = matched.or(default) else {
|
|
171
162
|
continue;
|
|
172
163
|
};
|
|
173
|
-
|
|
174
|
-
let body: Vec<&
|
|
175
|
-
.
|
|
176
|
-
.flat_map(|case| &case.cons)
|
|
177
|
-
.collect();
|
|
164
|
+
let cases = switch.cases[start..].iter();
|
|
165
|
+
let body: Vec<&Statement<'a>> =
|
|
166
|
+
cases.flat_map(|case| &case.consequent).collect();
|
|
178
167
|
if body
|
|
179
168
|
.iter()
|
|
180
|
-
.any(|statement| matches!(statement,
|
|
169
|
+
.any(|statement| matches!(statement, Statement::BreakStatement(_)))
|
|
181
170
|
{
|
|
182
171
|
return None;
|
|
183
172
|
}
|
|
@@ -191,203 +180,157 @@ impl Path {
|
|
|
191
180
|
}
|
|
192
181
|
Some(None)
|
|
193
182
|
}
|
|
194
|
-
|
|
195
|
-
fn truthy(&self, expression: &Expr) -> Option<bool> {
|
|
196
|
-
match expression {
|
|
197
|
-
Expr::Paren(inner) => self.truthy(&inner.expr),
|
|
198
|
-
Expr::Unary(unary) if unary.op == UnaryOp::Bang => Some(!self.truthy(&unary.arg)?),
|
|
199
|
-
Expr::Lit(Lit::Bool(value)) => Some(value.value),
|
|
200
|
-
Expr::Bin(binary) => {
|
|
201
|
-
let (left, right) = (self.number(&binary.left)?, self.number(&binary.right)?);
|
|
202
|
-
match binary.op {
|
|
203
|
-
BinaryOp::EqEqEq | BinaryOp::EqEq => Some(left == right),
|
|
204
|
-
BinaryOp::NotEqEq | BinaryOp::NotEq => Some(left != right),
|
|
205
|
-
BinaryOp::Lt => Some(left < right),
|
|
206
|
-
BinaryOp::LtEq => Some(left <= right),
|
|
207
|
-
BinaryOp::Gt => Some(left > right),
|
|
208
|
-
BinaryOp::GtEq => Some(left >= right),
|
|
209
|
-
_ => None,
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
_ => None,
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
fn number(&self, expression: &Expr) -> Option<f64> {
|
|
217
|
-
ast::fold_number(expression, &|leaf| {
|
|
218
|
-
self.values.get(&leaf.as_ident()?.to_id()).copied()
|
|
219
|
-
})
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/// Returns parameter positions for the target and arguments of a call such as `target(a, b)`. Each
|
|
224
|
-
/// must refer to a parameter.
|
|
225
|
-
fn parameter_call(expression: &Expr, params: &[Id]) -> Option<Vec<usize>> {
|
|
226
|
-
let call = expression.as_call()?;
|
|
227
|
-
let arguments = call
|
|
228
|
-
.args
|
|
229
|
-
.iter()
|
|
230
|
-
.map(|arg| arg.spread.is_none().then_some(&*arg.expr));
|
|
231
|
-
iter::once(Some(&**call.callee.as_expr()?))
|
|
232
|
-
.chain(arguments)
|
|
233
|
-
.map(|expression| parameter_position(expression?, params))
|
|
234
|
-
.collect()
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/// Returns the index in `params` of the parameter named by `expression`.
|
|
238
|
-
fn parameter_position(expression: &Expr, params: &[Id]) -> Option<usize> {
|
|
239
|
-
let id = expression.as_ident()?.to_id();
|
|
240
|
-
params.iter().position(|param| *param == id)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/// The parameter positions of `target` and `args` in `Reflect.apply(target, undefined, args)`.
|
|
244
|
-
struct ReflectApply {
|
|
245
|
-
target: usize,
|
|
246
|
-
arguments: usize,
|
|
247
183
|
}
|
|
248
184
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
unary.op == UnaryOp::Void && !effects::may_have_effects(&unary.arg, globals)
|
|
261
|
-
}
|
|
262
|
-
_ => false,
|
|
185
|
+
/// Accepts unary and binary operations whose leaves pass `leaf`, excluding `delete`.
|
|
186
|
+
fn operation(expression: &Expression<'_>, leaf: &impl Fn(&Expression<'_>) -> bool) -> bool {
|
|
187
|
+
match expression.get_inner_expression() {
|
|
188
|
+
Expression::UnaryExpression(unary) => {
|
|
189
|
+
unary.operator != UnaryOperator::Delete && operation(&unary.argument, leaf)
|
|
190
|
+
}
|
|
191
|
+
Expression::BinaryExpression(binary) => {
|
|
192
|
+
operation(&binary.left, leaf) && operation(&binary.right, leaf)
|
|
193
|
+
}
|
|
194
|
+
Expression::LogicalExpression(logical) => {
|
|
195
|
+
operation(&logical.left, leaf) && operation(&logical.right, leaf)
|
|
263
196
|
}
|
|
264
|
-
{
|
|
265
|
-
Some(ReflectApply {
|
|
266
|
-
target: parameter_position(&function.expr, params)?,
|
|
267
|
-
arguments: parameter_position(&arguments.expr, params)?,
|
|
268
|
-
})
|
|
269
|
-
} else {
|
|
270
|
-
None
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/// Operators other than `delete` combining leaves that `leaf` accepts.
|
|
275
|
-
fn is_operation(expression: &Expr, leaf: &impl Fn(&Expr) -> bool) -> bool {
|
|
276
|
-
match expression {
|
|
277
|
-
Expr::Paren(inner) => is_operation(&inner.expr, leaf),
|
|
278
|
-
Expr::Unary(unary) => unary.op != UnaryOp::Delete && is_operation(&unary.arg, leaf),
|
|
279
|
-
Expr::Bin(binary) => is_operation(&binary.left, leaf) && is_operation(&binary.right, leaf),
|
|
280
197
|
expression => leaf(expression),
|
|
281
198
|
}
|
|
282
199
|
}
|
|
283
200
|
|
|
284
|
-
struct
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
201
|
+
struct Inline<'b, 'a> {
|
|
202
|
+
analysis: &'b Analysis<'a>,
|
|
203
|
+
functions: &'b HashMap<Id, &'a Function<'a>>,
|
|
204
|
+
all: bool,
|
|
288
205
|
changed: bool,
|
|
289
206
|
}
|
|
290
207
|
|
|
291
|
-
impl
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
208
|
+
impl<'a> Inline<'_, 'a> {
|
|
209
|
+
/// Selects the reached return without evaluating unknown code, then checks its forwarding form.
|
|
210
|
+
/// Direct calls must preserve argument order and omit only numeric selectors. `Reflect.apply`
|
|
211
|
+
/// requires global `Reflect` and an effect-free undefined receiver. Repeated or reordered
|
|
212
|
+
/// operator operands must themselves be effect-free.
|
|
213
|
+
fn replacement(
|
|
214
|
+
&self,
|
|
215
|
+
id: Id,
|
|
216
|
+
arguments: &[Argument<'a>],
|
|
217
|
+
span: Span,
|
|
218
|
+
) -> Option<Expression<'a>> {
|
|
219
|
+
let analysis = self.analysis;
|
|
220
|
+
let function = *self.functions.get(&id)?;
|
|
221
|
+
if function.r#async || function.generator {
|
|
295
222
|
return None;
|
|
296
223
|
}
|
|
297
|
-
let
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
let path = Path {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
.filter_map(|(param, arg)| Some((param.clone(), number(arg)?)))
|
|
314
|
-
.collect(),
|
|
224
|
+
let parameters = ast::parameters(function)?;
|
|
225
|
+
let arguments: Vec<&Expression<'a>> = arguments
|
|
226
|
+
.iter()
|
|
227
|
+
.map(Argument::as_expression)
|
|
228
|
+
.collect::<Option<_>>()?;
|
|
229
|
+
ast::number(arguments.first()?)?;
|
|
230
|
+
let count = if self.all { arguments.len() } else { 1 };
|
|
231
|
+
let known = parameters.iter().zip(arguments.iter().take(count));
|
|
232
|
+
let values = known
|
|
233
|
+
.filter_map(|(&id, argument)| Some((id, ast::number(argument)?)))
|
|
234
|
+
.collect();
|
|
235
|
+
let path = Path { values, analysis };
|
|
236
|
+
let returned = path.run(&function.body.as_ref()?.statements)??;
|
|
237
|
+
let position = |expression: Option<&Expression<'a>>| {
|
|
238
|
+
let id = analysis.expression_id(expression?)?;
|
|
239
|
+
parameters.iter().position(|parameter| *parameter == id)
|
|
315
240
|
};
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
&& let Some(positions) =
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
&&
|
|
324
|
-
&&
|
|
241
|
+
if self.all
|
|
242
|
+
&& let Expression::CallExpression(call) = returned
|
|
243
|
+
&& let Some(positions) = iter::once(Some(&call.callee))
|
|
244
|
+
.chain(call.arguments.iter().map(Argument::as_expression))
|
|
245
|
+
.map(&position)
|
|
246
|
+
.collect::<Option<Vec<usize>>>()
|
|
247
|
+
&& arguments.len() == parameters.len()
|
|
248
|
+
&& positions.is_sorted_by(|left, right| left < right)
|
|
249
|
+
&& (0..arguments.len())
|
|
250
|
+
.all(|index| positions.contains(&index) || ast::number(arguments[index]).is_some())
|
|
251
|
+
&& let [target, passed @ ..] = positions.as_slice()
|
|
252
|
+
&& matches!(arguments[*target], Expression::Identifier(_))
|
|
325
253
|
{
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
..Default::default()
|
|
330
|
-
}));
|
|
254
|
+
let passed = passed.iter().map(|&index| self.argument(arguments[index]));
|
|
255
|
+
let passed = ArenaVec::from_iter_in(passed, &analysis.ast);
|
|
256
|
+
return Some(self.call(span, arguments[*target], passed));
|
|
331
257
|
}
|
|
332
|
-
if let Some(
|
|
333
|
-
&& let
|
|
334
|
-
&&
|
|
335
|
-
&& let
|
|
336
|
-
&&
|
|
337
|
-
.elems
|
|
338
|
-
.iter()
|
|
339
|
-
.map(|element| element.clone().filter(|element| element.spread.is_none()))
|
|
340
|
-
.collect::<Option<Vec<_>>>()
|
|
258
|
+
if let Some((reflect, [function, this, applied])) = ast::method_call(returned, "apply")
|
|
259
|
+
&& let Expression::Identifier(reflect) = reflect
|
|
260
|
+
&& analysis.is_global(reflect, "Reflect")
|
|
261
|
+
&& let Some(this) = this.as_expression()
|
|
262
|
+
&& analysis.is_undefined(this)
|
|
341
263
|
{
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
264
|
+
let target = position(function.as_expression())?;
|
|
265
|
+
let applied = position(applied.as_expression())?;
|
|
266
|
+
let (Expression::Identifier(_), Expression::ArrayExpression(array)) =
|
|
267
|
+
(arguments.get(target)?, arguments.get(applied)?)
|
|
268
|
+
else {
|
|
269
|
+
return None;
|
|
270
|
+
};
|
|
271
|
+
let elements = array.elements.iter();
|
|
272
|
+
let passed = elements
|
|
273
|
+
.map(|element| Some(self.argument(element.as_expression()?)))
|
|
274
|
+
.collect::<Option<Vec<_>>>()?;
|
|
275
|
+
let passed = ArenaVec::from_iter_in(passed, &analysis.ast);
|
|
276
|
+
return Some(self.call(span, arguments[target], passed));
|
|
347
277
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
leaf => matches!(leaf, Expr::Lit(Lit::Num(_))),
|
|
278
|
+
let forwards = |expression: &Expression<'_>| {
|
|
279
|
+
let id = analysis.expression_id(expression);
|
|
280
|
+
id.is_some_and(|id| parameters.contains(&id))
|
|
281
|
+
|| matches!(expression, Expression::NumericLiteral(_))
|
|
353
282
|
};
|
|
354
|
-
let
|
|
355
|
-
|
|
356
|
-
|
|
283
|
+
let effect_free = |expression: &Expression<'_>| {
|
|
284
|
+
expression.is_literal()
|
|
285
|
+
|| matches!(expression, Expression::Identifier(_))
|
|
286
|
+
&& !expression.may_have_side_effects(analysis)
|
|
357
287
|
};
|
|
358
|
-
if
|
|
359
|
-
&&
|
|
360
|
-
&&
|
|
361
|
-
{
|
|
362
|
-
let values: HashMap<Id, &Expr> = candidate
|
|
363
|
-
.params
|
|
288
|
+
if arguments.len() == parameters.len()
|
|
289
|
+
&& operation(returned, &forwards)
|
|
290
|
+
&& arguments
|
|
364
291
|
.iter()
|
|
365
|
-
.
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
Some(helper_objects::replace_parameters(returned, values))
|
|
370
|
-
} else {
|
|
371
|
-
None
|
|
292
|
+
.all(|argument| operation(argument, &effect_free))
|
|
293
|
+
{
|
|
294
|
+
let values = parameters.into_iter().zip(arguments).collect();
|
|
295
|
+
return Some(ast::replace_parameters(returned, &values, analysis));
|
|
372
296
|
}
|
|
297
|
+
None
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
fn argument(&self, expression: &Expression<'a>) -> Argument<'a> {
|
|
301
|
+
Argument::from(expression.clone_in_with_semantic_ids(self.analysis.allocator()))
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
fn call(
|
|
305
|
+
&self,
|
|
306
|
+
span: Span,
|
|
307
|
+
callee: &Expression<'a>,
|
|
308
|
+
arguments: ArenaVec<'a, Argument<'a>>,
|
|
309
|
+
) -> Expression<'a> {
|
|
310
|
+
let callee = callee.clone_in_with_semantic_ids(self.analysis.allocator());
|
|
311
|
+
Expression::new_call_expression(span, callee, None, arguments, false, &self.analysis.ast)
|
|
373
312
|
}
|
|
374
313
|
}
|
|
375
314
|
|
|
376
|
-
impl VisitMut for
|
|
377
|
-
fn
|
|
378
|
-
|
|
379
|
-
if let Some((callee,
|
|
380
|
-
&& let Some(
|
|
315
|
+
impl<'a> VisitMut<'a> for Inline<'_, 'a> {
|
|
316
|
+
fn visit_expression(&mut self, expression: &mut Expression<'a>) {
|
|
317
|
+
walk_mut::walk_expression(self, expression);
|
|
318
|
+
if let Some((callee, arguments)) = ast::direct_call(expression)
|
|
319
|
+
&& let Some(id) = self.analysis.id(callee)
|
|
320
|
+
&& let Some(value) = self.replacement(id, arguments, callee.span)
|
|
381
321
|
{
|
|
382
|
-
*expression =
|
|
383
|
-
self.changed = true
|
|
322
|
+
*expression = value;
|
|
323
|
+
self.changed = true
|
|
384
324
|
}
|
|
385
325
|
}
|
|
386
326
|
}
|
|
387
327
|
|
|
388
328
|
#[cfg(test)]
|
|
389
329
|
mod tests {
|
|
390
|
-
use
|
|
330
|
+
use oxc::allocator::Allocator;
|
|
331
|
+
use oxc::ast::ast::Statement;
|
|
332
|
+
|
|
333
|
+
use crate::deobfuscate::{pipeline, testing};
|
|
391
334
|
|
|
392
335
|
const APPLY: &str = "var b; b = function (n, m, r) {
|
|
393
336
|
switch (3832 ^ n) {
|
|
@@ -402,7 +345,7 @@ mod tests {
|
|
|
402
345
|
|
|
403
346
|
#[test]
|
|
404
347
|
fn applies_the_target_only_for_provable_applications() {
|
|
405
|
-
let inline = |source: &str| testing::rewrite(source, super::run
|
|
348
|
+
let inline = |source: &str| testing::rewrite(source, super::run);
|
|
406
349
|
let output = inline(&format!(
|
|
407
350
|
"{APPLY} f(b(971996, encode, [x, 1]), b(428000, g, []));"
|
|
408
351
|
));
|
|
@@ -422,7 +365,7 @@ mod tests {
|
|
|
422
365
|
|
|
423
366
|
#[test]
|
|
424
367
|
fn calls_targets_selected_by_several_selectors_only_in_argument_order() {
|
|
425
|
-
let inline = |source: &str| testing::rewrite(source, super::run_all
|
|
368
|
+
let inline = |source: &str| testing::rewrite(source, super::run_all);
|
|
426
369
|
let dispatchers = "function c(n, m, f, x, y) {
|
|
427
370
|
switch (n ^ 5) { case 1: switch (3 ^ m) { case 1: return f(x, y); } return; }
|
|
428
371
|
}
|
|
@@ -430,7 +373,7 @@ mod tests {
|
|
|
430
373
|
let source = format!("{dispatchers} g(c(4, 2, encode, a(), b));");
|
|
431
374
|
let output = inline(&source);
|
|
432
375
|
assert!(output.contains("g(encode(a(), b))"), "{output}");
|
|
433
|
-
let decoding = testing::rewrite(&source, super::run
|
|
376
|
+
let decoding = testing::rewrite(&source, super::run);
|
|
434
377
|
assert!(decoding.contains("g(c(4, 2,"), "{decoding}");
|
|
435
378
|
for call in [
|
|
436
379
|
"c(4, 2, o.encode, a, b)",
|
|
@@ -445,11 +388,11 @@ mod tests {
|
|
|
445
388
|
|
|
446
389
|
#[test]
|
|
447
390
|
fn inlines_selected_operations_through_switches_if_chains_and_xor_keys() {
|
|
448
|
-
let inline = |source: &str| testing::rewrite(source, super::run
|
|
391
|
+
let inline = |source: &str| testing::rewrite(source, super::run);
|
|
449
392
|
let output = inline(&format!(
|
|
450
393
|
"{OPERATOR} function g(a, b) {{ f(w(1, 630, 622), w(2, a, b + 1), w(9, 7, 2)); }}"
|
|
451
394
|
));
|
|
452
|
-
testing::assert_contains(&output, &["f(630 - 622, (b + 1) * a, 7 % 2)"]
|
|
395
|
+
testing::assert_contains(&output, &["f(630 - 622, (b + 1) * a, 7 % 2)"]);
|
|
453
396
|
let output = inline(
|
|
454
397
|
"t = function (V, c, X) {
|
|
455
398
|
if (!(V !== 0)) { return c + X; } else { if (!(2 === V)) { return c % X; } else { return X * c; } }
|
|
@@ -457,7 +400,7 @@ mod tests {
|
|
|
457
400
|
function q(J, r, n) { switch (2774 ^ J) { case 0: return r | n; default: return r & n; } }
|
|
458
401
|
function g(a, b) { f(t(0, a, b), t(2, a, b), t(5, a, b), q(2774, a, b), q(2775, a, b)); }",
|
|
459
402
|
);
|
|
460
|
-
testing::assert_contains(&output, &["f(a + b, b * a, a % b, a | b, a & b)"]
|
|
403
|
+
testing::assert_contains(&output, &["f(a + b, b * a, a % b, a | b, a & b)"]);
|
|
461
404
|
// Arguments with effects and unknown selectors stay.
|
|
462
405
|
for call in ["w(1, g(), 2)", "w(n, 1, 2)", "w(1, 2)", "w(1, missing, 2)"] {
|
|
463
406
|
let output = inline(&format!("{OPERATOR} f({call});"));
|
|
@@ -467,17 +410,14 @@ mod tests {
|
|
|
467
410
|
|
|
468
411
|
#[test]
|
|
469
412
|
fn only_bodies_that_can_select_a_return_are_candidates() {
|
|
470
|
-
use swc_core::ecma::ast::{Decl, Stmt};
|
|
471
|
-
|
|
472
413
|
let selects = |body: &str| {
|
|
473
|
-
let
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
panic!("not a function declaration: {body}");
|
|
414
|
+
let allocator = Allocator::default();
|
|
415
|
+
let source = format!("function f(n) {{ {body} }}");
|
|
416
|
+
let (program, _) = pipeline::parse(&allocator, &source).unwrap();
|
|
417
|
+
let Statement::FunctionDeclaration(function) = &program.body[0] else {
|
|
418
|
+
panic!("not a function declaration")
|
|
479
419
|
};
|
|
480
|
-
super::may_select(&function.
|
|
420
|
+
super::may_select(&function.body.as_ref().unwrap().statements)
|
|
481
421
|
};
|
|
482
422
|
for body in [
|
|
483
423
|
"return 1;",
|