Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extract_cve_from_tag to Shadowserver parser _config.py #2457

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions intelmq/bots/parsers/shadowserver/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ def category_or_detail(value: str, row: Dict[str, str]) -> str:
return row.get('detail', '')


def extract_cve_from_tag(tag: str) -> Optional[str]:
""" Returns a string with a sorted semicolon-separated list of CVEs or None if no CVE found in tag. """
cveset = set()
tags = tag.split(";")

for t in tags:
if re.match('^cve-[0-9]+-[0-9]+$', t):
cveset.add(t)

if not (len(cveset)):
return None
return (';'.join(str(c) for c in sorted(cveset)))


functions = {
'add_UTC_to_timestamp': add_UTC_to_timestamp,
'convert_bool': convert_bool,
Expand All @@ -308,6 +322,7 @@ def category_or_detail(value: str, row: Dict[str, str]) -> str:
'scan_exchange_type': scan_exchange_type,
'scan_exchange_identifier': scan_exchange_identifier,
'category_or_detail': category_or_detail,
'extract_cve_from_tag': extract_cve_from_tag,
}


Expand Down
Loading