2
2
import multiprocessing
3
3
import time
4
4
from ipaddress import IPv4Interface
5
- from typing import Any , Callable , Collection , Dict , List , Optional , Sequence
5
+ from typing import Any , Callable , Dict , List , Optional , Sequence
6
6
7
7
from egg_timer import EggTimer
8
8
9
- from common .agent_configuration import PluginConfiguration
10
9
from infection_monkey .i_control_channel import IControlChannel , IslandCommunicationError
11
10
from infection_monkey .i_master import IMaster
12
11
from infection_monkey .i_puppet import IPuppet
@@ -127,7 +126,7 @@ def _run_simulation(self):
127
126
return
128
127
129
128
credentials_collector_thread = create_daemon_thread (
130
- target = self ._run_plugins_legacy ,
129
+ target = self ._run_plugins ,
131
130
name = "CredentialsCollectorThread" ,
132
131
args = (
133
132
config .credentials_collectors ,
@@ -156,13 +155,13 @@ def _run_simulation(self):
156
155
payload_thread .start ()
157
156
payload_thread .join ()
158
157
159
- def _collect_credentials (self , collector : PluginConfiguration ):
158
+ def _collect_credentials (self , collector_name : str , collector_options : Dict [ str , Any ] ):
160
159
credentials = self ._puppet .run_credentials_collector (
161
- collector . name , collector . options , self ._stop
160
+ collector_name , collector_options , self ._stop
162
161
)
163
162
164
163
if not credentials :
165
- logger .debug (f"No credentials were collected by { collector } " )
164
+ logger .debug (f"No credentials were collected by { collector_name } " )
166
165
167
166
def _run_payload (self , name : str , options : Dict ):
168
167
self ._puppet .run_payload (name , options , self ._stop )
@@ -188,26 +187,5 @@ def _run_plugins(
188
187
189
188
logger .info (f"Finished running { plugin_type } s" )
190
189
191
- def _run_plugins_legacy (
192
- self ,
193
- plugins : Collection [PluginConfiguration ],
194
- plugin_type : str ,
195
- callback : Callable [[Any ], None ],
196
- ):
197
- logger .info (f"Running { plugin_type } s" )
198
- logger .debug (f"Found { len (plugins )} { plugin_type } (s) to run" )
199
-
200
- interrupted_message = f"Received a stop signal, skipping remaining { plugin_type } s"
201
- for p in interruptible_iter (plugins , self ._stop , interrupted_message ):
202
- try :
203
- callback (p )
204
- except Exception :
205
- logger .exception (
206
- f"Got unhandled exception when running { plugin_type } plugin { p } . "
207
- f"Plugin was passed to { callback } "
208
- )
209
-
210
- logger .info (f"Finished running { plugin_type } s" )
211
-
212
190
def cleanup (self ):
213
191
pass
0 commit comments