Skip to content

Commit

Permalink
Change: Extend ignore list of overlong description lines plugin. Adju…
Browse files Browse the repository at this point in the history
…st tests.
  • Loading branch information
cfi-gb authored and NiklasHargarter committed Jan 13, 2025
1 parent 810d34f commit 3affb07
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/plugins/test_overlong_description_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


class CheckOverlongDescriptionLinesTestCase(PluginTestCase):
def test_ok(self):
def test_ok_generic(self):
nasl_file = Path(__file__).parent / "test.nasl"
content = (
"ignored line that is not part of description"
Expand Down Expand Up @@ -61,6 +61,30 @@ def test_ok(self):

self.assertEqual(len(results), 0)

def test_ok_urls_in_comments(self):
nasl_file = Path(__file__).parent / "test.nasl"
content = (
"if (description)\n"
"{\n"
' script_version("2021-09-02T14:01:33+0000");\n'
" # https://overlongurlisokxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");\n'
" # > https://anothervariantwhichisokxxxxxxxxxxxxxxxxxxx"
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");\n'
" # - https://anothervariantwhichisalsookxxxxxxxxxxxxxxx"
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");\n'
" exit(0);\n"
"}\n"
)
fake_context = self.create_file_plugin_context(
nasl_file=nasl_file, file_content=content
)
plugin = CheckOverlongDescriptionLines(fake_context)

results = list(plugin.run())

self.assertEqual(len(results), 0)

def test_line_too_long(self):
nasl_file = Path(__file__).parent / "test.nasl"
content = (
Expand Down
8 changes: 8 additions & 0 deletions troubadix/plugins/overlong_description_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
"script_name",
"script_xref",
"script_add_preference",
# nb: Various variants of URLs in comments which we can't / shouldn't
# trim down
" # http://",
" # https://",
" # - http://",
" # - https://",
" # > http://",
" # > https://",
# nb: Special cases we should ignore (at least for now) as these are
# commonly used like this and is only two chars "too long".
'script_tag(name:"vuldetect", value:"Checks if a vulnerable version is '
Expand Down

0 comments on commit 3affb07

Please sign in to comment.