diff --git a/tests/plugins/test_overlong_description_lines.py b/tests/plugins/test_overlong_description_lines.py index 2ddd8aa7..3e23282b 100644 --- a/tests/plugins/test_overlong_description_lines.py +++ b/tests/plugins/test_overlong_description_lines.py @@ -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" @@ -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 = ( diff --git a/troubadix/plugins/overlong_description_lines.py b/troubadix/plugins/overlong_description_lines.py index 3cfa8dda..5f0418c7 100644 --- a/troubadix/plugins/overlong_description_lines.py +++ b/troubadix/plugins/overlong_description_lines.py @@ -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 '