identifierNamesGenerator option

This commit is contained in:
sanex3339
2017-12-05 00:09:34 +03:00
parent fb8b604ec4
commit 74351be750
54 changed files with 366 additions and 341 deletions
+2
View File
@@ -2,6 +2,8 @@ Change Log
===
v0.13.0
---
* **Breaking change:** `mangle` option was removed.
* **New option:** `identifierNamesGenerator` allows to set identifier names generator (`hexadecimal` or `mangled`).
* **Breaking change:** all CLI options were renamed to `kebab-case` format (`--disableConsoleOutout` -> `--disable-console-output`)
* Implemented custom `mangle` option algorithm without `esmangle`; fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/110
+61 -57
View File
@@ -256,8 +256,8 @@ Following options are available for the JS Obfuscator:
debugProtectionInterval: false,
disableConsoleOutput: false,
domainLock: [],
identifierNamesGenerator: 'hexadecimal',
log: false,
mangle: false,
renameGlobals: false,
reservedNames: [],
rotateStringArray: true,
@@ -292,8 +292,8 @@ Following options are available for the JS Obfuscator:
--debug-protection-interval <boolean>
--disable-console-output <boolean>
--domain-lock '<list>' (comma separated)
--identifier-names-generator <string> [hexadecimal, mangled]
--log <boolean>
--mangle <boolean>
--rename-globals <boolean>
--reserved-names '<list>' (comma separated)
--rotate-string-array <boolean>
@@ -539,16 +539,20 @@ Locks the obfuscated source code so it only runs on specific domains and/or sub-
##### Multiple domains and sub-domains
It's possible to lock your code to more than one domain or sub-domain. For instance, to lock it so the code only runs on **www.example.com** add `www.example.com`, to make it work on any sub-domain from example.com, use `.example.com`.
### `identifierNamesGenerator`
Type: `string` Default: `hexadecimal`
Sets identifier names generator.
Available values:
* `hexadecimal`: identifier names like `_0xabc123`
* `mangled`: short identifier names like `a`, `b`, `c`
### `log`
Type: `boolean` Default: `false`
Enables logging of the information to the console.
### `mangle`
Type: `boolean` Default: `false`
Enables mangling of variable names.
### `renameGlobals`
Type: `boolean` Default: `false`
@@ -649,7 +653,7 @@ Type: `boolean|string` Default: `false`
##### :warning: `stringArray` option must be enabled
This option can slightly slow down your script.
This option can slow down your script.
Encode all string literals of the [`stringArray`](#stringarray) using `base64` or `rc4` and inserts a special code that used to decode it back at runtime.
@@ -697,23 +701,23 @@ Performance will 50-100% slower than without obfuscation
```javascript
{
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
deadCodeInjection: true,
deadCodeInjectionThreshold: 1,
debugProtection: true,
debugProtectionInterval: true,
disableConsoleOutput: true,
log: false,
mangle: false,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: 'rc4',
stringArrayThreshold: 1,
unicodeEscapeSequence: false
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
deadCodeInjection: true,
deadCodeInjectionThreshold: 1,
debugProtection: true,
debugProtectionInterval: true,
disableConsoleOutput: true,
identifierNamesGenerator: 'hexadecimal',
log: false,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: 'rc4',
stringArrayThreshold: 1,
unicodeEscapeSequence: false
}
```
@@ -723,23 +727,23 @@ Performance will 30-35% slower than without obfuscation
```javascript
{
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.75,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.4,
debugProtection: false,
debugProtectionInterval: false,
disableConsoleOutput: true,
log: false,
mangle: false,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: 'base64',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.75,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.4,
debugProtection: false,
debugProtectionInterval: false,
disableConsoleOutput: true,
identifierNamesGenerator: 'hexadecimal',
log: false,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: 'base64',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false
}
```
@@ -749,21 +753,21 @@ Performance will slightly slower than without obfuscation
```javascript
{
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: false,
disableConsoleOutput: true,
log: false,
mangle: true,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: false,
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: false,
disableConsoleOutput: true,
identifierNamesGenerator: 'hexadecimal',
log: false,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: false,
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false
}
```
+1 -1
View File
File diff suppressed because one or more lines are too long
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "0.13.0-dev.1",
"version": "0.13.0-dev.2",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
@@ -37,17 +37,17 @@
"tslib": "1.8.0"
},
"devDependencies": {
"@types/chai": "4.0.6",
"@types/chai": "4.0.7",
"@types/chance": "0.7.35",
"@types/commander": "2.11.0",
"@types/commander": "2.12.2",
"@types/escodegen": "0.0.6",
"@types/esprima": "4.0.1",
"@types/estraverse": "0.0.6",
"@types/estree": "0.0.38",
"@types/md5": "2.1.32",
"@types/mkdirp": "0.5.1",
"@types/mkdirp": "0.5.2",
"@types/mocha": "2.2.44",
"@types/node": "8.0.53",
"@types/node": "8.0.54",
"@types/sinon": "4.0.0",
"@types/string-template": "1.0.2",
"@types/webpack-env": "1.13.2",
@@ -66,10 +66,10 @@
"ts-node": "3.3.0",
"tslint": "5.8.0",
"tslint-eslint-rules": "4.1.1",
"tslint-language-service": "0.9.6",
"tslint-language-service": "0.9.7",
"tslint-webpack-plugin": "1.0.0",
"typescript": "2.6.2",
"webpack": "3.9.1",
"webpack": "3.10.0",
"webpack-node-externals": "1.6.0"
},
"repository": {
+2 -2
View File
@@ -240,11 +240,11 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
ArraySanitizer
)
.option(
'--log <boolean>', 'Enables logging of the information to the console',
'--identifier-names-generator <string> [hexadecimal, mangled]', 'Sets identifier names generator (Default: hexadecimal)',
BooleanSanitizer
)
.option(
'--mangle <boolean>', 'Enables mangling of variable names',
'--log <boolean>', 'Enables logging of the information to the console',
BooleanSanitizer
)
.option(
+2 -2
View File
@@ -4,7 +4,7 @@ export enum ServiceIdentifiers {
Factory__IControlFlowReplacer = 'Factory<IControlFlowReplacer>',
Factory__ICustomNode = 'Factory<ICustomNode>',
Factory__ICustomNodeGroup = 'Factory<ICustomNodeGroup>',
Factory__IIdentifierNameGenerator = 'Factory<IIdentifierNameGenerator>',
Factory__IIdentifierNamesGenerator = 'Factory<IIdentifierNamesGenerator>',
Factory__IIdentifierObfuscatingReplacer = 'Factory<IIdentifierObfuscatingReplacer>',
Factory__INodeGuard = 'Factory<INodeGuard>',
Factory__INodeTransformer = 'Factory<INodeTransformer[]>',
@@ -18,7 +18,7 @@ export enum ServiceIdentifiers {
ICustomNodeGroup = 'ICustomNodeGroup',
IControlFlowReplacer = 'IControlFlowReplacer',
IEscapeSequenceEncoder = 'IEscapeSequenceEncoder',
IIdentifierNameGenerator = 'IIdentifierNameGenerator',
IIdentifierNamesGenerator = 'IIdentifierNamesGenerator',
IIdentifierObfuscatingReplacer = 'IIdentifierObfuscatingReplacer',
IJavaScriptObfuscator = 'IJavaScriptObfuscator',
ILogger = 'ILogger',
@@ -145,7 +145,7 @@ export const customNodesModule: interfaces.ContainerModule = new ContainerModule
.toFactory<ICustomNode>(InversifyContainerFacade
.getConstructorFactory<ControlFlowCustomNode, ICustomNode>(
ServiceIdentifiers.Newable__ICustomNode,
ServiceIdentifiers.Factory__IIdentifierNameGenerator,
ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
ServiceIdentifiers.IRandomGenerator,
ServiceIdentifiers.IOptions
));
@@ -1,58 +1,58 @@
import { ContainerModule, interfaces } from 'inversify';
import { ServiceIdentifiers } from '../../ServiceIdentifiers';
import { IIdentifierNameGenerator } from '../../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { IIdentifierNamesGenerator } from '../../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IOptions } from '../../../interfaces/options/IOptions';
import { IdentifierNameGenerator } from '../../../enums/generators/identifier-name-generators/IdentifierNameGenerator';
import { IdentifierNamesGenerator } from '../../../enums/generators/identifier-names-generators/IdentifierNamesGenerator';
import { HexadecimalIdentifierNameGenerator } from '../../../generators/identifier-name-generators/HexadecimalIdentifierNameGenerator';
import { MangledIdentifierNameGenerator } from '../../../generators/identifier-name-generators/MangledIdentifierNameGenerator';
import { HexadecimalIdentifierNamesGenerator } from '../../../generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator';
import { MangledIdentifierNamesGenerator } from '../../../generators/identifier-names-generators/MangledIdentifierNamesGenerator';
export const generatorsModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
// identifier name generators
bind<IIdentifierNameGenerator>(ServiceIdentifiers.IIdentifierNameGenerator)
.to(HexadecimalIdentifierNameGenerator)
bind<IIdentifierNamesGenerator>(ServiceIdentifiers.IIdentifierNamesGenerator)
.to(HexadecimalIdentifierNamesGenerator)
.inSingletonScope()
.whenTargetNamed(IdentifierNameGenerator.HexadecimalIdentifierNameGenerator);
.whenTargetNamed(IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator);
bind<IIdentifierNameGenerator>(ServiceIdentifiers.IIdentifierNameGenerator)
.to(MangledIdentifierNameGenerator)
bind<IIdentifierNamesGenerator>(ServiceIdentifiers.IIdentifierNamesGenerator)
.to(MangledIdentifierNamesGenerator)
.inSingletonScope()
.whenTargetNamed(IdentifierNameGenerator.MangledIdentifierNameGenerator);
.whenTargetNamed(IdentifierNamesGenerator.MangledIdentifierNamesGenerator);
// identifier name generator factory
bind<IIdentifierNameGenerator>(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
.toFactory<IIdentifierNameGenerator>((context: interfaces.Context): (options: IOptions) => IIdentifierNameGenerator => {
const cache: Map <boolean, IIdentifierNameGenerator> = new Map();
bind<IIdentifierNamesGenerator>(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
.toFactory<IIdentifierNamesGenerator>((context: interfaces.Context): (options: IOptions) => IIdentifierNamesGenerator => {
let cachedIdentifierNamesGenerator: IIdentifierNamesGenerator | null = null;
return (options: IOptions) => {
if (cache.has(options.mangle)) {
return <IIdentifierNameGenerator>cache.get(options.mangle);
if (cachedIdentifierNamesGenerator) {
return cachedIdentifierNamesGenerator;
}
let identifierNameGenerator: IIdentifierNameGenerator;
let identifierNamesGenerator: IIdentifierNamesGenerator;
switch (options.mangle) {
case true:
identifierNameGenerator = context.container.getNamed<IIdentifierNameGenerator>(
ServiceIdentifiers.IIdentifierNameGenerator,
IdentifierNameGenerator.MangledIdentifierNameGenerator
switch (options.identifierNamesGenerator) {
case IdentifierNamesGenerator.MangledIdentifierNamesGenerator:
identifierNamesGenerator = context.container.getNamed<IIdentifierNamesGenerator>(
ServiceIdentifiers.IIdentifierNamesGenerator,
IdentifierNamesGenerator.MangledIdentifierNamesGenerator
);
break;
case false:
case IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator:
default:
identifierNameGenerator = context.container.getNamed<IIdentifierNameGenerator>(
ServiceIdentifiers.IIdentifierNameGenerator,
IdentifierNameGenerator.HexadecimalIdentifierNameGenerator
identifierNamesGenerator = context.container.getNamed<IIdentifierNamesGenerator>(
ServiceIdentifiers.IIdentifierNamesGenerator,
IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
);
}
cache.set(options.mangle, identifierNameGenerator);
cachedIdentifierNamesGenerator = identifierNamesGenerator;
return identifierNameGenerator;
return identifierNamesGenerator;
};
});
});
+8 -8
View File
@@ -1,11 +1,11 @@
import { inject, injectable } from 'inversify';
import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
import { TIdentifierNameGeneratorFactory } from '../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../types/node/TStatement';
import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode';
import { IIdentifierNameGenerator } from '../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { IIdentifierNamesGenerator } from '../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IOptions } from '../interfaces/options/IOptions';
import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
@@ -35,9 +35,9 @@ export abstract class AbstractCustomNode implements ICustomNode {
protected cachedNode: TStatement[];
/**
* @type {IIdentifierNameGenerator}
* @type {IIdentifierNamesGenerator}
*/
protected readonly identifierNameGenerator: IIdentifierNameGenerator;
protected readonly identifierNamesGenerator: IIdentifierNamesGenerator;
/**
* @type {IOptions}
@@ -50,17 +50,17 @@ export abstract class AbstractCustomNode implements ICustomNode {
protected readonly randomGenerator: IRandomGenerator;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
this.identifierNameGenerator = identifierNameGeneratorFactory(options);
this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
this.randomGenerator = randomGenerator;
this.options = options;
}
+8 -8
View File
@@ -1,12 +1,12 @@
import { inject, injectable } from 'inversify';
import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
import { TIdentifierNameGeneratorFactory } from '../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TNodeWithBlockStatement } from '../types/node/TNodeWithBlockStatement';
import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode';
import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup';
import { IIdentifierNameGenerator } from '../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { IIdentifierNamesGenerator } from '../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IOptions } from '../interfaces/options/IOptions';
import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
import { IStackTraceData } from '../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
@@ -27,9 +27,9 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup {
protected abstract customNodes: Map <CustomNode, ICustomNode>;
/**
* @type {IIdentifierNameGenerator}
* @type {IIdentifierNamesGenerator}
*/
protected readonly identifierNameGenerator: IIdentifierNameGenerator;
protected readonly identifierNamesGenerator: IIdentifierNamesGenerator;
/**
* @type {IOptions}
@@ -47,17 +47,17 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup {
protected readonly stackTraceData: IStackTraceData[];
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
this.identifierNameGenerator = identifierNameGeneratorFactory(options);
this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
this.randomGenerator = randomGenerator;
this.options = options;
}
@@ -17,7 +17,7 @@ import { initializable } from '../../decorators/Initializable';
import { AbstractCustomNode } from '../AbstractCustomNode';
import { NodeUtils } from '../../node/NodeUtils';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
@injectable()
export class ConsoleOutputDisableExpressionNode extends AbstractCustomNode {
@@ -28,17 +28,17 @@ export class ConsoleOutputDisableExpressionNode extends AbstractCustomNode {
private callsControllerFunctionName: string;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -64,7 +64,7 @@ export class ConsoleOutputDisableExpressionNode extends AbstractCustomNode {
: GlobalVariableNoEvalTemplate();
return format(ConsoleOutputDisableExpressionTemplate(), {
consoleLogDisableFunctionName: this.identifierNameGenerator.generate(6),
consoleLogDisableFunctionName: this.identifierNamesGenerator.generate(6),
globalVariableTemplate,
singleNodeCallControllerFunctionName: this.callsControllerFunctionName
});
@@ -2,7 +2,7 @@ import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
@@ -38,18 +38,18 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
/**
* @param {TCustomNodeFactory} customNodeFactory
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.customNodeFactory = customNodeFactory;
}
@@ -92,7 +92,7 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
return;
}
const callsControllerFunctionName: string = this.identifierNameGenerator.generate(6);
const callsControllerFunctionName: string = this.identifierNamesGenerator.generate(6);
const consoleOutputDisableExpressionNode: ICustomNode = this.customNodeFactory(CustomNode.ConsoleOutputDisableExpressionNode);
const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNode.NodeCallsControllerFunctionNode);
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { BinaryOperator } from 'estree';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -24,17 +24,17 @@ export class BinaryExpressionFunctionNode extends AbstractCustomNode {
private operator: BinaryOperator;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as ESTree from 'estree';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -37,17 +37,17 @@ export class BlockStatementControlFlowFlatteningNode extends AbstractCustomNode
private shuffledKeys: number[];
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as ESTree from 'estree';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -24,17 +24,17 @@ export class CallExpressionFunctionNode extends AbstractCustomNode {
private expressionArguments: (ESTree.Expression | ESTree.SpreadElement)[];
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { LogicalOperator } from 'estree';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -24,17 +24,17 @@ export class LogicalExpressionFunctionNode extends AbstractCustomNode {
private operator: LogicalOperator;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -1,7 +1,7 @@
import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -21,17 +21,17 @@ export class StringLiteralNode extends AbstractCustomNode {
private literalValue: string;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -4,7 +4,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import * as ESTree from 'estree';
import { Expression } from 'estree';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../../types/node/TStatement';
import { IOptions } from '../../../interfaces/options/IOptions';
@@ -43,17 +43,17 @@ export class CallExpressionControlFlowStorageCallNode extends AbstractCustomNode
private expressionArguments: (ESTree.Expression | ESTree.SpreadElement)[];
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import * as ESTree from 'estree';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../../types/node/TStatement';
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
@@ -26,17 +26,17 @@ export class ControlFlowStorageNode extends AbstractCustomNode {
private controlFlowStorage: IStorage <ICustomNode>;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import { Expression } from 'estree';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../../types/node/TStatement';
import { IOptions } from '../../../interfaces/options/IOptions';
@@ -42,17 +42,17 @@ export class ExpressionWithOperatorControlFlowStorageCallNode extends AbstractCu
private rightValue: Expression;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -1,7 +1,7 @@
import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../../types/node/TStatement';
import { IOptions } from '../../../interfaces/options/IOptions';
@@ -28,17 +28,17 @@ export class StringLiteralControlFlowStorageCallNode extends AbstractCustomNode
private controlFlowStorageName: string;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -31,17 +31,17 @@ export class DebugProtectionFunctionCallNode extends AbstractCustomNode {
private debugProtectionFunctionName: string;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -25,17 +25,17 @@ export class DebugProtectionFunctionIntervalNode extends AbstractCustomNode {
private debugProtectionFunctionName: string;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -29,17 +29,17 @@ export class DebugProtectionFunctionNode extends AbstractCustomNode {
private debugProtectionFunctionName: string;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -2,7 +2,7 @@ import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
@@ -38,18 +38,18 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
/**
* @param {TCustomNodeFactory} customNodeFactory
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.customNodeFactory = customNodeFactory;
}
@@ -105,8 +105,8 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
return;
}
const debugProtectionFunctionName: string = this.identifierNameGenerator.generate(6);
const callsControllerFunctionName: string = this.identifierNameGenerator.generate(6);
const debugProtectionFunctionName: string = this.identifierNamesGenerator.generate(6);
const callsControllerFunctionName: string = this.identifierNamesGenerator.generate(6);
const debugProtectionFunctionNode: ICustomNode = this.customNodeFactory(CustomNode.DebugProtectionFunctionNode);
const debugProtectionFunctionCallNode: ICustomNode = this.customNodeFactory(CustomNode.DebugProtectionFunctionCallNode);
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { ICryptUtils } from '../../interfaces/utils/ICryptUtils';
@@ -34,19 +34,19 @@ export class DomainLockNode extends AbstractCustomNode {
private readonly cryptUtils: ICryptUtils;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {ICryptUtils} cryptUtils
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.ICryptUtils) cryptUtils: ICryptUtils,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.cryptUtils = cryptUtils;
}
@@ -79,7 +79,7 @@ export class DomainLockNode extends AbstractCustomNode {
: GlobalVariableNoEvalTemplate();
return format(DomainLockNodeTemplate(), {
domainLockFunctionName: this.identifierNameGenerator.generate(6),
domainLockFunctionName: this.identifierNamesGenerator.generate(6),
diff: diff,
domains: hiddenDomainsString,
globalVariableTemplate,
@@ -2,7 +2,7 @@ import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
@@ -38,18 +38,18 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
/**
* @param {TCustomNodeFactory} customNodeFactory
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.customNodeFactory = customNodeFactory;
}
@@ -92,7 +92,7 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
return;
}
const callsControllerFunctionName: string = this.identifierNameGenerator.generate(6);
const callsControllerFunctionName: string = this.identifierNamesGenerator.generate(6);
const domainLockNode: ICustomNode = this.customNodeFactory(CustomNode.DomainLockNode);
const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNode.NodeCallsControllerFunctionNode);
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -36,17 +36,17 @@ export class NodeCallsControllerFunctionNode extends AbstractCustomNode {
private appendEvent: ObfuscationEvent;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -76,7 +76,7 @@ export class NodeCallsControllerFunctionNode extends AbstractCustomNode {
}),
{
...NO_CUSTOM_NODES_PRESET,
mangle: this.options.mangle,
identifierNamesGenerator: this.options.identifierNamesGenerator,
seed: this.options.seed
}
).getObfuscatedCode();
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
@@ -34,19 +34,19 @@ export class SelfDefendingUnicodeNode extends AbstractCustomNode {
private callsControllerFunctionName: string;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IEscapeSequenceEncoder} escapeSequenceEncoder
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.escapeSequenceEncoder = escapeSequenceEncoder;
}
@@ -71,12 +71,12 @@ export class SelfDefendingUnicodeNode extends AbstractCustomNode {
protected getTemplate (): string {
return JavaScriptObfuscator.obfuscate(
format(SelfDefendingTemplate(this.escapeSequenceEncoder), {
selfDefendingFunctionName: this.identifierNameGenerator.generate(6),
selfDefendingFunctionName: this.identifierNamesGenerator.generate(6),
singleNodeCallControllerFunctionName: this.callsControllerFunctionName
}),
{
...NO_CUSTOM_NODES_PRESET,
mangle: this.options.mangle,
identifierNamesGenerator: this.options.identifierNamesGenerator,
seed: this.options.seed,
unicodeEscapeSequence: true
}
@@ -2,7 +2,7 @@ import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
@@ -38,18 +38,18 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
/**
* @param {TCustomNodeFactory} customNodeFactory
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.customNodeFactory = customNodeFactory;
}
@@ -92,7 +92,7 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
return;
}
const callsControllerFunctionName: string = this.identifierNameGenerator.generate(6);
const callsControllerFunctionName: string = this.identifierNamesGenerator.generate(6);
const selfDefendingUnicodeNode: ICustomNode = this.customNodeFactory(CustomNode.SelfDefendingUnicodeNode);
const nodeCallsControllerFunctionNode: ICustomNode = this.customNodeFactory(CustomNode.NodeCallsControllerFunctionNode);
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
@@ -49,19 +49,19 @@ export class StringArrayCallsWrapper extends AbstractCustomNode {
private stringArrayCallsWrapperName: string;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IEscapeSequenceEncoder} escapeSequenceEncoder
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.escapeSequenceEncoder = escapeSequenceEncoder;
}
@@ -99,7 +99,7 @@ export class StringArrayCallsWrapper extends AbstractCustomNode {
}),
{
...NO_CUSTOM_NODES_PRESET,
mangle: this.options.mangle,
identifierNamesGenerator: this.options.identifierNamesGenerator,
seed: this.options.seed
}
).getObfuscatedCode();
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IOptions } from '../../interfaces/options/IOptions';
@@ -39,17 +39,17 @@ export class StringArrayNode extends AbstractCustomNode {
private stringArrayRotateValue: number;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
}
/**
@@ -3,7 +3,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import * as format from 'string-template';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TStatement } from '../../types/node/TStatement';
import { IEscapeSequenceEncoder } from '../../interfaces/utils/IEscapeSequenceEncoder';
@@ -42,19 +42,19 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode {
private stringArrayRotateValue: number;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IEscapeSequenceEncoder} escapeSequenceEncoder
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IEscapeSequenceEncoder) escapeSequenceEncoder: IEscapeSequenceEncoder,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.escapeSequenceEncoder = escapeSequenceEncoder;
}
@@ -82,8 +82,8 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode {
* @returns {string}
*/
protected getTemplate (): string {
const timesName: string = this.identifierNameGenerator.generate(6);
const whileFunctionName: string = this.identifierNameGenerator.generate(6);
const timesName: string = this.identifierNamesGenerator.generate(6);
const whileFunctionName: string = this.identifierNamesGenerator.generate(6);
let code: string = '';
@@ -106,7 +106,7 @@ export class StringArrayRotateFunctionNode extends AbstractCustomNode {
}),
{
...NO_CUSTOM_NODES_PRESET,
mangle: this.options.mangle,
identifierNamesGenerator: this.options.identifierNamesGenerator,
seed: this.options.seed
}
).getObfuscatedCode();
@@ -2,7 +2,7 @@ import { inject, injectable, } from 'inversify';
import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
import { TCustomNodeFactory } from '../../../types/container/custom-nodes/TCustomNodeFactory';
import { TIdentifierNameGeneratorFactory } from '../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { TNodeWithBlockStatement } from '../../../types/node/TNodeWithBlockStatement';
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
@@ -46,19 +46,19 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
/**
* @param {TCustomNodeFactory} customNodeFactory
* @param {IStorage<string>} stringArrayStorage
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__ICustomNode) customNodeFactory: TCustomNodeFactory,
@inject(ServiceIdentifiers.TStringArrayStorage) stringArrayStorage: IStorage<string>,
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(identifierNameGeneratorFactory, randomGenerator, options);
super(identifierNamesGeneratorFactory, randomGenerator, options);
this.customNodeFactory = customNodeFactory;
this.stringArrayStorage = stringArrayStorage;
@@ -1,4 +0,0 @@
export enum IdentifierNameGenerator {
HexadecimalIdentifierNameGenerator,
MangledIdentifierNameGenerator
}
@@ -0,0 +1,4 @@
export enum IdentifierNamesGenerator {
HexadecimalIdentifierNamesGenerator = 'hexadecimal',
MangledIdentifierNamesGenerator = 'mangled'
}
@@ -1,12 +1,12 @@
import { inject, injectable } from 'inversify';
import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { IIdentifierNameGenerator } from '../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { IIdentifierNamesGenerator } from '../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IOptions } from '../../interfaces/options/IOptions';
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
@injectable()
export abstract class AbstractIdentifierNameGenerator implements IIdentifierNameGenerator {
export abstract class AbstractIdentifierNamesGenerator implements IIdentifierNamesGenerator {
/**
* @type {IOptions}
*/
@@ -4,11 +4,11 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { IOptions } from '../../interfaces/options/IOptions';
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
import { AbstractIdentifierNameGenerator } from './AbstractIdentifierNameGenerator';
import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGenerator';
import { Utils } from '../../utils/Utils';
@injectable()
export class HexadecimalIdentifierNameGenerator extends AbstractIdentifierNameGenerator {
export class HexadecimalIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator {
/**
* @type {Set<string>}
*/
@@ -4,10 +4,10 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { IOptions } from '../../interfaces/options/IOptions';
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
import { AbstractIdentifierNameGenerator } from './AbstractIdentifierNameGenerator';
import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGenerator';
@injectable()
export class MangledIdentifierNameGenerator extends AbstractIdentifierNameGenerator {
export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator {
/**
* @type {string}
*/
@@ -32,7 +32,7 @@ export class MangledIdentifierNameGenerator extends AbstractIdentifierNameGenera
/**
* @type {string}
*/
private previousMangledName: string = MangledIdentifierNameGenerator.initMangledNameCharacter;
private previousMangledName: string = MangledIdentifierNamesGenerator.initMangledNameCharacter;
/**
* @param {IRandomGenerator} randomGenerator
@@ -51,7 +51,7 @@ export class MangledIdentifierNameGenerator extends AbstractIdentifierNameGenera
*/
private static generateNewMangledName (previousMangledName: string): string {
const generateNewMangledName: (name: string) => string = (name: string): string => {
const nameSequence: string[] = MangledIdentifierNameGenerator.nameSequence;
const nameSequence: string[] = MangledIdentifierNamesGenerator.nameSequence;
const zeroSequenceCache: string[] = [];
const zeroSequence: (num: number) => string = (num: number): string => {
@@ -87,8 +87,8 @@ export class MangledIdentifierNameGenerator extends AbstractIdentifierNameGenera
let newMangledName: string = generateNewMangledName(previousMangledName);
if (!MangledIdentifierNameGenerator.validateMangledName(newMangledName)) {
newMangledName = MangledIdentifierNameGenerator.generateNewMangledName(newMangledName);
if (!MangledIdentifierNamesGenerator.validateMangledName(newMangledName)) {
newMangledName = MangledIdentifierNamesGenerator.generateNewMangledName(newMangledName);
}
return newMangledName;
@@ -99,7 +99,7 @@ export class MangledIdentifierNameGenerator extends AbstractIdentifierNameGenera
* @returns {boolean}
*/
private static validateMangledName (mangledName: string): boolean {
return !MangledIdentifierNameGenerator.reservedNames.includes(mangledName);
return !MangledIdentifierNamesGenerator.reservedNames.includes(mangledName);
}
/**
@@ -107,7 +107,7 @@ export class MangledIdentifierNameGenerator extends AbstractIdentifierNameGenera
* @returns {string}
*/
public generate (length: number): string {
const newName: string = MangledIdentifierNameGenerator.generateNewMangledName(this.previousMangledName);
const newName: string = MangledIdentifierNamesGenerator.generateNewMangledName(this.previousMangledName);
this.previousMangledName = newName;
@@ -1,4 +1,4 @@
export interface IIdentifierNameGenerator {
export interface IIdentifierNamesGenerator {
/**
* @param {number} length
* @returns {string}
+2 -1
View File
@@ -1,5 +1,6 @@
import { TStringArrayEncoding } from '../../types/options/TStringArrayEncoding';
import { IdentifierNamesGenerator } from '../../enums/generators/identifier-names-generators/IdentifierNamesGenerator';
import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
import { SourceMapMode } from '../../enums/source-map/SourceMapMode';
@@ -13,8 +14,8 @@ export interface IOptions {
readonly debugProtectionInterval: boolean;
readonly disableConsoleOutput: boolean;
readonly domainLock: string[];
readonly identifierNamesGenerator: IdentifierNamesGenerator;
readonly log: boolean;
readonly mangle: boolean;
readonly renameGlobals: boolean;
readonly reservedNames: string[];
readonly rotateStringArray: boolean;
@@ -3,9 +3,9 @@ import { ServiceIdentifiers } from '../../../../container/ServiceIdentifiers';
import * as ESTree from 'estree';
import { TIdentifierNameGeneratorFactory } from '../../../../types/container/generators/TIdentifierNameGeneratorFactory';
import { TIdentifierNamesGeneratorFactory } from '../../../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { IIdentifierNameGenerator } from '../../../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { IIdentifierNamesGenerator } from '../../../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IIdentifierObfuscatingReplacer } from '../../../../interfaces/node-transformers/obfuscating-transformers/obfuscating-replacers/IIdentifierObfuscatingReplacer';
import { IOptions } from '../../../../interfaces/options/IOptions';
@@ -15,9 +15,9 @@ import { Nodes } from '../../../../node/Nodes';
@injectable()
export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplacer implements IIdentifierObfuscatingReplacer {
/**
* @type {IIdentifierNameGenerator}
* @type {IIdentifierNamesGenerator}
*/
private readonly identifierNameGenerator: IIdentifierNameGenerator;
private readonly identifierNamesGenerator: IIdentifierNamesGenerator;
/**
* @type {Map<string, string>}
@@ -25,17 +25,17 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac
private readonly namesMap: Map<string, string> = new Map();
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(options);
this.identifierNameGenerator = identifierNameGeneratorFactory(options);
this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
}
/**
@@ -65,7 +65,7 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac
return;
}
this.namesMap.set(`${nodeName}-${String(nodeIdentifier)}`, this.identifierNameGenerator.generate(6));
this.namesMap.set(`${nodeName}-${String(nodeIdentifier)}`, this.identifierNamesGenerator.generate(6));
}
/**
+8 -4
View File
@@ -21,6 +21,7 @@ import { TStringArrayEncoding } from '../types/options/TStringArrayEncoding';
import { IOptions } from '../interfaces/options/IOptions';
import { IdentifierNamesGenerator } from '../enums/generators/identifier-names-generators/IdentifierNamesGenerator';
import { ObfuscationTarget } from '../enums/ObfuscationTarget';
import { SourceMapMode } from '../enums/source-map/SourceMapMode';
import { StringArrayEncoding } from '../enums/StringArrayEncoding';
@@ -102,16 +103,19 @@ export class Options implements IOptions {
public readonly domainLock: string[];
/**
* @type {boolean}
* @type {IdentifierNamesGenerator}
*/
@IsBoolean()
public readonly log: boolean;
@IsIn([
IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
IdentifierNamesGenerator.MangledIdentifierNamesGenerator
])
public readonly identifierNamesGenerator: IdentifierNamesGenerator;
/**
* @type {boolean}
*/
@IsBoolean()
public readonly mangle: boolean;
public readonly log: boolean;
/**
* @type {boolean}
+2 -1
View File
@@ -1,5 +1,6 @@
import { TInputOptions } from '../../types/options/TInputOptions';
import { IdentifierNamesGenerator } from '../../enums/generators/identifier-names-generators/IdentifierNamesGenerator';
import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
import { SourceMapMode } from '../../enums/source-map/SourceMapMode';
@@ -14,8 +15,8 @@ export const DEFAULT_PRESET: TInputOptions = Object.freeze({
debugProtectionInterval: false,
disableConsoleOutput: false,
domainLock: [],
identifierNamesGenerator: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
log: false,
mangle: false,
renameGlobals: false,
reservedNames: [],
rotateStringArray: true,
+2 -1
View File
@@ -1,5 +1,6 @@
import { TInputOptions } from '../../types/options/TInputOptions';
import { IdentifierNamesGenerator } from '../../enums/generators/identifier-names-generators/IdentifierNamesGenerator';
import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
import { SourceMapMode } from '../../enums/source-map/SourceMapMode';
@@ -13,8 +14,8 @@ export const NO_CUSTOM_NODES_PRESET: TInputOptions = Object.freeze({
debugProtectionInterval: false,
disableConsoleOutput: false,
domainLock: [],
identifierNamesGenerator: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
log: false,
mangle: false,
renameGlobals: false,
reservedNames: [],
rotateStringArray: false,
+10 -10
View File
@@ -4,8 +4,8 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
import { IArrayUtils } from '../../interfaces/utils/IArrayUtils';
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
import { TIdentifierNameGeneratorFactory } from '../../types/container/generators/TIdentifierNameGeneratorFactory';
import { IIdentifierNameGenerator } from '../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
import { IIdentifierNamesGenerator } from '../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IOptions } from '../../interfaces/options/IOptions';
import { ArrayStorage } from '../ArrayStorage';
@@ -18,26 +18,26 @@ export class StringArrayStorage extends ArrayStorage <string> {
private readonly arrayUtils: IArrayUtils;
/**
* @type {IIdentifierNameGenerator}
* @type {IIdentifierNamesGenerator}
*/
private readonly identifierNameGenerator: IIdentifierNameGenerator;
private readonly identifierNamesGenerator: IIdentifierNamesGenerator;
/**
* @param {TIdentifierNameGeneratorFactory} identifierNameGeneratorFactory
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
* @param {IArrayUtils} arrayUtils
* @param {IRandomGenerator} randomGenerator
* @param {IOptions} options
*/
constructor (
@inject(ServiceIdentifiers.Factory__IIdentifierNameGenerator)
identifierNameGeneratorFactory: TIdentifierNameGeneratorFactory,
@inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
@inject(ServiceIdentifiers.IArrayUtils) arrayUtils: IArrayUtils,
@inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@inject(ServiceIdentifiers.IOptions) options: IOptions
) {
super(randomGenerator, options);
this.identifierNameGenerator = identifierNameGeneratorFactory(options);
this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
this.arrayUtils = arrayUtils;
}
@@ -45,8 +45,8 @@ export class StringArrayStorage extends ArrayStorage <string> {
public initialize (): void {
super.initialize();
const stringArrayName: string = this.identifierNameGenerator.generate(4);
const stringArrayCallsWrapperName: string = this.identifierNameGenerator.generate(4);
const stringArrayName: string = this.identifierNamesGenerator.generate(4);
const stringArrayCallsWrapperName: string = this.identifierNamesGenerator.generate(4);
this.storageId = `${stringArrayName}|${stringArrayCallsWrapperName}`;
}
@@ -1,4 +0,0 @@
import { IIdentifierNameGenerator } from '../../../interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { IOptions } from '../../../interfaces/options/IOptions';
export type TIdentifierNameGeneratorFactory = (options: IOptions) => IIdentifierNameGenerator;
@@ -0,0 +1,4 @@
import { IIdentifierNamesGenerator } from '../../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IOptions } from '../../../interfaces/options/IOptions';
export type TIdentifierNamesGeneratorFactory = (options: IOptions) => IIdentifierNamesGenerator;
+1 -1
View File
@@ -35,7 +35,7 @@ import { NO_CUSTOM_NODES_PRESET } from '../../src/options/presets/NoCustomNodes'
{
...NO_CUSTOM_NODES_PRESET,
compact: false,
mangle: true
identifierNamesGenerator: 'mangled'
}
).getObfuscatedCode();
@@ -9,6 +9,8 @@ import { JavaScriptObfuscator } from '../../../src/JavaScriptObfuscatorFacade';
import { NO_CUSTOM_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes';
import { IdentifierNamesGenerator } from '../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
import { buildLargeCode } from '../../helpers/buildLargeCode';
import { getRegExpMatch } from '../../helpers/getRegExpMatch';
import { readFileAsString } from '../../helpers/readFileAsString';
@@ -444,7 +446,7 @@ describe('JavaScriptObfuscator', () => {
});
});
describe('mangle', () => {
describe('mangled identifier names generator', () => {
const regExp: RegExp = /var *c *= *0x1/;
let obfuscatedCode: string;
@@ -454,7 +456,7 @@ describe('JavaScriptObfuscator', () => {
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
code,
{
mangle: true
identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator
}
);
+2 -2
View File
@@ -14,8 +14,8 @@ import './unit-tests/cli/sanitizers/StringArrayEncodingSanitizer.spec';
import './unit-tests/cli/utils/CLIUtils.spec';
import './unit-tests/cli/utils/SourceCodeReader.spec';
import './unit-tests/decorators/initializable/Initializable.spec';
import './unit-tests/generators/identifier-name-generators/HexadecimalIdentifierNameGenerator.spec';
import './unit-tests/generators/identifier-name-generators/MangledlIdentifierNameGenerator.spec';
import './unit-tests/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.spec';
import './unit-tests/generators/identifier-names-generators/MangledlIdentifierNamesGenerator.spec';
import './unit-tests/javascript-obfuscator/JavaScriptObfuscator.spec';
import './unit-tests/logger/Logger.spec';
import './unit-tests/node/node-appender/NodeAppender.spec';
@@ -4,16 +4,16 @@ import { assert } from 'chai';
import { ServiceIdentifiers } from '../../../../src/container/ServiceIdentifiers';
import { IIdentifierNameGenerator } from '../../../../src/interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { IIdentifierNamesGenerator } from '../../../../src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
import { IdentifierNameGenerator } from '../../../../src/enums/generators/identifier-name-generators/IdentifierNameGenerator';
import { IdentifierNamesGenerator } from '../../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
import { InversifyContainerFacade } from '../../../../src/container/InversifyContainerFacade';
describe('HexadecimalIdentifierNameGenerator', () => {
describe('HexadecimalIdentifierNamesGenerator', () => {
describe('generate (length: number): string', () => {
let identifierNameGenerator: IIdentifierNameGenerator,
let identifierNamesGenerator: IIdentifierNamesGenerator,
hexadecimalIdentifierName: string,
regExp: RegExp;
@@ -21,15 +21,15 @@ describe('HexadecimalIdentifierNameGenerator', () => {
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
inversifyContainerFacade.load('', {});
identifierNameGenerator = inversifyContainerFacade.getNamed<IIdentifierNameGenerator>(
ServiceIdentifiers.IIdentifierNameGenerator,
IdentifierNameGenerator.HexadecimalIdentifierNameGenerator
identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
ServiceIdentifiers.IIdentifierNamesGenerator,
IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
)
});
describe('variant #1: hexadecimal name with length `4`', () => {
before(() => {
hexadecimalIdentifierName = identifierNameGenerator.generate(4);
hexadecimalIdentifierName = identifierNamesGenerator.generate(4);
regExp = /^_0x(\w){4}$/;
});
@@ -40,7 +40,7 @@ describe('HexadecimalIdentifierNameGenerator', () => {
describe('variant #2: hexadecimal name with length `6`', () => {
before(() => {
hexadecimalIdentifierName = identifierNameGenerator.generate(6);
hexadecimalIdentifierName = identifierNamesGenerator.generate(6);
regExp = /^_0x(\w){4,6}$/;
});
@@ -4,25 +4,25 @@ import { assert } from 'chai';
import { ServiceIdentifiers } from '../../../../src/container/ServiceIdentifiers';
import { IIdentifierNameGenerator } from '../../../../src/interfaces/generators/identifier-name-generators/IIdentifierNameGenerator';
import { IIdentifierNamesGenerator } from '../../../../src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
import { IdentifierNameGenerator } from '../../../../src/enums/generators/identifier-name-generators/IdentifierNameGenerator';
import { IdentifierNamesGenerator } from '../../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
import { InversifyContainerFacade } from '../../../../src/container/InversifyContainerFacade';
describe('MangledIdentifierNameGenerator', () => {
describe('MangledIdentifierNamesGenerator', () => {
describe('generate (length: number): string', () => {
let identifierNameGenerator: IIdentifierNameGenerator,
let identifierNamesGenerator: IIdentifierNamesGenerator,
mangledIdentifierName: string;
before(() => {
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
inversifyContainerFacade.load('', {});
identifierNameGenerator = inversifyContainerFacade.getNamed<IIdentifierNameGenerator>(
ServiceIdentifiers.IIdentifierNameGenerator,
IdentifierNameGenerator.MangledIdentifierNameGenerator
identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
ServiceIdentifiers.IIdentifierNamesGenerator,
IdentifierNamesGenerator.MangledIdentifierNamesGenerator
)
});
@@ -30,7 +30,7 @@ describe('MangledIdentifierNameGenerator', () => {
const expectedMangledIdentifierName: string = 'a';
before(() => {
mangledIdentifierName = identifierNameGenerator.generate(4);
mangledIdentifierName = identifierNamesGenerator.generate(4);
});
it('should return hexadecimal name', () => {
@@ -42,7 +42,7 @@ describe('MangledIdentifierNameGenerator', () => {
const expectedMangledIdentifierName: string = 'b';
before(() => {
mangledIdentifierName = identifierNameGenerator.generate(6);
mangledIdentifierName = identifierNamesGenerator.generate(6);
});
it('should return hexadecimal name', () => {
@@ -55,7 +55,7 @@ describe('MangledIdentifierNameGenerator', () => {
before(() => {
for (let i: number = 0; i <= 49; i++) {
mangledIdentifierName = identifierNameGenerator.generate(6);
mangledIdentifierName = identifierNamesGenerator.generate(6);
}
});
@@ -69,7 +69,7 @@ describe('MangledIdentifierNameGenerator', () => {
before(() => {
for (let i: number = 0; i < 1; i++) {
mangledIdentifierName = identifierNameGenerator.generate(6);
mangledIdentifierName = identifierNamesGenerator.generate(6);
}
});
@@ -83,7 +83,7 @@ describe('MangledIdentifierNameGenerator', () => {
before(() => {
for (let i: number = 0; i < 10; i++) {
mangledIdentifierName = identifierNameGenerator.generate(6);
mangledIdentifierName = identifierNamesGenerator.generate(6);
}
});
+31 -21
View File
@@ -2,19 +2,19 @@
# yarn lockfile v1
"@types/chai@4.0.6":
version "4.0.6"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.6.tgz#9cb5a7fb7dd83be0cfcaafdbd95a2b5dd351762f"
"@types/chai@4.0.7":
version "4.0.7"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.7.tgz#cab25b9fcb45903fe6c7fa716dc6394314c13dd8"
"@types/chance@0.7.35":
version "0.7.35"
resolved "https://registry.yarnpkg.com/@types/chance/-/chance-0.7.35.tgz#e76f3441b7763476c58eb7dc32f62da3d8ea547e"
"@types/commander@2.11.0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@types/commander/-/commander-2.11.0.tgz#7fc765ccad14827e2babd6a99583359ff3e40563"
"@types/commander@2.12.2":
version "2.12.2"
resolved "https://registry.yarnpkg.com/@types/commander/-/commander-2.12.2.tgz#183041a23842d4281478fa5d23c5ca78e6fd08ae"
dependencies:
"@types/node" "*"
commander "*"
"@types/escodegen@0.0.6":
version "0.0.6"
@@ -36,15 +36,19 @@
version "0.0.38"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.38.tgz#c1be40aa933723c608820a99a373a16d215a1ca2"
"@types/events@*":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-1.1.0.tgz#93b1be91f63c184450385272c47b6496fd028e02"
"@types/md5@2.1.32":
version "2.1.32"
resolved "https://registry.yarnpkg.com/@types/md5/-/md5-2.1.32.tgz#93e23437fcd17a7b9ca98d02aa6002e835842fe8"
dependencies:
"@types/node" "*"
"@types/mkdirp@0.5.1":
version "0.5.1"
resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.1.tgz#ea887cd024f691c1ca67cce20b7606b053e43b0f"
"@types/mkdirp@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f"
dependencies:
"@types/node" "*"
@@ -52,10 +56,16 @@
version "2.2.44"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.44.tgz#1d4a798e53f35212fd5ad4d04050620171cd5b5e"
"@types/node@*", "@types/node@8.0.53":
"@types/node@*":
version "8.0.53"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.53.tgz#396b35af826fa66aad472c8cb7b8d5e277f4e6d8"
"@types/node@8.0.54":
version "8.0.54"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.54.tgz#3fd9357db4af388b79e03845340259440edffde6"
dependencies:
"@types/events" "*"
"@types/sinon@4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-4.0.0.tgz#9a93ffa4ee1329e85166278a5ed99f81dc4c8362"
@@ -1054,14 +1064,14 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"
commander@*, commander@2.12.2, commander@^2.11.0, commander@^2.9.0:
version "2.12.2"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555"
commander@2.11.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"
commander@2.12.2, commander@^2.11.0, commander@^2.9.0:
version "2.12.2"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555"
commondir@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
@@ -3670,9 +3680,9 @@ tslint-eslint-rules@4.1.1:
tslib "^1.0.0"
tsutils "^1.4.0"
tslint-language-service@0.9.6:
version "0.9.6"
resolved "https://registry.yarnpkg.com/tslint-language-service/-/tslint-language-service-0.9.6.tgz#882bb0704cf8397b332ddc0af7168c7f22f279ea"
tslint-language-service@0.9.7:
version "0.9.7"
resolved "https://registry.yarnpkg.com/tslint-language-service/-/tslint-language-service-0.9.7.tgz#94a35442bc1163e4629df8804e6fa694ced549ff"
tslint-webpack-plugin@1.0.0:
version "1.0.0"
@@ -3872,9 +3882,9 @@ webpack-sources@^1.0.1:
source-list-map "^2.0.0"
source-map "~0.5.3"
webpack@3.9.1:
version "3.9.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.9.1.tgz#9a60aa544ed5d4d454c069e3f521aa007e02643c"
webpack@3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.10.0.tgz#5291b875078cf2abf42bdd23afe3f8f96c17d725"
dependencies:
acorn "^5.0.0"
acorn-dynamic-import "^2.0.0"