浏览代码

Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/260

sanex3339 7 年之前
父节点
当前提交
833e832860

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@ Change Log
 v0.17.0
 ---
 * **Browser version**: Added browser version dist
+* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/260
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/252
 * Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/247
 

文件差异内容过多而无法显示
+ 0 - 0
dist/index.browser.js


文件差异内容过多而无法显示
+ 0 - 0
dist/index.cli.js


文件差异内容过多而无法显示
+ 0 - 0
dist/index.js


+ 8 - 8
package.json

@@ -21,7 +21,7 @@
   },
   "types": "index.d.ts",
   "dependencies": {
-    "@babel/runtime": "7.0.0-beta.46",
+    "@babel/runtime": "7.0.0-beta.47",
     "chalk": "2.4.1",
     "chance": "1.0.16",
     "class-validator": "0.8.5",
@@ -38,13 +38,13 @@
     "reflect-metadata": "0.1.12",
     "source-map-support": "0.5.6",
     "string-template": "1.0.0",
-    "tslib": "1.9.0"
+    "tslib": "1.9.1"
   },
   "devDependencies": {
-    "@babel/cli": "7.0.0-beta.46",
-    "@babel/core": "7.0.0-beta.46",
-    "@babel/plugin-transform-runtime": "7.0.0-beta.46",
-    "@babel/preset-env": "7.0.0-beta.46",
+    "@babel/cli": "7.0.0-beta.47",
+    "@babel/core": "7.0.0-beta.47",
+    "@babel/plugin-transform-runtime": "7.0.0-beta.47",
+    "@babel/preset-env": "7.0.0-beta.47",
     "@types/chai": "4.1.3",
     "@types/chance": "1.0.0",
     "@types/escodegen": "0.0.6",
@@ -54,7 +54,7 @@
     "@types/mkdirp": "0.5.2",
     "@types/mocha": "5.2.0",
     "@types/multimatch": "2.1.2",
-    "@types/node": "10.0.8",
+    "@types/node": "10.1.1",
     "@types/rimraf": "2.0.2",
     "@types/sinon": "4.3.3",
     "@types/string-template": "1.0.2",
@@ -72,7 +72,7 @@
     "threads": "0.11.0",
     "ts-node": "6.0.3",
     "tslint": "5.10.0",
-    "tslint-eslint-rules": "5.2.0",
+    "tslint-eslint-rules": "5.3.1",
     "tslint-language-service": "0.9.9",
     "tslint-microsoft-contrib": "5.0.3",
     "tslint-webpack-plugin": "1.2.2",

+ 0 - 2
src/templates/domain-lock-nodes/domain-lock-node/DomainLockNodeTemplate.ts

@@ -65,8 +65,6 @@ export function DomainLockNodeTemplate (): string {
                     if (currentDomain.length == domain.length || domain.indexOf(".") === 0) {
                         ok = true;
                     }
-                    
-                    break;
                 }
             }
                

+ 196 - 8
test/functional-tests/templates/domain-lock-nodes/DomainLockNodeTemplate.spec.ts

@@ -1,3 +1,5 @@
+import 'reflect-metadata';
+
 import format from 'string-template';
 
 import { assert } from 'chai';
@@ -76,9 +78,9 @@ describe('DomainLockNodeTemplate (): string', () => {
         });
     });
 
