Bladeren bron

Merge pull request #483 from javascript-obfuscator/stack-trace-analazer-rename

StackTraceAnalyzer rename to CallsGraphAnalyzer
Timofey Kachalov 5 jaren geleden
bovenliggende
commit
023c5b54a7
42 gewijzigde bestanden met toevoegingen van 226 en 226 verwijderingen
  1. 0 0
      dist/index.browser.js
  2. 0 0
      dist/index.cli.js
  3. 0 0
      dist/index.js
  4. 22 22
      src/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.ts
  5. 2 2
      src/analyzers/calls-graph-analyzer/callee-data-extractors/AbstractCalleeDataExtractor.ts
  6. 1 1
      src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts
  7. 1 1
      src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts
  8. 2 2
      src/analyzers/calls-graph-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts
  9. 1 1
      src/container/ServiceIdentifiers.ts
  10. 10 10
      src/container/modules/analyzers/AnalyzersModule.ts
  11. 6 6
      src/custom-nodes/AbstractCustomNodeGroup.ts
  12. 8 8
      src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts
  13. 8 8
      src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts
  14. 8 8
      src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts
  15. 8 8
      src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts
  16. 3 3
      src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts
  17. 0 0
      src/enums/analyzers/calls-graph-analyzer/CalleeDataExtractor.ts
  18. 0 0
      src/interfaces/analyzers/calls-graph-analyzer/ICalleeData.d.ts
  19. 0 0
      src/interfaces/analyzers/calls-graph-analyzer/ICalleeDataExtractor.d.ts
  20. 12 0
      src/interfaces/analyzers/calls-graph-analyzer/ICallsGraphAnalyzer.d.ts
  21. 5 0
      src/interfaces/analyzers/calls-graph-analyzer/ICallsGraphData.d.ts
  22. 0 12
      src/interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer.d.ts
  23. 0 5
      src/interfaces/analyzers/stack-trace-analyzer/IStackTraceData.d.ts
  24. 3 3
      src/interfaces/custom-nodes/ICustomNodeGroup.d.ts
  25. 12 12
      src/node-transformers/preparing-transformers/CustomNodesTransformer.ts
  26. 10 10
      src/node/NodeAppender.ts
  27. 0 0
      src/types/analyzers/calls-graph-analyzer/TObjectMembersCallsChain.d.ts
  28. 2 2
      src/types/container/calls-graph-analyzer/TCalleeDataExtractorFactory.d.ts
  29. 77 77
      test/functional-tests/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.spec.ts
  30. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/basic-1.js
  31. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/basic-2.js
  32. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/call-before-declaration.js
  33. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/call-expression-of-object-member-1.js
  34. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/call-expression-of-object-member-2.js
  35. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/deep-conditions-nesting.js
  36. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/no-call-expressions.js
  37. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/no-recursion.js
  38. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/only-call-expression.js
  39. 0 0
      test/functional-tests/analyzers/calls-graph-analyzer/fixtures/self-invoking-functions.js
  40. 2 2
      test/index.spec.ts
  41. 6 6
      test/unit-tests/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.spec.ts
  42. 17 17
      test/unit-tests/node/node-appender/NodeAppender.spec.ts

File diff suppressed because it is too large
+ 0 - 0
dist/index.browser.js


File diff suppressed because it is too large
+ 0 - 0
dist/index.cli.js


File diff suppressed because it is too large
+ 0 - 0
dist/index.js


+ 22 - 22
src/analyzers/stack-trace-analyzer/StackTraceAnalyzer.ts → src/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.ts

@@ -4,19 +4,19 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TCalleeDataExtractorFactory } from '../../types/container/stack-trace-analyzer/TCalleeDataExtractorFactory';
+import { TCalleeDataExtractorFactory } from '../../types/container/calls-graph-analyzer/TCalleeDataExtractorFactory';
 
 
-import { ICalleeData } from '../../interfaces/analyzers/stack-trace-analyzer/ICalleeData';
-import { IStackTraceAnalyzer } from '../../interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer';
-import { IStackTraceData } from '../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICalleeData } from '../../interfaces/analyzers/calls-graph-analyzer/ICalleeData';
+import { ICallsGraphAnalyzer } from '../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphAnalyzer';
+import { ICallsGraphData } from '../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
-import { CalleeDataExtractor } from '../../enums/analyzers/stack-trace-analyzer/CalleeDataExtractor';
+import { CalleeDataExtractor } from '../../enums/analyzers/calls-graph-analyzer/CalleeDataExtractor';
 
 
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeGuards } from '../../node/NodeGuards';
 import { NodeStatementUtils } from '../../node/NodeStatementUtils';
 import { NodeStatementUtils } from '../../node/NodeStatementUtils';
 
 
 /**
 /**
- * This class generates a data with a stack trace of functions calls
+ * This class generates a data with a graph of functions calls
  *
  *
  * For example:
  * For example:
  *
  *
@@ -47,7 +47,7 @@ import { NodeStatementUtils } from '../../node/NodeStatementUtils';
  * ]
  * ]
  */
  */
 @injectable()
 @injectable()
-export class StackTraceAnalyzer implements IStackTraceAnalyzer {
+export class CallsGraphAnalyzer implements ICallsGraphAnalyzer {
     /**
     /**
      * @type {CalleeDataExtractor[]}
      * @type {CalleeDataExtractor[]}
      */
      */
@@ -84,13 +84,13 @@ export class StackTraceAnalyzer implements IStackTraceAnalyzer {
      */
      */
     public static getLimitIndex (blockScopeBodyLength: number): number {
     public static getLimitIndex (blockScopeBodyLength: number): number {
         const lastIndex: number = blockScopeBodyLength - 1;
         const lastIndex: number = blockScopeBodyLength - 1;
-        const limitThresholdActivationIndex: number = StackTraceAnalyzer.limitThresholdActivationLength - 1;
+        const limitThresholdActivationIndex: number = CallsGraphAnalyzer.limitThresholdActivationLength - 1;
 
 
         let limitIndex: number = lastIndex;
         let limitIndex: number = lastIndex;
 
 
         if (lastIndex > limitThresholdActivationIndex) {
         if (lastIndex > limitThresholdActivationIndex) {
             limitIndex = Math.round(
             limitIndex = Math.round(
-                limitThresholdActivationIndex + (lastIndex * StackTraceAnalyzer.limitThreshold)
+                limitThresholdActivationIndex + (lastIndex * CallsGraphAnalyzer.limitThreshold)
             );
             );
 
 
             if (limitIndex > lastIndex) {
             if (limitIndex > lastIndex) {
@@ -103,19 +103,19 @@ export class StackTraceAnalyzer implements IStackTraceAnalyzer {
 
 
     /**
     /**
      * @param {Program} astTree
      * @param {Program} astTree
-     * @returns {IStackTraceData[]}
+     * @returns {ICallsGraphData[]}
      */
      */
-    public analyze (astTree: ESTree.Program): IStackTraceData[] {
+    public analyze (astTree: ESTree.Program): ICallsGraphData[] {
         return this.analyzeRecursive(astTree.body);
         return this.analyzeRecursive(astTree.body);
     }
     }
 
 
     /**
     /**
      * @param {NodeGuards[]} blockScopeBody
      * @param {NodeGuards[]} blockScopeBody
-     * @returns {IStackTraceData[]}
+     * @returns {ICallsGraphData[]}
      */
      */
-    private analyzeRecursive (blockScopeBody: ESTree.Node[]): IStackTraceData[] {
-        const limitIndex: number = StackTraceAnalyzer.getLimitIndex(blockScopeBody.length);
-        const stackTraceData: IStackTraceData[] = [];
+    private analyzeRecursive (blockScopeBody: ESTree.Node[]): ICallsGraphData[] {
+        const limitIndex: number = CallsGraphAnalyzer.getLimitIndex(blockScopeBody.length);
+        const callsGraphData: ICallsGraphData[] = [];
         const blockScopeBodyLength: number = blockScopeBody.length;
         const blockScopeBodyLength: number = blockScopeBody.length;
 
 
         for (let index: number = 0; index < blockScopeBodyLength; index++) {
         for (let index: number = 0; index < blockScopeBodyLength; index++) {
@@ -135,25 +135,25 @@ export class StackTraceAnalyzer implements IStackTraceAnalyzer {
                         return estraverse.VisitorOption.Skip;
                         return estraverse.VisitorOption.Skip;
                     }
                     }
 
 
-                    this.analyzeCallExpressionNode(stackTraceData, blockScopeBody, node);
+                    this.analyzeCallExpressionNode(callsGraphData, blockScopeBody, node);
                 }
                 }
             });
             });
         }
         }
 
 
-        return stackTraceData;
+        return callsGraphData;
     }
     }
 
 
     /**
     /**
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      * @param {NodeGuards[]} blockScopeBody
      * @param {NodeGuards[]} blockScopeBody
      * @param {CallExpression} callExpressionNode
      * @param {CallExpression} callExpressionNode
      */
      */
     private analyzeCallExpressionNode (
     private analyzeCallExpressionNode (
-        stackTraceData: IStackTraceData[],
+        callsGraphData: ICallsGraphData[],
         blockScopeBody: ESTree.Node[],
         blockScopeBody: ESTree.Node[],
         callExpressionNode: ESTree.CallExpression
         callExpressionNode: ESTree.CallExpression
     ): void {
     ): void {
-        StackTraceAnalyzer.calleeDataExtractorsList.forEach((calleeDataExtractorName: CalleeDataExtractor) => {
+        CallsGraphAnalyzer.calleeDataExtractorsList.forEach((calleeDataExtractorName: CalleeDataExtractor) => {
             const calleeData: ICalleeData | null = this.calleeDataExtractorFactory(calleeDataExtractorName)
             const calleeData: ICalleeData | null = this.calleeDataExtractorFactory(calleeDataExtractorName)
                 .extract(blockScopeBody, callExpressionNode.callee);
                 .extract(blockScopeBody, callExpressionNode.callee);
 
 
@@ -161,9 +161,9 @@ export class StackTraceAnalyzer implements IStackTraceAnalyzer {
                 return;
                 return;
             }
             }
 
 
-            stackTraceData.push({
+            callsGraphData.push({
                 ...calleeData,
                 ...calleeData,
-                stackTrace: this.analyzeRecursive(calleeData.callee.body)
+                callsGraph: this.analyzeRecursive(calleeData.callee.body)
             });
             });
         });
         });
     }
     }

+ 2 - 2
src/analyzers/stack-trace-analyzer/callee-data-extractors/AbstractCalleeDataExtractor.ts → src/analyzers/calls-graph-analyzer/callee-data-extractors/AbstractCalleeDataExtractor.ts

@@ -2,8 +2,8 @@ import { injectable } from 'inversify';
 
 
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { ICalleeData } from '../../../interfaces/analyzers/stack-trace-analyzer/ICalleeData';
-import { ICalleeDataExtractor } from '../../../interfaces/analyzers/stack-trace-analyzer/ICalleeDataExtractor';
+import { ICalleeData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICalleeData';
+import { ICalleeDataExtractor } from '../../../interfaces/analyzers/calls-graph-analyzer/ICalleeDataExtractor';
 
 
 @injectable()
 @injectable()
 export abstract class AbstractCalleeDataExtractor implements ICalleeDataExtractor {
 export abstract class AbstractCalleeDataExtractor implements ICalleeDataExtractor {

+ 1 - 1
src/analyzers/stack-trace-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts → src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor.ts

@@ -3,7 +3,7 @@ import { injectable } from 'inversify';
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { ICalleeData } from '../../../interfaces/analyzers/stack-trace-analyzer/ICalleeData';
+import { ICalleeData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICalleeData';
 
 
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { NodeGuards } from '../../../node/NodeGuards';
 import { NodeGuards } from '../../../node/NodeGuards';

+ 1 - 1
src/analyzers/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts → src/analyzers/calls-graph-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor.ts

@@ -3,7 +3,7 @@ import { injectable } from 'inversify';
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { ICalleeData } from '../../../interfaces/analyzers/stack-trace-analyzer/ICalleeData';
+import { ICalleeData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICalleeData';
 
 
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { NodeGuards } from '../../../node/NodeGuards';
 import { NodeGuards } from '../../../node/NodeGuards';

+ 2 - 2
src/analyzers/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts → src/analyzers/calls-graph-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor.ts

@@ -3,9 +3,9 @@ import { injectable } from 'inversify';
 import * as estraverse from 'estraverse';
 import * as estraverse from 'estraverse';
 import * as ESTree from 'estree';
 import * as ESTree from 'estree';
 
 
-import { TObjectMembersCallsChain } from '../../../types/analyzers/stack-trace-analyzer/TObjectMembersCallsChain';
+import { TObjectMembersCallsChain } from '../../../types/analyzers/calls-graph-analyzer/TObjectMembersCallsChain';
 
 
-import { ICalleeData } from '../../../interfaces/analyzers/stack-trace-analyzer/ICalleeData';
+import { ICalleeData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICalleeData';
 
 
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { AbstractCalleeDataExtractor } from './AbstractCalleeDataExtractor';
 import { NodeGuards } from '../../../node/NodeGuards';
 import { NodeGuards } from '../../../node/NodeGuards';

+ 1 - 1
src/container/ServiceIdentifiers.ts

@@ -16,6 +16,7 @@ export enum ServiceIdentifiers {
     Factory__TControlFlowStorage = 'Factory<TControlFlowStorage>',
     Factory__TControlFlowStorage = 'Factory<TControlFlowStorage>',
     IArrayUtils = 'IArrayUtils',
     IArrayUtils = 'IArrayUtils',
     ICalleeDataExtractor = 'ICalleeDataExtractor',
     ICalleeDataExtractor = 'ICalleeDataExtractor',
+    ICallsGraphAnalyzer = 'ICallsGraphAnalyzer',
     ICryptUtils = 'ICryptUtils',
     ICryptUtils = 'ICryptUtils',
     ICustomNode = 'ICustomNode',
     ICustomNode = 'ICustomNode',
     ICustomNodeGroup = 'ICustomNodeGroup',
     ICustomNodeGroup = 'ICustomNodeGroup',
@@ -38,7 +39,6 @@ export enum ServiceIdentifiers {
     IRandomGenerator = 'IRandomGenerator',
     IRandomGenerator = 'IRandomGenerator',
     ISourceCode = 'ISourceCode',
     ISourceCode = 'ISourceCode',
     ISourceMapCorrector = 'ISourceMapCorrector',
     ISourceMapCorrector = 'ISourceMapCorrector',
-    IStackTraceAnalyzer = 'IStackTraceAnalyzer',
     ITransformersRunner = 'ITransformersRunner',
     ITransformersRunner = 'ITransformersRunner',
     Newable__ICustomNode = 'Newable<ICustomNode>',
     Newable__ICustomNode = 'Newable<ICustomNode>',
     Newable__TControlFlowStorage = 'Newable<TControlFlowStorage>',
     Newable__TControlFlowStorage = 'Newable<TControlFlowStorage>',

+ 10 - 10
src/container/modules/analyzers/AnalyzersModule.ts

@@ -2,19 +2,19 @@ import { InversifyContainerFacade } from '../../InversifyContainerFacade';
 import { ContainerModule, interfaces } from 'inversify';
 import { ContainerModule, interfaces } from 'inversify';
 import { ServiceIdentifiers } from '../../ServiceIdentifiers';
 import { ServiceIdentifiers } from '../../ServiceIdentifiers';
 
 
-import { ICalleeDataExtractor } from '../../../interfaces/analyzers/stack-trace-analyzer/ICalleeDataExtractor';
-import { IStackTraceAnalyzer } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer';
+import { ICalleeDataExtractor } from '../../../interfaces/analyzers/calls-graph-analyzer/ICalleeDataExtractor';
+import { ICallsGraphAnalyzer } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphAnalyzer';
 
 
-import { CalleeDataExtractor } from '../../../enums/analyzers/stack-trace-analyzer/CalleeDataExtractor';
-import { FunctionDeclarationCalleeDataExtractor } from '../../../analyzers/stack-trace-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor';
-import { FunctionExpressionCalleeDataExtractor } from '../../../analyzers/stack-trace-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor';
-import { ObjectExpressionCalleeDataExtractor } from '../../../analyzers/stack-trace-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor';
-import { StackTraceAnalyzer } from '../../../analyzers/stack-trace-analyzer/StackTraceAnalyzer';
+import { CalleeDataExtractor } from '../../../enums/analyzers/calls-graph-analyzer/CalleeDataExtractor';
+import { CallsGraphAnalyzer } from '../../../analyzers/calls-graph-analyzer/CallsGraphAnalyzer';
+import { FunctionDeclarationCalleeDataExtractor } from '../../../analyzers/calls-graph-analyzer/callee-data-extractors/FunctionDeclarationCalleeDataExtractor';
+import { FunctionExpressionCalleeDataExtractor } from '../../../analyzers/calls-graph-analyzer/callee-data-extractors/FunctionExpressionCalleeDataExtractor';
+import { ObjectExpressionCalleeDataExtractor } from '../../../analyzers/calls-graph-analyzer/callee-data-extractors/ObjectExpressionCalleeDataExtractor';
 
 
 export const analyzersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
 export const analyzersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
-    // stack trace analyzer
-    bind<IStackTraceAnalyzer>(ServiceIdentifiers.IStackTraceAnalyzer)
-        .to(StackTraceAnalyzer)
+    // calls graph analyzer
+    bind<ICallsGraphAnalyzer>(ServiceIdentifiers.ICallsGraphAnalyzer)
+        .to(CallsGraphAnalyzer)
         .inSingletonScope();
         .inSingletonScope();
 
 
     // callee data extractors
     // callee data extractors

+ 6 - 6
src/custom-nodes/AbstractCustomNodeGroup.ts

@@ -9,7 +9,7 @@ import { ICustomNodeGroup } from '../interfaces/custom-nodes/ICustomNodeGroup';
 import { IIdentifierNamesGenerator } from '../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
 import { IIdentifierNamesGenerator } from '../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
 import { IOptions } from '../interfaces/options/IOptions';
 import { IOptions } from '../interfaces/options/IOptions';
 import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
-import { IStackTraceData } from '../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphData } from '../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { CustomNode } from '../enums/custom-nodes/CustomNode';
 import { CustomNode } from '../enums/custom-nodes/CustomNode';
 import { ObfuscationEvent } from '../enums/event-emitters/ObfuscationEvent';
 import { ObfuscationEvent } from '../enums/event-emitters/ObfuscationEvent';
@@ -59,9 +59,9 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup {
 
 
     /**
     /**
      * @param {TNodeWithStatements} nodeWithStatements
      * @param {TNodeWithStatements} nodeWithStatements
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      */
      */
-    public abstract appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void;
+    public abstract appendCustomNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void;
 
 
     /**
     /**
      * @returns {ObfuscationEvent}
      * @returns {ObfuscationEvent}
@@ -94,10 +94,10 @@ export abstract class AbstractCustomNodeGroup implements ICustomNodeGroup {
     }
     }
 
 
     /**
     /**
-     * @param {number} stackTraceLength
+     * @param {number} callsGraphLength
      * @returns {number}
      * @returns {number}
      */
      */
-    protected getRandomStackTraceIndex (stackTraceLength: number): number {
-        return this.randomGenerator.getRandomInteger(0, Math.max(0, Math.round(stackTraceLength - 1)));
+    protected getRandomCallsGraphIndex (callsGraphLength: number): number {
+        return this.randomGenerator.getRandomInteger(0, Math.max(0, Math.round(callsGraphLength - 1)));
     }
     }
 }
 }

+ 8 - 8
src/custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup.ts

@@ -8,7 +8,7 @@ import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
-import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { initializable } from '../../../decorators/Initializable';
 import { initializable } from '../../../decorators/Initializable';
 
 
@@ -56,25 +56,25 @@ export class ConsoleOutputCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
     /**
     /**
      * @param {TNodeWithStatements} nodeWithStatements
      * @param {TNodeWithStatements} nodeWithStatements
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      */
      */
-    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
-        const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+        const randomCallsGraphIndex: number = this.getRandomCallsGraphIndex(callsGraphData.length);
 
 
         // consoleOutputDisableExpressionNode append
         // consoleOutputDisableExpressionNode append
         this.appendCustomNodeIfExist(CustomNode.ConsoleOutputDisableExpressionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.ConsoleOutputDisableExpressionNode, (customNode: ICustomNode) => {
             NodeAppender.appendToOptimalBlockScope(
             NodeAppender.appendToOptimalBlockScope(
-                stackTraceData,
+                callsGraphData,
                 nodeWithStatements,
                 nodeWithStatements,
                 customNode.getNode(),
                 customNode.getNode(),
-                randomStackTraceIndex
+                randomCallsGraphIndex
             );
             );
         });
         });
 
 
         // nodeCallsControllerFunctionNode append
         // nodeCallsControllerFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
-            const targetNodeWithStatements: TNodeWithStatements = stackTraceData.length
-                ? NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1)
+            const targetNodeWithStatements: TNodeWithStatements = callsGraphData.length
+                ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex, 1)
                 : nodeWithStatements;
                 : nodeWithStatements;
 
 
             NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());
             NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());

+ 8 - 8
src/custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup.ts

@@ -8,7 +8,7 @@ import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
-import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { initializable } from '../../../decorators/Initializable';
 import { initializable } from '../../../decorators/Initializable';
 
 
@@ -57,18 +57,18 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
     /**
     /**
      * @param {TNodeWithStatements} nodeWithStatements
      * @param {TNodeWithStatements} nodeWithStatements
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      */
      */
-    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
-        const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+        const randomCallsGraphIndex: number = this.getRandomCallsGraphIndex(callsGraphData.length);
 
 
         // debugProtectionFunctionCallNode append
         // debugProtectionFunctionCallNode append
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionCallNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.DebugProtectionFunctionCallNode, (customNode: ICustomNode) => {
             NodeAppender.appendToOptimalBlockScope(
             NodeAppender.appendToOptimalBlockScope(
-                stackTraceData,
+                callsGraphData,
                 nodeWithStatements,
                 nodeWithStatements,
                 customNode.getNode(),
                 customNode.getNode(),
-                randomStackTraceIndex
+                randomCallsGraphIndex
             );
             );
         });
         });
 
 
@@ -89,8 +89,8 @@ export class DebugProtectionCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
         // nodeCallsControllerFunctionNode append
         // nodeCallsControllerFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
-            const targetNodeWithStatements: TNodeWithStatements = stackTraceData.length
-                ? NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1)
+            const targetNodeWithStatements: TNodeWithStatements = callsGraphData.length
+                ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex, 1)
                 : nodeWithStatements;
                 : nodeWithStatements;
 
 
             NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());
             NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());

+ 8 - 8
src/custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup.ts

@@ -8,7 +8,7 @@ import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
-import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { initializable } from '../../../decorators/Initializable';
 import { initializable } from '../../../decorators/Initializable';
 
 
@@ -56,25 +56,25 @@ export class DomainLockCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
     /**
     /**
      * @param {TNodeWithStatements} nodeWithStatements
      * @param {TNodeWithStatements} nodeWithStatements
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      */
      */
-    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
-        const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+        const randomCallsGraphIndex: number = this.getRandomCallsGraphIndex(callsGraphData.length);
 
 
         // domainLockNode append
         // domainLockNode append
         this.appendCustomNodeIfExist(CustomNode.DomainLockNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.DomainLockNode, (customNode: ICustomNode) => {
             NodeAppender.appendToOptimalBlockScope(
             NodeAppender.appendToOptimalBlockScope(
-                stackTraceData,
+                callsGraphData,
                 nodeWithStatements,
                 nodeWithStatements,
                 customNode.getNode(),
                 customNode.getNode(),
-                randomStackTraceIndex
+                randomCallsGraphIndex
             );
             );
         });
         });
 
 
         // nodeCallsControllerFunctionNode append
         // nodeCallsControllerFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
-            const targetNodeWithStatements: TNodeWithStatements = stackTraceData.length
-                ? NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1)
+            const targetNodeWithStatements: TNodeWithStatements = callsGraphData.length
+                ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex, 1)
                 : nodeWithStatements;
                 : nodeWithStatements;
 
 
             NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());
             NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());

+ 8 - 8
src/custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup.ts

@@ -8,7 +8,7 @@ import { TNodeWithStatements } from '../../../types/node/TNodeWithStatements';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
-import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { initializable } from '../../../decorators/Initializable';
 import { initializable } from '../../../decorators/Initializable';
 
 
@@ -56,25 +56,25 @@ export class SelfDefendingCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
     /**
     /**
      * @param {TNodeWithStatements} nodeWithStatements
      * @param {TNodeWithStatements} nodeWithStatements
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      */
      */
-    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
-        const randomStackTraceIndex: number = this.getRandomStackTraceIndex(stackTraceData.length);
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
+        const randomCallsGraphIndex: number = this.getRandomCallsGraphIndex(callsGraphData.length);
 
 
         // selfDefendingUnicodeNode append
         // selfDefendingUnicodeNode append
         this.appendCustomNodeIfExist(CustomNode.SelfDefendingUnicodeNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.SelfDefendingUnicodeNode, (customNode: ICustomNode) => {
             NodeAppender.appendToOptimalBlockScope(
             NodeAppender.appendToOptimalBlockScope(
-                stackTraceData,
+                callsGraphData,
                 nodeWithStatements,
                 nodeWithStatements,
                 customNode.getNode(),
                 customNode.getNode(),
-                randomStackTraceIndex
+                randomCallsGraphIndex
             );
             );
         });
         });
 
 
         // nodeCallsControllerFunctionNode append
         // nodeCallsControllerFunctionNode append
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
         this.appendCustomNodeIfExist(CustomNode.NodeCallsControllerFunctionNode, (customNode: ICustomNode) => {
-            const targetNodeWithStatements: TNodeWithStatements = stackTraceData.length
-                ? NodeAppender.getOptimalBlockScope(stackTraceData, randomStackTraceIndex, 1)
+            const targetNodeWithStatements: TNodeWithStatements = callsGraphData.length
+                ? NodeAppender.getOptimalBlockScope(callsGraphData, randomCallsGraphIndex, 1)
                 : nodeWithStatements;
                 : nodeWithStatements;
 
 
             NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());
             NodeAppender.prepend(targetNodeWithStatements, customNode.getNode());

+ 3 - 3
src/custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup.ts

@@ -9,7 +9,7 @@ import { TStringArrayStorage } from '../../../types/storages/TStringArrayStorage
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IOptions } from '../../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
 import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
-import { IStackTraceData } from '../../../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphData } from '../../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { initializable } from '../../../decorators/Initializable';
 import { initializable } from '../../../decorators/Initializable';
 
 
@@ -65,9 +65,9 @@ export class StringArrayCustomNodeGroup extends AbstractCustomNodeGroup {
 
 
     /**
     /**
      * @param {TNodeWithStatements} nodeWithStatements
      * @param {TNodeWithStatements} nodeWithStatements
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      */
      */
-    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void {
+    public appendCustomNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void {
         if (!this.stringArrayStorage.getLength()) {
         if (!this.stringArrayStorage.getLength()) {
             return;
             return;
         }
         }

+ 0 - 0
src/enums/analyzers/stack-trace-analyzer/CalleeDataExtractor.ts → src/enums/analyzers/calls-graph-analyzer/CalleeDataExtractor.ts


+ 0 - 0
src/interfaces/analyzers/stack-trace-analyzer/ICalleeData.d.ts → src/interfaces/analyzers/calls-graph-analyzer/ICalleeData.d.ts


+ 0 - 0
src/interfaces/analyzers/stack-trace-analyzer/ICalleeDataExtractor.d.ts → src/interfaces/analyzers/calls-graph-analyzer/ICalleeDataExtractor.d.ts


+ 12 - 0
src/interfaces/analyzers/calls-graph-analyzer/ICallsGraphAnalyzer.d.ts

@@ -0,0 +1,12 @@
+import * as ESTree from 'estree';
+
+import { IAnalyzer } from '../IAnalyzer';
+import { ICallsGraphData } from './ICallsGraphData';
+
+export interface ICallsGraphAnalyzer extends IAnalyzer<ICallsGraphData> {
+    /**
+     * @param {Program} astTree
+     * @returns {ICallsGraphData[]}
+     */
+    analyze (astTree: ESTree.Program): ICallsGraphData[];
+}

+ 5 - 0
src/interfaces/analyzers/calls-graph-analyzer/ICallsGraphData.d.ts

@@ -0,0 +1,5 @@
+import { ICalleeData } from './ICalleeData';
+
+export interface ICallsGraphData extends ICalleeData {
+    callsGraph: ICallsGraphData[];
+}

+ 0 - 12
src/interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer.d.ts

@@ -1,12 +0,0 @@
-import * as ESTree from 'estree';
-
-import { IAnalyzer } from '../IAnalyzer';
-import { IStackTraceData } from './IStackTraceData';
-
-export interface IStackTraceAnalyzer extends IAnalyzer<IStackTraceData> {
-    /**
-     * @param {Program} astTree
-     * @returns {IStackTraceData[]}
-     */
-    analyze (astTree: ESTree.Program): IStackTraceData[];
-}

+ 0 - 5
src/interfaces/analyzers/stack-trace-analyzer/IStackTraceData.d.ts

@@ -1,5 +0,0 @@
-import { ICalleeData } from './ICalleeData';
-
-export interface IStackTraceData extends ICalleeData {
-    stackTrace: IStackTraceData[];
-}

+ 3 - 3
src/interfaces/custom-nodes/ICustomNodeGroup.d.ts

@@ -2,7 +2,7 @@ import { TNodeWithStatements } from '../../types/node/TNodeWithStatements';
 
 
 import { ICustomNode } from './ICustomNode';
 import { ICustomNode } from './ICustomNode';
 import { IInitializable } from '../IInitializable';
 import { IInitializable } from '../IInitializable';
-import { IStackTraceData } from '../analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphData } from '../analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { CustomNode } from '../../enums/custom-nodes/CustomNode';
 import { CustomNode } from '../../enums/custom-nodes/CustomNode';
 import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent';
 import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent';
@@ -10,9 +10,9 @@ import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent';
 export interface ICustomNodeGroup extends IInitializable {
 export interface ICustomNodeGroup extends IInitializable {
     /**
     /**
      * @param nodeWithStatements
      * @param nodeWithStatements
-     * @param stackTraceData
+     * @param callsGraphData
      */
      */
-    appendCustomNodes (nodeWithStatements: TNodeWithStatements, stackTraceData: IStackTraceData[]): void;
+    appendCustomNodes (nodeWithStatements: TNodeWithStatements, callsGraphData: ICallsGraphData[]): void;
 
 
     /**
     /**
      * @returns {ObfuscationEvent}
      * @returns {ObfuscationEvent}

+ 12 - 12
src/node-transformers/preparing-transformers/CustomNodesTransformer.ts

@@ -9,8 +9,8 @@ import { ICustomNodeGroup } from '../../interfaces/custom-nodes/ICustomNodeGroup
 import { IObfuscationEventEmitter } from '../../interfaces/event-emitters/IObfuscationEventEmitter';
 import { IObfuscationEventEmitter } from '../../interfaces/event-emitters/IObfuscationEventEmitter';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IOptions } from '../../interfaces/options/IOptions';
 import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 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 { ICallsGraphAnalyzer } from '../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphAnalyzer';
+import { ICallsGraphData } from '../../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
 import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
 
 
 import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent';
 import { ObfuscationEvent } from '../../enums/event-emitters/ObfuscationEvent';
@@ -35,24 +35,24 @@ export class CustomNodesTransformer extends AbstractNodeTransformer {
     private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
     private readonly obfuscationEventEmitter: IObfuscationEventEmitter;
 
 
     /**
     /**
-     * @type {IStackTraceAnalyzer}
+     * @type {ICallsGraphAnalyzer}
      */
      */
-    private readonly stackTraceAnalyzer: IStackTraceAnalyzer;
+    private readonly callsGraphAnalyzer: ICallsGraphAnalyzer;
 
 
     /**
     /**
-     * @type {IStackTraceData[]}
+     * @type {ICallsGraphData[]}
      */
      */
-    private stackTraceData: IStackTraceData[] = [];
+    private callsGraphData: ICallsGraphData[] = [];
 
 
     /**
     /**
-     * @param {IStackTraceAnalyzer} stackTraceAnalyzer
+     * @param {ICallsGraphAnalyzer} callsGraphAnalyzer
      * @param {IObfuscationEventEmitter} obfuscationEventEmitter
      * @param {IObfuscationEventEmitter} obfuscationEventEmitter
      * @param {TCustomNodeGroupStorage} customNodeGroupStorage
      * @param {TCustomNodeGroupStorage} customNodeGroupStorage
      * @param {IRandomGenerator} randomGenerator
      * @param {IRandomGenerator} randomGenerator
      * @param {IOptions} options
      * @param {IOptions} options
      */
      */
     constructor (
     constructor (
-        @inject(ServiceIdentifiers.IStackTraceAnalyzer) stackTraceAnalyzer: IStackTraceAnalyzer,
+        @inject(ServiceIdentifiers.ICallsGraphAnalyzer) callsGraphAnalyzer: ICallsGraphAnalyzer,
         @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
         @inject(ServiceIdentifiers.IObfuscationEventEmitter) obfuscationEventEmitter: IObfuscationEventEmitter,
         @inject(ServiceIdentifiers.TCustomNodeGroupStorage) customNodeGroupStorage: TCustomNodeGroupStorage,
         @inject(ServiceIdentifiers.TCustomNodeGroupStorage) customNodeGroupStorage: TCustomNodeGroupStorage,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
         @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
@@ -60,7 +60,7 @@ export class CustomNodesTransformer extends AbstractNodeTransformer {
     ) {
     ) {
         super(randomGenerator, options);
         super(randomGenerator, options);
 
 
-        this.stackTraceAnalyzer = stackTraceAnalyzer;
+        this.callsGraphAnalyzer = callsGraphAnalyzer;
         this.obfuscationEventEmitter = obfuscationEventEmitter;
         this.obfuscationEventEmitter = obfuscationEventEmitter;
         this.customNodeGroupStorage = customNodeGroupStorage;
         this.customNodeGroupStorage = customNodeGroupStorage;
     }
     }
@@ -102,7 +102,7 @@ export class CustomNodesTransformer extends AbstractNodeTransformer {
      * @param {Node | null} parentNode
      * @param {Node | null} parentNode
      */
      */
     public analyzeNode (node: ESTree.Program, parentNode: ESTree.Node | null): void {
     public analyzeNode (node: ESTree.Program, parentNode: ESTree.Node | null): void {
-        this.stackTraceData = this.stackTraceAnalyzer.analyze(node);
+        this.callsGraphData = this.callsGraphAnalyzer.analyze(node);
     }
     }
 
 
     /**
     /**
@@ -130,7 +130,7 @@ export class CustomNodesTransformer extends AbstractNodeTransformer {
                 );
                 );
             });
             });
 
 
-        this.obfuscationEventEmitter.emit(ObfuscationEvent.BeforeObfuscation, node, this.stackTraceData);
+        this.obfuscationEventEmitter.emit(ObfuscationEvent.BeforeObfuscation, node, this.callsGraphData);
     }
     }
 
 
     /**
     /**
@@ -138,6 +138,6 @@ export class CustomNodesTransformer extends AbstractNodeTransformer {
      * @param {Node | null} parentNode
      * @param {Node | null} parentNode
      */
      */
     private appendCustomNodesAfterObfuscation (node: ESTree.Program, parentNode: ESTree.Node | null): void {
     private appendCustomNodesAfterObfuscation (node: ESTree.Program, parentNode: ESTree.Node | null): void {
-        this.obfuscationEventEmitter.emit(ObfuscationEvent.AfterObfuscation, node, this.stackTraceData);
+        this.obfuscationEventEmitter.emit(ObfuscationEvent.AfterObfuscation, node, this.callsGraphData);
     }
     }
 }
 }

+ 10 - 10
src/node/NodeAppender.ts

@@ -3,7 +3,7 @@ import * as ESTree from 'estree';
 import { TNodeWithStatements } from '../types/node/TNodeWithStatements';
 import { TNodeWithStatements } from '../types/node/TNodeWithStatements';
 import { TStatement } from '../types/node/TStatement';
 import { TStatement } from '../types/node/TStatement';
 
 
-import { IStackTraceData } from '../interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphData } from '../interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { NodeGuards } from './NodeGuards';
 import { NodeGuards } from './NodeGuards';
 
 
@@ -38,19 +38,19 @@ export class NodeAppender {
      *
      *
      * Appends node into block statement of `baz` function expression
      * Appends node into block statement of `baz` function expression
      *
      *
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      * @param {TNodeWithStatements} nodeWithStatements
      * @param {TNodeWithStatements} nodeWithStatements
      * @param {TStatement[]} bodyStatements
      * @param {TStatement[]} bodyStatements
      * @param {number} index
      * @param {number} index
      */
      */
     public static appendToOptimalBlockScope (
     public static appendToOptimalBlockScope (
-        stackTraceData: IStackTraceData[],
+        callsGraphData: ICallsGraphData[],
         nodeWithStatements: TNodeWithStatements,
         nodeWithStatements: TNodeWithStatements,
         bodyStatements: TStatement[],
         bodyStatements: TStatement[],
         index: number = 0
         index: number = 0
     ): void {
     ): void {
-        const targetBlockScope: TNodeWithStatements = stackTraceData.length
-            ? NodeAppender.getOptimalBlockScope(stackTraceData, index)
+        const targetBlockScope: TNodeWithStatements = callsGraphData.length
+            ? NodeAppender.getOptimalBlockScope(callsGraphData, index)
             : nodeWithStatements;
             : nodeWithStatements;
 
 
         NodeAppender.prepend(targetBlockScope, bodyStatements);
         NodeAppender.prepend(targetBlockScope, bodyStatements);
@@ -59,24 +59,24 @@ export class NodeAppender {
     /**
     /**
      * Returns deepest block scope node at given deep.
      * Returns deepest block scope node at given deep.
      *
      *
-     * @param {IStackTraceData[]} stackTraceData
+     * @param {ICallsGraphData[]} callsGraphData
      * @param {number} index
      * @param {number} index
      * @param {number} deep
      * @param {number} deep
      * @returns {BlockStatement}
      * @returns {BlockStatement}
      */
      */
     public static getOptimalBlockScope (
     public static getOptimalBlockScope (
-        stackTraceData: IStackTraceData[],
+        callsGraphData: ICallsGraphData[],
         index: number,
         index: number,
         deep: number = Infinity
         deep: number = Infinity
     ): ESTree.BlockStatement {
     ): ESTree.BlockStatement {
-        const firstCall: IStackTraceData = stackTraceData[index];
+        const firstCall: ICallsGraphData = callsGraphData[index];
 
 
         if (deep <= 0) {
         if (deep <= 0) {
             throw new Error('Invalid `deep` argument value. Value should be bigger then 0.');
             throw new Error('Invalid `deep` argument value. Value should be bigger then 0.');
         }
         }
 
 
-        if (deep > 1 && firstCall.stackTrace.length) {
-            return NodeAppender.getOptimalBlockScope(firstCall.stackTrace, 0, --deep);
+        if (deep > 1 && firstCall.callsGraph.length) {
+            return NodeAppender.getOptimalBlockScope(firstCall.callsGraph, 0, --deep);
         } else {
         } else {
             return firstCall.callee;
             return firstCall.callee;
         }
         }

+ 0 - 0
src/types/analyzers/stack-trace-analyzer/TObjectMembersCallsChain.d.ts → src/types/analyzers/calls-graph-analyzer/TObjectMembersCallsChain.d.ts


+ 2 - 2
src/types/container/stack-trace-analyzer/TCalleeDataExtractorFactory.d.ts → src/types/container/calls-graph-analyzer/TCalleeDataExtractorFactory.d.ts

@@ -1,5 +1,5 @@
-import { ICalleeDataExtractor } from '../../../interfaces/analyzers/stack-trace-analyzer/ICalleeDataExtractor';
+import { ICalleeDataExtractor } from '../../../interfaces/analyzers/calls-graph-analyzer/ICalleeDataExtractor';
 
 
-import { CalleeDataExtractor } from '../../../enums/analyzers/stack-trace-analyzer/CalleeDataExtractor';
+import { CalleeDataExtractor } from '../../../enums/analyzers/calls-graph-analyzer/CalleeDataExtractor';
 
 
 export type TCalleeDataExtractorFactory = (calleeDataExtractorName: CalleeDataExtractor) => ICalleeDataExtractor;
 export type TCalleeDataExtractorFactory = (calleeDataExtractorName: CalleeDataExtractor) => ICalleeDataExtractor;

+ 77 - 77
test/functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts → test/functional-tests/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.spec.ts

@@ -10,8 +10,8 @@ import { assert } from 'chai';
 import { TNodeWithStatements } from '../../../../src/types/node/TNodeWithStatements';
 import { TNodeWithStatements } from '../../../../src/types/node/TNodeWithStatements';
 
 
 import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
 import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
-import { IStackTraceAnalyzer } from '../../../../src/interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer';
-import { IStackTraceData } from '../../../../src/interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphAnalyzer } from '../../../../src/interfaces/analyzers/calls-graph-analyzer/ICallsGraphAnalyzer';
+import { ICallsGraphData } from '../../../../src/interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { readFileAsString } from '../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../helpers/readFileAsString';
 
 
@@ -148,18 +148,18 @@ function getObjectFunctionExpressionByName (astTree: ESTree.Node, objectName: st
     return functionExpressionNode;
     return functionExpressionNode;
 }
 }
 
 
-describe('StackTraceAnalyzer', () => {
+describe('CallsGraphAnalyzer', () => {
     describe('extract', () => {
     describe('extract', () => {
-        let stackTraceAnalyzer: IStackTraceAnalyzer,
-            expectedStackTraceData: IStackTraceData[],
-            stackTraceData: IStackTraceData[];
+        let callsGraphAnalyzer: ICallsGraphAnalyzer,
+            expectedCallsGraphData: ICallsGraphData[],
+            callsGraphData: ICallsGraphData[];
 
 
         before(() => {
         before(() => {
             const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
             const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
 
 
             inversifyContainerFacade.load('', '', {});
             inversifyContainerFacade.load('', '', {});
-            stackTraceAnalyzer = inversifyContainerFacade
-                .get<IStackTraceAnalyzer>(ServiceIdentifiers.IStackTraceAnalyzer);
+            callsGraphAnalyzer = inversifyContainerFacade
+                .get<ICallsGraphAnalyzer>(ServiceIdentifiers.ICallsGraphAnalyzer);
         });
         });
 
 
         describe('Variant #1: basic-1', () => {
         describe('Variant #1: basic-1', () => {
@@ -169,46 +169,46 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [
+                expectedCallsGraphData = [
                     {
                     {
                         name: 'baz',
                         name: 'baz',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'baz')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'baz')).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                     {
                     {
                         name: 'foo',
                         name: 'foo',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'foo')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'foo')).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                     {
                     {
                         name: 'bar',
                         name: 'bar',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'bar')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'bar')).body,
-                        stackTrace: [
+                        callsGraph: [
                             {
                             {
                                 name: 'inner2',
                                 name: 'inner2',
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner2')).body,
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner2')).body,
-                                stackTrace: [
+                                callsGraph: [
                                     {
                                     {
                                         name: 'inner3',
                                         name: 'inner3',
                                         callee: (<ESTree.FunctionExpression>getFunctionExpressionByName(astTree, 'inner3')).body,
                                         callee: (<ESTree.FunctionExpression>getFunctionExpressionByName(astTree, 'inner3')).body,
-                                        stackTrace: []
+                                        callsGraph: []
                                     },
                                     },
                                 ]
                                 ]
                             },
                             },
                             {
                             {
                                 name: 'inner1',
                                 name: 'inner1',
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner1')).body,
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner1')).body,
-                                stackTrace: []
+                                callsGraph: []
                             },
                             },
                         ]
                         ]
                     }
                     }
                 ];
                 ];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -219,35 +219,35 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [
+                expectedCallsGraphData = [
                     {
                     {
                         name: 'bar',
                         name: 'bar',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'bar')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'bar')).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                     {
                     {
                         name: 'baz',
                         name: 'baz',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'baz')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'baz')).body,
-                        stackTrace: [
+                        callsGraph: [
                             {
                             {
                                 name: 'inner1',
                                 name: 'inner1',
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner1')).body,
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner1')).body,
-                                stackTrace: []
+                                callsGraph: []
                             },
                             },
                         ]
                         ]
                     },
                     },
                     {
                     {
                         name: 'foo',
                         name: 'foo',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'foo')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'foo')).body,
-                        stackTrace: []
+                        callsGraph: []
                     }
                     }
                 ];
                 ];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -258,35 +258,35 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [
+                expectedCallsGraphData = [
                     {
                     {
                         name: 'bar',
                         name: 'bar',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'bar')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'bar')).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                     {
                     {
                         name: 'baz',
                         name: 'baz',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'baz')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'baz')).body,
-                        stackTrace: [
+                        callsGraph: [
                             {
                             {
                                 name: 'inner1',
                                 name: 'inner1',
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner1')).body,
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner1')).body,
-                                stackTrace: []
+                                callsGraph: []
                             },
                             },
                         ]
                         ]
                     },
                     },
                     {
                     {
                         name: 'foo',
                         name: 'foo',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'foo')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'foo')).body,
-                        stackTrace: []
+                        callsGraph: []
                     }
                     }
                 ];
                 ];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -297,19 +297,19 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [
+                expectedCallsGraphData = [
                     {
                     {
                         name: 'bar',
                         name: 'bar',
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'bar')).body,
                         callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'bar')).body,
-                        stackTrace: []
+                        callsGraph: []
                     }
                     }
                 ];
                 ];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -320,30 +320,30 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [
+                expectedCallsGraphData = [
                     {
                     {
                         name: 'baz',
                         name: 'baz',
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 'baz')).body,
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 'baz')).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                     {
                     {
                         name: 'baz',
                         name: 'baz',
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 'baz')).body,
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 'baz')).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                     {
                     {
                         name: 'func',
                         name: 'func',
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 'func')).body,
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 'func')).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                     {
                     {
                         name: 'bar',
                         name: 'bar',
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 'bar')).body,
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 'bar')).body,
-                        stackTrace: [
+                        callsGraph: [
                             {
                             {
                                 name: 'inner1',
                                 name: 'inner1',
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner1')).body,
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner1')).body,
-                                stackTrace: [
+                                callsGraph: [
 
 
                                 ]
                                 ]
                             },
                             },
@@ -352,11 +352,11 @@ describe('StackTraceAnalyzer', () => {
                     {
                     {
                         name: 'bar',
                         name: 'bar',
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object', 'bar')).body,
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object', 'bar')).body,
-                        stackTrace: [
+                        callsGraph: [
                             {
                             {
                                 name: 'inner',
                                 name: 'inner',
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner')).body,
                                 callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner')).body,
-                                stackTrace: [
+                                callsGraph: [
 
 
                                 ]
                                 ]
                             },
                             },
@@ -364,11 +364,11 @@ describe('StackTraceAnalyzer', () => {
                     }
                     }
                 ];
                 ];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -379,24 +379,24 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [
+                expectedCallsGraphData = [
                     {
                     {
                         name: 'baz',
                         name: 'baz',
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object', 'baz')).body,
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object', 'baz')).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                     {
                     {
                         name: 1,
                         name: 1,
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 1)).body,
                         callee: (<ESTree.FunctionExpression>getObjectFunctionExpressionByName(astTree, 'object1', 1)).body,
-                        stackTrace: []
+                        callsGraph: []
                     },
                     },
                 ];
                 ];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -407,13 +407,13 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [];
+                expectedCallsGraphData = [];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -424,13 +424,13 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [];
+                expectedCallsGraphData = [];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -441,31 +441,31 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [
+                expectedCallsGraphData = [
                     {
                     {
                         name: null,
                         name: null,
                         callee: (<ESTree.FunctionExpression>getFunctionExpressionById(astTree, 'foo')).body,
                         callee: (<ESTree.FunctionExpression>getFunctionExpressionById(astTree, 'foo')).body,
-                        stackTrace: [{
+                        callsGraph: [{
                             name: null,
                             name: null,
                             callee: (<ESTree.FunctionExpression>getFunctionExpressionById(astTree, 'bar')).body,
                             callee: (<ESTree.FunctionExpression>getFunctionExpressionById(astTree, 'bar')).body,
-                            stackTrace: [{
+                            callsGraph: [{
                                 name: null,
                                 name: null,
                                 callee: (<ESTree.FunctionExpression>getFunctionExpressionById(astTree, 'baz')).body,
                                 callee: (<ESTree.FunctionExpression>getFunctionExpressionById(astTree, 'baz')).body,
-                                stackTrace: [{
+                                callsGraph: [{
                                     name: 'inner',
                                     name: 'inner',
                                     callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner')).body,
                                     callee: (<ESTree.FunctionDeclaration>getFunctionDeclarationByName(astTree, 'inner')).body,
-                                    stackTrace: []
+                                    callsGraph: []
                                 }]
                                 }]
                             }]
                             }]
                         }]
                         }]
                     }
                     }
                 ];
                 ];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
 
 
@@ -476,19 +476,19 @@ describe('StackTraceAnalyzer', () => {
                     NodeUtils.convertCodeToStructure(code)
                     NodeUtils.convertCodeToStructure(code)
                 );
                 );
 
 
-                expectedStackTraceData = [
+                expectedCallsGraphData = [
                     {
                     {
                         name: 'bar',
                         name: 'bar',
                         callee: (<ESTree.FunctionExpression>getFunctionExpressionByName(astTree, 'bar')).body,
                         callee: (<ESTree.FunctionExpression>getFunctionExpressionByName(astTree, 'bar')).body,
-                        stackTrace: []
+                        callsGraph: []
                     }
                     }
                 ];
                 ];
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
             });
             });
 
 
-            it('should return correct stack trace data', () => {
-                assert.deepEqual(stackTraceData, expectedStackTraceData);
+            it('should return correct calls graph data', () => {
+                assert.deepEqual(callsGraphData, expectedCallsGraphData);
             });
             });
         });
         });
     });
     });

+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/basic-1.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/basic-1.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/basic-2.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/basic-2.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/call-before-declaration.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/call-before-declaration.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/call-expression-of-object-member-1.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/call-expression-of-object-member-1.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/call-expression-of-object-member-2.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/call-expression-of-object-member-2.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/deep-conditions-nesting.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/deep-conditions-nesting.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/no-call-expressions.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/no-call-expressions.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/no-recursion.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/no-recursion.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/only-call-expression.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/only-call-expression.js


+ 0 - 0
test/functional-tests/analyzers/stack-trace-analyzer/fixtures/self-invoking-functions.js → test/functional-tests/analyzers/calls-graph-analyzer/fixtures/self-invoking-functions.js


+ 2 - 2
test/index.spec.ts

@@ -5,7 +5,7 @@ require('source-map-support').install();
 /**
 /**
  * Unit tests
  * Unit tests
  */
  */
-import './unit-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec';
+import './unit-tests/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.spec';
 import './unit-tests/cli/sanitizers/ArraySanitizer.spec';
 import './unit-tests/cli/sanitizers/ArraySanitizer.spec';
 import './unit-tests/cli/sanitizers/BooleanSanitizer.spec';
 import './unit-tests/cli/sanitizers/BooleanSanitizer.spec';
 import './unit-tests/cli/sanitizers/IdentifierNamesGeneratorSanitizer.spec';
 import './unit-tests/cli/sanitizers/IdentifierNamesGeneratorSanitizer.spec';
@@ -42,7 +42,7 @@ import './unit-tests/utils/Utils.spec';
 /**
 /**
  * Functional tests
  * Functional tests
  */
  */
-import './functional-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec';
+import './functional-tests/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.spec';
 import './functional-tests/cli/JavaScriptObfuscatorCLI.spec';
 import './functional-tests/cli/JavaScriptObfuscatorCLI.spec';
 import './functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec';
 import './functional-tests/custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode.spec';
 import './functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec';
 import './functional-tests/custom-nodes/domain-lock-nodes/DomainLockNode.spec';

+ 6 - 6
test/unit-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec.ts → test/unit-tests/analyzers/calls-graph-analyzer/CallsGraphAnalyzer.spec.ts

@@ -1,8 +1,8 @@
 import { assert } from 'chai';
 import { assert } from 'chai';
 
 
-import { StackTraceAnalyzer } from '../../../../src/analyzers/stack-trace-analyzer/StackTraceAnalyzer';
+import { CallsGraphAnalyzer } from '../../../../src/analyzers/calls-graph-analyzer/CallsGraphAnalyzer';
 
 
-describe('StackTraceAnalyzer', () => {
+describe('CallsGraphAnalyzer', () => {
     describe('getLimitIndex', () => {
     describe('getLimitIndex', () => {
         let limitIndex: number;
         let limitIndex: number;
 
 
@@ -11,7 +11,7 @@ describe('StackTraceAnalyzer', () => {
             const expectedLimitIndex: number = 44;
             const expectedLimitIndex: number = 44;
 
 
             before(() => {
             before(() => {
-                limitIndex = StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength);
+                limitIndex = CallsGraphAnalyzer.getLimitIndex(blockScopeBodyLength);
             });
             });
 
 
             it('should return correct limit index based on block scope body length', () => {
             it('should return correct limit index based on block scope body length', () => {
@@ -24,7 +24,7 @@ describe('StackTraceAnalyzer', () => {
             const expectedLimitIndex: number = 26;
             const expectedLimitIndex: number = 26;
 
 
             before(() => {
             before(() => {
-                limitIndex = StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength);
+                limitIndex = CallsGraphAnalyzer.getLimitIndex(blockScopeBodyLength);
             });
             });
 
 
             it('should return correct limit index based on block scope body length', () => {
             it('should return correct limit index based on block scope body length', () => {
@@ -37,7 +37,7 @@ describe('StackTraceAnalyzer', () => {
             const expectedLimitIndex: number = 24;
             const expectedLimitIndex: number = 24;
 
 
             before(() => {
             before(() => {
-                limitIndex = StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength);
+                limitIndex = CallsGraphAnalyzer.getLimitIndex(blockScopeBodyLength);
             });
             });
 
 
             it('should return correct limit index based on block scope body length', () => {
             it('should return correct limit index based on block scope body length', () => {
@@ -50,7 +50,7 @@ describe('StackTraceAnalyzer', () => {
             const expectedLimitIndex: number = 4;
             const expectedLimitIndex: number = 4;
 
 
             before(() => {
             before(() => {
-                limitIndex = StackTraceAnalyzer.getLimitIndex(blockScopeBodyLength);
+                limitIndex = CallsGraphAnalyzer.getLimitIndex(blockScopeBodyLength);
             });
             });
 
 
             it('should return correct limit index based on block scope body length', () => {
             it('should return correct limit index based on block scope body length', () => {

+ 17 - 17
test/unit-tests/node/node-appender/NodeAppender.spec.ts

@@ -9,8 +9,8 @@ import { assert } from 'chai';
 import { TStatement } from '../../../../src/types/node/TStatement';
 import { TStatement } from '../../../../src/types/node/TStatement';
 
 
 import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
 import { IInversifyContainerFacade } from '../../../../src/interfaces/container/IInversifyContainerFacade';
-import { IStackTraceAnalyzer } from '../../../../src/interfaces/analyzers/stack-trace-analyzer/IStackTraceAnalyzer';
-import { IStackTraceData } from '../../../../src/interfaces/analyzers/stack-trace-analyzer/IStackTraceData';
+import { ICallsGraphAnalyzer } from '../../../../src/interfaces/analyzers/calls-graph-analyzer/ICallsGraphAnalyzer';
+import { ICallsGraphData } from '../../../../src/interfaces/analyzers/calls-graph-analyzer/ICallsGraphData';
 
 
 import { readFileAsString } from '../../../helpers/readFileAsString';
 import { readFileAsString } from '../../../helpers/readFileAsString';
 
 
@@ -63,18 +63,18 @@ describe('NodeAppender', () => {
     });
     });
 
 
     describe('appendToOptimalBlockScope', () => {
     describe('appendToOptimalBlockScope', () => {
-        let stackTraceAnalyzer: IStackTraceAnalyzer,
+        let callsGraphAnalyzer: ICallsGraphAnalyzer,
             astTree: ESTree.Program,
             astTree: ESTree.Program,
             expectedAstTree: ESTree.Program,
             expectedAstTree: ESTree.Program,
             node: TStatement[],
             node: TStatement[],
-            stackTraceData: IStackTraceData[];
+            callsGraphData: ICallsGraphData[];
 
 
         before(() => {
         before(() => {
             const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
             const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
 
 
             inversifyContainerFacade.load('', '', {});
             inversifyContainerFacade.load('', '', {});
-            stackTraceAnalyzer = inversifyContainerFacade
-                .get<IStackTraceAnalyzer>(ServiceIdentifiers.IStackTraceAnalyzer);
+            callsGraphAnalyzer = inversifyContainerFacade
+                .get<ICallsGraphAnalyzer>(ServiceIdentifiers.ICallsGraphAnalyzer);
         });
         });
 
 
         beforeEach(() => {
         beforeEach(() => {
@@ -86,8 +86,8 @@ describe('NodeAppender', () => {
                 astTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-1.js');
                 astTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-1.js');
                 expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-1-expected.js');
                 expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-1-expected.js');
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                NodeAppender.appendToOptimalBlockScope(stackTraceData, astTree, node);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
+                NodeAppender.appendToOptimalBlockScope(callsGraphData, astTree, node);
             });
             });
 
 
             it('should append node into first and deepest function call in nested function calls', () => {
             it('should append node into first and deepest function call in nested function calls', () => {
@@ -100,8 +100,8 @@ describe('NodeAppender', () => {
                 astTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-2.js');
                 astTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-2.js');
                 expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-2-expected.js');
                 expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/variant-2-expected.js');
 
 
-                stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                NodeAppender.appendToOptimalBlockScope(stackTraceData, astTree, node);
+                callsGraphData = callsGraphAnalyzer.analyze(astTree);
+                NodeAppender.appendToOptimalBlockScope(callsGraphData, astTree, node);
 
 
             });
             });
 
 
@@ -121,8 +121,8 @@ describe('NodeAppender', () => {
                 beforeEach(() => {
                 beforeEach(() => {
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-1-expected.js');
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-1-expected.js');
 
 
-                    stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                    NodeAppender.appendToOptimalBlockScope(stackTraceData, astTree, node, 2);
+                    callsGraphData = callsGraphAnalyzer.analyze(astTree);
+                    NodeAppender.appendToOptimalBlockScope(callsGraphData, astTree, node, 2);
 
 
                 });
                 });
 
 
@@ -135,8 +135,8 @@ describe('NodeAppender', () => {
                 beforeEach(() => {
                 beforeEach(() => {
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-2-expected.js');
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-2-expected.js');
 
 
-                    stackTraceData = stackTraceAnalyzer.analyze(astTree);
-                    NodeAppender.appendToOptimalBlockScope(stackTraceData, astTree, node, 1);
+                    callsGraphData = callsGraphAnalyzer.analyze(astTree);
+                    NodeAppender.appendToOptimalBlockScope(callsGraphData, astTree, node, 1);
 
 
                 });
                 });
 
 
@@ -150,12 +150,12 @@ describe('NodeAppender', () => {
                     astTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-3.js');
                     astTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-3.js');
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-3-expected.js');
                     expectedAstTree = convertCodeToAst('/fixtures/append-node-to-optimal-block-scope/by-index-variant-3-expected.js');
 
 
-                    stackTraceData = stackTraceAnalyzer.analyze(astTree);
+                    callsGraphData = callsGraphAnalyzer.analyze(astTree);
                     NodeAppender.appendToOptimalBlockScope(
                     NodeAppender.appendToOptimalBlockScope(
-                        stackTraceData,
+                        callsGraphData,
                         astTree,
                         astTree,
                         node,
                         node,
-                        stackTraceData.length - 1
+                        callsGraphData.length - 1
                     );
                     );
 
 
                 });
                 });

Some files were not shown because too many files changed in this diff