diff --git a/dist/index.js b/dist/index.js index 6b08a5bb..5070cf29 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1673,7 +1673,7 @@ var JavaScriptObfuscatorCLI = function () { return val.split(','); }).option('--reservedNames ', 'Disable obfuscation of variable names, function names and names of function parameters that match the passed RegExp patterns (comma separated)', function (val) { return val.split(','); - }).option('--rotateUnicodeArray ', 'Disable rotation of unicode array values during obfuscation', JavaScriptObfuscatorCLI.parseBoolean).option('--selfDefending ', 'Disables self-defending for obfuscated code', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMap ', 'Enables source map generation', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMapBaseUrl ', 'Sets base url to the source map import url when `--sourceMapMode=separate`').option('--sourceMapFileName ', 'Sets file name for output source map when `--sourceMapMode=separate`').option('--sourceMapMode [inline, separate]', 'Specify source map output mode', JavaScriptObfuscatorCLI.parseSourceMapMode).option('--unicodeArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean).option('--unicodeArrayEncoding [base64, rc4]', 'All literals in Unicode array become encoded in using base64 or rc4 (this option can slightly slow down your code speed', JavaScriptObfuscatorCLI.parseUnicodeArrayEncoding).option('--unicodeArrayThreshold ', 'The probability that the literal string will be inserted into unicodeArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).parse(this.rawArguments); + }).option('--rotateUnicodeArray ', 'Disable rotation of unicode array values during obfuscation', JavaScriptObfuscatorCLI.parseBoolean).option('--selfDefending ', 'Disables self-defending for obfuscated code', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMap ', 'Enables source map generation', JavaScriptObfuscatorCLI.parseBoolean).option('--sourceMapBaseUrl ', 'Sets base url to the source map import url when `--sourceMapMode=separate`').option('--sourceMapFileName ', 'Sets file name for output source map when `--sourceMapMode=separate`').option('--sourceMapMode [inline, separate]', 'Specify source map output mode', JavaScriptObfuscatorCLI.parseSourceMapMode).option('--unicodeArray ', 'Disables gathering of all literal strings into an array and replacing every literal string with an array call', JavaScriptObfuscatorCLI.parseBoolean).option('--unicodeArrayEncoding [true, false, base64, rc4]', 'All literals in Unicode array become encoded in using base64 or rc4 (this option can slightly slow down your code speed', JavaScriptObfuscatorCLI.parseUnicodeArrayEncoding).option('--unicodeArrayThreshold ', 'The probability that the literal string will be inserted into unicodeArray (Default: 0.8, Min: 0, Max: 1)', parseFloat).parse(this.rawArguments); this.commands.on('--help', function () { console.log(' Examples:\n'); console.log(' %> javascript-obfuscator in.js --compact true --selfDefending false'); @@ -3610,7 +3610,7 @@ var StackTraceAnalyzer = function () { }(); StackTraceAnalyzer.limitThresholdActivationLength = 25; -StackTraceAnalyzer.limitThreshold = 0.1; +StackTraceAnalyzer.limitThreshold = 0.002; exports.StackTraceAnalyzer = StackTraceAnalyzer; /***/ }, diff --git a/src/stack-trace-analyzer/StackTraceAnalyzer.ts b/src/stack-trace-analyzer/StackTraceAnalyzer.ts index 38a44401..e80d91ad 100644 --- a/src/stack-trace-analyzer/StackTraceAnalyzer.ts +++ b/src/stack-trace-analyzer/StackTraceAnalyzer.ts @@ -56,7 +56,7 @@ export class StackTraceAnalyzer implements IStackTraceAnalyzer { /** * @type {number} */ - private static limitThreshold: number = 0.1; + private static limitThreshold: number = 0.002; /** * @type {ESTree.Node[]} diff --git a/test/dev/dev-runtime-performance.ts b/test/dev/dev-runtime-performance.ts index b3f64d55..9e903b71 100644 --- a/test/dev/dev-runtime-performance.ts +++ b/test/dev/dev-runtime-performance.ts @@ -70,7 +70,7 @@ if (!(global)._babelPolyfill) { } catch (error) { console.log(error); } - `).repeat(200)} + `).repeat(1000)} console.log = log; console.log(new Date() - start); diff --git a/test/unit-tests/stack-trace-analyzer/StackTraceAnalyzer.spec.ts b/test/unit-tests/stack-trace-analyzer/StackTraceAnalyzer.spec.ts index 853e57db..0ef09d63 100644 --- a/test/unit-tests/stack-trace-analyzer/StackTraceAnalyzer.spec.ts +++ b/test/unit-tests/stack-trace-analyzer/StackTraceAnalyzer.spec.ts @@ -7,17 +7,15 @@ const assert: any = chai.assert; describe('StackTraceAnalyzer', () => { describe('getLimitIndex (blockScopeBodyLength: number): number', () => { it('should returns correct limit index based on block scope body length', () => { - const blockScopeBodyLength1: number = 100; - const blockScopeBodyLength2: number = 22; - const blockScopeBodyLength3: number = 26; - const blockScopeBodyLength4: number = 28; - const blockScopeBodyLength5: number = 34; + const blockScopeBodyLength1: number = 10000; + const blockScopeBodyLength2: number = 1000; + const blockScopeBodyLength3: number = 25; + const blockScopeBodyLength4: number = 5; - assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength1), 34); - assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength2), 21); - assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength3), 25); - assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength4), 27); - assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength5), 27); + assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength1), 44); + assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength2), 26); + assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength3), 24); + assert.equal(StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength4), 4); }); }); });