@@ -52,13 +52,20 @@ def get_iocs_from_string(
52
52
include_source_ip : Optional [bool ] = False ,
53
53
) -> dict :
54
54
iocs = Iocs ()
55
- string = self .replace_dots_hxxp (string , ioc_parsing_rules )
56
55
if not include_ioc_types or "ip" in include_ioc_types :
57
56
iocs .ip .extend (self ._find_all_str_by_regex (string , IP_IOC_REGEXP_PATTERN ))
58
57
if not include_ioc_types or "domain" in include_ioc_types :
59
- iocs .domain .extend (self ._find_all_str_by_regex (string , DOMAIN_IOC_REGEXP_PATTERN ))
58
+ for domain in self ._find_all_str_by_regex (string , DOMAIN_IOC_REGEXP_PATTERN ):
59
+ for domain_val in domain :
60
+ if domain_val :
61
+ iocs .domain .extend (self .replace_dots_hxxp (domain_val ))
60
62
if not include_ioc_types or "url" in include_ioc_types :
61
- iocs .url .extend ([url .rstrip ("." ) for url in self ._find_all_str_by_regex (string , URL_IOC_REGEXP_PATTERN )])
63
+ iocs .url .extend (
64
+ [
65
+ self .replace_dots_hxxp (url ).rstrip ("." )
66
+ for url in self ._find_all_str_by_regex (string , URL_IOC_REGEXP_PATTERN )
67
+ ]
68
+ )
62
69
if not include_ioc_types or "hash" in include_ioc_types :
63
70
if not include_hash_types :
64
71
include_hash_types = list (hash_regexes .keys ())
@@ -74,7 +81,7 @@ def get_iocs_from_string(
74
81
raise IocsLimitExceededException (f"IOCs count { total_count } exceeds limit { limit } ." )
75
82
return iocs .return_iocs (include_source_ip )
76
83
77
- def replace_dots_hxxp (self , string : str , ioc_parsing_rules : Optional [list [IocParsingRule ]]) -> str :
84
+ def replace_dots_hxxp (self , string : str , ioc_parsing_rules : Optional [list [IocParsingRule ]] = None ) -> str :
78
85
if ioc_parsing_rules is None or "replace_dots" in ioc_parsing_rules :
79
86
string = self ._replace_dots (string )
80
87
if ioc_parsing_rules is None or "replace_hxxp" in ioc_parsing_rules :
0 commit comments