Pārlūkot izejas kodu

Merge pull request #175 from javascript-obfuscator/custom-nodes-transformer

Custom nodes transformer
Timofey Kachalov 7 gadi atpakaļ
vecāks
revīzija
be150f7307

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
dist/index.js


+ 1 - 48
src/JavaScriptObfuscator.ts

@@ -6,23 +6,17 @@ import * as escodegen from 'escodegen-wallaby';
 import * as ESTree from 'estree';
 import * as packageJson from 'pjson';
 
-import { ICustomNodeGroup } from './interfaces/custom-nodes/ICustomNodeGroup';
 import { IGeneratorOutput } from './interfaces/IGeneratorOutput';
 import { IJavaScriptObfuscator } from './interfaces/IJavaScriptObfsucator';
 import { ILogger } from './interfaces/logger/ILogger';
-import { IObfuscationEventEmitter } from './interfaces/event-emitters/IObfuscationEventEmitter';
 import { IObfuscationResult } from './interfaces/IObfuscationResult';
 import { IOptions } from './interfaces/options/IOptions';
 import { IRandomGenerator } from './interfaces/utils/IRandomGenerator';
 import { ISourceMapCorrector } from './interfaces/source-map/ISourceMapCorrector';
-import { IStackTraceAnalyzer } from './interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer';
-import { IStackTraceData } from './interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
-import { IStorage } from './interfaces/storages/IStorage';
 import { ITransformersRunner } from './interfaces/node-transformers/ITransformersRunner';
 
 import { LoggingMessage } from './enums/logger/LoggingMessage';
 import { NodeTransformer } from './enums/node-transformers/NodeTransformer';
-import { ObfuscationEvent } from './enums/event-emitters/ObfuscationEvent';
 import { TransformationStage } from './enums/node-transformers/TransformationStage';
 
 import { NodeGuards } from './node/NodeGuards';
@@ -45,6 +39,7 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
         NodeTransformer.BlockStatementControlFlowTransformer,
         NodeTransformer.ClassDeclarationTransformer,
         NodeTransformer.CommentsTransformer,
+        NodeTransformer.CustomNodesTransformer,
         NodeTransformer.DeadCodeInjectionTransformer,
         NodeTransformer.EvalCallExpressionTransformer,
         NodeTransformer.FunctionControlFlowTransformer,
@@ -63,21 +58,11 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
         NodeTransformer.VariableDeclarationTransformer
     ];
 
-    /**
-     * @type {IStorage<ICustomNodeGroup>}
-     */
-    private readonly customNodeGroupStorage: IStorage<ICustomNodeGroup>;
-
     /**
      * @type {ILogger}
      */
     private readonly logger: ILogger;
 
-    /**
-     * @type {IObfuscationEventEmitter}
-     */
-    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
-
     /**
      * @type {IOptions}
      */
@@ -93,20 +78,12 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
      */
     private readonly sourceMapCorrector: ISourceMapCorrector;
 
