this is the processor to run after docker machine is up to grab the log files or do other needed process...
| 14 | |
| 15 | |
| 16 | class ModuleProcessor: |
| 17 | """ |
| 18 | this is the processor to run after docker machine is up to grab the |
| 19 | log files or do other needed process... |
| 20 | """ |
| 21 | |
| 22 | def __init__(self): |
| 23 | self.kill_flag = False |
| 24 | |
| 25 | def processor(self): |
| 26 | """ |
| 27 | processor function will be called as a new thread and will be |
| 28 | die when kill_flag is True |
| 29 | """ |
| 30 | while not self.kill_flag: |
| 31 | if os.path.exists(LOGFILE) and os.path.getsize(LOGFILE) > 0: |
| 32 | |
| 33 | # os.rename(self.log_filename, self.log_filename_dump) |
| 34 | data_dump = open(LOGFILE).readlines() |
| 35 | open(LOGFILE, 'w').write('') |
| 36 | # data_dump = open(self.log_filename_dump).readlines() |
| 37 | for data in data_dump: |
| 38 | data_json = json.loads(data) |
| 39 | ip = data_json["ip"] |
| 40 | time_of_insertion = data_json["time"] |
| 41 | if data_json["authorization"] != "-": |
| 42 | authorization = \ |
| 43 | data_json["authorization"].split(' ')[1] |
| 44 | # binascii is returning bytes |
| 45 | authorization = binascii.a2b_base64(authorization).decode('utf-8') |
| 46 | username = authorization.split(":")[0] |
| 47 | password = ":".join(authorization.split(":")[1:]) |
| 48 | insert_to_credential_events_collection( |
| 49 | CredentialEvent( |
| 50 | ip_src=ip, |
| 51 | username=username, |
| 52 | password=password, |
| 53 | module_name="http/basic_auth_strong_password", |
| 54 | date=time_of_insertion |
| 55 | ) |
| 56 | ) |
| 57 | time.sleep(0.1) |
| 58 | |
| 59 | |
| 60 | def module_configuration(): |
no outgoing calls
no test coverage detected