mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed TypeError: Assignment to constant variable when auto-detection of kind of variables is inserted const variables for controlFlowStorage nodes
This commit is contained in:
@@ -8,19 +8,25 @@ import { readFileAsString } from '../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
const getEnvironmentCode = () => `
|
||||
global.document = {
|
||||
domain: 'obfuscator.io'
|
||||
};
|
||||
`;
|
||||
|
||||
describe('JavaScriptObfuscator runtime eval', function () {
|
||||
const options: TInputOptions = {
|
||||
controlFlowFlattening: true,
|
||||
controlFlowFlatteningThreshold: 1,
|
||||
deadCodeInjection: true,
|
||||
deadCodeInjectionThreshold: 1,
|
||||
debugProtection: true,
|
||||
selfDefending: true,
|
||||
disableConsoleOutput: true,
|
||||
rotateStringArray: true,
|
||||
splitStrings: true,
|
||||
splitStringsChunkLength: 5,
|
||||
stringArray: true,
|
||||
rotateStringArray: true,
|
||||
stringArrayEncoding: StringArrayEncoding.Rc4,
|
||||
stringArrayThreshold: 1,
|
||||
transformObjectKeys: true,
|
||||
unicodeEscapeSequence: true
|
||||
};
|
||||
@@ -42,6 +48,7 @@ describe('JavaScriptObfuscator runtime eval', function () {
|
||||
it('should obfuscate code without any runtime errors after obfuscation: Variant #1 astring', () => {
|
||||
assert.equal(
|
||||
eval(`
|
||||
${getEnvironmentCode()}
|
||||
${obfuscatedCode}
|
||||
const code = generate({
|
||||
"type": "Program",
|
||||
@@ -120,7 +127,11 @@ describe('JavaScriptObfuscator runtime eval', function () {
|
||||
|
||||
it('should obfuscate code without any runtime errors after obfuscation: Variant #2 sha256', () => {
|
||||
assert.equal(
|
||||
eval(`${obfuscatedCode} sha256('test');`),
|
||||
eval(`
|
||||
${getEnvironmentCode()}
|
||||
${obfuscatedCode}
|
||||
sha256('test');
|
||||
`),
|
||||
'9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08'
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user