Skip to content

Commit

Permalink
Add extract_cve_from_tag to Shadowserver parser _config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
th-certbund committed Feb 5, 2024
1 parent 51500be commit 31d2864
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 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 comma-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 Down

0 comments on commit 31d2864

Please sign in to comment.