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
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
use std::{mem, ptr};
|
|
4
4
|
|
|
5
|
-
use
|
|
5
|
+
use oxc::ast::ast::Function;
|
|
6
6
|
|
|
7
7
|
use super::copies::Copies;
|
|
8
8
|
use super::intrinsic;
|
|
9
|
+
use super::plan::Routine;
|
|
9
10
|
use super::run::{Decrypted, Run, Snapshot, Stop};
|
|
10
11
|
use crate::vm::dispatch::Decoded;
|
|
11
12
|
use crate::vm::output::Path;
|
|
@@ -24,7 +25,7 @@ pub(crate) struct Invocation<'session, 'ast> {
|
|
|
24
25
|
pub pc: u32,
|
|
25
26
|
/// The dispatch key the opcode byte leaves.
|
|
26
27
|
pub key: u8,
|
|
27
|
-
pub handler: &'ast Function
|
|
28
|
+
pub handler: &'ast Function<'ast>,
|
|
28
29
|
/// The instance fields the constructor derives from the program.
|
|
29
30
|
pub fields: &'session HashMap<String, Value<'ast>>,
|
|
30
31
|
/// Strings decrypted from the program so far.
|
|
@@ -65,7 +66,8 @@ pub(crate) fn explore<'ast>(invocation: &Invocation<'_, 'ast>) -> Option<Ways<'a
|
|
|
65
66
|
let plan = if special {
|
|
66
67
|
None
|
|
67
68
|
} else {
|
|
68
|
-
|
|
69
|
+
Routine::function(handler)
|
|
70
|
+
.and_then(|routine| session.compiled.slots(session.script, routine))
|
|
69
71
|
};
|
|
70
72
|
// A run that thaws a shared session object leaves no results; explore again with the
|
|
71
73
|
// object copied.
|
|
@@ -196,22 +198,17 @@ pub(crate) struct Branching {
|
|
|
196
198
|
pub(crate) fn decode<'ast>(
|
|
197
199
|
session: &Session<'ast>,
|
|
198
200
|
program: &[u8],
|
|
199
|
-
decoder:
|
|
201
|
+
decoder: Routine<'ast>,
|
|
200
202
|
arguments: Vec<Value<'ast>>,
|
|
201
203
|
pc: u32,
|
|
202
204
|
key: u8,
|
|
203
205
|
) -> Result<Decoded, String> {
|
|
204
|
-
let decoder = Callable::Script {
|
|
205
|
-
name: None,
|
|
206
|
-
function: decoder,
|
|
207
|
-
scope: None,
|
|
208
|
-
};
|
|
209
206
|
// A run that thaws a shared session object decodes again with the object copied.
|
|
210
207
|
let (outcome, next) = loop {
|
|
211
208
|
let mut run = Run::new(session, program, Vec::new(), Some(Copies::default()));
|
|
212
209
|
run.sharing = true;
|
|
213
210
|
run.start_at(pc, key);
|
|
214
|
-
let outcome = run.
|
|
211
|
+
let outcome = run.routine(decoder, None, Value::Undefined, arguments.clone());
|
|
215
212
|
let next = run.register_value(session.layout.key);
|
|
216
213
|
for scope in run.scopes() {
|
|
217
214
|
scope.borrow_mut().variables.clear();
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//! Integer formulas captured from scripts, evaluated with JavaScript's number semantics.
|
|
2
|
+
//!
|
|
3
|
+
//! The obfuscator varies the arithmetic of some helpers per build. A [`super::pattern`]
|
|
4
|
+
//! template captures such arithmetic as a formula over named inputs instead of fixing it.
|
|
5
|
+
|
|
6
|
+
use oxc::ast::ast::{Expression, IdentifierReference};
|
|
7
|
+
use oxc::syntax::operator::BinaryOperator;
|
|
8
|
+
|
|
9
|
+
use crate::js;
|
|
10
|
+
use crate::vm::convert;
|
|
11
|
+
use crate::vm::value::Value;
|
|
12
|
+
|
|
13
|
+
/// An expression of numeric literals, named inputs, indexed inputs, and arithmetic or bitwise
|
|
14
|
+
/// operators.
|
|
15
|
+
#[derive(Clone)]
|
|
16
|
+
pub(super) enum Formula {
|
|
17
|
+
Number(f64),
|
|
18
|
+
Input(String),
|
|
19
|
+
Index {
|
|
20
|
+
input: String,
|
|
21
|
+
index: Box<Formula>,
|
|
22
|
+
},
|
|
23
|
+
Binary {
|
|
24
|
+
operator: BinaryOperator,
|
|
25
|
+
left: Box<Formula>,
|
|
26
|
+
right: Box<Formula>,
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/// A formula input's value.
|
|
31
|
+
pub(super) enum Input<'a, 'ast> {
|
|
32
|
+
Number(f64),
|
|
33
|
+
Array(&'a [Value<'ast>]),
|
|
34
|
+
Bytes(&'a [u8]),
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
impl Formula {
|
|
38
|
+
/// Compiles `expression`, with each subexpression in the form `normal` gives it, naming each
|
|
39
|
+
/// identifier with `name`. Returns `None` for anything outside the supported forms.
|
|
40
|
+
pub(super) fn compile<'e>(
|
|
41
|
+
expression: &'e Expression<'e>,
|
|
42
|
+
normal: &impl Fn(&'e Expression<'e>) -> &'e Expression<'e>,
|
|
43
|
+
name: &impl Fn(&IdentifierReference<'_>) -> Option<String>,
|
|
44
|
+
) -> Option<Self> {
|
|
45
|
+
let compile = |expression| Self::compile(expression, normal, name);
|
|
46
|
+
Some(match normal(expression).without_parentheses() {
|
|
47
|
+
Expression::NumericLiteral(number) => Self::Number(number.value),
|
|
48
|
+
Expression::Identifier(identifier) => Self::Input(name(identifier)?),
|
|
49
|
+
Expression::ComputedMemberExpression(member) => {
|
|
50
|
+
let Expression::Identifier(input) = normal(&member.object) else {
|
|
51
|
+
return None;
|
|
52
|
+
};
|
|
53
|
+
Self::Index {
|
|
54
|
+
input: name(input)?,
|
|
55
|
+
index: Box::new(compile(&member.expression)?),
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
Expression::BinaryExpression(binary)
|
|
59
|
+
if matches!(
|
|
60
|
+
binary.operator,
|
|
61
|
+
BinaryOperator::BitwiseAnd
|
|
62
|
+
| BinaryOperator::BitwiseOR
|
|
63
|
+
| BinaryOperator::BitwiseXOR
|
|
64
|
+
| BinaryOperator::Addition
|
|
65
|
+
| BinaryOperator::Subtraction
|
|
66
|
+
| BinaryOperator::Multiplication
|
|
67
|
+
| BinaryOperator::ShiftLeft
|
|
68
|
+
| BinaryOperator::ShiftRight
|
|
69
|
+
| BinaryOperator::ShiftRightZeroFill
|
|
70
|
+
) =>
|
|
71
|
+
{
|
|
72
|
+
Self::Binary {
|
|
73
|
+
operator: binary.operator,
|
|
74
|
+
left: Box::new(compile(&binary.left)?),
|
|
75
|
+
right: Box::new(compile(&binary.right)?),
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
_ => return None,
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Evaluates the formula as the script would, given every input's value by name. Returns
|
|
83
|
+
/// `None` where the script would see a non-number, such as an index out of range.
|
|
84
|
+
pub(super) fn evaluate(&self, inputs: &[(&str, Input<'_, '_>)]) -> Option<f64> {
|
|
85
|
+
let input = |name: &str| {
|
|
86
|
+
let (_, input) = inputs.iter().find(|(found, _)| *found == name)?;
|
|
87
|
+
Some(input)
|
|
88
|
+
};
|
|
89
|
+
Some(match self {
|
|
90
|
+
Self::Number(number) => *number,
|
|
91
|
+
Self::Input(name) => match input(name)? {
|
|
92
|
+
Input::Number(number) => *number,
|
|
93
|
+
Input::Array(_) | Input::Bytes(_) => return None,
|
|
94
|
+
},
|
|
95
|
+
Self::Index { input: name, index } => {
|
|
96
|
+
let index = convert::index(index.evaluate(inputs)?)?;
|
|
97
|
+
match input(name)? {
|
|
98
|
+
Input::Array(elements) => match elements.get(index)? {
|
|
99
|
+
Value::Number(number) => *number,
|
|
100
|
+
_ => return None,
|
|
101
|
+
},
|
|
102
|
+
Input::Bytes(bytes) => f64::from(*bytes.get(index)?),
|
|
103
|
+
Input::Number(_) => return None,
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
Self::Binary {
|
|
107
|
+
operator,
|
|
108
|
+
left,
|
|
109
|
+
right,
|
|
110
|
+
} => {
|
|
111
|
+
// Operands are numbers, so each operator is its numeric case.
|
|
112
|
+
let (left, right) = (left.evaluate(inputs)?, right.evaluate(inputs)?);
|
|
113
|
+
let shift = || js::int32(right) as u32 & 31;
|
|
114
|
+
match operator {
|
|
115
|
+
BinaryOperator::BitwiseAnd => f64::from(js::int32(left) & js::int32(right)),
|
|
116
|
+
BinaryOperator::BitwiseOR => f64::from(js::int32(left) | js::int32(right)),
|
|
117
|
+
BinaryOperator::BitwiseXOR => f64::from(js::int32(left) ^ js::int32(right)),
|
|
118
|
+
BinaryOperator::Addition => left + right,
|
|
119
|
+
BinaryOperator::Subtraction => left - right,
|
|
120
|
+
BinaryOperator::Multiplication => left * right,
|
|
121
|
+
BinaryOperator::ShiftLeft => f64::from(js::int32(left).wrapping_shl(shift())),
|
|
122
|
+
BinaryOperator::ShiftRight => f64::from(js::int32(left) >> shift()),
|
|
123
|
+
BinaryOperator::ShiftRightZeroFill => {
|
|
124
|
+
f64::from(js::int32(left) as u32 >> shift())
|
|
125
|
+
}
|
|
126
|
+
_ => unreachable!("compile admits only these operators"),
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -13,11 +13,9 @@
|
|
|
13
13
|
use std::cell::RefCell;
|
|
14
14
|
use std::rc::Rc;
|
|
15
15
|
|
|
16
|
-
use
|
|
17
|
-
use swc_core::atoms::Atom;
|
|
18
|
-
|
|
19
|
-
use crate::vm::HashMap;
|
|
16
|
+
use crate::js::ast::Binding;
|
|
20
17
|
use crate::vm::value::Value;
|
|
18
|
+
use crate::vm::{HashMap, HashSet};
|
|
21
19
|
|
|
22
20
|
#[derive(Default)]
|
|
23
21
|
pub(crate) struct Frozen {
|
|
@@ -32,7 +30,7 @@ pub(crate) struct Frozen {
|
|
|
32
30
|
impl Frozen {
|
|
33
31
|
/// Groups the objects reachable from `bindings` and shares those of groups that reach no
|
|
34
32
|
/// function with captured state.
|
|
35
|
-
pub(crate) fn of(bindings: &HashMap<
|
|
33
|
+
pub(crate) fn of(bindings: &HashMap<Binding<'_>, Value<'_>>) -> Self {
|
|
36
34
|
let mut groups = Groups::default();
|
|
37
35
|
for value in bindings.values() {
|
|
38
36
|
let mut reached = Reached::default();
|
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
//! Native versions of
|
|
2
|
-
//!
|
|
3
|
-
//!
|
|
4
|
-
//! interpreted.
|
|
1
|
+
//! Native versions of script functions. Register bookkeeping is recognized structurally;
|
|
2
|
+
//! BLAKE3 compression must also agree on test inputs. Calls outside each native version's
|
|
3
|
+
//! supported arguments are interpreted.
|
|
5
4
|
|
|
6
5
|
use std::ptr;
|
|
7
6
|
|
|
8
|
-
use
|
|
9
|
-
use
|
|
7
|
+
use oxc::ast::ast::{Function, NumericLiteral, ObjectProperty};
|
|
8
|
+
use oxc::ast_visit::{Visit, walk};
|
|
9
|
+
use oxc::semantic::ScopeFlags;
|
|
10
10
|
|
|
11
11
|
use super::copies::Copies;
|
|
12
|
+
use super::mix32::Mix32;
|
|
13
|
+
use super::pattern;
|
|
14
|
+
use super::register_helpers::{self, Helper};
|
|
12
15
|
use super::run::Run;
|
|
13
16
|
use crate::js;
|
|
14
|
-
use crate::vm::HashMap;
|
|
15
17
|
use crate::vm::session::Session;
|
|
16
18
|
use crate::vm::value::{Callable, Value};
|
|
19
|
+
use crate::vm::{HashMap, extract};
|
|
17
20
|
|
|
18
21
|
/// A native function equivalent to a script function.
|
|
19
22
|
#[derive(Clone, Copy)]
|
|
20
23
|
pub(crate) enum Intrinsic {
|
|
24
|
+
RegisterRead,
|
|
25
|
+
RegisterWrite,
|
|
26
|
+
/// Bookkeeping on the interpreter's unmasked register file.
|
|
27
|
+
Register(Helper),
|
|
28
|
+
Mix32(Mix32),
|
|
21
29
|
/// `compress(cv, block, counter, length, flags)`: overwrites the 8 words of `cv` with the
|
|
22
30
|
/// BLAKE3 compression of the 16-word `block`.
|
|
23
31
|
Blake3Compress,
|
|
@@ -27,59 +35,144 @@ pub(crate) enum Intrinsic {
|
|
|
27
35
|
pub(crate) type Intrinsics = HashMap<usize, Intrinsic>;
|
|
28
36
|
|
|
29
37
|
/// The address identifying `function` in [`Intrinsics`].
|
|
30
|
-
pub(super) fn address(function: &Function) -> usize {
|
|
38
|
+
pub(super) fn address(function: &Function<'_>) -> usize {
|
|
31
39
|
ptr::from_ref(function).addr()
|
|
32
40
|
}
|
|
33
41
|
|
|
34
|
-
/// Finds
|
|
35
|
-
///
|
|
42
|
+
/// Finds register helpers and mixers, and validates BLAKE3 candidates taking five parameters
|
|
43
|
+
/// and mentioning its initialization vector's first word, which some builds store complemented.
|
|
36
44
|
pub(crate) fn intrinsics(session: &Session<'_>) -> Intrinsics {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
let mut intrinsics = Intrinsics::default();
|
|
46
|
+
let script = session.script;
|
|
47
|
+
for function in session.functions.values() {
|
|
48
|
+
let intrinsic = if let Some(helper) =
|
|
49
|
+
register_helpers::recognize(script, function, session.register_access)
|
|
50
|
+
{
|
|
51
|
+
Intrinsic::Register(helper)
|
|
52
|
+
} else if let Some(mixer) = Mix32::recognize(script, function) {
|
|
53
|
+
Intrinsic::Mix32(mixer)
|
|
54
|
+
} else if extract::parameter_count(&function.params) == 5
|
|
55
|
+
// `~IV[0]` is written as the negation of `IV[0] + 1`.
|
|
56
|
+
&& (mentions(function, f64::from(IV[0]))
|
|
57
|
+
|| mentions(function, f64::from(IV[0]) + 1.0))
|
|
58
|
+
&& compresses_like_native(session, function)
|
|
59
|
+
{
|
|
60
|
+
Intrinsic::Blake3Compress
|
|
61
|
+
} else {
|
|
62
|
+
continue;
|
|
63
|
+
};
|
|
64
|
+
intrinsics.insert(address(function), intrinsic);
|
|
65
|
+
}
|
|
66
|
+
// Registers in the abstract machine already contain decoded values. The save helper
|
|
67
|
+
// preserves lazy string records in the real VM, but is the same read in this model.
|
|
68
|
+
if let crate::vm::registers::Access::Functions { read, write } = session.register_access {
|
|
69
|
+
intrinsics.insert(address(read), Intrinsic::RegisterRead);
|
|
70
|
+
intrinsics.insert(address(write), Intrinsic::RegisterWrite);
|
|
71
|
+
let helpers = pattern::binary_helpers(session);
|
|
72
|
+
let save = pattern::template(
|
|
73
|
+
"function save(registers, index) {
|
|
74
|
+
if (registers.J[index] === -4) { return registers.H[index]; }
|
|
75
|
+
else { return $read(registers, index); } }",
|
|
76
|
+
);
|
|
77
|
+
for function in session.functions.values() {
|
|
78
|
+
if let Some(captures) = pattern::matches(&save, script, function, &helpers)
|
|
79
|
+
&& let Some(reader) = captures
|
|
80
|
+
.name("$read")
|
|
81
|
+
.and_then(|name| session.function(name))
|
|
82
|
+
&& ptr::eq(reader, read)
|
|
83
|
+
{
|
|
84
|
+
intrinsics.insert(address(function), Intrinsic::RegisterRead);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
intrinsics
|
|
44
89
|
}
|
|
45
90
|
|
|
46
91
|
impl Intrinsic {
|
|
47
|
-
/// Runs
|
|
92
|
+
/// Runs a register helper or mixer natively. Returns `None` for BLAKE3 compression, which
|
|
93
|
+
/// [`blake3_compress`] runs, and for arguments outside what the native version reproduces
|
|
48
94
|
/// exactly, leaving the call to the interpreter.
|
|
49
|
-
pub(super) fn call<'ast>(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
flags,
|
|
58
|
-
] = arguments
|
|
59
|
-
else {
|
|
95
|
+
pub(super) fn call<'ast>(
|
|
96
|
+
self,
|
|
97
|
+
run: &mut Run<'ast, '_>,
|
|
98
|
+
arguments: &[Value<'ast>],
|
|
99
|
+
) -> Option<Value<'ast>> {
|
|
100
|
+
let register = match self {
|
|
101
|
+
Self::RegisterRead | Self::RegisterWrite => {
|
|
102
|
+
let [Value::Registers, Value::Number(register), rest @ ..] = arguments else {
|
|
60
103
|
return None;
|
|
61
104
|
};
|
|
62
|
-
let
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
&words(cv.get(..8)?)?,
|
|
66
|
-
&words(block.get(..16)?)?,
|
|
67
|
-
Counter::of(counter.as_number()?),
|
|
68
|
-
js::int32(length.as_number()?) as u32,
|
|
69
|
-
js::int32(flags.as_number()?) as u32,
|
|
70
|
-
)
|
|
71
|
-
};
|
|
72
|
-
let mut cv = cv.borrow_mut();
|
|
73
|
-
for (slot, word) in cv.iter_mut().zip(output) {
|
|
74
|
-
// The script stores the results of `^`, which are signed.
|
|
75
|
-
*slot = Value::Number(f64::from(word as i32));
|
|
105
|
+
let register = crate::vm::convert::byte(*register)?;
|
|
106
|
+
if matches!(self, Self::RegisterRead) {
|
|
107
|
+
return Some(run.register_value(register));
|
|
76
108
|
}
|
|
77
|
-
|
|
109
|
+
run.write_register(register, rest.first()?.clone());
|
|
110
|
+
return Some(Value::Undefined);
|
|
111
|
+
}
|
|
112
|
+
Self::Mix32(mixer) => {
|
|
113
|
+
let Some(Value::Number(number)) = arguments.first() else {
|
|
114
|
+
return None;
|
|
115
|
+
};
|
|
116
|
+
return Some(Value::Number(mixer.call(*number)));
|
|
117
|
+
}
|
|
118
|
+
Self::Register(Helper::Number) => {
|
|
119
|
+
return arguments
|
|
120
|
+
.first()
|
|
121
|
+
.filter(|value| matches!(value, Value::Number(_)))
|
|
122
|
+
.cloned();
|
|
123
|
+
}
|
|
124
|
+
Self::Register(Helper::Mask) => {
|
|
125
|
+
return matches!(arguments.first(), Some(Value::Registers))
|
|
126
|
+
.then_some(Value::Undefined);
|
|
78
127
|
}
|
|
128
|
+
Self::Register(Helper::Pc) => run.session.layout.pc,
|
|
129
|
+
Self::Register(Helper::Key) => run.session.layout.key,
|
|
130
|
+
Self::Blake3Compress => return None,
|
|
131
|
+
};
|
|
132
|
+
let [Value::Registers, value @ Value::Number(number), ..] = arguments else {
|
|
133
|
+
return None;
|
|
134
|
+
};
|
|
135
|
+
// Both setter branches store exactly this value for signed integers other than -0.
|
|
136
|
+
if *number != f64::from(js::int32(*number)) || (*number == 0.0 && number.is_sign_negative())
|
|
137
|
+
{
|
|
138
|
+
return None;
|
|
79
139
|
}
|
|
140
|
+
run.set_register(register, value.clone());
|
|
141
|
+
Some(value.clone())
|
|
80
142
|
}
|
|
81
143
|
}
|
|
82
144
|
|
|
145
|
+
/// Runs [`Intrinsic::Blake3Compress`]. Returns `None` if the arguments are outside what it
|
|
146
|
+
/// reproduces exactly, leaving the call to the interpreter.
|
|
147
|
+
pub(super) fn blake3_compress<'ast>(arguments: &[Value<'ast>]) -> Option<Value<'ast>> {
|
|
148
|
+
let [
|
|
149
|
+
Value::Array(cv),
|
|
150
|
+
Value::Array(block),
|
|
151
|
+
counter,
|
|
152
|
+
length,
|
|
153
|
+
flags,
|
|
154
|
+
] = arguments
|
|
155
|
+
else {
|
|
156
|
+
return None;
|
|
157
|
+
};
|
|
158
|
+
let output = {
|
|
159
|
+
let (cv, block) = (cv.borrow(), block.borrow());
|
|
160
|
+
compress(
|
|
161
|
+
&words(cv.get(..8)?)?,
|
|
162
|
+
&words(block.get(..16)?)?,
|
|
163
|
+
Counter::of(counter.as_number()?),
|
|
164
|
+
js::int32(length.as_number()?) as u32,
|
|
165
|
+
js::int32(flags.as_number()?) as u32,
|
|
166
|
+
)
|
|
167
|
+
};
|
|
168
|
+
let mut cv = cv.borrow_mut();
|
|
169
|
+
for (slot, word) in cv.iter_mut().zip(output) {
|
|
170
|
+
// The script stores the results of `^`, which are signed.
|
|
171
|
+
*slot = Value::Number(f64::from(word as i32));
|
|
172
|
+
}
|
|
173
|
+
Some(Value::Undefined)
|
|
174
|
+
}
|
|
175
|
+
|
|
83
176
|
impl Value<'_> {
|
|
84
177
|
fn as_number(&self) -> Option<f64> {
|
|
85
178
|
match self {
|
|
@@ -92,7 +185,7 @@ impl Value<'_> {
|
|
|
92
185
|
/// Converts state or message words. The script first adds three words before truncating, which
|
|
93
186
|
/// matches wrapping addition only while the sum is exact, so larger or fractional words are
|
|
94
187
|
/// rejected.
|
|
95
|
-
fn words<const N: usize>(values: &[Value<'_>]) -> Option<[u32; N]> {
|
|
188
|
+
pub(super) fn words<const N: usize>(values: &[Value<'_>]) -> Option<[u32; N]> {
|
|
96
189
|
let mut words = [0; N];
|
|
97
190
|
for (word, value) in words.iter_mut().zip(values) {
|
|
98
191
|
let number = value.as_number()?;
|
|
@@ -107,13 +200,13 @@ fn words<const N: usize>(values: &[Value<'_>]) -> Option<[u32; N]> {
|
|
|
107
200
|
/// A block counter split as the script splits it: `counter | 0` and
|
|
108
201
|
/// `counter / 4294967296 | 0`.
|
|
109
202
|
#[derive(Clone, Copy)]
|
|
110
|
-
struct Counter {
|
|
203
|
+
pub(super) struct Counter {
|
|
111
204
|
low: u32,
|
|
112
205
|
high: u32,
|
|
113
206
|
}
|
|
114
207
|
|
|
115
208
|
impl Counter {
|
|
116
|
-
fn of(counter: f64) -> Self {
|
|
209
|
+
pub(super) fn of(counter: f64) -> Self {
|
|
117
210
|
Self {
|
|
118
211
|
low: js::int32(counter) as u32,
|
|
119
212
|
high: js::int32(counter / 4_294_967_296.0) as u32,
|
|
@@ -136,7 +229,7 @@ const IV: [u32; 8] = [
|
|
|
136
229
|
const PERMUTATION: [usize; 16] = [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8];
|
|
137
230
|
|
|
138
231
|
/// The BLAKE3 compression function, truncated to the chaining value.
|
|
139
|
-
fn compress(
|
|
232
|
+
pub(super) fn compress(
|
|
140
233
|
cv: &[u32; 8],
|
|
141
234
|
block: &[u32; 16],
|
|
142
235
|
counter: Counter,
|
|
@@ -177,32 +270,41 @@ fn mix(state: &mut [u32; 16], [a, b, c, d]: [usize; 4], x: u32, y: u32) {
|
|
|
177
270
|
}
|
|
178
271
|
|
|
179
272
|
/// Whether `function` contains the numeric literal `number`.
|
|
180
|
-
fn mentions(function: &Function
|
|
273
|
+
fn mentions(function: &Function<'_>, number: f64) -> bool {
|
|
181
274
|
struct Finder {
|
|
182
275
|
number: f64,
|
|
183
276
|
found: bool,
|
|
184
277
|
}
|
|
185
278
|
|
|
186
|
-
impl Visit for Finder {
|
|
187
|
-
fn
|
|
188
|
-
self.found |=
|
|
279
|
+
impl<'a> Visit<'a> for Finder {
|
|
280
|
+
fn visit_numeric_literal(&mut self, literal: &NumericLiteral<'a>) {
|
|
281
|
+
self.found |= literal.value == self.number;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/// A numeric key names a property; only computed keys hold values.
|
|
285
|
+
fn visit_object_property(&mut self, property: &ObjectProperty<'a>) {
|
|
286
|
+
if property.computed {
|
|
287
|
+
walk::walk_object_property(self, property);
|
|
288
|
+
} else {
|
|
289
|
+
self.visit_expression(&property.value);
|
|
290
|
+
}
|
|
189
291
|
}
|
|
190
292
|
}
|
|
191
293
|
|
|
192
294
|
let mut finder = Finder {
|
|
193
|
-
number
|
|
295
|
+
number,
|
|
194
296
|
found: false,
|
|
195
297
|
};
|
|
196
|
-
|
|
298
|
+
finder.visit_function(function, ScopeFlags::Function);
|
|
197
299
|
finder.found
|
|
198
300
|
}
|
|
199
301
|
|
|
200
|
-
/// Whether interpreting `function` gives the result of [`
|
|
302
|
+
/// Whether interpreting `function` gives the result of [`blake3_compress`] on every
|
|
201
303
|
/// test input, returning nothing and recording no effects.
|
|
202
|
-
fn compresses_like_native<'ast>(session: &Session<'ast>, function: &'ast Function) -> bool {
|
|
304
|
+
fn compresses_like_native<'ast>(session: &Session<'ast>, function: &'ast Function<'ast>) -> bool {
|
|
203
305
|
TEST_INPUTS.iter().all(|input| {
|
|
204
306
|
let native = input.arguments();
|
|
205
|
-
if
|
|
307
|
+
if blake3_compress(&native).is_none() {
|
|
206
308
|
return false;
|
|
207
309
|
}
|
|
208
310
|
// Clones share the arrays, so `interpreted` shows what the script wrote.
|
|
@@ -345,6 +447,6 @@ mod tests {
|
|
|
345
447
|
fn rejects_inexact_words() {
|
|
346
448
|
let mut arguments = TEST_INPUTS[0].arguments();
|
|
347
449
|
arguments[1] = Value::array(vec![Value::Number(0.5); 16]);
|
|
348
|
-
assert!(
|
|
450
|
+
assert!(blake3_compress(&arguments).is_none());
|
|
349
451
|
}
|
|
350
452
|
}
|