mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Dependencies update #3: Estree
This commit is contained in:
+4
-10
@@ -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();
|
||||
|
||||
|
||||
+32
-1
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
(function () {
|
||||
var a, b;
|
||||
({a, ...b} = {a: 1, b: 2});
|
||||
|
||||
console.log(a, b);
|
||||
})();
|
||||
Reference in New Issue
Block a user