mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Ignore object expressions as body of arrow function expression when transformObjectKeys option is enabled
This commit is contained in:
+4
-30
@@ -1,46 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
|
||||
import { StringArrayIndexesType } from '../../src/enums/node-transformers/string-array-transformers/StringArrayIndexesType';
|
||||
|
||||
(function () {
|
||||
const JavaScriptObfuscator: any = require('../../index');
|
||||
|
||||
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
// Paste your JavaScript code here
|
||||
function hi() {
|
||||
function inner () {
|
||||
console.log('inner');
|
||||
console.log('inner1');
|
||||
}
|
||||
|
||||
console.log("Hello World!");
|
||||
|
||||
inner();
|
||||
}
|
||||
hi();
|
||||
const test = () => ({
|
||||
foo: 'bar'
|
||||
});
|
||||
`,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
compact: false,
|
||||
rotateStringArray: true,
|
||||
shuffleStringArray: true,
|
||||
stringArray: true,
|
||||
/*stringArrayEncoding: [
|
||||
StringArrayEncoding.None,
|
||||
StringArrayEncoding.Rc4
|
||||
],*/
|
||||
stringArrayIndexesType: [
|
||||
StringArrayIndexesType.HexadecimalNumericString,
|
||||
StringArrayIndexesType.HexadecimalNumber
|
||||
],
|
||||
stringArrayIndexShift: true,
|
||||
stringArrayThreshold: 1,
|
||||
stringArrayWrappersCount: 1,
|
||||
stringArrayWrappersChainedCalls: true,
|
||||
stringArrayWrappersParametersMaxCount: 2,
|
||||
stringArrayWrappersType: 'function'
|
||||
transformObjectKeys: true
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
|
||||
+27
@@ -1948,5 +1948,32 @@ describe('ObjectExpressionKeysTransformer', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #13: object expression as body of arrow function expression', () => {
|
||||
const match: string = `` +
|
||||
`const test *= *\\(\\) *=> *\\({`+
|
||||
`'foo' *: *'bar'` +
|
||||
`}\\);` +
|
||||
``;
|
||||
const regExp: RegExp = new RegExp(match);
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/object-expression-as-body-of-arrow-function-expression.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
transformObjectKeys: true
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('shouldn ignore object expressions keys transformation', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
const test = () => ({
|
||||
foo: 'bar'
|
||||
});
|
||||
Reference in New Issue
Block a user