Skip to content

Commit daba144

Browse files
authored
Merge pull request javascript-obfuscator#555 from javascript-obfuscator/new-mangled-names-generator
Improved mangled identifier names generator
2 parents 029d595 + 16a7656 commit daba144

File tree

108 files changed

+1260
-634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1260
-634
lines changed

.ncurc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"reject": [
3+
"@types/node",
34
"ts-node"
45
]
56
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Change Log
22

33
v0.25.0
44
---
5+
* Improved `mangled` identifier names generator logic
56
* Fixed conflicts between generated names and names from untouched identifiers from source code. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/550. Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/549
67
* Prevented transformation of object keys in sequence expression that has `super` call
78

dist/index.browser.js

Lines changed: 6 additions & 6 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
@@ -45,45 +45,45 @@
4545
"tslib": "1.10.0"
4646
},
4747
"devDependencies": {
48-
"@types/chai": "4.2.8",
48+
"@types/chai": "4.2.9",
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",
55-
"@types/mkdirp": "0.5.2",
55+
"@types/mkdirp": "1.0.0",
5656
"@types/mocha": "7.0.1",
5757
"@types/multimatch": "4.0.0",
5858
"@types/node": "12.12.14",
5959
"@types/rimraf": "2.0.3",
6060
"@types/sinon": "7.5.1",
6161
"@types/string-template": "1.0.2",
6262
"@types/webpack-env": "1.15.1",
63-
"@typescript-eslint/eslint-plugin": "2.19.0",
64-
"@typescript-eslint/parser": "2.19.0",
63+
"@typescript-eslint/eslint-plugin": "2.19.2",
64+
"@typescript-eslint/parser": "2.19.2",
6565
"chai": "4.2.0",
6666
"coveralls": "3.0.9",
6767
"eslint": "6.8.0",
6868
"eslint-plugin-import": "2.20.1",
6969
"eslint-plugin-jsdoc": "21.0.0",
7070
"eslint-plugin-no-null": "1.0.2",
7171
"eslint-plugin-prefer-arrow": "1.1.7",
72-
"eslint-plugin-unicorn": "16.0.0",
72+
"eslint-plugin-unicorn": "16.1.0",
7373
"fork-ts-checker-notifier-webpack-plugin": "2.0.0",
7474
"fork-ts-checker-webpack-plugin": "4.0.3",
7575
"mocha": "7.0.1",
7676
"nyc": "15.0.0",
7777
"pjson": "1.0.9",
7878
"pre-commit": "1.2.2",
79-
"rimraf": "3.0.1",
79+
"rimraf": "3.0.2",
8080
"sinon": "8.1.1",
81-
"threads": "1.0.2",
81+
"threads": "1.1.0",
8282
"ts-loader": "6.2.1",
8383
"ts-node": "6.1.0",
8484
"typescript": "3.8.0-beta",
85-
"webpack": "4.41.5",
86-
"webpack-cli": "3.3.10",
85+
"webpack": "4.41.6",
86+
"webpack-cli": "3.3.11",
8787
"webpack-node-externals": "1.7.2"
8888
},
8989
"repository": {

src/container/InversifyContainerFacade.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { convertingTransformersModule } from './modules/node-transformers/Conver
77
import { customNodesModule } from './modules/custom-nodes/CustomNodesModule';
88
import { finalizingTransformersModule } from './modules/node-transformers/FinalizingTransformersModule';
99
import { generatorsModule } from './modules/generators/GeneratorsModule';
10+
import { nodeModule } from './modules/node/NodeModule';
1011
import { nodeTransformersModule } from './modules/node-transformers/NodeTransformersModule';
1112
import { obfuscatingTransformersModule } from './modules/node-transformers/ObfuscatingTransformersModule';
1213
import { optionsModule } from './modules/options/OptionsModule';
@@ -196,6 +197,7 @@ export class InversifyContainerFacade implements IInversifyContainerFacade {
196197
this.container.load(customNodesModule);
197198
this.container.load(finalizingTransformersModule);
198199
this.container.load(generatorsModule);
200+
this.container.load(nodeModule);
199201
this.container.load(nodeTransformersModule);
200202
this.container.load(obfuscatingTransformersModule);
201203
this.container.load(optionsModule);

src/container/ServiceIdentifiers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export enum ServiceIdentifiers {
2222
ICustomNodeGroup = 'ICustomNodeGroup',
2323
IControlFlowReplacer = 'IControlFlowReplacer',
2424
ICustomNodeFormatter = 'ICustomNodeFormatter',
25+
ICustomNodeObfuscator = 'ICustomNodeObfuscator',
2526
IEscapeSequenceEncoder = 'IEscapeSequenceEncoder',
2627
IIdentifierNamesGenerator = 'IIdentifierNamesGenerator',
2728
IIdentifierObfuscatingReplacer = 'IIdentifierObfuscatingReplacer',
@@ -39,8 +40,8 @@ export enum ServiceIdentifiers {
3940
IPrevailingKindOfVariablesAnalyzer = 'IPrevailingKindOfVariablesAnalyzer',
4041
IObjectExpressionExtractor = 'IObjectExpressionExtractor',
4142
IRandomGenerator = 'IRandomGenerator',
43+
IScopeIdentifiersTraverser = 'IScopeIdentifiersTraverser',
4244
ISourceCode = 'ISourceCode',
43-
ISourceMapCorrector = 'ISourceMapCorrector',
4445
IScopeAnalyzer = 'IScopeAnalyzer',
4546
IStringArrayStorage = 'IStringArrayStorage',
4647
IStringArrayStorageAnalyzer = 'IStringArrayStorageAnalyzer',

src/container/modules/custom-nodes/CustomNodesModule.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import { StringArrayNode } from '../../../custom-nodes/string-array-nodes/String
4040
import { StringArrayRotateFunctionNode } from '../../../custom-nodes/string-array-nodes/StringArrayRotateFunctionNode';
4141
import { StringLiteralControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode';
4242
import { StringLiteralNode } from '../../../custom-nodes/control-flow-flattening-nodes/StringLiteralNode';
43+
import { ICustomNodeObfuscator } from '../../../interfaces/custom-nodes/ICustomNodeObfuscator';
44+
import { CustomNodeObfuscator } from '../../../custom-nodes/CustomNodeObfuscator';
4345

4446
export const customNodesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
4547
// custom nodes
@@ -163,6 +165,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
163165
ServiceIdentifiers.Newable__ICustomNode,
164166
ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
165167
ServiceIdentifiers.ICustomNodeFormatter,
168+
ServiceIdentifiers.ICustomNodeObfuscator,
166169
ServiceIdentifiers.IRandomGenerator,
167170
ServiceIdentifiers.IOptions,
168171
ServiceIdentifiers.IPrevailingKindOfVariablesAnalyzer
@@ -175,6 +178,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
175178
ServiceIdentifiers.Newable__ICustomNode,
176179
ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
177180
ServiceIdentifiers.ICustomNodeFormatter,
181+
ServiceIdentifiers.ICustomNodeObfuscator,
178182
ServiceIdentifiers.IRandomGenerator,
179183
ServiceIdentifiers.IOptions
180184
));
@@ -186,6 +190,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
186190
ServiceIdentifiers.Newable__ICustomNode,
187191
ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
188192
ServiceIdentifiers.ICustomNodeFormatter,
193+
ServiceIdentifiers.ICustomNodeObfuscator,
189194
ServiceIdentifiers.IRandomGenerator,
190195
ServiceIdentifiers.IOptions,
191196
ServiceIdentifiers.IPrevailingKindOfVariablesAnalyzer
@@ -200,4 +205,9 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
200205
bind<ICustomNodeFormatter>(ServiceIdentifiers.ICustomNodeFormatter)
201206
.to(CustomNodeFormatter)
202207
.inSingletonScope();
208+
209+
// custom node obfuscator
210+
bind<ICustomNodeObfuscator>(ServiceIdentifiers.ICustomNodeObfuscator)
211+
.to(CustomNodeObfuscator)
212+
.inSingletonScope();
203213
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ContainerModule, interfaces } from 'inversify';
2+
import { ServiceIdentifiers } from '../../ServiceIdentifiers';
3+
4+
import { IScopeIdentifiersTraverser } from '../../../interfaces/node/IScopeIdentifiersTraverser';
5+
6+
import { ScopeIdentifiersTraverser } from '../../../node/ScopeIdentifiersTraverser';
7+
8+
export const nodeModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
9+
// scope identifiers traverser
10+
bind<IScopeIdentifiersTraverser>(ServiceIdentifiers.IScopeIdentifiersTraverser)
11+
.to(ScopeIdentifiersTraverser)
12+
.inSingletonScope();
13+
});

0 commit comments

Comments
 (0)