cfsolve 0.1.2 → 0.1.4
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 +22 -0
- data/README.md +8 -3
- 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 +14 -6
- 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/chrome-157-macos/answers.json +4777 -0
- data/lib/cfsolve/profiles/chrome-157-macos.json +613 -0
- 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/lib/cfsolve.rb +1 -1
- data/vendor/cfsolve/Cargo.lock +561 -1729
- data/vendor/cfsolve/Cargo.toml +26 -8
- data/vendor/cfsolve/README.md +57 -5
- 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/turnstile_smoke.rs +58 -0
- data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
- data/vendor/cfsolve/profiles/chrome-157-macos/answers.json +4777 -0
- data/vendor/cfsolve/profiles/chrome-157-macos.json +613 -0
- 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 +132 -24
- data/vendor/cfsolve/src/embedding_page/page.rs +41 -1
- 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 +12 -11
- data/vendor/cfsolve/src/session/probes.rs +1 -0
- 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/analyze.rs +33 -4
- data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
- data/vendor/cfsolve/src/stage2/analysis/discovery.rs +13 -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 +113 -41
- data/vendor/cfsolve/src/stage2/call_stack.rs +1564 -1041
- data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
- data/vendor/cfsolve/src/stage2/fixtures/encoded_benchmark_worker.js +1 -0
- 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/dates.rs +44 -0
- data/vendor/cfsolve/src/stage2/probes/parent_info_array.rs +326 -0
- data/vendor/cfsolve/src/stage2/probes/performance.rs +12 -8
- data/vendor/cfsolve/src/stage2/probes/stack.rs +117 -4
- data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +80 -2
- data/vendor/cfsolve/src/stage2/probes.rs +1 -0
- data/vendor/cfsolve/src/stage2/queries.rs +50 -0
- data/vendor/cfsolve/src/stage2/reference.rs +5 -0
- data/vendor/cfsolve/src/stage2/registry.rs +8 -2
- data/vendor/cfsolve/src/stage2/replay.rs +34 -3
- data/vendor/cfsolve/src/stage2/stylesheets.rs +35 -0
- data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
- data/vendor/cfsolve/src/stage2/trace.rs +134 -108
- data/vendor/cfsolve/src/stage2/value_labels.rs +185 -0
- data/vendor/cfsolve/src/stage2/vocabulary.rs +112 -17
- data/vendor/cfsolve/src/stage2.rs +3 -0
- data/vendor/cfsolve/src/vm/disassemble.rs +75 -7
- data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
- data/vendor/cfsolve/src/vm/encoded_names.rs +635 -0
- data/vendor/cfsolve/src/vm/extract.rs +550 -250
- data/vendor/cfsolve/src/vm/fixtures/free_functions/README.md +9 -0
- data/vendor/cfsolve/src/vm/fixtures/free_functions/machine.js +7438 -0
- data/vendor/cfsolve/src/vm/fixtures/free_functions/program.base64 +1 -0
- data/vendor/cfsolve/src/vm/interpret/access.rs +71 -50
- 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 +160 -58
- 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 +1765 -0
- data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
- data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +392 -0
- data/vendor/cfsolve/src/vm/interpret/run.rs +120 -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 +116 -51
- data/vendor/cfsolve/src/vm/output.rs +19 -6
- data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
- data/vendor/cfsolve/src/vm/registers.rs +35 -21
- data/vendor/cfsolve/src/vm/session.rs +189 -121
- data/vendor/cfsolve/src/vm/value.rs +22 -19
- data/vendor/cfsolve/src/vm.rs +3 -1
- data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
- data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
- metadata +106 -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,531 +1,356 @@
|
|
|
1
1
|
//! Tracks static property reads, calls, definitions, escapes, and dynamic accesses, so rewrites
|
|
2
|
-
//! can decide whether properties
|
|
2
|
+
//! can decide whether properties keep their defined values.
|
|
3
3
|
|
|
4
|
-
use
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
SimpleAssignTarget, TaggedTpl, ThisExpr, UnaryExpr, UnaryOp, UpdateExpr, VarDeclarator,
|
|
4
|
+
use oxc::ast::ast::{
|
|
5
|
+
AssignmentExpression, AssignmentTarget, CallExpression, Expression, IdentifierReference,
|
|
6
|
+
MemberExpression, ObjectExpression, ObjectPropertyKind, Program, PropertyKind, ThisExpression,
|
|
7
|
+
UnaryExpression, UpdateExpression, VariableDeclarator,
|
|
9
8
|
};
|
|
10
|
-
use
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
use
|
|
14
|
-
use crate::
|
|
15
|
-
|
|
16
|
-
///
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
///
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
///
|
|
33
|
-
|
|
34
|
-
///
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
indexed: bool,
|
|
39
|
-
deleted: bool,
|
|
40
|
-
/// A property value mentions `this`, so calling it as a method may observe or mutate the
|
|
41
|
-
/// object.
|
|
42
|
-
this: bool,
|
|
43
|
-
/// Assigned through a property with `=`: `binding.key = value` or `binding[key] = value`.
|
|
44
|
-
pub(crate) written_through: bool,
|
|
45
|
-
/// Static keys accessed through reads, calls, updates, deletions, destructuring writes, or
|
|
46
|
-
/// loop targets. Excludes plain `binding.key = value` assignments.
|
|
47
|
-
pub(crate) accessed: HashSet<Atom>,
|
|
48
|
-
/// The static keys called as methods, `binding.key(...)`.
|
|
49
|
-
called: HashSet<Atom>,
|
|
50
|
-
/// Definition counts for static keys, including object literals, assignments, updates,
|
|
51
|
-
/// destructuring patterns, and loop targets.
|
|
52
|
-
defined: HashMap<Atom, usize>,
|
|
9
|
+
use oxc::ast_visit::{Visit, walk};
|
|
10
|
+
use oxc::syntax::operator::{AssignmentOperator, UnaryOperator};
|
|
11
|
+
|
|
12
|
+
use super::{Analysis, Id};
|
|
13
|
+
use crate::deobfuscate::{HashMap, HashSet, ast};
|
|
14
|
+
|
|
15
|
+
/// Observations and definitions of an object, merged over its single-assignment aliases.
|
|
16
|
+
#[derive(Default)]
|
|
17
|
+
pub(in crate::deobfuscate) struct Uses<'a> {
|
|
18
|
+
/// The object escapes: it is passed, returned, stored, coerced, or copied into a binding
|
|
19
|
+
/// with several writes.
|
|
20
|
+
pub whole: bool,
|
|
21
|
+
/// An unknown or special key, unsupported property definition, or indexed method call.
|
|
22
|
+
pub dynamic: bool,
|
|
23
|
+
/// Accessed through a constant non-negative integer index.
|
|
24
|
+
pub indexed: bool,
|
|
25
|
+
/// Deleting a property can expose inherited values.
|
|
26
|
+
pub deleted: bool,
|
|
27
|
+
/// A property value mentions `this` and may observe or mutate the object when called.
|
|
28
|
+
pub this: bool,
|
|
29
|
+
/// A property is assigned or updated through some alias.
|
|
30
|
+
pub written: bool,
|
|
31
|
+
/// Static keys read, called, updated, or written by destructuring and loop targets.
|
|
32
|
+
pub read: HashSet<&'a str>,
|
|
33
|
+
/// Static keys called with the object as receiver, including inherited methods.
|
|
34
|
+
pub called: HashSet<&'a str>,
|
|
35
|
+
/// Definition counts from literal entries, assignments, updates, and pattern targets.
|
|
36
|
+
pub defined: HashMap<&'a str, usize>,
|
|
53
37
|
}
|
|
54
38
|
|
|
55
|
-
impl Uses {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
self.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*self.defined.entry(key.clone()).or_default() += count;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/// Checks for uses of the whole object or access through a key that could name any
|
|
71
|
-
/// property.
|
|
72
|
-
#[must_use]
|
|
73
|
-
pub(crate) fn is_used_dynamically(&self) -> bool {
|
|
74
|
-
self.whole || self.computed || self.indexed
|
|
39
|
+
impl Uses<'_> {
|
|
40
|
+
/// Checks that no untracked observation can change the object's properties. Rejects escapes,
|
|
41
|
+
/// dynamic or indexed keys, deletion, `this` in property values, and calls to inherited
|
|
42
|
+
/// methods such as `hasOwnProperty`.
|
|
43
|
+
pub(in crate::deobfuscate) fn is_tracked(&self) -> bool {
|
|
44
|
+
!self.whole
|
|
45
|
+
&& !self.dynamic
|
|
46
|
+
&& !self.indexed
|
|
47
|
+
&& !self.deleted
|
|
48
|
+
&& !self.this
|
|
49
|
+
&& self.called.iter().all(|key| self.defined.contains_key(key))
|
|
75
50
|
}
|
|
51
|
+
}
|
|
76
52
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
..Self::default()
|
|
83
|
-
};
|
|
84
|
-
*self == indexed_reads
|
|
85
|
-
}
|
|
53
|
+
/// Property uses by object identity. Single-write copies such as `alias = object` share a root;
|
|
54
|
+
/// the copy itself is not an escape.
|
|
55
|
+
#[derive(Default)]
|
|
56
|
+
pub(in crate::deobfuscate) struct Properties<'a> {
|
|
57
|
+
uses: HashMap<Id, Uses<'a>>,
|
|
86
58
|
}
|
|
87
59
|
|
|
88
|
-
impl Properties {
|
|
89
|
-
|
|
90
|
-
pub(crate) fn collect(program: &Program, bindings: &Bindings) -> Self {
|
|
60
|
+
impl<'a> Properties<'a> {
|
|
61
|
+
pub(crate) fn collect(program: &Program<'a>, analysis: &Analysis<'a>) -> Self {
|
|
91
62
|
let mut collect = Collect {
|
|
92
|
-
|
|
93
|
-
|
|
63
|
+
analysis,
|
|
64
|
+
properties: Self::default(),
|
|
94
65
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
let mut objects: HashMap<Id, Uses> = HashMap::default();
|
|
98
|
-
for (id, uses) in &uses {
|
|
99
|
-
objects.entry(bindings.root(id)).or_default().merge(uses);
|
|
100
|
-
}
|
|
101
|
-
Self {
|
|
102
|
-
uses,
|
|
103
|
-
objects,
|
|
104
|
-
roots: bindings.roots(),
|
|
105
|
-
none: Uses::default(),
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/// The uses through `id` itself.
|
|
110
|
-
#[must_use]
|
|
111
|
-
pub(crate) fn binding(&self, id: &Id) -> &Uses {
|
|
112
|
-
self.uses.get(id).unwrap_or(&self.none)
|
|
66
|
+
collect.visit_program(program);
|
|
67
|
+
collect.properties
|
|
113
68
|
}
|
|
114
69
|
|
|
115
|
-
/// Returns uses
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let root = self.roots.get(id).unwrap_or(id);
|
|
119
|
-
self.objects.get(root).unwrap_or(&self.none)
|
|
70
|
+
/// Returns the uses merged over every binding with the same copy-chain root as `id`.
|
|
71
|
+
pub(crate) fn get(&self, id: Id, analysis: &Analysis<'_>) -> Option<&Uses<'a>> {
|
|
72
|
+
self.uses.get(&analysis.bindings.root(&id))
|
|
120
73
|
}
|
|
121
74
|
|
|
122
|
-
/// Checks
|
|
123
|
-
///
|
|
124
|
-
///
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
object.is_used_dynamically()
|
|
129
|
-
|| object.deleted
|
|
130
|
-
|| object.this
|
|
131
|
-
|| object
|
|
132
|
-
.called
|
|
133
|
-
.iter()
|
|
134
|
-
.any(|name| !object.defined.contains_key(name))
|
|
75
|
+
/// Checks that `id.key` has exactly one definition and no untracked observation can change
|
|
76
|
+
/// it (see [`Uses::is_tracked`]). Inlining also needs a separate proof that the definition
|
|
77
|
+
/// runs first.
|
|
78
|
+
pub(crate) fn stable(&self, id: Id, key: &str, analysis: &Analysis<'_>) -> bool {
|
|
79
|
+
self.get(id, analysis)
|
|
80
|
+
.is_some_and(|uses| uses.is_tracked() && uses.defined.get(key) == Some(&1))
|
|
135
81
|
}
|
|
136
82
|
|
|
137
|
-
/// Checks that
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
83
|
+
/// Checks that every observation is a constant-index read, with no calls, writes, or escapes.
|
|
84
|
+
pub(crate) fn only_indexed(&self, id: Id, analysis: &Analysis<'_>) -> bool {
|
|
85
|
+
self.get(id, analysis).is_some_and(|uses| {
|
|
86
|
+
!uses.whole
|
|
87
|
+
&& !uses.dynamic
|
|
88
|
+
&& !uses.deleted
|
|
89
|
+
&& !uses.this
|
|
90
|
+
&& !uses.written
|
|
91
|
+
&& uses.called.is_empty()
|
|
92
|
+
&& uses.read.is_empty()
|
|
93
|
+
})
|
|
142
94
|
}
|
|
143
95
|
}
|
|
144
96
|
|
|
145
|
-
|
|
146
|
-
#[derive(Clone, Copy, PartialEq)]
|
|
97
|
+
#[derive(Clone, Copy, PartialEq, Eq)]
|
|
147
98
|
enum Access {
|
|
148
99
|
Read,
|
|
149
100
|
Call,
|
|
150
|
-
/// `binding.key = value`.
|
|
151
|
-
Assign,
|
|
152
|
-
/// Read and written: a compound assignment or an update.
|
|
153
|
-
Update,
|
|
154
|
-
/// Written by a destructuring pattern or a loop head.
|
|
155
|
-
Pattern,
|
|
156
101
|
Delete,
|
|
102
|
+
Write,
|
|
103
|
+
ReadWrite,
|
|
157
104
|
}
|
|
158
105
|
|
|
159
|
-
struct Collect<'
|
|
160
|
-
|
|
161
|
-
|
|
106
|
+
struct Collect<'b, 'a> {
|
|
107
|
+
analysis: &'b Analysis<'a>,
|
|
108
|
+
properties: Properties<'a>,
|
|
162
109
|
}
|
|
163
110
|
|
|
164
|
-
impl Collect<'_> {
|
|
165
|
-
fn uses(&mut self, id:
|
|
166
|
-
self.
|
|
111
|
+
impl<'a> Collect<'_, 'a> {
|
|
112
|
+
fn uses(&mut self, id: Id) -> &mut Uses<'a> {
|
|
113
|
+
let root = self.analysis.bindings.root(&id);
|
|
114
|
+
self.properties.uses.entry(root).or_default()
|
|
167
115
|
}
|
|
168
116
|
|
|
169
|
-
/// Records an
|
|
170
|
-
///
|
|
171
|
-
fn
|
|
172
|
-
let
|
|
173
|
-
|
|
174
|
-
return;
|
|
175
|
-
};
|
|
176
|
-
let uses = self.uses(object);
|
|
177
|
-
match member_key(&member.prop) {
|
|
178
|
-
Some(key) => {
|
|
179
|
-
if matches!(access, Access::Assign | Access::Update | Access::Pattern) {
|
|
180
|
-
*uses.defined.entry(key.clone()).or_default() += 1;
|
|
181
|
-
}
|
|
182
|
-
if access == Access::Call {
|
|
183
|
-
uses.called.insert(key.clone());
|
|
184
|
-
}
|
|
185
|
-
if access != Access::Assign {
|
|
186
|
-
uses.accessed.insert(key);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
None if access == Access::Read && constant_index(&member.prop).is_some() => {
|
|
190
|
-
uses.indexed = true;
|
|
191
|
-
}
|
|
192
|
-
None => uses.computed = true,
|
|
117
|
+
/// Records an object literal assigned to `id`, and returns whether `value` is the tracked
|
|
118
|
+
/// copy that makes `id` an alias.
|
|
119
|
+
fn define(&mut self, id: Id, value: &Expression<'a>) -> bool {
|
|
120
|
+
if let Expression::ObjectExpression(object) = value.get_inner_expression() {
|
|
121
|
+
self.object(id, object)
|
|
193
122
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
123
|
+
self.analysis
|
|
124
|
+
.expression_id(value)
|
|
125
|
+
.is_some_and(|source| self.analysis.bindings.copy_source(&id) == Some(&source))
|
|
197
126
|
}
|
|
198
127
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
.as_ident()
|
|
206
|
-
.is_some_and(|value| copy_source == Some(&value.to_id()));
|
|
207
|
-
};
|
|
208
|
-
let this = mentions_this(literal);
|
|
209
|
-
let uses = self.uses(binding);
|
|
210
|
-
uses.this |= this;
|
|
211
|
-
for property in &literal.props {
|
|
212
|
-
let key = match property.as_prop().map(|property| &**property) {
|
|
213
|
-
Some(Prop::KeyValue(property)) => prop_key(&property.key),
|
|
214
|
-
Some(Prop::Getter(property)) => prop_key(&property.key),
|
|
215
|
-
Some(Prop::Setter(property)) => prop_key(&property.key),
|
|
216
|
-
Some(Prop::Method(property)) => prop_key(&property.key),
|
|
217
|
-
Some(Prop::Shorthand(property)) => Some(property.sym.clone()),
|
|
218
|
-
Some(Prop::Assign(_)) | None => None,
|
|
128
|
+
fn object(&mut self, id: Id, object: &ObjectExpression<'a>) {
|
|
129
|
+
let uses = self.uses(id);
|
|
130
|
+
for property in &object.properties {
|
|
131
|
+
let ObjectPropertyKind::ObjectProperty(property) = property else {
|
|
132
|
+
uses.dynamic = true;
|
|
133
|
+
continue;
|
|
219
134
|
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
135
|
+
let Some(key) = ast::key(&property.key, property.computed) else {
|
|
136
|
+
uses.dynamic = true;
|
|
137
|
+
continue;
|
|
138
|
+
};
|
|
139
|
+
uses.dynamic |= property.method || property.kind != PropertyKind::Init;
|
|
140
|
+
uses.dynamic |= key == "__proto__";
|
|
141
|
+
*uses.defined.entry(key).or_default() += 1;
|
|
142
|
+
uses.this |= mentions_this(&property.value);
|
|
224
143
|
}
|
|
225
|
-
false
|
|
226
144
|
}
|
|
227
145
|
|
|
228
|
-
/// Records a
|
|
229
|
-
fn
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
146
|
+
/// Records how a member is used, then visits its evaluated object and computed key operands.
|
|
147
|
+
fn member(&mut self, member: &MemberExpression<'a>, access: Access) {
|
|
148
|
+
if let Some(id) = self.analysis.expression_id(member.object()) {
|
|
149
|
+
let key = member.static_property_name().and_then(|name| name.as_str());
|
|
150
|
+
let indexed = matches!(member, MemberExpression::ComputedMemberExpression(computed)
|
|
151
|
+
if ast::number(&computed.expression)
|
|
152
|
+
.is_some_and(|index| index >= 0.0 && index.fract() == 0.0));
|
|
153
|
+
let uses = self.uses(id);
|
|
154
|
+
let write = matches!(access, Access::Write | Access::ReadWrite);
|
|
155
|
+
uses.dynamic |= access == Access::Call && key.is_none();
|
|
156
|
+
uses.written |= write;
|
|
157
|
+
uses.deleted |= access == Access::Delete;
|
|
158
|
+
if let Some(key) = key {
|
|
159
|
+
if write {
|
|
160
|
+
*uses.defined.entry(key).or_default() += 1;
|
|
161
|
+
}
|
|
162
|
+
if access != Access::Write {
|
|
163
|
+
uses.read.insert(key);
|
|
164
|
+
}
|
|
165
|
+
if access == Access::Call {
|
|
166
|
+
uses.called.insert(key);
|
|
167
|
+
}
|
|
168
|
+
uses.dynamic |= key == "__proto__";
|
|
169
|
+
} else if indexed {
|
|
170
|
+
uses.indexed = true
|
|
171
|
+
} else {
|
|
172
|
+
uses.dynamic = true
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
self.visit_expression(member.object())
|
|
176
|
+
}
|
|
177
|
+
if let MemberExpression::ComputedMemberExpression(computed) = member {
|
|
178
|
+
self.visit_expression(&computed.expression)
|
|
238
179
|
}
|
|
239
180
|
}
|
|
240
181
|
}
|
|
241
182
|
|
|
242
|
-
impl Visit for Collect<'_> {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/// Declaring or assigning a binding does not access the object's contents.
|
|
249
|
-
fn visit_binding_ident(&mut self, _: &BindingIdent) {}
|
|
250
|
-
|
|
251
|
-
fn visit_member_expr(&mut self, member: &MemberExpr) {
|
|
252
|
-
self.member(member, Access::Read);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
fn visit_call_expr(&mut self, call: &CallExpr) {
|
|
256
|
-
match &call.callee {
|
|
257
|
-
Callee::Expr(callee) => self.callee(callee),
|
|
258
|
-
callee => callee.visit_with(self),
|
|
183
|
+
impl<'a> Visit<'a> for Collect<'_, 'a> {
|
|
184
|
+
fn visit_identifier_reference(&mut self, reference: &IdentifierReference<'a>) {
|
|
185
|
+
if let Some(id) = self.analysis.id(reference) {
|
|
186
|
+
self.uses(id).whole = true
|
|
259
187
|
}
|
|
260
|
-
call.args.visit_with(self);
|
|
261
188
|
}
|
|
262
189
|
|
|
263
|
-
fn
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
fn visit_tagged_tpl(&mut self, template: &TaggedTpl) {
|
|
269
|
-
self.callee(&template.tag);
|
|
270
|
-
template.tpl.visit_with(self);
|
|
190
|
+
fn visit_expression(&mut self, expression: &Expression<'a>) {
|
|
191
|
+
match expression.as_member_expression() {
|
|
192
|
+
Some(member) => self.member(member, Access::Read),
|
|
193
|
+
None => walk::walk_expression(self, expression),
|
|
194
|
+
}
|
|
271
195
|
}
|
|
272
196
|
|
|
273
|
-
fn
|
|
274
|
-
let
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
197
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
198
|
+
if let Some(id) = self.analysis.target_id(&assignment.left) {
|
|
199
|
+
if !self.define(id, &assignment.right) {
|
|
200
|
+
self.visit_expression(&assignment.right)
|
|
201
|
+
}
|
|
202
|
+
} else if let Some(member) = assignment.left.as_member_expression() {
|
|
203
|
+
if let Some(id) = self.analysis.expression_id(member.object()) {
|
|
204
|
+
self.uses(id).this |= mentions_this(&assignment.right)
|
|
205
|
+
}
|
|
206
|
+
let access = if assignment.operator == AssignmentOperator::Assign {
|
|
207
|
+
Access::Write
|
|
282
208
|
} else {
|
|
283
|
-
Access::
|
|
209
|
+
Access::ReadWrite
|
|
284
210
|
};
|
|
285
|
-
if let Some(object) = member.obj.as_ident()
|
|
286
|
-
&& mentions_this(&assignment.right)
|
|
287
|
-
{
|
|
288
|
-
self.uses(object).this = true;
|
|
289
|
-
}
|
|
290
211
|
self.member(member, access);
|
|
291
|
-
|
|
292
|
-
&& let Some(target) = assignment.left.as_ident()
|
|
293
|
-
{
|
|
294
|
-
if self.assignment(&target.id, &assignment.right) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
212
|
+
self.visit_expression(&assignment.right)
|
|
297
213
|
} else {
|
|
298
|
-
|
|
214
|
+
walk::walk_assignment_expression(self, assignment)
|
|
299
215
|
}
|
|
300
|
-
assignment.right.visit_with(self);
|
|
301
216
|
}
|
|
302
217
|
|
|
303
|
-
fn
|
|
304
|
-
if let
|
|
305
|
-
&& let Some(
|
|
306
|
-
&& self.
|
|
218
|
+
fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
|
|
219
|
+
if let Some(id) = ast::pattern_id(&declarator.id)
|
|
220
|
+
&& let Some(value) = &declarator.init
|
|
221
|
+
&& self.define(id, value)
|
|
307
222
|
{
|
|
308
223
|
return;
|
|
309
224
|
}
|
|
310
|
-
|
|
225
|
+
walk::walk_variable_declarator(self, declarator)
|
|
311
226
|
}
|
|
312
227
|
|
|
313
|
-
fn
|
|
314
|
-
match
|
|
315
|
-
|
|
316
|
-
|
|
228
|
+
fn visit_assignment_target(&mut self, target: &AssignmentTarget<'a>) {
|
|
229
|
+
match target.as_member_expression() {
|
|
230
|
+
Some(member) => self.member(member, Access::ReadWrite),
|
|
231
|
+
None => walk::walk_assignment_target(self, target),
|
|
317
232
|
}
|
|
318
233
|
}
|
|
319
234
|
|
|
320
|
-
fn
|
|
321
|
-
match
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
235
|
+
fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
|
|
236
|
+
match call.callee.get_inner_expression().as_member_expression() {
|
|
237
|
+
Some(member) => self.member(member, Access::Call),
|
|
238
|
+
None => self.visit_expression(&call.callee),
|
|
239
|
+
}
|
|
240
|
+
for argument in &call.arguments {
|
|
241
|
+
self.visit_argument(argument)
|
|
326
242
|
}
|
|
327
243
|
}
|
|
328
244
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
245
|
+
fn visit_unary_expression(&mut self, unary: &UnaryExpression<'a>) {
|
|
246
|
+
if unary.operator == UnaryOperator::Delete
|
|
247
|
+
&& let Some(member) = unary.argument.get_inner_expression().as_member_expression()
|
|
248
|
+
{
|
|
249
|
+
self.member(member, Access::Delete)
|
|
250
|
+
} else {
|
|
251
|
+
walk::walk_unary_expression(self, unary)
|
|
336
252
|
}
|
|
337
253
|
}
|
|
338
|
-
}
|
|
339
254
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
255
|
+
fn visit_update_expression(&mut self, update: &UpdateExpression<'a>) {
|
|
256
|
+
match update.argument.as_member_expression() {
|
|
257
|
+
Some(member) => self.member(member, Access::ReadWrite),
|
|
258
|
+
None => walk::walk_update_expression(self, update),
|
|
259
|
+
}
|
|
260
|
+
}
|
|
344
261
|
}
|
|
345
262
|
|
|
346
|
-
///
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
/// Returns the own-property name in `object.name`, `object["name"]`, or ``object[`name`]``.
|
|
351
|
-
/// Rejects keys containing lone surrogates, since converting them to Rust strings would replace
|
|
352
|
-
/// them with U+FFFD and could match a different key.
|
|
353
|
-
#[must_use]
|
|
354
|
-
pub(crate) fn member_key(property: &MemberProp) -> Option<Atom> {
|
|
355
|
-
ast::member_str(property)
|
|
356
|
-
.filter(|name| *name != PROTO)
|
|
357
|
-
.map(Atom::from)
|
|
358
|
-
}
|
|
263
|
+
/// Checks for `this`, including in nested functions, since a method may pass its receiver on.
|
|
264
|
+
fn mentions_this(value: &Expression<'_>) -> bool {
|
|
265
|
+
struct This(bool);
|
|
359
266
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
.map(Atom::from)
|
|
366
|
-
}
|
|
267
|
+
impl<'a> Visit<'a> for This {
|
|
268
|
+
fn visit_this_expression(&mut self, _: &ThisExpression) {
|
|
269
|
+
self.0 = true
|
|
270
|
+
}
|
|
271
|
+
}
|
|
367
272
|
|
|
368
|
-
/// Checks for `this` anywhere in `node`, including nested functions. A method mentioning it may
|
|
369
|
-
/// observe or change its receiver.
|
|
370
|
-
fn mentions_this<N: VisitWith<This>>(node: &N) -> bool {
|
|
371
273
|
let mut this = This(false);
|
|
372
|
-
|
|
274
|
+
this.visit_expression(value);
|
|
373
275
|
this.0
|
|
374
276
|
}
|
|
375
277
|
|
|
376
|
-
struct This(bool);
|
|
377
|
-
|
|
378
|
-
impl Visit for This {
|
|
379
|
-
fn visit_this_expr(&mut self, _: &ThisExpr) {
|
|
380
|
-
self.0 = true;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
278
|
#[cfg(test)]
|
|
385
279
|
mod tests {
|
|
386
|
-
use
|
|
387
|
-
use swc_core::ecma::ast::{Expr, MemberProp, Program, PropName};
|
|
388
|
-
|
|
389
|
-
use super::{Properties, member_key, prop_key};
|
|
390
|
-
use crate::deobfuscate::analysis::Bindings;
|
|
280
|
+
use super::Properties;
|
|
391
281
|
use crate::deobfuscate::testing;
|
|
392
|
-
use crate::js::ast;
|
|
393
|
-
|
|
394
|
-
fn properties(program: &Program) -> Properties {
|
|
395
|
-
Properties::collect(program, &Bindings::collect(program))
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
fn member(source: &str) -> MemberProp {
|
|
399
|
-
match ast::parse_expression("member", source).unwrap() {
|
|
400
|
-
Expr::Member(member) => member.prop,
|
|
401
|
-
other => panic!("{source} is {other:?}"),
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
fn key(source: &str) -> PropName {
|
|
406
|
-
let Expr::Object(object) = ast::parse_expression("object", source).unwrap() else {
|
|
407
|
-
panic!("{source} is not an object");
|
|
408
|
-
};
|
|
409
|
-
let property = object.props[0].as_prop().unwrap();
|
|
410
|
-
property.as_key_value().unwrap().key.clone()
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
#[test]
|
|
414
|
-
fn resolves_static_keys() {
|
|
415
|
-
for source in ["o.name", "o['name']", "o[`name`]", r#"o["n\x61me"]"#] {
|
|
416
|
-
assert_eq!(
|
|
417
|
-
member_key(&member(source)).as_deref(),
|
|
418
|
-
Some("name"),
|
|
419
|
-
"{source}"
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
assert_eq!(prop_key(&key("{ 'name': 1 }")).as_deref(), Some("name"));
|
|
423
|
-
assert_eq!(prop_key(&key("{ name: 1 }")).as_deref(), Some("name"));
|
|
424
|
-
// Dynamic, prototype, and lone-surrogate names have no key.
|
|
425
|
-
for source in [
|
|
426
|
-
"o[k]",
|
|
427
|
-
"o[0]",
|
|
428
|
-
"o[`${k}`]",
|
|
429
|
-
"o.__proto__",
|
|
430
|
-
"o['__proto__']",
|
|
431
|
-
r#"o["\uD800"]"#,
|
|
432
|
-
r#"o["\uDC00"]"#,
|
|
433
|
-
] {
|
|
434
|
-
assert_eq!(member_key(&member(source)), None, "{source}");
|
|
435
|
-
}
|
|
436
|
-
for source in [
|
|
437
|
-
"{ __proto__: 1 }",
|
|
438
|
-
"{ '__proto__': 1 }",
|
|
439
|
-
"{ 0: 1 }",
|
|
440
|
-
"{ [k]: 1 }",
|
|
441
|
-
] {
|
|
442
|
-
assert_eq!(prop_key(&key(source)), None, "{source}");
|
|
443
|
-
}
|
|
444
|
-
assert_eq!(
|
|
445
|
-
prop_key(&key(r#"{ "\uD800": 1 }"#)),
|
|
446
|
-
None,
|
|
447
|
-
"two different lone surrogates must not become the same key"
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
282
|
|
|
451
283
|
#[test]
|
|
452
284
|
fn counts_definitions_through_aliases() {
|
|
453
285
|
testing::check(
|
|
454
|
-
"function f(h,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
assert!(!properties.is_stable(&id("h"), &"a".into()));
|
|
463
|
-
assert!(properties.is_stable(&id("q"), &"b".into()));
|
|
464
|
-
assert!(properties.is_stable(&id("h"), &"c".into()));
|
|
465
|
-
assert!(!properties.is_stable(&id("o"), &"d".into()));
|
|
466
|
-
let object = properties.object(&id("p"));
|
|
286
|
+
"function f(h,p,q,o){h={a:1,b:function(){}};p=h;var q=p;q.c=2;p.a+=1;h.b();o={d:1};o.d++;return [q.a,p.c];}",
|
|
287
|
+
|program, analysis, id| {
|
|
288
|
+
let properties = Properties::collect(program, analysis);
|
|
289
|
+
assert!(!properties.stable(id("h"), "a", analysis));
|
|
290
|
+
assert!(properties.stable(id("q"), "b", analysis));
|
|
291
|
+
assert!(properties.stable(id("h"), "c", analysis));
|
|
292
|
+
assert!(!properties.stable(id("o"), "d", analysis));
|
|
293
|
+
let object = properties.get(id("p"), analysis).unwrap();
|
|
467
294
|
for key in ["a", "b", "c"] {
|
|
468
|
-
assert!(object.
|
|
295
|
+
assert!(object.read.contains(key), "{key}")
|
|
469
296
|
}
|
|
470
|
-
assert!(properties.binding(&id("q")).written_through);
|
|
471
|
-
assert!(!properties.binding(&id("h")).written_through);
|
|
472
297
|
},
|
|
473
298
|
);
|
|
474
299
|
}
|
|
475
300
|
|
|
476
301
|
#[test]
|
|
477
|
-
fn
|
|
478
|
-
for
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
(
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
(
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
"h = { m: function () {} }; h.m(); h.a = 1; [h.b] = [1]; h.c;",
|
|
495
|
-
false,
|
|
496
|
-
),
|
|
302
|
+
fn rejects_escapes_dynamic_keys_and_observable_mutations() {
|
|
303
|
+
for source in [
|
|
304
|
+
"use(h);",
|
|
305
|
+
"use({h});",
|
|
306
|
+
"h[k]=1;",
|
|
307
|
+
"h[0];",
|
|
308
|
+
"h.__proto__;",
|
|
309
|
+
"delete h.a;",
|
|
310
|
+
"h.hasOwnProperty('a');",
|
|
311
|
+
"(h.hasOwnProperty)('a');",
|
|
312
|
+
"h?.hasOwnProperty('a');",
|
|
313
|
+
"h.m=function(){return this};h.m();",
|
|
314
|
+
"p=h;p=2;h.a;",
|
|
315
|
+
"[h.a]=[1];",
|
|
316
|
+
"for(h.a of list);",
|
|
317
|
+
"h.a++;",
|
|
318
|
+
"h.a+=1;",
|
|
497
319
|
] {
|
|
498
320
|
testing::check(
|
|
499
|
-
&format!("function f(h,
|
|
500
|
-
|program, id| {
|
|
501
|
-
|
|
321
|
+
&format!("function f(h,p,k){{h={{a:1}};{source}}}"),
|
|
322
|
+
|program, analysis, id| {
|
|
323
|
+
assert!(
|
|
324
|
+
!Properties::collect(program, analysis).stable(id("h"), "a", analysis),
|
|
325
|
+
"{source}"
|
|
326
|
+
)
|
|
502
327
|
},
|
|
503
328
|
);
|
|
504
329
|
}
|
|
505
330
|
}
|
|
506
331
|
|
|
507
332
|
#[test]
|
|
508
|
-
fn
|
|
333
|
+
fn distinguishes_constant_index_reads_from_writes() {
|
|
509
334
|
for (source, only_indexed) in [
|
|
510
|
-
("f
|
|
511
|
-
("f
|
|
512
|
-
("f
|
|
513
|
-
("f
|
|
514
|
-
("
|
|
515
|
-
("
|
|
516
|
-
("
|
|
517
|
-
("f
|
|
518
|
-
("f
|
|
519
|
-
("
|
|
335
|
+
("f[0]+f[3];", true),
|
|
336
|
+
("f[0]();", false),
|
|
337
|
+
("f[0]=1;", false),
|
|
338
|
+
("f[0]++;", false),
|
|
339
|
+
("delete f[0];", false),
|
|
340
|
+
("[f[0]]=[1];", false),
|
|
341
|
+
("for(f[0] of [1]);", false),
|
|
342
|
+
("f.length;", false),
|
|
343
|
+
("f[i];", false),
|
|
344
|
+
("use({f});", false),
|
|
520
345
|
] {
|
|
521
346
|
testing::check(
|
|
522
|
-
&format!("function g(a,
|
|
523
|
-
|program, id| {
|
|
347
|
+
&format!("function g(a,f,i){{f=[a];{source}}}"),
|
|
348
|
+
|program, analysis, id| {
|
|
524
349
|
assert_eq!(
|
|
525
|
-
|
|
350
|
+
Properties::collect(program, analysis).only_indexed(id("f"), analysis),
|
|
526
351
|
only_indexed,
|
|
527
352
|
"{source}"
|
|
528
|
-
)
|
|
353
|
+
)
|
|
529
354
|
},
|
|
530
355
|
);
|
|
531
356
|
}
|