mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed incorrect rename of the identifiers of the added helpers in some rare cases
Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/804
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user