Skip to content

Commit

Permalink
Change: PR review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-gb committed Jan 8, 2025
1 parent 33d4a51 commit 9307cf1
Showing 1 changed file with 28 additions and 35 deletions.
63 changes: 28 additions & 35 deletions troubadix/plugins/valid_oid.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ def check_content(
)
return

family_pattern = get_special_script_tag_pattern(SpecialScriptTag.FAMILY)
family_match = family_pattern.search(file_content)

# Vendor-specific OIDs
if "1.3.6.1.4.1.25623.1.1." in oid:
family_pattern = get_special_script_tag_pattern(
SpecialScriptTag.FAMILY
)
family_match = family_pattern.search(file_content)
if family_match is None or family_match.group("value") is None:
yield LinterError(
"VT is missing a script family!",
Expand Down Expand Up @@ -405,47 +404,41 @@ def check_content(
return

return

# Fixed OID-scheme for Windows OIDs
if "1.3.6.1.4.1.25623.1.3." in oid:
family_pattern = get_special_script_tag_pattern(
SpecialScriptTag.FAMILY
)
family_match = family_pattern.search(file_content)
if not family_match or not family_match.group("value"):
family = family_match.group("value")
if not family_match or not family:
yield LinterError(
"VT is missing a script name!",
"VT is missing a script family!",
file=nasl_file,
plugin=self.name,
)
return

family = family_match.group("value")

# Fixed OID-scheme for win-vt-generator
if "1.3.6.1.4.1.25623.1.3" in oid:
if family != windows_family_template:
yield LinterError(
f"script_oid() {is_using_reserved} 'Windows' ("
f"{str(oid)})",
file=nasl_file,
plugin=self.name,
)
return

windows_oid_match = re.search(
r"^1\.3\.6\.1\.4\.1\.25623\.1\.3\.[0-9]{5}\.[0-9]\.[0-9]{7}\.[0-9]{30}",
oid,
if family != windows_family_template:
yield LinterError(
f"script_oid() {is_using_reserved} 'Windows' ("
f"{str(oid)})",
file=nasl_file,
plugin=self.name,
)
if not windows_oid_match:
yield LinterError(
f"script_oid() {invalid_oid} '{str(oid)}' "
"(Windows pattern: 1.3.6.1.4.1.25623.1.3."
"[product_id].[platform_id].[kb_article_id].[fixed_build_number])",
file=nasl_file,
plugin=self.name,
)
return
return

windows_oid_match = re.search(
r"^1\.3\.6\.1\.4\.1\.25623\.1\.3\.[0-9]{5}\.[0-9]\.[0-9]{7}\.[0-9]{30}",
oid,
)
if not windows_oid_match:
yield LinterError(
f"script_oid() {invalid_oid} '{str(oid)}' "
"(Windows pattern: 1.3.6.1.4.1.25623.1.3."
"[product_id].[platform_id].[kb_article_id].[fixed_build_number])",
file=nasl_file,
plugin=self.name,
)
return
return

oid_digit_match = re.search(
r"^1\.3\.6\.1\.4\.1\.25623\.1\.0\.([0-9]+)", oid
Expand Down

0 comments on commit 9307cf1

Please sign in to comment.