From 4f44401252c4f293a2027d7b461cbf4fcca0cf09 Mon Sep 17 00:00:00 2001 From: patel-bhavin Date: Tue, 13 Jul 2021 13:30:48 -0500 Subject: [PATCH] adding lookup files --- bin/generate.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/generate.py b/bin/generate.py index c769122bcf..f36651dab0 100644 --- a/bin/generate.py +++ b/bin/generate.py @@ -14,6 +14,7 @@ from jinja2 import Environment, FileSystemLoader import re from attackcti import attack_client import csv +import shutil def load_objects(file_path, VERBOSE, REPO_PATH): @@ -45,6 +46,16 @@ def load_file(file_path): sys.exit("ERROR: reading {0}".format(file_path)) return file +def generate_lookup_files(lookups, TEMPLATE_PATH, OUTPUT_PATH,REPO_PATH): + sorted_lookups = sorted(lookups, key=lambda i: i['name']) + utc_time = datetime.datetime.utcnow().replace(microsecond=0).isoformat() + for i in sorted_lookups: + for k,v in i.items(): + if k == 'filename': + lookup_file = REPO_PATH +'/lookups/'+ v + dist_lookup_dir = OUTPUT_PATH +'/lookups' + shutil.copy(lookup_file,dist_lookup_dir) + return sorted_lookups def generate_transforms_conf(lookups, TEMPLATE_PATH, OUTPUT_PATH): sorted_lookups = sorted(lookups, key=lambda i: i['name']) @@ -625,9 +636,10 @@ def main(REPO_PATH, OUTPUT_PATH, PRODUCT, VERBOSE): except Exception as e: print('Error: ' + str(e)) print("WARNING: Generation of Mitre lookup failed.") - + lookups_path = generate_transforms_conf(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH) lookups_path = generate_collections_conf(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH) + lookups_files = generate_lookup_files(objects["lookups"], TEMPLATE_PATH, OUTPUT_PATH,REPO_PATH) detection_path = generate_savedsearches_conf(objects["detections"], objects["response_tasks"], objects["baselines"], objects["deployments"], TEMPLATE_PATH, OUTPUT_PATH) @@ -673,4 +685,4 @@ if __name__ == "__main__": VERBOSE = args.verbose PRODUCT = args.product - main(REPO_PATH, OUTPUT_PATH, PRODUCT, VERBOSE) + main(REPO_PATH, OUTPUT_PATH, PRODUCT, VERBOSE) \ No newline at end of file