Dependencies update #3: Estree

This commit is contained in:
sanex3339
2020-03-22 21:07:22 +03:00
parent b053886595
commit 3ba7a8172b
16 changed files with 455 additions and 148 deletions
+4 -10
View File
@@ -7,19 +7,13 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
`
#!/usr/bin/env node
/**
* @license
*/
var foo = 'abc';
//bar
var a, b;
({a, ...b} = {a: 1, b: 2, c: 3});
`,
{
...NO_ADDITIONAL_NODES_PRESET,
stringArray: true,
stringArrayThreshold: 1,
compact: false
compact: false,
renameGlobals: true
}
).getObfuscatedCode();
@@ -617,7 +617,7 @@ describe('ScopeIdentifiersTransformer VariableDeclaration identifiers', () => {
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/object-rest.js');
const code: string = readFileAsString(__dirname + '/fixtures/object-rest-1.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
@@ -707,4 +707,35 @@ describe('ScopeIdentifiersTransformer VariableDeclaration identifiers', () => {
assert.match(obfuscatedCode, variablesUsageRegExp);
});
});
describe('Variant #20: destructing assignment without declaration #3', () => {
const variablesDeclaration: RegExp = /var a, *_0x[a-f0-9]{4,6};/;
const destructingAssignmentRegExp: RegExp = /\({ *a, *\.\.\._0x[a-f0-9]{4,6} *} *= *{ *'a' *: *0x1, *'b' *: *0x2 *}\);/;
const variablesUsageRegExp: RegExp = /console\['log']\(a, *_0x[a-f0-9]{4,6}\);/;
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/destructing-assignment-without-declaration-3.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET
}
).getObfuscatedCode();
});
it('match #1: should transform variables declaration', () => {
assert.match(obfuscatedCode, variablesDeclaration);
});
it('match #2: should transform destructing assignment without declaration', () => {
assert.match(obfuscatedCode, destructingAssignmentRegExp);
});
it('match #3: should transform variables usage', () => {
assert.match(obfuscatedCode, variablesUsageRegExp);
});
});
});
@@ -0,0 +1,6 @@
(function () {
var a, b;
({a, ...b} = {a: 1, b: 2});
console.log(a, b);
})();