mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Auto detection of prevailing kind of variables
This commit is contained in:
@@ -15,6 +15,7 @@ import { IdentifierNamesGenerator } from '../../../src/enums/generators/identifi
|
||||
import { buildLargeCode } from '../../helpers/buildLargeCode';
|
||||
import { getRegExpMatch } from '../../helpers/getRegExpMatch';
|
||||
import { readFileAsString } from '../../helpers/readFileAsString';
|
||||
import { TInputOptions } from '../../../src/types/options/TInputOptions';
|
||||
|
||||
describe('JavaScriptObfuscator', () => {
|
||||
describe('obfuscate', () => {
|
||||
@@ -710,5 +711,92 @@ describe('JavaScriptObfuscator', () => {
|
||||
assert.equal(areCollisionsExists, false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Prevailing kind of variables', () => {
|
||||
const baseParams: TInputOptions = {
|
||||
compact: true,
|
||||
controlFlowFlattening: true,
|
||||
controlFlowFlatteningThreshold: 1,
|
||||
deadCodeInjection: true,
|
||||
deadCodeInjectionThreshold: 1,
|
||||
debugProtection: true,
|
||||
debugProtectionInterval: true,
|
||||
disableConsoleOutput: false,
|
||||
rotateStringArray: true,
|
||||
selfDefending: true,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 1,
|
||||
transformObjectKeys: true,
|
||||
unicodeEscapeSequence: false
|
||||
};
|
||||
|
||||
describe('`var` kind', function () {
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/prevailing-kind-of-variables-var.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
...baseParams,
|
||||
stringArrayEncoding: StringArrayEncoding.Rc4
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
});
|
||||
|
||||
it('does not break on run', () => {
|
||||
assert.doesNotThrow(() => eval(obfuscatedCode));
|
||||
});
|
||||
});
|
||||
|
||||
describe('`const` kind', function () {
|
||||
describe('Variant #1: StringArrayEncoding: rc4', () => {
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/prevailing-kind-of-variables-const.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
...baseParams,
|
||||
stringArrayEncoding: StringArrayEncoding.Rc4
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
});
|
||||
|
||||
it('does not break on run', () => {
|
||||
assert.doesNotThrow(() => eval(obfuscatedCode));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: StringArrayEncoding: base64', () => {
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/prevailing-kind-of-variables-const.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
...baseParams,
|
||||
stringArrayEncoding: StringArrayEncoding.Rc4
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
});
|
||||
|
||||
it('does not break on run', () => {
|
||||
assert.doesNotThrow(() => eval(obfuscatedCode));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user