mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Additional fixes of transformObjectKeys
This commit is contained in:
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "javascript-obfuscator",
|
||||
"version": "0.24.0-rc.4",
|
||||
"version": "0.24.0-rc.5",
|
||||
"description": "JavaScript obfuscator",
|
||||
"keywords": [
|
||||
"obfuscator",
|
||||
|
||||
@@ -97,12 +97,12 @@ export class ObjectExpressionKeysTransformer extends AbstractNodeTransformer {
|
||||
if (identifierNamesSet.includes(node.name)) {
|
||||
isReferencedIdentifierName = true;
|
||||
}
|
||||
|
||||
return estraverse.VisitorOption.Break;
|
||||
},
|
||||
leave: (node: ESTree.Node): void | estraverse.VisitorOption => {
|
||||
if (node === objectExpressionNode) {
|
||||
isCurrentNode = false;
|
||||
|
||||
return estraverse.VisitorOption.Break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
-11
@@ -7,17 +7,8 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
|
||||
|
||||
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
function test() {
|
||||
var foo;
|
||||
|
||||
return foo
|
||||
? {
|
||||
bar: foo.foo
|
||||
}
|
||||
: 1;
|
||||
}
|
||||
|
||||
console.log(test());
|
||||
var passthrough = value => value;
|
||||
var foo = 1, bar = {baz: passthrough(foo)}
|
||||
`,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
|
||||
+26
@@ -1698,5 +1698,31 @@ describe('ObjectExpressionKeysTransformer', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #8: variable declarator identifier reference', () => {
|
||||
const match: string = `` +
|
||||
`var *passthrough *= *${variableMatch} *=> *${variableMatch};` +
|
||||
`var foo *= *0x1, *bar *= *{'baz' *: *passthrough\\(foo\\)};` +
|
||||
``;
|
||||
const regExp: RegExp = new RegExp(match);
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/variable-declarator-identifier-reference.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
transformObjectKeys: true
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('shouldn ignore variable declarator object expression if it references other variable declarator identifier', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
var passthrough = value => value;
|
||||
var foo = 1, bar = {baz: passthrough(foo)}
|
||||
Reference in New Issue
Block a user