Fixed isIncrementedMangledName algorithm

This commit is contained in:
sanex
2020-09-19 21:49:28 +03:00
parent ae52c1dab7
commit 77ff574e67
11 changed files with 314 additions and 157 deletions
@@ -869,6 +869,52 @@ describe('JavaScriptObfuscator', () => {
});
});
describe('Eval `Hello World`', function () {
this.timeout(20000);
const samplesCount: number = 100;
const expectedEvaluationResult: string = 'aaabbbcccdddeee';
let isEvaluationSuccessful: boolean = true;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/eval-hello-world.js');
for (let i = 0; i < samplesCount; i++) {
const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
compact: false,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
deadCodeInjection: true,
deadCodeInjectionThreshold: 1,
disableConsoleOutput: true,
identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
renameProperties: true,
simplify: false,
stringArray: true,
stringArrayThreshold: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersCount: 1,
stringArrayWrappersType: StringArrayWrappersType.Variable
}
).getObfuscatedCode();
const evaluationResult: string = eval(obfuscatedCode);
if (evaluationResult !== expectedEvaluationResult) {
isEvaluationSuccessful = false;
break;
}
}
});
it('should correctly evaluate obfuscated code', () => {
assert.equal(isEvaluationSuccessful, true);
});
});
describe('Identifier names collision between base code and appended string array nodes', function () {
this.timeout(10000);