Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7093526
commit 3b2fc33
Showing
2 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 19 additions & 2 deletions
21
stix_shifter_modules/reaqta/stix_translation/results_translator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
import os | ||
import json | ||
from stix_shifter_utils.stix_translation.src.json_to_stix.json_to_stix import JSONToStix | ||
|
||
|
||
class ResultsTranslator(JSONToStix): | ||
pass | ||
|
||
def __init__(self, options, dialect, base_file_path=None, callback=None): | ||
super().__init__(options, dialect, base_file_path, callback) | ||
|
||
event_names_path = os.path.abspath(os.path.join(base_file_path, "json", "event_names_map.json")) | ||
self.event_names = self.read_json(event_names_path, options) | ||
|
||
def translate_results(self, data_source, data): | ||
results = json.loads(data) | ||
for result in results: | ||
payload = result['payload'] | ||
if payload.get('eventType'): | ||
event_name = self.event_names[str(payload.get('eventType'))] | ||
result['payload']['eventName'] = event_name | ||
|
||
data = json.dumps(results, indent=4) | ||
return super().translate_results(data_source, data) |