Ver código fonte

Merge pull request #467 from javascript-obfuscator/dependencies-update-01.01.2020

Dependencies update #1
Timofey Kachalov 5 anos atrás
pai
commit
f14077c8e8

+ 1 - 0
.gitignore

@@ -1,6 +1,7 @@
 .awcache
 .DS_Store
 .idea
+.nyc_output
 npm-debug.log
 *.js.map
 /coverage

+ 1 - 0
.npmignore

@@ -1,6 +1,7 @@
 .awcache
 .github
 .idea
+.nyc_output
 coverage
 images
 test/fixtures/compile-performance.js

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
dist/index.browser.js


+ 14 - 16
package.json

@@ -21,12 +21,13 @@
   },
   "types": "index.d.ts",
   "dependencies": {
+    "@nuxtjs/opencollective": "0.2.2",
     "chalk": "3.0.0",
-    "chance": "1.1.3",
+    "chance": "1.1.4",
     "class-validator": "0.11.0",
     "commander": "4.0.1",
     "escodegen-wallaby": "1.6.27",
-    "espree": "^6.1.2",
+    "espree": "6.1.2",
     "estraverse": "4.3.0",
     "eventemitter3": "4.0.0",
     "inversify": "5.0.1",
@@ -34,15 +35,14 @@
     "md5": "2.2.1",
     "mkdirp": "0.5.1",
     "multimatch": "4.0.0",
-    "opencollective": "1.0.3",
     "reflect-metadata": "0.1.13",
     "source-map-support": "0.5.16",
     "string-template": "1.0.0",
     "tslib": "1.10.0"
   },
   "devDependencies": {
-    "@types/chai": "4.2.5",
-    "@types/chance": "1.0.7",
+    "@types/chai": "4.2.7",
+    "@types/chance": "1.0.8",
     "@types/escodegen": "0.0.6",
     "@types/estraverse": "0.0.6",
     "@types/estree": "0.0.38",
@@ -58,21 +58,21 @@
     "awesome-typescript-loader": "5.2.1",
     "chai": "4.2.0",
     "coveralls": "3.0.9",
-    "istanbul": "1.1.0-alpha.1",
     "mocha": "6.2.2",
+    "nyc": "15.0.0",
     "pjson": "1.0.9",
     "pre-commit": "1.2.2",
     "rimraf": "3.0.0",
     "sinon": "7.5.0",
-    "threads": "0.12.0",
+    "threads": "1.0.0",
     "ts-node": "6.1.0",
-    "tslint": "5.11.0",
-    "tslint-eslint-rules": "5.3.1",
+    "tslint": "5.20.1",
+    "tslint-eslint-rules": "5.4.0",
     "tslint-language-service": "0.9.9",
-    "tslint-microsoft-contrib": "5.2.0",
+    "tslint-microsoft-contrib": "6.2.0",
     "tslint-webpack-plugin": "1.2.2",
-    "typescript": "3.7.2",
-    "webpack": "4.41.2",
+    "typescript": "3.7.4",
+    "webpack": "4.41.5",
     "webpack-cli": "3.3.10",
     "webpack-node-externals": "1.7.2"
   },
@@ -99,7 +99,7 @@
     "tslint": "scripts/tslint",
     "travis": "scripts/travis",
     "git:addFiles": "scripts/git-add-files",
-    "postinstall": "opencollective postinstall"
+    "postinstall": "opencollective || exit 0"
   },
   "pre-commit": [
     "build",
@@ -114,8 +114,6 @@
   ],
   "license": "BSD-2-Clause",
   "collective": {
-    "type": "opencollective",
-    "url": "https://opencollective.com/javascript-obfuscator",
-    "logo": "https://opencollective.com/opencollective/logo.txt"
+    "url": "https://opencollective.com/javascript-obfuscator"
   }
 }

+ 2 - 2
scripts/test-coveralls

