Skip to content

Commit 16138fe

Browse files
committed
gis-9379 fix
1 parent e078abf commit 16138fe

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

uncoder-core/app/translator/core/parser_cti.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,20 @@ def get_iocs_from_string(
5252
include_source_ip: Optional[bool] = False,
5353
) -> dict:
5454
iocs = Iocs()
55-
string = self.replace_dots_hxxp(string, ioc_parsing_rules)
5655
if not include_ioc_types or "ip" in include_ioc_types:
5756
iocs.ip.extend(self._find_all_str_by_regex(string, IP_IOC_REGEXP_PATTERN))
5857
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))
6062
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+
)
6269
if not include_ioc_types or "hash" in include_ioc_types:
6370
if not include_hash_types:
6471
include_hash_types = list(hash_regexes.keys())
@@ -74,7 +81,7 @@ def get_iocs_from_string(
7481
raise IocsLimitExceededException(f"IOCs count {total_count} exceeds limit {limit}.")
7582
return iocs.return_iocs(include_source_ip)
7683

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:
7885
if ioc_parsing_rules is None or "replace_dots" in ioc_parsing_rules:
7986
string = self._replace_dots(string)
8087
if ioc_parsing_rules is None or "replace_hxxp" in ioc_parsing_rules:

uncoder-core/app/translator/tools/const.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
IOCType = Literal["ip", "domain", "url", "hash"]
88
HashType = Literal["md5", "sha1", "sha256", "sha512"]
9-
IocParsingRule = Literal["replace_dots", "remove_private_and_reserved_ips", "replace_hxxp"]
9+
IocParsingRule = Literal["remove_private_and_reserved_ips"]
1010

1111
DefaultIOCType = list(get_args(IOCType))
1212
DefaultHashType = list(get_args(HashType))
13-
DefaultIocParsingRule = list(get_args(Literal["remove_private_and_reserved_ips"]))
13+
DefaultIocParsingRule = list(get_args(IocParsingRule))
1414

1515
HASH_MAP = {"md5": "HashMd5", "sha1": "HashSha1", "sha256": "HashSha256", "sha512": "HashSha512"}
1616

@@ -22,10 +22,10 @@
2222
}
2323

2424
LOGSOURCE_MAP = {
25-
"hash": {"category": "process_creation"},
25+
"hash": {"category": "file_event"},
2626
"domain": {"category": "proxy"},
2727
"url": {"category": "proxy"},
28-
"ip": {"category": "proxy"},
28+
"ip": {"category": "firewall"},
2929
"emails": {"category": "mail"},
3030
"files": {"category": "file_event"},
3131
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy