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 2, 2025
1 parent f58bc25 commit 3a8c96b
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(

Check warning on line 412 in troubadix/plugins/valid_oid.py

View check run for this annotation

Codecov / codecov/patch

troubadix/plugins/valid_oid.py#L412

Added line #L412 was not covered by tests
"VT is missing a script name!",
"VT is missing a script family!",
file=nasl_file,
plugin=self.name,
)
return

Check warning on line 417 in troubadix/plugins/valid_oid.py

View check run for this annotation

Codecov / codecov/patch

troubadix/plugins/valid_oid.py#L417

Added line #L417 was not covered by tests

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(

Check warning on line 433 in troubadix/plugins/valid_oid.py

View check run for this annotation

Codecov / codecov/patch

troubadix/plugins/valid_oid.py#L433

Added line #L433 was not covered by tests
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

Check warning on line 440 in troubadix/plugins/valid_oid.py

View check run for this annotation

Codecov / codecov/patch

troubadix/plugins/valid_oid.py#L440

Added line #L440 was not covered by tests
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 3a8c96b

Please sign in to comment.