-    /**
-     * @type {IStackTraceAnalyzer}
-     */
-    private readonly stackTraceAnalyzer: IStackTraceAnalyzer;
-
     /**
      * @type {ITransformersRunner}
      */
     private readonly transformersRunner: ITransformersRunner;
 
     /**
-     * @param {IStackTraceAnalyzer} stackTraceAnalyzer
-     * @param {IObfuscationEventEmitter} obfuscationEventEmitter
-     * @param {IStorage<ICustomNodeGroup>} customNodeGroupStorage
      * @param {ITransformersRunner} transformersRunner
      * @param {ISourceMapCorrector} sourceMapCorrector
      * @param {IRandomGenerator} randomGenerator
@@ -114,18 +91,12 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
      * @param {IOptions} options
      */
     constructor (
-        @inject(ServiceIdentifiers.IStackTraceAnalyzer) stackTraceAnalyzer: IStackTraceAnalyzer,
-        @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
-        @inject(ServiceIdentifiers.TCustomNodeGroupStorage) customNodeGroupStorage: IStorage<ICustomNodeGroup>,
         @inject(ServiceIdentifiers.ITransformersRunner) transformersRunner: ITransformersRunner,
         @inject(ServiceIdentifiers.ISourceMapCorrector) sourceMapCorrector: ISourceMapCorrector,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.ILogger) logger: ILogger,
         @inject(ServiceIdentifiers.IOptions) options: IOptions
     ) {
-        this.stackTraceAnalyzer = stackTraceAnalyzer;
-        this.obfuscationEventEmitter = obfuscationEventEmitter;
-        this.customNodeGroupStorage = customNodeGroupStorage;
         this.transformersRunner = transformersRunner;
         this.sourceMapCorrector = sourceMapCorrector;
         this.randomGenerator = randomGenerator;
@@ -186,22 +157,6 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
 
         astTree = this.runTransformationStage(astTree, TransformationStage.Preparing);
 
-        this.logger.info(LoggingMessage.AnalyzingASTTreeStage);
-        const stackTraceData: IStackTraceData[] = this.stackTraceAnalyzer.analyze(astTree);
-
-        this.customNodeGroupStorage
-            .getStorage()
-            .forEach((customNodeGroup: ICustomNodeGroup) => {
-                customNodeGroup.initialize();
-
-                this.obfuscationEventEmitter.once(
-                    customNodeGroup.getAppendEvent(),
-                    customNodeGroup.appendCustomNodes.bind(customNodeGroup)
-                );
-            });
-
-        this.obfuscationEventEmitter.emit(ObfuscationEvent.BeforeObfuscation, astTree, stackTraceData);
-
         if (this.options.deadCodeInjection) {
             astTree = this.runTransformationStage(astTree, TransformationStage.DeadCodeInjection);
         }
@@ -214,8 +169,6 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
         astTree = this.runTransformationStage(astTree, TransformationStage.Obfuscating);
         astTree = this.runTransformationStage(astTree, TransformationStage.Finalizing);
 
-        this.obfuscationEventEmitter.emit(ObfuscationEvent.AfterObfuscation, astTree, stackTraceData);
-
         return astTree;
     }
 

+ 5 - 0
src/container/modules/node-transformers/PreparingTransformersModule.ts

@@ -11,6 +11,7 @@ import { ObfuscatingGuard } from '../../../enums/node-transformers/preparing-tra
 import { BlackListObfuscatingGuard } from '../../../node-transformers/preparing-transformers/obfuscating-guards/BlackListObfuscatingGuard';
 import { CommentsTransformer } from '../../../node-transformers/preparing-transformers/CommentsTransformer';
 import { ConditionalCommentObfuscatingGuard } from '../../../node-transformers/preparing-transformers/obfuscating-guards/ConditionalCommentObfuscatingGuard';
+import { CustomNodesTransformer } from '../../../node-transformers/preparing-transformers/CustomNodesTransformer';
 import { EvalCallExpressionTransformer } from '../../../node-transformers/preparing-transformers/EvaCallExpressionTransformer';
 import { ObfuscatingGuardsTransformer } from '../../../node-transformers/preparing-transformers/ObfuscatingGuardsTransformer';
 import { ParentificationTransformer } from '../../../node-transformers/preparing-transformers/ParentificationTransformer';
@@ -21,6 +22,10 @@ export const preparingTransformersModule: interfaces.ContainerModule = new Conta
         .to(CommentsTransformer)
         .whenTargetNamed(NodeTransformer.CommentsTransformer);
 
+    bind<INodeTransformer>(ServiceIdentifiers.INodeTransformer)
+        .to(CustomNodesTransformer)
+        .whenTargetNamed(NodeTransformer.CustomNodesTransformer);
+
     bind<INodeTransformer>(ServiceIdentifiers.INodeTransformer)
         .to(EvalCallExpressionTransformer)
         .whenTargetNamed(NodeTransformer.EvalCallExpressionTransformer);

+ 15 - 14
src/custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode.ts

@@ -48,21 +48,22 @@ export class BinaryExpressionFunctionNode extends AbstractCustomNode {
      * @returns {TStatement[]}
      */
     protected getNodeStructure (): TStatement[] {
-        const structure: TStatement = Nodes.getFunctionDeclarationNode(
-            this.randomGenerator.getRandomString(3),
-            [
-                Nodes.getIdentifierNode('x'),
-                Nodes.getIdentifierNode('y')
-            ],
-            Nodes.getBlockStatementNode([
-                Nodes.getReturnStatementNode(
-                    Nodes.getBinaryExpressionNode(
-                        this.operator,
-                        Nodes.getIdentifierNode('x'),
-                        Nodes.getIdentifierNode('y')
+        const structure: TStatement = Nodes.getExpressionStatementNode(
+            Nodes.getFunctionExpressionNode(
+                [
+                    Nodes.getIdentifierNode('x'),
+                    Nodes.getIdentifierNode('y')
+                ],
+                Nodes.getBlockStatementNode([
+                    Nodes.getReturnStatementNode(
+                        Nodes.getBinaryExpressionNode(
+                            this.operator,
+                            Nodes.getIdentifierNode('x'),
+                            Nodes.getIdentifierNode('y')
+                        )
                     )
-                )
-            ])
+                ])
+            )
         );
 
         NodeUtils.parentize(structure);

+ 14 - 13
src/custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode.ts

@@ -56,20 +56,21 @@ export class CallExpressionFunctionNode extends AbstractCustomNode {
             params.push(Nodes.getIdentifierNode(`param${i + 1}`));
         }
 
-        const structure: TStatement = Nodes.getFunctionDeclarationNode(
-            this.randomGenerator.getRandomString(3),
-            [
-                calleeIdentifier,
-                ...params
-            ],
-            Nodes.getBlockStatementNode([
-                Nodes.getReturnStatementNode(
-                    Nodes.getCallExpressionNode(
-                        calleeIdentifier,
-                        params
+        const structure: TStatement = Nodes.getExpressionStatementNode(
+            Nodes.getFunctionExpressionNode(
+                [
+                    calleeIdentifier,
+                    ...params
+                ],
+                Nodes.getBlockStatementNode([
+                    Nodes.getReturnStatementNode(
+                        Nodes.getCallExpressionNode(
+                            calleeIdentifier,
+                            params
+                        )
                     )
-                )
-            ])
+                ])
+            )
         );
 
         NodeUtils.parentize(structure);

+ 15 - 14
src/custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode.ts

@@ -48,21 +48,22 @@ export class LogicalExpressionFunctionNode extends AbstractCustomNode {
      * @returns {TStatement[]}
      */
     protected getNodeStructure (): TStatement[] {
-        const structure: TStatement = Nodes.getFunctionDeclarationNode(
-            this.randomGenerator.getRandomString(3),
-            [
-                Nodes.getIdentifierNode('x'),
-                Nodes.getIdentifierNode('y')
-            ],
-            Nodes.getBlockStatementNode([
-                Nodes.getReturnStatementNode(
-                    Nodes.getLogicalExpressionNode(
-                        this.operator,
-                        Nodes.getIdentifierNode('x'),
-                        Nodes.getIdentifierNode('y')
+        const structure: TStatement = Nodes.getExpressionStatementNode(
+            Nodes.getFunctionExpressionNode(
+                [
+                    Nodes.getIdentifierNode('x'),
+                    Nodes.getIdentifierNode('y')
+                ],
+                Nodes.getBlockStatementNode([
+                    Nodes.getReturnStatementNode(
+                        Nodes.getLogicalExpressionNode(
+                            this.operator,
+                            Nodes.getIdentifierNode('x'),
+                            Nodes.getIdentifierNode('y')
+                        )
                     )
-                )
-            ])
+                ])
+            )
         );
 
         NodeUtils.parentize(structure);

+ 3 - 1
src/custom-nodes/control-flow-flattening-nodes/StringLiteralNode.ts

@@ -45,7 +45,9 @@ export class StringLiteralNode extends AbstractCustomNode {
      * @returns {TStatement[]}
      */
     protected getNodeStructure (): TStatement[] {
-        const structure: TStatement = <any>Nodes.getLiteralNode(this.literalValue);
+        const structure: TStatement = Nodes.getExpressionStatementNode(
+            Nodes.getLiteralNode(this.literalValue)
+        );
 
         return [structure];
     }

+ 17 - 10
src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.ts

@@ -14,6 +14,7 @@ import { IStorage } from '../../../interfaces/storages/IStorage';
 import { initializable } from '../../../decorators/Initializable';
 
 import { AbstractCustomNode } from '../../AbstractCustomNode';
+import { NodeGuards } from '../../../node/NodeGuards';
 import { Nodes } from '../../../node/Nodes';
 import { NodeUtils } from '../../../node/NodeUtils';
 
@@ -50,19 +51,25 @@ export class ControlFlowStorageNode extends AbstractCustomNode {
      * @returns {TStatement[]}
      */
     protected getNodeStructure (): TStatement[] {
+        const propertyNodes: ESTree.Property[] = Array
+            .from<[string, ICustomNode]>(this.controlFlowStorage.getStorage())
+            .map(([key, value]: [string, ICustomNode]) => {
+                const node: ESTree.Node = value.getNode()[0];
+
+                if (!NodeGuards.isExpressionStatementNode(node)) {
+                    throw new Error('Function node for control flow storage object should be passed inside the `ExpressionStatement` node!');
+                }
+
+                return Nodes.getPropertyNode(
+                    Nodes.getIdentifierNode(key),
+                    node.expression
+                );
+            });
+
         let structure: ESTree.Node = Nodes.getVariableDeclarationNode([
             Nodes.getVariableDeclaratorNode(
                 Nodes.getIdentifierNode(this.controlFlowStorage.getStorageId()),
-                Nodes.getObjectExpressionNode(
-                    Array
-                        .from<[string, ICustomNode]>(this.controlFlowStorage.getStorage())
-                        .map(([key, value]: [string, ICustomNode]) => {
-                            return Nodes.getPropertyNode(
-                                Nodes.getIdentifierNode(key),
-                                <any>value.getNode()[0]
-                            );
-                        })
-                )
+                Nodes.getObjectExpressionNode(propertyNodes)
             )
         ]);
 

+ 0 - 1
src/enums/logger/LoggingMessage.ts

@@ -1,5 +1,4 @@
 export enum LoggingMessage {
-    AnalyzingASTTreeStage = 'Stage: analyzing AST-tree...',
     EmptySourceCode = 'Empty source code. Obfuscation canceled...',
     ObfuscationCompleted = 'Obfuscation completed. Total time: %s sec.',
     ObfuscationStarted = 'Obfuscation started...',

+ 1 - 0
src/enums/node-transformers/NodeTransformer.ts

@@ -2,6 +2,7 @@ export enum NodeTransformer {
     BlockStatementControlFlowTransformer = 'BlockStatementControlFlowTransformer',
     ClassDeclarationTransformer = 'ClassDeclarationTransformer',
     CommentsTransformer = 'CommentsTransformer',
+    CustomNodesTransformer = 'CustomNodesTransformer',
     DeadCodeInjectionTransformer = 'DeadCodeInjectionTransformer',
     EvalCallExpressionTransformer = 'EvalCallExpressionTransformer',
     FunctionControlFlowTransformer = 'FunctionControlFlowTransformer',

+ 2 - 2
src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.ts

@@ -244,7 +244,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
         parentNode: ESTree.Node
     ): ESTree.BlockStatement {
         /**
-         * we should wrap original random block statement node into the parent block statement node (ast root host node)
+         * Should wrap original random block statement node into the parent block statement node (ast root host node)
          * with function declaration node. This function declaration node will create block scope for all identifiers
          * inside random block statement node and this identifiers won't affect identifiers of the rest AST tree.
          */
@@ -257,7 +257,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
         ]);
 
         /**
-         * we should store that host node and then extract random block statement node on the `finalizing` stage
+         * Should store that host node and then extract random block statement node on the `finalizing` stage
          */
         this.deadCodeInjectionRootAstHostNodeSet.add(deadCodeInjectionRootAstHostNode);
 

+ 142 - 0
src/node-transformers/preparing-transformers/CustomNodesTransformer.ts

@@ -0,0 +1,142 @@
+import { inject, injectable, } from 'inversify';
+import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
+
+import * as ESTree from 'estree';
+
+import { ICustomNodeGroup } from '../../interfaces/custom-nodes/ICustomNodeGroup';
+import { IObfuscationEventEmitter } from '../../interfaces/event-emitters/IObfuscationEventEmitter';
+import { IOptions } from '../../interfaces/options/IOptions';
+import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
+import { IStackTraceAnalyzer } from '../../interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer';
+import { IStackTraceData } from '../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { IStorage } from '../../interfaces/storages/IStorage';
+import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
+
+import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent';
+import { TransformationStage } from '../../enums/node-transformers/TransformationStage';
+
+import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
+import { NodeGuards } from '../../node/NodeGuards';
+
+/**
+ * Analyzing AST-tree and appending custom nodes
+ */
+@injectable()
+export class CustomNodesTransformer extends AbstractNodeTransformer {
+    /**
+     * @type {IStorage<ICustomNodeGroup>}
+     */
+    private readonly customNodeGroupStorage: IStorage<ICustomNodeGroup>;
+
+    /**
+     * @type {IObfuscationEventEmitter}
+     */
+    private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
+
+    /**
+     * @type {IStackTraceAnalyzer}
+     */
+    private readonly stackTraceAnalyzer: IStackTraceAnalyzer;
+
+    /**
+     * @type {IStackTraceData[]}
+     */
+    private stackTraceData: IStackTraceData[];
+
+    /**
+     * @param {IStackTraceAnalyzer} stackTraceAnalyzer
+     * @param {IObfuscationEventEmitter} obfuscationEventEmitter
+     * @param {IStorage<ICustomNodeGroup>} customNodeGroupStorage
+     * @param {IRandomGenerator} randomGenerator
+     * @param {IOptions} options
+     */
+    constructor (
+        @inject(ServiceIdentifiers.IStackTraceAnalyzer) stackTraceAnalyzer: IStackTraceAnalyzer,
+        @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
+        @inject(ServiceIdentifiers.TCustomNodeGroupStorage) customNodeGroupStorage: IStorage<ICustomNodeGroup>,
+        @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
+        @inject(ServiceIdentifiers.IOptions) options: IOptions
+    ) {
+        super(randomGenerator, options);
+
+        this.stackTraceAnalyzer = stackTraceAnalyzer;
+        this.obfuscationEventEmitter = obfuscationEventEmitter;
+        this.customNodeGroupStorage = customNodeGroupStorage;
+    }
+
+    /**
+     * @param {TransformationStage} transformationStage
+     * @returns {IVisitor | null}
+     */
+    public getVisitor (transformationStage: TransformationStage): IVisitor | null {
+        switch (transformationStage) {
+            case TransformationStage.Preparing:
+                return {
+                    leave: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                        if (NodeGuards.isProgramNode(node)) {
+                            this.analyzeNode(node, parentNode);
+                            this.appendCustomNodesBeforeObfuscation(node, parentNode);
+
+                            return this.transformNode(node, parentNode);
+                        }
+                    }
+                };
+
+            case TransformationStage.Finalizing:
+                return {
+                    leave: (node: ESTree.Node, parentNode: ESTree.Node | null) => {
+                        if (NodeGuards.isProgramNode(node)) {
+                            this.appendCustomNodesAfterObfuscation(node, parentNode);
+                        }
+                    }
+                };
+
+            default:
+                return null;
+        }
+    }
+
+    /**
+     * @param {Program} node
+     * @param {Node | null} parentNode
+     */
+    public analyzeNode (node: ESTree.Program, parentNode: ESTree.Node | null): void {
+        this.stackTraceData = this.stackTraceAnalyzer.analyze(node);
+    }
+
+    /**
+     * @param {Program} node
+     * @param {Node | null} parentNode
+     * @returns {Node}
+     */
+    public transformNode (node: ESTree.Program, parentNode: ESTree.Node | null): ESTree.Node {
+        return node;
+    }
+
+    /**
+     * @param {Program} node
+     * @param {Node | null} parentNode
+     */
+    private appendCustomNodesBeforeObfuscation (node: ESTree.Program, parentNode: ESTree.Node | null): void {
+        this.customNodeGroupStorage
+            .getStorage()
+            .forEach((customNodeGroup: ICustomNodeGroup) => {
+                customNodeGroup.initialize();
+
+                this.obfuscationEventEmitter.once(
+                    customNodeGroup.getAppendEvent(),
+                    customNodeGroup.appendCustomNodes.bind(customNodeGroup)
+                );
+            });
+
+        this.obfuscationEventEmitter.emit(ObfuscationEvent.BeforeObfuscation, node, this.stackTraceData);
+    }
+
+    /**
+     * @param {Program} node
+     * @param {Node | null} parentNode
+     */
+    private appendCustomNodesAfterObfuscation (node: ESTree.Program, parentNode: ESTree.Node | null): void {
+        this.obfuscationEventEmitter.emit(ObfuscationEvent.AfterObfuscation, node, this.stackTraceData);
+    }
+}

+ 5 - 5
test/functional-tests/node-transformers/control-flow-transformers/function-control-flow-transformer/FunctionControlFlowTransformer.spec.ts

@@ -14,14 +14,14 @@ describe('FunctionControlFlowTransformer', function () {
     const variableMatch: string = '_0x([a-f0-9]){4,6}';
     const rootControlFlowStorageNodeMatch: string = `` +
         `var *${variableMatch} *= *\\{` +
-            `'\\w{5}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
+            `'\\w{5}' *: *function *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
                 `return *${variableMatch} *\\+ *${variableMatch};` +
             `\\}` +
         `\\};` +
     ``;
     const innerControlFlowStorageNodeMatch: string = `` +
         `var *${variableMatch} *= *\\{` +
-            `'\\w{5}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
+            `'\\w{5}' *: *function *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
                 `return *${variableMatch}\\['\\w{5}'\\]\\(${variableMatch}, *${variableMatch}\\);` +
             `\\}` +
         `\\};` +
@@ -107,10 +107,10 @@ describe('FunctionControlFlowTransformer', function () {
         describe('variant #3 - single `control flow storage` node with multiple items', () => {
             const regexp: RegExp = new RegExp(
                 `var *${variableMatch} *= *\\{` +
-                    `'\\w{5}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
+                    `'\\w{5}' *: *function *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
                         `return *${variableMatch} *\\+ *${variableMatch};` +
                     `\\}, *` +
-                    `'\\w{5}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
+                    `'\\w{5}' *: *function *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
                         `return *${variableMatch} *- *${variableMatch};` +
                     `\\}` +
                 `\\};`
@@ -167,7 +167,7 @@ describe('FunctionControlFlowTransformer', function () {
 
             const regExp: RegExp = new RegExp(
                 `var *[a-zA-Z]{6} *= *\\{` +
-                    `'\\w{5}' *: *function *_0x[0-9] *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
+                    `'\\w{5}' *: *function *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
                         `return *${variableMatch} *\\+ *${variableMatch};` +
                     `\\}` +
                 `\\};`

+ 1 - 1
test/functional-tests/node-transformers/converting-transformers/object-expression-keys-transformer/ObjectExpressionKeysTransformer.spec.ts

@@ -106,7 +106,7 @@ describe('ObjectExpressionKeysTransformer', () => {
         describe('variant #4: correct integration with control flow flattening object', () => {
             const match: string = `` +
                 `var *${variableMatch} *= *{};` +
-                `${variableMatch}\\['\\w{5}'] *= *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *{` +
+                `${variableMatch}\\['\\w{5}'] *= *function *\\(${variableMatch}, *${variableMatch}\\) *{` +
                     `return *${variableMatch} *\\+ *${variableMatch};` +
                 `};` +
                 `var *${variableMatch} *= *${variableMatch}\\['\\w{5}']\\(0x1, *0x2\\);` +

+ 1 - 1
test/functional-tests/node-transformers/preparing-transformers/eval-call-expression-transformer/EvalCallExpressionTransformer.spec.ts

@@ -291,7 +291,7 @@ describe('EvalCallExpressionTransformer', () => {
         const variableMatch: string = '_0x([a-f0-9]){4,6}';
         const controlFlowStorageNodeMatch: string = `` +
             `var *${variableMatch} *= *\\{` +
-                `'\\w{5}' *: *function *${variableMatch} *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
+                `'\\w{5}' *: *function *\\(${variableMatch}, *${variableMatch}\\) *\\{` +
                     `return *${variableMatch} *\\+ *${variableMatch};` +
                 `\\}` +
             `\\};` +

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels