mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Merge pull request #805 from javascript-obfuscator/fixed-attach-missing-ranges
Fixed incorrect rename of the identifiers of the added helpers in some rare cases
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
Change Log
|
||||
|
||||
v2.8.1
|
||||
---
|
||||
* Fixed incorrect rename of the identifiers of the added helpers in some rare cases. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/804
|
||||
|
||||
v2.8.0
|
||||
---
|
||||
* New option `ignoreRequireImports` prevents obfuscation of `require` imports. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/801
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+6
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "javascript-obfuscator",
|
||||
"version": "2.8.0",
|
||||
"version": "2.8.1",
|
||||
"description": "JavaScript obfuscator",
|
||||
"keywords": [
|
||||
"obfuscator",
|
||||
@@ -58,13 +58,13 @@
|
||||
"@types/mkdirp": "1.0.1",
|
||||
"@types/mocha": "8.0.3",
|
||||
"@types/multimatch": "4.0.0",
|
||||
"@types/node": "14.14.6",
|
||||
"@types/node": "14.14.7",
|
||||
"@types/rimraf": "3.0.0",
|
||||
"@types/sinon": "9.0.8",
|
||||
"@types/string-template": "1.0.2",
|
||||
"@types/webpack-env": "1.15.3",
|
||||
"@typescript-eslint/eslint-plugin": "4.6.1",
|
||||
"@typescript-eslint/parser": "4.6.1",
|
||||
"@typescript-eslint/eslint-plugin": "4.7.0",
|
||||
"@typescript-eslint/parser": "4.7.0",
|
||||
"chai": "4.2.0",
|
||||
"chai-exclude": "2.0.2",
|
||||
"coveralls": "3.1.0",
|
||||
@@ -76,7 +76,7 @@
|
||||
"eslint-plugin-prefer-arrow": "1.2.2",
|
||||
"eslint-plugin-unicorn": "23.0.0",
|
||||
"fork-ts-checker-notifier-webpack-plugin": "3.0.0",
|
||||
"fork-ts-checker-webpack-plugin": "6.0.0",
|
||||
"fork-ts-checker-webpack-plugin": "6.0.1",
|
||||
"mocha": "8.2.1",
|
||||
"nyc": "15.1.0",
|
||||
"pjson": "1.0.9",
|
||||
@@ -84,7 +84,7 @@
|
||||
"rimraf": "3.0.2",
|
||||
"sinon": "9.2.1",
|
||||
"threads": "1.6.3",
|
||||
"ts-loader": "8.0.10",
|
||||
"ts-loader": "8.0.11",
|
||||
"ts-node": "9.0.0",
|
||||
"typescript": "4.1.0-beta",
|
||||
"webpack": "5.4.0",
|
||||
|
||||
@@ -46,11 +46,11 @@ export class ScopeAnalyzer implements IScopeAnalyzer {
|
||||
*/
|
||||
private static attachMissingRanges (astTree: ESTree.Node): void {
|
||||
estraverse.replace(astTree, {
|
||||
enter: (node: ESTree.Node): ESTree.Node => {
|
||||
enter: (node: ESTree.Node, parentNode: ESTree.Node | null): ESTree.Node => {
|
||||
if (!node.range) {
|
||||
node.range = [
|
||||
node.parentNode?.range?.[0] ?? ScopeAnalyzer.emptyRangeValue,
|
||||
node.parentNode?.range?.[1] ?? ScopeAnalyzer.emptyRangeValue
|
||||
parentNode?.range?.[0] ?? ScopeAnalyzer.emptyRangeValue,
|
||||
parentNode?.range?.[1] ?? ScopeAnalyzer.emptyRangeValue
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'reflect-metadata';
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { readFileAsString } from '../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
describe('ScopeAnalyzer', () => {
|
||||
describe('analyze', () => {
|
||||
/**
|
||||
* https://github.com/javascript-obfuscator/javascript-obfuscator/issues/804
|
||||
*/
|
||||
describe('Variant #1: should attach a valid missing ranges', function() {
|
||||
this.timeout(120000);
|
||||
|
||||
const samplesCount: number = 1000;
|
||||
let error: string | null = null;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/attach-missing-ranges.js');
|
||||
|
||||
for (let i = 0; i < samplesCount; i++) {
|
||||
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
stringArray: false,
|
||||
selfDefending: true,
|
||||
controlFlowFlattening: true,
|
||||
controlFlowFlatteningThreshold: 0.1,
|
||||
splitStrings: false,
|
||||
seed: i
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
try {
|
||||
eval(obfuscatedCode);
|
||||
} catch ({message}) {
|
||||
error = message;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should attach missing ranges based on the parent node and rename identifiers without errors', () => {
|
||||
assert.equal(error, null);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
function foo () {}
|
||||
|
||||
foo();
|
||||
@@ -51,6 +51,7 @@ import './unit-tests/utils/Utils.spec';
|
||||
* Functional tests
|
||||
*/
|
||||
import './functional-tests/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.spec';
|
||||
import './functional-tests/analyzers/scope-analyzer/ScopeAnalyzer.spec';
|
||||
import './functional-tests/cli/JavaScriptObfuscatorCLI.spec';
|
||||
import './functional-tests/code-transformers/preparing-transformers/hashbang-operator-transformer/HashbangOperatorTransformer.spec';
|
||||
import './functional-tests/custom-code-helpers/common/templates/GlobalVariableNoEvalTemplate.spec';
|
||||
|
||||
@@ -530,10 +530,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.3.tgz#6356df2647de9eac569f9a52eda3480fa9e70b4d"
|
||||
integrity sha512-01s+ac4qerwd6RHD+mVbOEsraDHSgUaefQlEdBbUolnQFjKwCr7luvAlEwW1RFojh67u0z4OUTjPn9LEl4zIkA==
|
||||
|
||||
"@types/node@14.14.6":
|
||||
version "14.14.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.6.tgz#146d3da57b3c636cc0d1769396ce1cfa8991147f"
|
||||
integrity sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw==
|
||||
"@types/node@14.14.7":
|
||||
version "14.14.7"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.7.tgz#8ea1e8f8eae2430cf440564b98c6dfce1ec5945d"
|
||||
integrity sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==
|
||||
|
||||
"@types/normalize-package-data@^2.4.0":
|
||||
version "2.4.0"
|
||||
@@ -580,61 +580,61 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.15.3.tgz#fb602cd4c2f0b7c0fb857e922075fdf677d25d84"
|
||||
integrity sha512-5oiXqR7kwDGZ6+gmzIO2lTC+QsriNuQXZDWNYRV3l2XRN/zmPgnC21DLSx2D05zvD8vnXW6qUg7JnXZ4I6qLVQ==
|
||||
|
||||
"@typescript-eslint/eslint-plugin@4.6.1":
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.6.1.tgz#99d77eb7a016fd5a5e749d2c44a7e4c317eb7da3"
|
||||
integrity sha512-SNZyflefTMK2JyrPfFFzzoy2asLmZvZJ6+/L5cIqg4HfKGiW2Gr1Go1OyEVqne/U4QwmoasuMwppoBHWBWF2nA==
|
||||
"@typescript-eslint/eslint-plugin@4.7.0":
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.7.0.tgz#85c9bbda00c0cb604d3c241f7bc7fb171a2d3479"
|
||||
integrity sha512-li9aiSVBBd7kU5VlQlT1AqP0uWGDK6JYKUQ9cVDnOg34VNnd9t4jr0Yqc/bKxJr/tDCPDaB4KzoSFN9fgVxe/Q==
|
||||
dependencies:
|
||||
"@typescript-eslint/experimental-utils" "4.6.1"
|
||||
"@typescript-eslint/scope-manager" "4.6.1"
|
||||
"@typescript-eslint/experimental-utils" "4.7.0"
|
||||
"@typescript-eslint/scope-manager" "4.7.0"
|
||||
debug "^4.1.1"
|
||||
functional-red-black-tree "^1.0.1"
|
||||
regexpp "^3.0.0"
|
||||
semver "^7.3.2"
|
||||
tsutils "^3.17.1"
|
||||
|
||||
"@typescript-eslint/experimental-utils@4.6.1":
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.6.1.tgz#a9c691dfd530a9570274fe68907c24c07a06c4aa"
|
||||
integrity sha512-qyPqCFWlHZXkEBoV56UxHSoXW2qnTr4JrWVXOh3soBP3q0o7p4pUEMfInDwIa0dB/ypdtm7gLOS0hg0a73ijfg==
|
||||
"@typescript-eslint/experimental-utils@4.7.0":
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.7.0.tgz#8d1058c38bec3d3bbd9c898a1c32318d80faf3c5"
|
||||
integrity sha512-cymzovXAiD4EF+YoHAB5Oh02MpnXjvyaOb+v+BdpY7lsJXZQN34oIETeUwVT2XfV9rSNpXaIcknDLfupO/tUoA==
|
||||
dependencies:
|
||||
"@types/json-schema" "^7.0.3"
|
||||
"@typescript-eslint/scope-manager" "4.6.1"
|
||||
"@typescript-eslint/types" "4.6.1"
|
||||
"@typescript-eslint/typescript-estree" "4.6.1"
|
||||
"@typescript-eslint/scope-manager" "4.7.0"
|
||||
"@typescript-eslint/types" "4.7.0"
|
||||
"@typescript-eslint/typescript-estree" "4.7.0"
|
||||
eslint-scope "^5.0.0"
|
||||
eslint-utils "^2.0.0"
|
||||
|
||||
"@typescript-eslint/parser@4.6.1":
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.6.1.tgz#b801bff67b536ecc4a840ac9289ba2be57e02428"
|
||||
integrity sha512-lScKRPt1wM9UwyKkGKyQDqf0bh6jm8DQ5iN37urRIXDm16GEv+HGEmum2Fc423xlk5NUOkOpfTnKZc/tqKZkDQ==
|
||||
"@typescript-eslint/parser@4.7.0":
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.7.0.tgz#44bdab0f788b478178368baa65d3365fdc63da1c"
|
||||
integrity sha512-+meGV8bMP1sJHBI2AFq1GeTwofcGiur8LoIr6v+rEmD9knyCqDlrQcFHR0KDDfldHIFDU/enZ53fla6ReF4wRw==
|
||||
dependencies:
|
||||
"@typescript-eslint/scope-manager" "4.6.1"
|
||||
"@typescript-eslint/types" "4.6.1"
|
||||
"@typescript-eslint/typescript-estree" "4.6.1"
|
||||
"@typescript-eslint/scope-manager" "4.7.0"
|
||||
"@typescript-eslint/types" "4.7.0"
|
||||
"@typescript-eslint/typescript-estree" "4.7.0"
|
||||
debug "^4.1.1"
|
||||
|
||||
"@typescript-eslint/scope-manager@4.6.1":
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.6.1.tgz#21872b91cbf7adfc7083f17b8041149148baf992"
|
||||
integrity sha512-f95+80r6VdINYscJY1KDUEDcxZ3prAWHulL4qRDfNVD0I5QAVSGqFkwHERDoLYJJWmEAkUMdQVvx7/c2Hp+Bjg==
|
||||
"@typescript-eslint/scope-manager@4.7.0":
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.7.0.tgz#2115526085fb72723ccdc1eeae75dec7126220ed"
|
||||
integrity sha512-ILITvqwDJYbcDCROj6+Ob0oCKNg3SH46iWcNcTIT9B5aiVssoTYkhKjxOMNzR1F7WSJkik4zmuqve5MdnA0DyA==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.6.1"
|
||||
"@typescript-eslint/visitor-keys" "4.6.1"
|
||||
"@typescript-eslint/types" "4.7.0"
|
||||
"@typescript-eslint/visitor-keys" "4.7.0"
|
||||
|
||||
"@typescript-eslint/types@4.6.1":
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.6.1.tgz#d3ad7478f53f22e7339dc006ab61aac131231552"
|
||||
integrity sha512-k2ZCHhJ96YZyPIsykickez+OMHkz06xppVLfJ+DY90i532/Cx2Z+HiRMH8YZQo7a4zVd/TwNBuRCdXlGK4yo8w==
|
||||
"@typescript-eslint/types@4.7.0":
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.7.0.tgz#5e95ef5c740f43d942542b35811f87b62fccca69"
|
||||
integrity sha512-uLszFe0wExJc+I7q0Z/+BnP7wao/kzX0hB5vJn4LIgrfrMLgnB2UXoReV19lkJQS1a1mHWGGODSxnBx6JQC3Sg==
|
||||
|
||||
"@typescript-eslint/typescript-estree@4.6.1":
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.6.1.tgz#6025cce724329413f57e4959b2d676fceeca246f"
|
||||
integrity sha512-/J/kxiyjQQKqEr5kuKLNQ1Finpfb8gf/NpbwqFFYEBjxOsZ621r9AqwS9UDRA1Rrr/eneX/YsbPAIhU2rFLjXQ==
|
||||
"@typescript-eslint/typescript-estree@4.7.0":
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.7.0.tgz#539531167f05ba20eb0b6785567076679e29d393"
|
||||
integrity sha512-5XZRQznD1MfUmxu1t8/j2Af4OxbA7EFU2rbo0No7meb46eHgGkSieFdfV6omiC/DGIBhH9H9gXn7okBbVOm8jw==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.6.1"
|
||||
"@typescript-eslint/visitor-keys" "4.6.1"
|
||||
"@typescript-eslint/types" "4.7.0"
|
||||
"@typescript-eslint/visitor-keys" "4.7.0"
|
||||
debug "^4.1.1"
|
||||
globby "^11.0.1"
|
||||
is-glob "^4.0.1"
|
||||
@@ -642,12 +642,12 @@
|
||||
semver "^7.3.2"
|
||||
tsutils "^3.17.1"
|
||||
|
||||
"@typescript-eslint/visitor-keys@4.6.1":
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.6.1.tgz#6b125883402d8939df7b54528d879e88f7ba3614"
|
||||
integrity sha512-owABze4toX7QXwOLT3/D5a8NecZEjEWU1srqxENTfqsY3bwVnl3YYbOh6s1rp2wQKO9RTHFGjKes08FgE7SVMw==
|
||||
"@typescript-eslint/visitor-keys@4.7.0":
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.7.0.tgz#6783824f22acfc49e754970ed21b88ac03b80e6f"
|
||||
integrity sha512-aDJDWuCRsf1lXOtignlfiPODkzSxxop7D0rZ91L6ZuMlcMCSh0YyK+gAfo5zN/ih6WxMwhoXgJWC3cWQdaKC+A==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.6.1"
|
||||
"@typescript-eslint/types" "4.7.0"
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
"@ungap/promise-all-settled@1.1.2":
|
||||
@@ -2187,10 +2187,10 @@ fork-ts-checker-notifier-webpack-plugin@3.0.0:
|
||||
dependencies:
|
||||
node-notifier "^6.0.0"
|
||||
|
||||
fork-ts-checker-webpack-plugin@6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.0.0.tgz#7166d972fb07ce4b6e954085e02159a82d030d62"
|
||||
integrity sha512-fa+ergrDxdy8d8fkCp14hy9slxrdXUnWwaHZEyM+k9qimq3RA+x3GncTz3oliTZrTshCTiFz8auPBedS19Tviw==
|
||||
fork-ts-checker-webpack-plugin@6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.0.1.tgz#77d73640c9275ebfee6b60e6571c6efb7256ee84"
|
||||
integrity sha512-G2uKf40W+a8/TzoCrGK+22ccTIzSBDFz7RquT5WaQ8kKw6TpplY9+THKp71h/3ne6BnXc7CXc2lcwj/nuHd8Vw==
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.8.3"
|
||||
"@types/json-schema" "^7.0.5"
|
||||
@@ -4311,10 +4311,10 @@ tough-cookie@~2.5.0:
|
||||
psl "^1.1.28"
|
||||
punycode "^2.1.1"
|
||||
|
||||
ts-loader@8.0.10:
|
||||
version "8.0.10"
|
||||
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.10.tgz#4af4afb8d26847290cd010df93a4c172df92278f"
|
||||
integrity sha512-5fVbbZldz6LQi6RQ0v1P7lZ98CZGlQyM8b4xGZXw3G/XUqL8GIH+Ib6H01nImPhkHZ9+PVXZgTb+v3fRsaIHlg==
|
||||
ts-loader@8.0.11:
|
||||
version "8.0.11"
|
||||
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.11.tgz#35d58a65932caacb120426eea59eca841786c899"
|
||||
integrity sha512-06X+mWA2JXoXJHYAesUUL4mHFYhnmyoCdQVMXofXF552Lzd4wNwSGg7unJpttqUP7ziaruM8d7u8LUB6I1sgzA==
|
||||
dependencies:
|
||||
chalk "^2.3.0"
|
||||
enhanced-resolve "^4.0.0"
|
||||
|
||||
Reference in New Issue
Block a user