Skip to content

Commit

Permalink
Change: move check for script family to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-gb committed Jan 15, 2025
1 parent 437fd08 commit bd2f8fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
7 changes: 6 additions & 1 deletion tests/plugins/test_valid_oid.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
class CheckValidOIDTestCase(PluginTestCase):
def test_ok(self):
path = Path("some/file.nasl")
content = ' script_oid("1.3.6.1.4.1.25623.1.0.100376");\n'
content = (
' script_oid("1.3.6.1.4.1.25623.1.0.100376");\n'
' script_family("Huawei EulerOS Local Security Checks");\n'
)
fake_context = self.create_file_plugin_context(
nasl_file=path, file_content=content
)
Expand Down Expand Up @@ -764,6 +767,7 @@ def test_script_name__product_firefox_ok(self):
content = (
' script_oid("1.3.6.1.4.1.25623.1.2.1.2020.255");\n'
' script_name("Mozilla Firefox Security Advisory");\n'
' script_family("General");'
)
fake_context = self.create_file_plugin_context(
nasl_file=path, file_content=content
Expand All @@ -779,6 +783,7 @@ def test_script_name__product_firefox(self):
content = (
' script_oid("1.3.6.1.4.1.25623.1.2.1.2020.255");\n'
' script_name("AdaptBB Detection (HTTP)");\n'
' script_family("General");'
)
fake_context = self.create_file_plugin_context(
nasl_file=path, file_content=content
Expand Down
25 changes: 8 additions & 17 deletions troubadix/plugins/valid_oid.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,17 @@ def check_content(
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!",
file=nasl_file,
plugin=self.name,
)
return

# Vendor-specific OIDs
if "1.3.6.1.4.1.25623.1.1." in oid:
if family_match is None or family_match.group("value") is None:
yield LinterError(
"VT is missing a script family!",
file=nasl_file,
plugin=self.name,
)
return

family = family_match.group("value")

vendor_number_match = re.search(
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.([0-9]+)\.", oid
)
Expand Down Expand Up @@ -389,14 +388,6 @@ def check_content(

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

if family_match.group("value") != windows_family_template:
yield LinterError(
f"script_oid() {is_using_reserved} 'Windows' ("
Expand Down

0 comments on commit bd2f8fc

Please sign in to comment.