Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-gb committed Jun 21, 2024
1 parent 3d517f3 commit 9365bea
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions troubadix/standalone_plugins/deprecate_vts.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DeprecatedFile:


# CHANGE AS NEEDED
FILENAME_REGEX = re.compile(r"gb_rhsa_2021")
FILENAME_REGEX = re.compile(r"gb_rhsa_2020")

KB_ITEMS = re.compile(r"set_kb_item\(.+\);")

Expand All @@ -55,9 +55,10 @@ def update_summary(file: DeprecatedFile, oid_mapping_path: Path = None) -> str:
else:
deprecate_text = "This VT has been deprecated."

summary = get_summary(file.content)
if summary:
file.content = deprecate_text + summary
old_summary = get_summary(file.content)
if old_summary:
new_summary = deprecate_text + old_summary
file.content = file.content.replace(old_summary, new_summary)
else:
print(f"No summary in: {file.name}")

Expand Down Expand Up @@ -174,21 +175,21 @@ def deprecate(
file.content,
)
if dependencies:
tags_to_remove += dependencies.group()
tags_to_remove.append(dependencies.group())

udp = re.search(
get_special_script_tag_pattern(SpecialScriptTag.REQUIRE_UDP_PORTS),
file.content,
)
if udp:
tags_to_remove += udp.group()
tags_to_remove.append(udp.group())

man_keys = re.search(
get_special_script_tag_pattern(SpecialScriptTag.MANDATORY_KEYS),
file.content,
)
if man_keys:
tags_to_remove += man_keys.group()
tags_to_remove.append(man_keys.group())

for tag in tags_to_remove:
file.content = file.content.replace(tag + "\n", "")
Expand Down

0 comments on commit 9365bea

Please sign in to comment.