-    describe('Variant #2: urrent domain matches with base domain of `domainsString` item', () => {
-        const domainsString: string = ['www.test.com', '.example.com'].join(';');
-        const currentDomain: string = 'subdomain.example.com';
+    describe('Variant #2: current domain matches with base domain of `domainsString`', () => {
+        const domainsString: string = ['.example.com'].join(';');
+        const currentDomain: string = 'www.example.com';
 
         let testFunc: () => void;
 
@@ -102,9 +104,115 @@ describe('DomainLockNodeTemplate (): string', () => {
         });
     });
 
-    describe('Variant #3: current domain doesn\'t match with `domainsString`', () => {
-        const domainsString: string = ['www.example.com'].join(';');
-        const currentDomain: string = 'www.test.com';
+    describe('Variant #3: current domain matches with all domains of `domainsString`', () => {
+        describe('Variant #1', () => {
+            const domainsString: string = ['example.com', '.example.com'].join(';');
+            const currentDomain: string = 'example.com';
+
+            let testFunc: () => void;
+
+            before(() => {
+                const [
+                    hiddenDomainsString,
+                    diff
+                ] = cryptUtils.hideString(domainsString, domainsString.length * 3);
+
+                testFunc = () => getFunctionFromTemplate({
+                    domainLockFunctionName: 'domainLockFunction',
+                    diff: diff,
+                    domains: hiddenDomainsString,
+                    globalVariableTemplate: GlobalVariableTemplate1(),
+                    singleNodeCallControllerFunctionName
+                }, singleNodeCallControllerFunctionName, currentDomain);
+            });
+
+            it('should correctly run code inside template', () => {
+                assert.doesNotThrow(testFunc);
+            });
+        });
+
+        describe('Variant #2', () => {
+            const domainsString: string = ['example.com', '.example.com'].join(';');
+            const currentDomain: string = 'subdomain.example.com';
+
+            let testFunc: () => void;
+
+            before(() => {
+                const [
+                    hiddenDomainsString,
+                    diff
+                ] = cryptUtils.hideString(domainsString, domainsString.length * 3);
+
+                testFunc = () => getFunctionFromTemplate({
+                    domainLockFunctionName: 'domainLockFunction',
+                    diff: diff,
+                    domains: hiddenDomainsString,
+                    globalVariableTemplate: GlobalVariableTemplate1(),
+                    singleNodeCallControllerFunctionName
+                }, singleNodeCallControllerFunctionName, currentDomain);
+            });
+
+            it('should correctly run code inside template', () => {
+                assert.doesNotThrow(testFunc);
+            });
+        });
+
+        describe('Variant #3', () => {
+            const domainsString: string = ['.example.com', 'example.com'].join(';');
+            const currentDomain: string = 'subdomain.example.com';
+
+            let testFunc: () => void;
+
+            before(() => {
+                const [
+                    hiddenDomainsString,
+                    diff
+                ] = cryptUtils.hideString(domainsString, domainsString.length * 3);
+
+                testFunc = () => getFunctionFromTemplate({
+                    domainLockFunctionName: 'domainLockFunction',
+                    diff: diff,
+                    domains: hiddenDomainsString,
+                    globalVariableTemplate: GlobalVariableTemplate1(),
+                    singleNodeCallControllerFunctionName
+                }, singleNodeCallControllerFunctionName, currentDomain);
+            });
+
+            it('should correctly run code inside template', () => {
+                assert.doesNotThrow(testFunc);
+            });
+        });
+
+        describe('Variant #4', () => {
+            const domainsString: string = ['sub1.example.com', 'sub2.example.com'].join(';');
+            const currentDomain: string = 'sub1.example.com';
+
+            let testFunc: () => void;
+
+            before(() => {
+                const [
+                    hiddenDomainsString,
+                    diff
+                ] = cryptUtils.hideString(domainsString, domainsString.length * 3);
+
+                testFunc = () => getFunctionFromTemplate({
+                    domainLockFunctionName: 'domainLockFunction',
+                    diff: diff,
+                    domains: hiddenDomainsString,
+                    globalVariableTemplate: GlobalVariableTemplate1(),
+                    singleNodeCallControllerFunctionName
+                }, singleNodeCallControllerFunctionName, currentDomain);
+            });
+
+            it('should correctly run code inside template', () => {
+                assert.doesNotThrow(testFunc);
+            });
+        });
+    });
+
+    describe('Variant #4: current domain matches with base domain of `domainsString` item', () => {
+        const domainsString: string = ['www.test.com', '.example.com'].join(';');
+        const currentDomain: string = 'subdomain.example.com';
 
         let testFunc: () => void;
 
@@ -123,8 +231,88 @@ describe('DomainLockNodeTemplate (): string', () => {
             }, singleNodeCallControllerFunctionName, currentDomain);
         });
 
-        it('should throw an error', () => {
-            assert.throws(testFunc);
+        it('should correctly run code inside template', () => {
+            assert.doesNotThrow(testFunc);
+        });
+    });
+
+    describe('Variant #5: current domain doesn\'t match with `domainsString`', () => {
+        describe('Variant #1', () => {
+            const domainsString: string = ['www.example.com'].join(';');
+            const currentDomain: string = 'www.test.com';
+
+            let testFunc: () => void;
+
+            before(() => {
+                const [
+                    hiddenDomainsString,
+                    diff
+                ] = cryptUtils.hideString(domainsString, domainsString.length * 3);
+
+                testFunc = () => getFunctionFromTemplate({
+                    domainLockFunctionName: 'domainLockFunction',
+                    diff: diff,
+                    domains: hiddenDomainsString,
+                    globalVariableTemplate: GlobalVariableTemplate1(),
+                    singleNodeCallControllerFunctionName
+                }, singleNodeCallControllerFunctionName, currentDomain);
+            });
+
+            it('should throw an error', () => {
+                assert.throws(testFunc);
+            });
+        });
+
+        describe('Variant #2', () => {
+            const domainsString: string = ['sub1.test.com', 'sub2.test.com'].join(';');
+            const currentDomain: string = 'sub3.test.com';
+
+            let testFunc: () => void;
+
+            before(() => {
+                const [
+                    hiddenDomainsString,
+                    diff
+                ] = cryptUtils.hideString(domainsString, domainsString.length * 3);
+
+                testFunc = () => getFunctionFromTemplate({
+                    domainLockFunctionName: 'domainLockFunction',
+                    diff: diff,
+                    domains: hiddenDomainsString,
+                    globalVariableTemplate: GlobalVariableTemplate1(),
+                    singleNodeCallControllerFunctionName
+                }, singleNodeCallControllerFunctionName, currentDomain);
+            });
+
+            it('should throw an error', () => {
+                assert.throws(testFunc);
+            });
+        });
+
+        describe('Variant #3', () => {
+            const domainsString: string = ['www.example.com', '.example.com', 'sub.test.com'].join(';');
+            const currentDomain: string = 'www.test.com';
+
+            let testFunc: () => void;
+
+            before(() => {
+                const [
+                    hiddenDomainsString,
+                    diff
+                ] = cryptUtils.hideString(domainsString, domainsString.length * 3);
+
+                testFunc = () => getFunctionFromTemplate({
+                    domainLockFunctionName: 'domainLockFunction',
+                    diff: diff,
+                    domains: hiddenDomainsString,
+                    globalVariableTemplate: GlobalVariableTemplate1(),
+                    singleNodeCallControllerFunctionName
+                }, singleNodeCallControllerFunctionName, currentDomain);
+            });
+
+            it('should throw an error', () => {
+                assert.throws(testFunc);
+            });
         });
     });
 });

文件差异内容过多而无法显示
+ 385 - 403
yarn.lock


部分文件因为文件数量过多而无法显示