New option: stringArrayIntermediateCalls sets the passed amount of intermediate variables for the string array

This commit is contained in:
sanex
2020-09-07 10:05:31 +03:00
parent 48eccacd5c
commit 1b656d7386
34 changed files with 351 additions and 59 deletions
@@ -53,6 +53,37 @@ describe('StringArrayCallsWrapperCodeHelper', () => {
});
});
describe('`stringArrayIntermediateCalls` option is set', () => {
const stringArrayCallRegExp: RegExp = new RegExp(
'return _0x([a-f0-9]){4,6};' +
'};' +
'var _0x([a-f0-9]){4} *= *_0x([a-f0-9]){4};' +
'var _0x([a-f0-9]){4} *= *_0x([a-f0-9]){4};' +
'var _0x([a-f0-9]){4} *= *_0x([a-f0-9]){4};' +
'var test *= *_0x([a-f0-9]){4}\\(\'0x0\'\\);'
);
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
stringArray: true,
stringArrayThreshold: 1,
stringArrayIntermediateCalls: 3
}
).getObfuscatedCode();
});
it('should correctly append `StringArrayCallsWrapperIntermediateTemplate` template into the obfuscated code', () => {
assert.match(obfuscatedCode, stringArrayCallRegExp);
});
});
describe('Preserve string array name', () => {
const callsWrapperRegExp: RegExp = new RegExp(`` +
`var b *= *function *\\(c, *d\\) *{ *` +