Bläddra i källkod

Sync with master branch

sanex3339 5 år sedan
förälder
incheckning
2b6e65af6a

+ 9 - 1
CHANGELOG.md

@@ -5,10 +5,18 @@ v0.24.0
 * **Internal refactoring:** completely new mechanism to rename variable names
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/496
 
+v0.23.2
+---
+* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/475
+* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/326
+
+v0.23.1
+---
+* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/498
+
 v0.23.0
 ---
 * **New option:** `shuffleStringArray` randomly shuffles string array items
-* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/498
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/494
 * **Internal change:** switched AST parser from `espree` on `acorn`
 * **Internal refactoring:** refactoring of string array storage and related things

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
dist/index.browser.js


+ 3 - 3
package.json

@@ -28,8 +28,8 @@
     "chance": "1.1.4",
     "class-validator": "0.11.0",
     "commander": "4.1.0",
-    "escodegen": "1.12.1",
-    "eslint-scope": "^5.0.0",
+    "escodegen": "1.13.0",
+    "eslint-scope": "5.0.0",
     "estraverse": "4.3.0",
     "eventemitter3": "4.0.0",
     "inversify": "5.0.1",
@@ -46,7 +46,7 @@
     "@types/chai": "4.2.7",
     "@types/chance": "1.0.8",
     "@types/escodegen": "0.0.6",
-    "@types/eslint-scope": "^3.7.0",
+    "@types/eslint-scope": "3.7.0",
     "@types/estraverse": "0.0.6",
     "@types/estree": "0.0.42",
     "@types/md5": "2.1.33",

+ 29 - 5
test/functional-tests/node-transformers/obfuscating-transformers/scope-identifiers-transformer/catch-clause/CatchClause.spec.ts

