Skip to content

Commit 3b0c20d

Browse files
authored
Merge pull request javascript-obfuscator#570 from javascript-obfuscator/global-identifiers-prefixes
Added prefixes to the generated global identifiers of the added code
2 parents e36138d + 6d03a2b commit 3b0c20d

File tree

28 files changed

+341
-205
lines changed

28 files changed

+341
-205
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Change Log
22

3+
v0.25.3
4+
---
5+
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/568
6+
37
v0.25.2
48
---
59
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/563

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ For example:
270270

271271
Kind of variables of inserted nodes will auto-detected, based on most prevailing kind of variables of source code.
272272

273+
## Conflicts of identifier names between different files
274+
275+
During obfuscation of the different files, the same names can be generated for the global identifiers between these files.
276+
To prevent this set the unique prefix for all global identifiers for each obfuscated file with [`identifiersPrefix`](#identifiersPrefix) option.
277+
278+
When using CLI this prefix will be added automatically.
279+
273280
## Antiviruses false positive virus alerts
274281

275282
Some input source code that will obfuscated with some obfuscation options can trigger false positive alerts in a few antiviruses. If you will get this false positive triggers, try to play with obfuscation options.

dist/index.browser.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.cli.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "javascript-obfuscator",
3-
"version": "0.25.2",
3+
"version": "0.25.3",
44
"description": "JavaScript obfuscator",
55
"keywords": [
66
"obfuscator",
@@ -23,7 +23,7 @@
2323
"dependencies": {
2424
"@gradecam/tsenum": "1.2.0",
2525
"@nuxtjs/opencollective": "0.2.2",
26-
"acorn": "7.1.0",
26+
"acorn": "7.1.1",
2727
"acorn-import-meta": "1.0.0",
2828
"chalk": "3.0.0",
2929
"chance": "1.1.4",
@@ -45,28 +45,28 @@
4545
"tslib": "1.11.1"
4646
},
4747
"devDependencies": {
48-
"@types/chai": "4.2.9",
48+
"@types/chai": "4.2.10",
4949
"@types/chance": "1.0.8",
5050
"@types/escodegen": "0.0.6",
5151
"@types/eslint-scope": "3.7.0",
5252
"@types/estraverse": "0.0.6",
5353
"@types/estree": "0.0.42",
5454
"@types/md5": "2.1.33",
5555
"@types/mkdirp": "1.0.0",
56-
"@types/mocha": "7.0.1",
56+
"@types/mocha": "7.0.2",
5757
"@types/multimatch": "4.0.0",
5858
"@types/node": "12.12.14",
5959
"@types/rimraf": "2.0.3",
6060
"@types/sinon": "7.5.2",
6161
"@types/string-template": "1.0.2",
6262
"@types/webpack-env": "1.15.1",
63-
"@typescript-eslint/eslint-plugin": "2.21.0",
64-
"@typescript-eslint/parser": "2.21.0",
63+
"@typescript-eslint/eslint-plugin": "2.22.0",
64+
"@typescript-eslint/parser": "2.22.0",
6565
"chai": "4.2.0",
6666
"coveralls": "3.0.9",
6767
"eslint": "6.8.0",
6868
"eslint-plugin-import": "2.20.1",
69-
"eslint-plugin-jsdoc": "21.0.0",
69+
"eslint-plugin-jsdoc": "22.0.0",
7070
"eslint-plugin-no-null": "1.0.2",
7171
"eslint-plugin-prefer-arrow": "1.1.7",
7272
"eslint-plugin-unicorn": "16.1.1",
@@ -81,8 +81,8 @@
8181
"threads": "1.3.0",
8282
"ts-loader": "6.2.1",
8383
"ts-node": "6.1.0",
84-
"typescript": "3.8.2",
85-
"webpack": "4.41.6",
84+
"typescript": "3.8.3",
85+
"webpack": "4.42.0",
8686
"webpack-cli": "3.3.11",
8787
"webpack-node-externals": "1.7.2"
8888
},

src/custom-code-helpers/domain-lock/group/DomainLockCustomCodeHelperGroup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ export class DomainLockCustomCodeHelperGroup extends AbstractCustomCodeHelperGro
8484
const domainLockFunctionName: string = domainLockFunctionLexicalScopeNode
8585
&& NodeGuards.isProgramNode(domainLockFunctionLexicalScopeNode)
8686
? this.identifierNamesGenerator.generate(domainLockFunctionLexicalScopeNode)
87-
: this.randomGenerator.getRandomString(5);
87+
: this.identifierNamesGenerator.generateNext();
8888
const callsControllerFunctionName: string = domainLockFunctionLexicalScopeNode
8989
&& NodeGuards.isProgramNode(domainLockFunctionLexicalScopeNode)
9090
? this.identifierNamesGenerator.generate(domainLockFunctionLexicalScopeNode)
91-
: this.randomGenerator.getRandomString(5);
91+
: this.identifierNamesGenerator.generateNext();
9292

9393
// domainLock helper nodes append
9494
this.appendCustomNodeIfExist(

src/custom-code-helpers/self-defending/group/SelfDefendingCodeHelperGroup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ export class SelfDefendingCodeHelperGroup extends AbstractCustomCodeHelperGroup
8282

8383
const selfDefendingFunctionName: string = selfDefendingFunctionLexicalScopeNode
8484
? this.identifierNamesGenerator.generate(selfDefendingFunctionLexicalScopeNode)
85-
: this.identifierNamesGenerator.generateForGlobalScope();
85+
: this.identifierNamesGenerator.generateNext();
8686
const callsControllerFunctionName: string = selfDefendingFunctionLexicalScopeNode
8787
? this.identifierNamesGenerator.generate(selfDefendingFunctionLexicalScopeNode)
88-
: this.identifierNamesGenerator.generateForGlobalScope();
88+
: this.identifierNamesGenerator.generateNext();
8989

9090
// selfDefendingUnicode helper nodes append
9191
this.appendCustomNodeIfExist(

src/custom-code-helpers/string-array/StringArrayRotateFunctionCodeHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ export class StringArrayRotateFunctionCodeHelper extends AbstractCustomCodeHelpe
9090
* @returns {string}
9191
*/
9292
protected getCodeHelperTemplate (): string {
93-
const timesName: string = this.identifierNamesGenerator.generateForGlobalScope();
94-
const whileFunctionName: string = this.identifierNamesGenerator.generateForGlobalScope();
93+
const timesName: string = this.identifierNamesGenerator.generateNext();
94+
const whileFunctionName: string = this.identifierNamesGenerator.generateNext();
9595
const preservedNames: string[] = [`^${this.stringArrayName}$`];
9696

9797
let code: string = '';

src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,5 @@ export abstract class AbstractIdentifierNamesGenerator implements IIdentifierNam
138138
* @param {number} nameLength
139139
* @returns {string}
140140
*/
141-
public abstract generateWithPrefix (nameLength?: number): string;
141+
public abstract generateNext (nameLength?: number): string;
142142
}

0 commit comments

Comments
 (0)