-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Expected Behavior
Generated variable name should not shadow outer scope variable
Current Behavior
Generated variable name might shadow outer scope variable
Source code:
[].forEach(a => a === { a: 1 });
Obfuscated code result:
[]['forEach'](aO=>aO===aO);}
Steps to Reproduce
See "Minimal working example that will help to reproduce issue"
Your Environment
- Obfuscator version used: 4.1.0
- Node version used: v18.17.1
Stack trace
Minimal working example that will help to reproduce issue
const JavaScriptObfuscator = require('javascript-obfuscator');
const options = {
stringArray: false,
identifierNamesGenerator: 'mangled',
transformObjectKeys: true,
};
const fileContent = `
() => {
${new Array(100).fill(0).map((_, i) => `const var${i} = 1;`).join('\n')}
[].forEach(a => a === { a: 1 });
}
`;
const obfuscationResult = JavaScriptObfuscator.obfuscate(fileContent, options)._obfuscatedCode;
console.log(obfuscationResult)
const idx = obfuscationResult.indexOf('forEach') + 14;
const [a, b] = obfuscationResult.substring(idx, idx + 7).split('===');
console.log(a, b, a === b)