@@ -2,6 +2,6 @@
 
 yarn run test:removeTmpDir &&
 yarn run test:compile &&
-$(yarn bin)/istanbul cover $(yarn bin)/_mocha -- test-tmp/test/index.spec.js --report lcovonly &&
-cat ./coverage/lcov.info | $(yarn bin)/coveralls &&
+$(yarn bin)/nyc $(yarn bin)/mocha -- test-tmp/test/index.spec.js --exit &&
+$(yarn bin)/nyc report --reporter=text-lcov | $(yarn bin)/coveralls &&
 yarn run test:removeTmpDir

+ 1 - 1
scripts/test-full

@@ -3,5 +3,5 @@
 yarn run test:removeTmpDir &&
 yarn run test:compile &&
 node test-tmp/test/dev/dev.js &&
-$(yarn bin)/istanbul cover $(yarn bin)/_mocha -- test-tmp/test/index.spec.js &&
+$(yarn bin)/nyc --reporter text-summary $(yarn bin)/mocha -- test-tmp/test/index.spec.js --exit &&
 yarn run test:removeTmpDir

+ 0 - 15
src/declarations/threads.d.ts

@@ -1,15 +0,0 @@
-declare module 'threads' {
-    type PostMessage <U> = (data: U) => void;
-    type SpawnCallback <T, U> = (data: T, postMessage: PostMessage <U>) => void;
-    type ResponseCallback <U> = (response: U) => void;
-
-    class Thread <T, U> {
-        public killed: boolean;
-
-        public send (data: T): Thread <T, U>;
-        public on (eventType: string, responseCallback: ResponseCallback<U>): Thread <T, U>;
-        public kill (): void;
-    }
-
-    export function spawn <T, U> (spawnCallback: SpawnCallback <T, U>): Thread <T, U>;
-}

+ 1 - 2
test/declarations/index.d.ts

@@ -2,5 +2,4 @@
 /// <reference path="../../src/declarations/escodegen-wallaby.d.ts" />
 /// <reference path="../../src/declarations/espree.d.ts" />
 /// <reference path="../../src/declarations/ESTree.d.ts" />
-/// <reference path="../../src/declarations/js-string-escape.d.ts" />
-/// <reference path="../../src/declarations/threads.d.ts" />
+/// <reference path="../../src/declarations/js-string-escape.d.ts" />

+ 3 - 1
test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts

@@ -667,7 +667,9 @@ describe('JavaScriptObfuscator', () => {
             });
         });
 
