From ddd8fbf7691a9507feb8558a0d9d9a25f64e2b6c Mon Sep 17 00:00:00 2001 From: MSAdministrator Date: Thu, 11 May 2023 15:20:20 -0500 Subject: [PATCH] fix: Updating error handling and checking in generated data --- generate_data/pyattckdata.py | 9 +++++++-- generate_data/services/stockpile.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/generate_data/pyattckdata.py b/generate_data/pyattckdata.py index 35981af..2fc4204 100644 --- a/generate_data/pyattckdata.py +++ b/generate_data/pyattckdata.py @@ -56,8 +56,12 @@ def go(self): NewBeeAttackDataset, AttckDatasources ]: - print(f"Processing {service} now.") - getattr(service(), 'get')() + try: + print(f"Processing {service} now.") + getattr(service(), 'get')() + except Exception as e: + print(f"ERROR WITH SERVICE '{service}': {e}") + continue return asdict(self.generated_data) def _update_attack_patterns(self, item, generated_data): @@ -125,6 +129,7 @@ def _save_json_data(self, force: bool=False) -> None: return True def save(self): + data = self.go() with open('generated_attck_data_v2.json', 'w+') as f: f.write(json.dumps(data)) diff --git a/generate_data/services/stockpile.py b/generate_data/services/stockpile.py index 3c94725..1e7313e 100644 --- a/generate_data/services/stockpile.py +++ b/generate_data/services/stockpile.py @@ -77,7 +77,7 @@ def gen_dict_extract(self, key, var): def __parse_yaml_content(self, content, url): if isinstance(content, list): for item in content: - if item.get('platforms'): + if item.get('platforms') and item.get("technique") and item.get("description"): if isinstance(item['platforms'], dict): new_item = self.gen_dict_extract('command', item) if new_item: