mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
This commit is contained in:
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
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -141,8 +141,10 @@ export class ImportDeclarationTransformer extends AbstractNodeTransformer {
|
||||
const newReplaceableIdentifier: ESTree.Identifier = this.identifierObfuscatingReplacer
|
||||
.replace(replaceableIdentifier.name, lexicalScopeNode);
|
||||
|
||||
replaceableIdentifier.name = newReplaceableIdentifier.name;
|
||||
NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
|
||||
if (replaceableIdentifier.name !== newReplaceableIdentifier.name) {
|
||||
replaceableIdentifier.name = newReplaceableIdentifier.name;
|
||||
NodeMetadata.set(replaceableIdentifier, { renamedIdentifier: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+32
@@ -141,5 +141,37 @@ describe('ImportDeclarationTransformer', () => {
|
||||
assert.equal(importSpecifierIdentifier, consoleLogIdentifier);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #5: Issue-360, prevent of set `renamedIdentifier` metadata property of all traversed identifiers', () => {
|
||||
const importSpecifierRegExp1: RegExp = /import _0x[a-f0-9]{4,6} *from *'foo';/;
|
||||
const importSpecifierRegExp2: RegExp = /import _0x[a-f0-9]{4,6} *from *'bar';/;
|
||||
const variableDeclarationIdentifierRegExp: RegExp = /const _0x[a-f0-9]{4,6} *= *0x1;/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/issue-360.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
renameGlobals: true
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('Match 1: should transform first import specifier identifier name', () => {
|
||||
assert.match(obfuscatedCode, importSpecifierRegExp1);
|
||||
});
|
||||
|
||||
it('Match 2: should transform second import specifier identifier name', () => {
|
||||
assert.match(obfuscatedCode, importSpecifierRegExp2);
|
||||
});
|
||||
|
||||
it('Match 3: should transform variable declaration identifier name', () => {
|
||||
assert.match(obfuscatedCode, variableDeclarationIdentifierRegExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import foo from 'foo';
|
||||
import bar from 'bar';
|
||||
|
||||
const baz = 1;
|
||||
Reference in New Issue
Block a user