-        describe('Identifier names collision between base code and appended string array nodes', () => {
+        describe('Identifier names collision between base code and appended string array nodes', function () {
+            this.timeout(10000);
+
             const samplesCount: number = 30;
 
             let areCollisionsExists: boolean = false;

+ 20 - 20
test/functional-tests/templates/debug-protection-nodes/DebugProtectionFunctionCallTemplate.spec.ts

@@ -1,5 +1,5 @@
 import { assert } from 'chai';
-import { spawn } from 'threads';
+import { spawn, Thread, Worker } from 'threads/dist';
 
 import { readFileAsString } from '../../../helpers/readFileAsString';
 
@@ -10,26 +10,26 @@ import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
 
 import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
 
-function spawnThread(inputCallback: Function, threadCallback: Function, timeoutCallback: Function): void {
-    const thread = spawn<string, number>((input: string, postMessage: Function) => {
-        postMessage(eval(input));
-    });
+
+
+async function spawnThread(obfuscatedCode: string, threadCallback: Function, timeoutCallback: Function): Promise<void> {
+    const evaluationWorker = await spawn(new Worker('./workers/evaluation-worker'));
 
     const timeout = setTimeout(() => {
-        thread.kill();
+        Thread.terminate(evaluationWorker);
         timeoutCallback();
     }, 1500);
 
-    thread
-        .send(inputCallback())
-        .on('message', (response: number) => {
-            clearTimeout(timeout);
-            thread.kill();
-            threadCallback(response);
-        });
+    const result: string = await evaluationWorker.evaluate(obfuscatedCode);
+
+    clearTimeout(timeout);
+    Thread.terminate(evaluationWorker);
+    threadCallback(result);
 }
 
-describe('DebugProtectionFunctionCallTemplate', () => {
+describe('DebugProtectionFunctionCallTemplate', function () {
+    this.timeout(5000);
+
     describe('Variant #1: correctly obfuscate code with `HexadecimalIdentifierNamesGenerator``', () => {
         const expectedEvaluationResult: number = 1;
 
@@ -49,7 +49,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
             ).getObfuscatedCode();
 
             spawnThread(
-                () => obfuscatedCode,
+                obfuscatedCode,
                 (response: number) => {
                     evaluationResult = response;
                     done();
@@ -84,7 +84,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
             ).getObfuscatedCode();
 
             spawnThread(
-                () => obfuscatedCode,
+                obfuscatedCode,
                 (response: number) => {
                     evaluationResult = response;
                     done();
@@ -120,7 +120,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
             ).getObfuscatedCode();
 
             spawnThread(
-                () => obfuscatedCode,
+                obfuscatedCode,
                 (response: number) => {
                     evaluationResult = response;
                     done();
@@ -155,7 +155,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
             ).getObfuscatedCode();
 
             spawnThread(
-                () => obfuscatedCode,
+                obfuscatedCode,
                 (response: number) => {
                     evaluationResult = response;
                     done();
@@ -190,7 +190,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
             obfuscatedCode = obfuscatedCode.replace(/\+\+ *_0x([a-f0-9]){4,6}/, '');
 
             spawnThread(
-                () => obfuscatedCode,
+                obfuscatedCode,
                 (response: number) => {
                     evaluationResult = response;
                     done();
@@ -224,7 +224,7 @@ describe('DebugProtectionFunctionCallTemplate', () => {
             ).getObfuscatedCode();
 
             spawnThread(
-                () => obfuscatedCode,
+                obfuscatedCode,
                 (response: number) => {
                     evaluationResult = response;
                     done();

+ 7 - 0
test/functional-tests/templates/debug-protection-nodes/workers/evaluation-worker.js

@@ -0,0 +1,7 @@
+const expose = require('threads/worker').expose;
+
+expose({
+    evaluate: (obfuscatedCode) => {
+        return eval(obfuscatedCode);
+    }
+});

+ 6 - 2
tslint.json

@@ -43,6 +43,9 @@
       "static-method-regex": "^[a-z][\\w\\d]+$",
       "function-regex": "^[a-zA-Z][\\w\\d]+$"
     }],
+    "no-function-constructor-with-string-args": false,
+    "no-use-before-declare": false,
+    "no-unnecessary-bind": false,
     "indent": [
       true,
       "spaces"
@@ -140,11 +143,11 @@
     "no-unsafe-any": false,
     "no-unsafe-finally": true,
     "no-unused-expression": true,
-    "no-use-before-declare": true,
     "no-useless-files": true,
     "no-var-keyword": true,
     "no-var-requires": true,
     "non-literal-require": false,
+    "non-literal-fs-path": false,
     "max-file-line-count": [true, 500],
     "object-curly-spacing": [true, "always"],
     "object-literal-sort-keys": false,
@@ -162,7 +165,7 @@
       true,
       {
         "import-sources-order": "any",
-        "grouped-imports": true,
+        "grouped-imports": false,
         "named-imports-order": "case-insensitive"
       }
     ],
@@ -233,6 +236,7 @@
       }
     ],
     "unified-signatures": true,
+    "unnecessary-bind": true,
     "use-isnan": true,
     "valid-jsdoc": [false, {
       "requireReturn": false,

Diferenças do arquivo suprimidas por serem muito extensas
+ 400 - 336
yarn.lock


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff