CustomNodesModule.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import { InversifyContainerFacade } from '../../InversifyContainerFacade';
  2. import { ContainerModule, interfaces } from 'inversify';
  3. import { ServiceIdentifiers } from '../../ServiceIdentifiers';
  4. import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
  5. import { ICustomNodeFormatter } from '../../../interfaces/custom-nodes/ICustomNodeFormatter';
  6. import { ICustomNodeGroup } from '../../../interfaces/custom-nodes/ICustomNodeGroup';
  7. import { ControlFlowCustomNode } from "../../../enums/custom-nodes/ControlFlowCustomNode";
  8. import { CustomNode } from '../../../enums/custom-nodes/CustomNode';
  9. import { CustomNodeGroup } from '../../../enums/custom-nodes/CustomNodeGroup';
  10. import { DeadCodeInjectionCustomNode } from '../../../enums/custom-nodes/DeadCodeInjectionCustomNode';
  11. import { ObjectExpressionKeysTransformerCustomNode } from '../../../enums/custom-nodes/ObjectExpressionKeysTransformerCustomNode';
  12. import { ConsoleOutputCustomNodeGroup } from '../../../custom-nodes/console-output-nodes/group/ConsoleOutputCustomNodeGroup';
  13. import { DebugProtectionCustomNodeGroup } from '../../../custom-nodes/debug-protection-nodes/group/DebugProtectionCustomNodeGroup';
  14. import { DomainLockCustomNodeGroup } from '../../../custom-nodes/domain-lock-nodes/group/DomainLockCustomNodeGroup';
  15. import { SelfDefendingCustomNodeGroup } from '../../../custom-nodes/self-defending-nodes/group/SelfDefendingCustomNodeGroup';
  16. import { StringArrayCustomNodeGroup } from '../../../custom-nodes/string-array-nodes/group/StringArrayCustomNodeGroup';
  17. import { ObjectExpressionVariableDeclarationHostNode } from '../../../custom-nodes/object-expression-keys-transformer-nodes/ObjectExpressionVariableDeclarationHostNode';
  18. import { BinaryExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/BinaryExpressionFunctionNode';
  19. import { BlockStatementControlFlowFlatteningNode } from '../../../custom-nodes/control-flow-flattening-nodes/BlockStatementControlFlowFlatteningNode';
  20. import { BlockStatementDeadCodeInjectionNode } from '../../../custom-nodes/dead-code-injection-nodes/BlockStatementDeadCodeInjectionNode';
  21. import { CallExpressionControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/CallExpressionControlFlowStorageCallNode';
  22. import { CallExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/CallExpressionFunctionNode';
  23. import { ControlFlowStorageNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode';
  24. import { ConsoleOutputDisableExpressionNode } from '../../../custom-nodes/console-output-nodes/ConsoleOutputDisableExpressionNode';
  25. import { CustomNodeFormatter } from '../../../custom-nodes/CustomNodeFormatter';
  26. import { DebugProtectionFunctionCallNode } from '../../../custom-nodes/debug-protection-nodes/DebugProtectionFunctionCallNode';
  27. import { DebugProtectionFunctionIntervalNode } from '../../../custom-nodes/debug-protection-nodes/DebugProtectionFunctionIntervalNode';
  28. import { DebugProtectionFunctionNode } from '../../../custom-nodes/debug-protection-nodes/DebugProtectionFunctionNode';
  29. import { DomainLockNode } from '../../../custom-nodes/domain-lock-nodes/DomainLockNode';
  30. import { ExpressionWithOperatorControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ExpressionWithOperatorControlFlowStorageCallNode';
  31. import { LogicalExpressionFunctionNode } from '../../../custom-nodes/control-flow-flattening-nodes/LogicalExpressionFunctionNode';
  32. import { NodeCallsControllerFunctionNode } from '../../../custom-nodes/node-calls-controller-nodes/NodeCallsControllerFunctionNode';
  33. import { SelfDefendingUnicodeNode } from '../../../custom-nodes/self-defending-nodes/SelfDefendingUnicodeNode';
  34. import { StringArrayCallsWrapper } from '../../../custom-nodes/string-array-nodes/StringArrayCallsWrapper';
  35. import { StringArrayNode } from '../../../custom-nodes/string-array-nodes/StringArrayNode';
  36. import { StringArrayRotateFunctionNode } from '../../../custom-nodes/string-array-nodes/StringArrayRotateFunctionNode';
  37. import { StringLiteralControlFlowStorageCallNode } from '../../../custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/StringLiteralControlFlowStorageCallNode';
  38. import { StringLiteralNode } from '../../../custom-nodes/control-flow-flattening-nodes/StringLiteralNode';
  39. export const customNodesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
  40. // custom nodes
  41. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  42. .to(ConsoleOutputDisableExpressionNode)
  43. .whenTargetNamed(CustomNode.ConsoleOutputDisableExpressionNode);
  44. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  45. .to(DebugProtectionFunctionCallNode)
  46. .whenTargetNamed(CustomNode.DebugProtectionFunctionCallNode);
  47. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  48. .to(DebugProtectionFunctionIntervalNode)
  49. .whenTargetNamed(CustomNode.DebugProtectionFunctionIntervalNode);
  50. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  51. .to(DebugProtectionFunctionNode)
  52. .whenTargetNamed(CustomNode.DebugProtectionFunctionNode);
  53. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  54. .to(DomainLockNode)
  55. .whenTargetNamed(CustomNode.DomainLockNode);
  56. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  57. .to(NodeCallsControllerFunctionNode)
  58. .whenTargetNamed(CustomNode.NodeCallsControllerFunctionNode);
  59. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  60. .to(SelfDefendingUnicodeNode)
  61. .whenTargetNamed(CustomNode.SelfDefendingUnicodeNode);
  62. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  63. .to(StringArrayCallsWrapper)
  64. .whenTargetNamed(CustomNode.StringArrayCallsWrapper);
  65. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  66. .to(StringArrayNode)
  67. .whenTargetNamed(CustomNode.StringArrayNode);
  68. bind<ICustomNode>(ServiceIdentifiers.ICustomNode)
  69. .to(StringArrayRotateFunctionNode)
  70. .whenTargetNamed(CustomNode.StringArrayRotateFunctionNode);
  71. // control flow custom nodes
  72. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  73. .toConstructor(BinaryExpressionFunctionNode)
  74. .whenTargetNamed(ControlFlowCustomNode.BinaryExpressionFunctionNode);
  75. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  76. .toConstructor(BlockStatementControlFlowFlatteningNode)
  77. .whenTargetNamed(ControlFlowCustomNode.BlockStatementControlFlowFlatteningNode);
  78. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  79. .toConstructor(CallExpressionControlFlowStorageCallNode)
  80. .whenTargetNamed(ControlFlowCustomNode.CallExpressionControlFlowStorageCallNode);
  81. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  82. .toConstructor(CallExpressionFunctionNode)
  83. .whenTargetNamed(ControlFlowCustomNode.CallExpressionFunctionNode);
  84. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  85. .toConstructor(ControlFlowStorageNode)
  86. .whenTargetNamed(ControlFlowCustomNode.ControlFlowStorageNode);
  87. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  88. .toConstructor(ExpressionWithOperatorControlFlowStorageCallNode)
  89. .whenTargetNamed(ControlFlowCustomNode.ExpressionWithOperatorControlFlowStorageCallNode);
  90. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  91. .toConstructor(LogicalExpressionFunctionNode)
  92. .whenTargetNamed(ControlFlowCustomNode.LogicalExpressionFunctionNode);
  93. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  94. .toConstructor(StringLiteralNode)
  95. .whenTargetNamed(ControlFlowCustomNode.StringLiteralNode);
  96. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  97. .toConstructor(StringLiteralControlFlowStorageCallNode)
  98. .whenTargetNamed(ControlFlowCustomNode.StringLiteralControlFlowStorageCallNode);
  99. // dead code injection custom nodes
  100. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  101. .toConstructor(BlockStatementDeadCodeInjectionNode)
  102. .whenTargetNamed(DeadCodeInjectionCustomNode.BlockStatementDeadCodeInjectionNode);
  103. // object expression keys transformer nodes
  104. bind<interfaces.Newable<ICustomNode>>(ServiceIdentifiers.Newable__ICustomNode)
  105. .toConstructor(ObjectExpressionVariableDeclarationHostNode)
  106. .whenTargetNamed(ObjectExpressionKeysTransformerCustomNode.ObjectExpressionVariableDeclarationHostNode);
  107. // node groups
  108. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  109. .to(ConsoleOutputCustomNodeGroup)
  110. .whenTargetNamed(CustomNodeGroup.ConsoleOutputCustomNodeGroup);
  111. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  112. .to(DebugProtectionCustomNodeGroup)
  113. .whenTargetNamed(CustomNodeGroup.DebugProtectionCustomNodeGroup);
  114. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  115. .to(DomainLockCustomNodeGroup)
  116. .whenTargetNamed(CustomNodeGroup.DomainLockCustomNodeGroup);
  117. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  118. .to(SelfDefendingCustomNodeGroup)
  119. .whenTargetNamed(CustomNodeGroup.SelfDefendingCustomNodeGroup);
  120. bind<ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup)
  121. .to(StringArrayCustomNodeGroup)
  122. .whenTargetNamed(CustomNodeGroup.StringArrayCustomNodeGroup);
  123. // customNode factory
  124. bind<ICustomNode>(ServiceIdentifiers.Factory__ICustomNode)
  125. .toFactory<ICustomNode>(InversifyContainerFacade
  126. .getFactory<CustomNode, ICustomNode>(ServiceIdentifiers.ICustomNode));
  127. // control flow customNode constructor factory
  128. bind<ICustomNode>(ServiceIdentifiers.Factory__IControlFlowCustomNode)
  129. .toFactory<ICustomNode>(InversifyContainerFacade
  130. .getConstructorFactory<ControlFlowCustomNode, ICustomNode>(
  131. ServiceIdentifiers.Newable__ICustomNode,
  132. ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
  133. ServiceIdentifiers.ICustomNodeFormatter,
  134. ServiceIdentifiers.IRandomGenerator,
  135. ServiceIdentifiers.IOptions,
  136. ServiceIdentifiers.IPrevailingKindOfVariablesAnalyzer
  137. ));
  138. // dead code injection customNode constructor factory
  139. bind<ICustomNode>(ServiceIdentifiers.Factory__IDeadCodeInjectionCustomNode)
  140. .toFactory<ICustomNode>(InversifyContainerFacade
  141. .getConstructorFactory<DeadCodeInjectionCustomNode, ICustomNode>(
  142. ServiceIdentifiers.Newable__ICustomNode,
  143. ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
  144. ServiceIdentifiers.ICustomNodeFormatter,
  145. ServiceIdentifiers.IRandomGenerator,
  146. ServiceIdentifiers.IOptions
  147. ));
  148. // object expression keys transformer customNode constructor factory
  149. bind<ICustomNode>(ServiceIdentifiers.Factory__IObjectExpressionKeysTransformerCustomNode)
  150. .toFactory<ICustomNode>(InversifyContainerFacade
  151. .getConstructorFactory<ObjectExpressionKeysTransformerCustomNode, ICustomNode>(
  152. ServiceIdentifiers.Newable__ICustomNode,
  153. ServiceIdentifiers.Factory__IIdentifierNamesGenerator,
  154. ServiceIdentifiers.ICustomNodeFormatter,
  155. ServiceIdentifiers.IRandomGenerator,
  156. ServiceIdentifiers.IOptions,
  157. ServiceIdentifiers.IPrevailingKindOfVariablesAnalyzer
  158. ));
  159. // customNodeGroup factory
  160. bind<ICustomNodeGroup>(ServiceIdentifiers.Factory__ICustomNodeGroup)
  161. .toFactory<ICustomNodeGroup>(InversifyContainerFacade
  162. .getFactory<CustomNodeGroup, ICustomNodeGroup>(ServiceIdentifiers.ICustomNodeGroup));
  163. // custom node formatter
  164. bind<ICustomNodeFormatter>(ServiceIdentifiers.ICustomNodeFormatter)
  165. .to(CustomNodeFormatter)
  166. .inSingletonScope();
  167. });