mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed stringArrayWrappersCount behaviour with arrow function scope without statements
This commit is contained in:
+63
-3
@@ -198,7 +198,67 @@ describe('StringArrayTransformer', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #3: prevailing kind of variables', () => {
|
||||
describe('Variant #3: prohibited scopes', () => {
|
||||
describe('Variant #1: if statement scope', () => {
|
||||
const stringArrayCallRegExp: RegExp = new RegExp(
|
||||
'var c *= *b;' +
|
||||
'if *\\(!!\\[]\\) *{' +
|
||||
'var foo *= *c\\(\'0x0\'\\);' +
|
||||
'}'
|
||||
);
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/string-array-wrappers-count-prohibited-scope-1.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 1,
|
||||
stringArrayWrappersCount: 1
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not add scope calls wrappers to a prohibited scope', () => {
|
||||
assert.match(obfuscatedCode, stringArrayCallRegExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: arrow function scope without statements', () => {
|
||||
const stringArrayCallRegExp: RegExp = new RegExp(
|
||||
'var c *= *b;' +
|
||||
'\\[]\\[c\\(\'0x0\'\\)]\\(\\(\\) *=> *c\\(\'0x1\'\\)\\);'
|
||||
);
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/string-array-wrappers-count-prohibited-scope-2.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 1,
|
||||
stringArrayWrappersCount: 1
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not add scope calls wrappers to a prohibited scope', () => {
|
||||
assert.match(obfuscatedCode, stringArrayCallRegExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #4: prevailing kind of variables', () => {
|
||||
const stringArrayCallRegExp: RegExp = new RegExp(
|
||||
'return _0x([a-f0-9]){4,6};' +
|
||||
'};' +
|
||||
@@ -230,7 +290,7 @@ describe('StringArrayTransformer', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #4: correct evaluation of the scope calls wrappers', () => {
|
||||
describe('Variant #5: correct evaluation of the scope calls wrappers', () => {
|
||||
const expectedEvaluationResult: string = 'aaabbbcccdddeee';
|
||||
let evaluationResult: string;
|
||||
|
||||
@@ -255,7 +315,7 @@ describe('StringArrayTransformer', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #5: `stringArrayWrappersChainedCalls` option is enabled', () => {
|
||||
describe('Variant #6: `stringArrayWrappersChainedCalls` option is enabled', () => {
|
||||
describe('Variant #1: correct chained calls', () => {
|
||||
describe('Variant #1: `Mangled` identifier names generator', () => {
|
||||
const stringArrayCallRegExp: RegExp = new RegExp(
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
if (true) {
|
||||
var foo = 'foo';
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
[].map(() => 'test');
|
||||
Reference in New Issue
Block a user