@@ -10,7 +10,7 @@ import { JavaScriptObfuscator } from '../../../../../../src/JavaScriptObfuscator
 describe('ScopeIdentifiersTransformer CatchClause identifiers', () => {
     let obfuscatedCode: string;
 
-    describe('transform identifiers', () => {
+    describe('Variant #1: base transform of catch clause parameter', () => {
         const paramNameRegExp: RegExp = /catch *\((_0x([a-f0-9]){4,6})\) *\{/;
         const bodyParamNameRegExp: RegExp = /console\['log'\]\((_0x([a-f0-9]){4,6})\);/;
 
@@ -43,7 +43,7 @@ describe('ScopeIdentifiersTransformer CatchClause identifiers', () => {
         });
     });
 
-    describe('object pattern as parameter', () => {
+    describe('Variant #2: object pattern as parameter', () => {
         const functionParameterMatch: RegExp = /\} *catch *\(\{ *name *\}\) *\{/;
         const functionBodyMatch: RegExp = /return *name;/;
 
@@ -67,8 +67,32 @@ describe('ScopeIdentifiersTransformer CatchClause identifiers', () => {
         });
     });
 
-    describe('Global variable scope', () => {
-        describe('`renameGlobals` is disabled', () => {
+    describe('Variant #3: optional catch binding support', () => {
+        const optionalCatchClauseRegExp: RegExp = /} *catch *\{/;
+        const bodyParamNameRegExp: RegExp = /console\['log'\]\(0x1\);/;
+
+        before(() => {
+            const code: string = readFileAsString(__dirname + '/fixtures/optional-catch-binding.js');
+
+            obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                code,
+                {
+                    ...NO_ADDITIONAL_NODES_PRESET
+                }
+            ).getObfuscatedCode();
+        });
+
+        it('match #1: should transform catch clause node', () => {
+            assert.match(obfuscatedCode, optionalCatchClauseRegExp);
+        });
+
+        it('match #2: should transform catch clause node', () => {
+            assert.match(obfuscatedCode, bodyParamNameRegExp);
+        });
+    });
+
+    describe('Variant #4: global variable scope', () => {
+        describe('Variant #1: `renameGlobals` is disabled', () => {
             const globalVariableRegExp: RegExp = /var test *= *0x1;/;
 
             before(() => {
@@ -87,7 +111,7 @@ describe('ScopeIdentifiersTransformer CatchClause identifiers', () => {
             });
         });
 
-        describe('`renameGlobals` is enabled', () => {
+        describe('Variant #2: `renameGlobals` is enabled', () => {
             const globalVariableRegExp: RegExp = /var _0x([a-f0-9]){4,6} *= *0x1;/;
 
             before(() => {

+ 5 - 0
test/functional-tests/node-transformers/obfuscating-transformers/scope-identifiers-transformer/catch-clause/fixtures/optional-catch-binding.js

@@ -0,0 +1,5 @@
+try {
+
+} catch {
+    console.log(1);
+}

+ 21 - 0
test/functional-tests/node-transformers/obfuscating-transformers/scope-identifiers-transformer/class-declaration/ClassDeclaration.spec.ts

@@ -222,5 +222,26 @@ describe('ScopeIdentifiersTransformer ClassDeclaration identifiers', () => {
                 assert.match(obfuscatedCode, defaultExportRegExp);
             });
         });
+
+        describe('Variant #8: super class expression parenthesis', () => {
+            const defaultExportRegExp: RegExp = /class Baz extends *\(Foo *\|| *Bar\) *{}/;
+
+            let obfuscatedCode: string;
+
+            before(() => {
+                const code: string = readFileAsString(__dirname + '/fixtures/super-class-expression-parenthesis.js');
+
+                obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                    code,
+                    {
+                        ...NO_ADDITIONAL_NODES_PRESET
+                    }
+                ).getObfuscatedCode();
+            });
+
+            it('Match #1: should keep super class expression parenthesis', () => {
+                assert.match(obfuscatedCode, defaultExportRegExp);
+            });
+        });
     });
 });

+ 4 - 0
test/functional-tests/node-transformers/obfuscating-transformers/scope-identifiers-transformer/class-declaration/fixtures/super-class-expression-parenthesis.js

@@ -0,0 +1,4 @@
+class Foo {}
+class Bar {}
+class Baz extends (Foo || Bar) {}
+

+ 14 - 19
yarn.lock

@@ -1598,30 +1598,30 @@ [email protected], escape-string-regexp@^1.0.5:
   resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
   integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
 
[email protected]2.1:
-  version "1.12.1"
-  resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.12.1.tgz#08770602a74ac34c7a90ca9229e7d51e379abc76"
-  integrity sha512-Q8t2YZ+0e0pc7NRVj3B4tSQ9rim1oi4Fh46k2xhJ2qOiEwhQfdjyEQddWdj7ZFaKmU+5104vn1qrcjEPWq+bgQ==
[email protected]3.0:
+  version "1.13.0"
+  resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.13.0.tgz#c7adf9bd3f3cc675bb752f202f79a720189cab29"
+  integrity sha512-eYk2dCkxR07DsHA/X2hRBj0CFAZeri/LyDMc0C8JT1Hqi6JnVpMhJ7XFITbb0+yZS3lVkaPL2oCkZ3AVmeVbMw==
   dependencies:
-    esprima "^3.1.3"
+    esprima "^4.0.1"
     estraverse "^4.2.0"
     esutils "^2.0.2"
     optionator "^0.8.1"
   optionalDependencies:
     source-map "~0.6.1"
 
-eslint-scope@^4.0.3:
-  version "4.0.3"
-  resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
-  integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==
+eslint-scope@5.0.0:
+  version "5.0.0"
+  resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9"
+  integrity sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==
   dependencies:
     esrecurse "^4.1.0"
     estraverse "^4.1.1"
 
-eslint-scope@^5.0.0:
-  version "5.0.0"
-  resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9"
-  integrity sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==
+eslint-scope@^4.0.3:
+  version "4.0.3"
+  resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
+  integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==
   dependencies:
     esrecurse "^4.1.0"
     estraverse "^4.1.1"
@@ -1631,12 +1631,7 @@ esm@^3.2.25:
   resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10"
   integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
 
-esprima@^3.1.3:
-  version "3.1.3"
-  resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
-  integrity sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=
-
-esprima@^4.0.0:
+esprima@^4.0.0, esprima@^4.0.1:
   version "4.0.1"
   resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
   integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==

Vissa filer visades inte eftersom för många filer har ändrats