From 0647e27385014b7e81c90c48b013dd9f4bdf36d6 Mon Sep 17 00:00:00 2001 From: Hannah Ward Date: Fri, 18 Nov 2016 14:42:17 +0000 Subject: [PATCH] Added rudimentary duplicate checking --- misp_taxii_hooks/hooks.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/misp_taxii_hooks/hooks.py b/misp_taxii_hooks/hooks.py index 2147748..ad18aa7 100644 --- a/misp_taxii_hooks/hooks.py +++ b/misp_taxii_hooks/hooks.py @@ -37,7 +37,17 @@ def post_stix(manager, content_block, collection_ids, service_id): # Load the package package = pymisp.tools.stix.load_stix(f.name) - + + # Check for duplicates + for attrib in package.attributes: + try: + if (0 != len(MISP.search_index(attrib.value)["response"])): + # It's a dupe! + package.attributes.remove(attrib) + except: + # idk, this is just in case pymisp does a weird + pass + # Delete that old temporary file os.unlink(f.name)