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:
sanex3339
2020-01-10 11:52:43 +03:00
parent f39b8a99fe
commit 1277acea20
48 changed files with 384 additions and 217 deletions
@@ -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'
);
});