|
@@ -2310,5 +2310,122 @@ describe('ObjectExpressionKeysTransformer', () => {
|
|
assert.match(obfuscatedCode, regExp);
|
|
assert.match(obfuscatedCode, regExp);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ describe('Variant #18: call expression as property value', () => {
|
|
|
|
+ describe('Variant #1: call expression as a direct property value', () => {
|
|
|
|
+ const match: string = `` +
|
|
|
|
+ `var ${variableMatch} *= *{` +
|
|
|
|
+ `'foo': *'bar',` +
|
|
|
|
+ `'baz': *${variableMatch}\\(\\)` +
|
|
|
|
+ `}` +
|
|
|
|
+ ``;
|
|
|
|
+ const regExp: RegExp = new RegExp(match);
|
|
|
|
+
|
|
|
|
+ let obfuscatedCode: string;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ const code: string = readFileAsString(__dirname + '/fixtures/call-expression-1.js');
|
|
|
|
+
|
|
|
|
+ obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
|
|
|
+ code,
|
|
|
|
+ {
|
|
|
|
+ ...NO_ADDITIONAL_NODES_PRESET,
|
|
|
|
+ transformObjectKeys: true
|
|
|
|
+ }
|
|
|
|
+ ).getObfuscatedCode();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('shouldn ignore object expression if it contains a call expression as a direct property value', () => {
|
|
|
|
+ assert.match(obfuscatedCode, regExp);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #2: call expression as an indirect property value', () => {
|
|
|
|
+ const match: string = `` +
|
|
|
|
+ `var ${variableMatch} *= *{` +
|
|
|
|
+ `'foo': *'bar',` +
|
|
|
|
+ `'baz': *'call' *\\+ *${variableMatch}\\(\\)` +
|
|
|
|
+ `}` +
|
|
|
|
+ ``;
|
|
|
|
+ const regExp: RegExp = new RegExp(match);
|
|
|
|
+
|
|
|
|
+ let obfuscatedCode: string;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ const code: string = readFileAsString(__dirname + '/fixtures/call-expression-2.js');
|
|
|
|
+
|
|
|
|
+ obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
|
|
|
+ code,
|
|
|
|
+ {
|
|
|
|
+ ...NO_ADDITIONAL_NODES_PRESET,
|
|
|
|
+ transformObjectKeys: true
|
|
|
|
+ }
|
|
|
|
+ ).getObfuscatedCode();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('shouldn ignore object expression if it contains a call expression as an indirect property value', () => {
|
|
|
|
+ assert.match(obfuscatedCode, regExp);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #3: call expression as a nested object expression as property value', () => {
|
|
|
|
+ const match: string = `` +
|
|
|
|
+ `var ${variableMatch} *= *{` +
|
|
|
|
+ `'foo': *'bar',` +
|
|
|
|
+ `'baz': *{` +
|
|
|
|
+ `'bark': *${variableMatch}\\(\\)` +
|
|
|
|
+ `}` +
|
|
|
|
+ `}` +
|
|
|
|
+ ``;
|
|
|
|
+ const regExp: RegExp = new RegExp(match);
|
|
|
|
+
|
|
|
|
+ let obfuscatedCode: string;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ const code: string = readFileAsString(__dirname + '/fixtures/call-expression-3.js');
|
|
|
|
+
|
|
|
|
+ obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
|
|
|
+ code,
|
|
|
|
+ {
|
|
|
|
+ ...NO_ADDITIONAL_NODES_PRESET,
|
|
|
|
+ transformObjectKeys: true
|
|
|
|
+ }
|
|
|
|
+ ).getObfuscatedCode();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('shouldn ignore object expression if it contains a call expression as a nested object expression as property value', () => {
|
|
|
|
+ assert.match(obfuscatedCode, regExp);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('Variant #4: call expression as a a property value after object expression property', () => {
|
|
|
|
+ const match: string = `` +
|
|
|
|
+ `var ${variableMatch} *= *{` +
|
|
|
|
+ `'foo': *'bar',` +
|
|
|
|
+ `'baz': *${variableMatch},` +
|
|
|
|
+ `'eagle': *${variableMatch}\\(\\)` +
|
|
|
|
+ `}` +
|
|
|
|
+ ``;
|
|
|
|
+ const regExp: RegExp = new RegExp(match);
|
|
|
|
+
|
|
|
|
+ let obfuscatedCode: string;
|
|
|
|
+
|
|
|
|
+ before(() => {
|
|
|
|
+ const code: string = readFileAsString(__dirname + '/fixtures/call-expression-4.js');
|
|
|
|
+
|
|
|
|
+ obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
|
|
|
+ code,
|
|
|
|
+ {
|
|
|
|
+ ...NO_ADDITIONAL_NODES_PRESET,
|
|
|
|
+ transformObjectKeys: true
|
|
|
|
+ }
|
|
|
|
+ ).getObfuscatedCode();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('shouldn ignore object expression if it contains a call expression and the previous property value is object expression', () => {
|
|
|
|
+ assert.match(obfuscatedCode, regExp);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
});
|
|
});
|
|
});
|
|
});
|