Skip to content

Commit

Permalink
Change: update windows oid formatting regex
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-gb authored and mbrinkhoff committed Jan 15, 2025
1 parent 819b572 commit 330f542
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions tests/plugins/test_valid_oid.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,3 +834,43 @@ def test_script_family__product_microsoft_not_ok(self):
),
results[0].message,
)

def test_oid_microsoft_ok(self):
path = Path("some/file.nasl")
content = (
' script_oid("1.3.6.1.4.1.25623.1.3.11571.0.5019966.494846484649555554514651545348");'
"\n"
' script_family("Windows : Microsoft Bulletins");\n'
)
fake_context = self.create_file_plugin_context(
nasl_file=path, file_content=content
)
plugin = CheckValidOID(fake_context)

results = list(plugin.run())

self.assertEqual(len(results), 0)

def test_oid_microsoft_not_ok(self):
path = Path("some/file.nasl")
content = (
' script_oid("1.3.6.1.4.1.25623.1.3.11571.0.494846484649555554514651545348");'
"\n"
' script_family("Windows : Microsoft Bulletins");\n'
)
fake_context = self.create_file_plugin_context(
nasl_file=path, file_content=content
)
plugin = CheckValidOID(fake_context)
results = list(plugin.run())

self.assertIsInstance(results[0], LinterError)
self.assertEqual(
(
"script_oid() is using an invalid OID "
"'1.3.6.1.4.1.25623.1.3.11571.0.494846484649555554514651545348' "
"(Windows pattern: 1.3.6.1.4.1.25623.1.3.[product_id].[platform_id]."
"[kb_article_id].[fixed_build_number])"
),
results[0].message,
)
2 changes: 1 addition & 1 deletion troubadix/plugins/valid_oid.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def check_content(
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}",
r"^1\.3\.6\.1\.4\.1\.25623\.1\.3\.\d+\.\d+\.\d+\.\d+",
oid,
)
if not windows_oid_match:
Expand Down

0 comments on commit 330f542

Please sign in to comment.