From fb86bb05101e0d9d4e479b64b754fcdb07047d5d Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Thu, 13 Jul 2023 10:14:04 -0400 Subject: [PATCH] chg: [expansion:extract_url_components] Better support in case attributes are not defined --- misp_modules/modules/expansion/extract_url_components.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/misp_modules/modules/expansion/extract_url_components.py b/misp_modules/modules/expansion/extract_url_components.py index d78da39..3806bf3 100644 --- a/misp_modules/modules/expansion/extract_url_components.py +++ b/misp_modules/modules/expansion/extract_url_components.py @@ -22,9 +22,12 @@ def createObjectFromURL(url): if parsed['subdomain'] is not None: obj.add_attribute('subdomain', type='text', value=parsed['subdomain']) obj.add_attribute('scheme', type='text', value=parsed['scheme']) - obj.add_attribute('resource_path', type='text', value=parsed['resource_path']) - obj.add_attribute('query_string', type='text', value=parsed['query_string']) - obj.add_attribute('port', type='port', value=parsed['port']) + if parsed['resource_path'] is not None: + obj.add_attribute('resource_path', type='text', value=parsed['resource_path']) + if parsed['query_string'] is not None: + obj.add_attribute('query_string', type='text', value=parsed['query_string']) + if parsed['port'] is not None: + obj.add_attribute('port', type='port', value=parsed['port']) obj.add_attribute('host', type='hostname', value=parsed['host']) if parsed['fragment'] is not None: obj.add_attribute('fragment', type='text', value=parsed['fragment'])