Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/helper/test_date_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class CheckCreationDateTestCase(TestCase):

def test_ok(self):
results = list(
check_date(
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_copyright_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ def test_fix_wrong_copyright_text(self):

self.assertIsInstance(results[0], LinterFix)
self.assertEqual(
"The copyright statement has been updated to " f"{CORRECT_COPYRIGHT_PHRASE}",
f"The copyright statement has been updated to {CORRECT_COPYRIGHT_PHRASE}",
results[0].message,
)
2 changes: 1 addition & 1 deletion tests/plugins/test_copyright_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_pre2008_fail(self):
results[0].message,
)
self.assertEqual(
"a pre2008 vt has a copyright value in the fileheader" " newer than the creation_year",
"a pre2008 vt has a copyright value in the fileheader newer than the creation_year",
results[1].message,
)

Expand Down
1 change: 0 additions & 1 deletion tests/plugins/test_creation_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


class CheckCreationDateTestCase(PluginTestCase):

def test_ok(self):
path = Path("some/file.nasl")
content = (
Expand Down
8 changes: 4 additions & 4 deletions tests/plugins/test_cve_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CheckCVEFormatTestCase(PluginTestCase):
def test_ok(self):
path = Path("some/file.nasl")
content = (
' script_tag(name:"cvss_base", value:"7.5");\n' ' script_cve_id("CVE-2022-23807");\n'
' script_tag(name:"cvss_base", value:"7.5");\n script_cve_id("CVE-2022-23807");\n'
)
fake_context = self.create_file_plugin_context(nasl_file=path, file_content=content)
plugin = CheckCVEFormat(fake_context)
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_no_cve_reference(self):
def test_invalid_cve_format(self):
path = Path("some/file.nasl")
content = (
' script_tag(name:"cvss_base", value:"10.0");\n' ' script_cve_id("CVE-a123-23807");\n'
' script_tag(name:"cvss_base", value:"10.0");\n script_cve_id("CVE-a123-23807");\n'
)
fake_context = self.create_file_plugin_context(nasl_file=path, file_content=content)
plugin = CheckCVEFormat(fake_context)
Expand All @@ -91,7 +91,7 @@ def test_invalid_cve_format(self):
def test_more_then_four_digits(self):
path = Path("some/file.nasl")
content = (
' script_tag(name:"cvss_base", value:"7.5");\n' ' script_cve_id("CVE-2021-03807");\n'
' script_tag(name:"cvss_base", value:"7.5");\n script_cve_id("CVE-2021-03807");\n'
)

fake_context = self.create_file_plugin_context(nasl_file=path, file_content=content)
Expand All @@ -109,7 +109,7 @@ def test_more_then_four_digits(self):
def test_invalid_year(self):
path = Path("some/file.nasl")
content = (
' script_tag(name:"cvss_base", value:"7.5");\n' ' script_cve_id("CVE-1971-3807");\n'
' script_tag(name:"cvss_base", value:"7.5");\n script_cve_id("CVE-1971-3807");\n'
)
fake_context = self.create_file_plugin_context(nasl_file=path, file_content=content)
plugin = CheckCVEFormat(fake_context)
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_cvss_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_invalid_base(self):

def test_missing_base(self):
path = Path("some/file.nasl")
content = ' script_tag(name:"cvss_base_vector", ' 'value:"AV:N/AC:L/Au:S/C:N/I:P/A:N");\n'
content = ' script_tag(name:"cvss_base_vector", value:"AV:N/AC:L/Au:S/C:N/I:P/A:N");\n'
fake_context = self.create_file_plugin_context(nasl_file=path, file_content=content)
plugin = CheckCVSSFormat(fake_context)

Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_dependency_missing(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
f"The script dependency {dependency} could " "not be found within the VTs.",
f"The script dependency {dependency} could not be found within the VTs.",
results[0].message,
)

Expand Down Expand Up @@ -187,7 +187,7 @@ def test_dependency_missing_newline(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"The script dependency example2.nasl could " "not be found within the VTs.",
"The script dependency example2.nasl could not be found within the VTs.",
results[0].message,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_dependency_category_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_dependency_missing(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
f"The script dependency {dependency} could " "not be found within the VTs.",
f"The script dependency {dependency} could not be found within the VTs.",
results[0].message,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_deprecated_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_dependency_missing(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
f"The script dependency {dependency} could " "not be found within the VTs.",
f"The script dependency {dependency} could not be found within the VTs.",
results[0].message,
)

Expand Down
5 changes: 2 additions & 3 deletions tests/plugins/test_deprecated_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ def test_ok_comment(self):

def test_deprecated_functions(self):
deprecated_output = {
'script_summary();, use script_tag(name:"'
'summary", value:""); instead': " script_"
'script_summary();, use script_tag(name:"summary", value:""); instead': " script_"
'summary("deprecated");',
"script_id();, use script_oid(); with " "the full OID instead": " script_id(123345);",
"script_id();, use script_oid(); with the full OID instead": " script_id(123345);",
"security_note();": ' security_note("deprecated");',
"security_warning();": ' security_warning("deprecated");',
"security_hole();": ' security_hole("deprecated");',
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_double_end_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def test_invalid(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"The script tag 'summary' " "is ending with two or more points: " "'Foo Bar...'.",
"The script tag 'summary' is ending with two or more points: 'Foo Bar...'.",
results[0].message,
)
2 changes: 1 addition & 1 deletion tests/plugins/test_duplicate_oid.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_ok_no_script_oid(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"Could not find an OID" " in 'test_files/nasl/21.04/fail_badwords.nasl'.",
"Could not find an OID in 'test_files/nasl/21.04/fail_badwords.nasl'.",
results[0].message,
)

Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/test_duplicated_script_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_duplicated_function(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"The VT is using the script tag " "'script_name' multiple number of times.",
"The VT is using the script tag 'script_name' multiple number of times.",
results[0].message,
)

Expand All @@ -80,7 +80,7 @@ def test_duplicated_tag(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"The VT is using the script tag " "'cvss_base' multiple number of times.",
"The VT is using the script tag 'cvss_base' multiple number of times.",
results[0].message,
)

Expand Down
8 changes: 2 additions & 6 deletions tests/plugins/test_script_add_preference_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ def test_invalid_with_parameters_order(self):
)
path = Path("some/file.nasl")
content = (
' script_tag(name:"cvss_base", value:"4.0");\n'
' script_name("Foo Bar");\n'
f"{add_pref}\n"
f' script_tag(name:"cvss_base", value:"4.0");\n script_name("Foo Bar");\n{add_pref}\n'
)
fake_context = self.create_file_plugin_context(nasl_file=path, file_content=content)
plugin = CheckScriptAddPreferenceType(fake_context)
Expand All @@ -119,9 +117,7 @@ def test_missing_type(self):
add_pref = 'script_add_preference(name:"File or Directory Name", value:"/home", id:1);'
path = Path("some/file.nasl")
content = (
' script_tag(name:"cvss_base", value:"4.0");\n'
' script_name("Foo Bar");\n'
f"{add_pref}\n"
f' script_tag(name:"cvss_base", value:"4.0");\n script_name("Foo Bar");\n{add_pref}\n'
)
fake_context = self.create_file_plugin_context(nasl_file=path, file_content=content)
plugin = CheckScriptAddPreferenceType(fake_context)
Expand Down
6 changes: 3 additions & 3 deletions tests/plugins/test_script_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_copyright_error(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertIn(
"The VT is using an incorrect syntax for its " "copyright statement.",
"The VT is using an incorrect syntax for its copyright statement.",
results[0].message,
)

Expand All @@ -69,7 +69,7 @@ def test_copyright_error2(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertIn(
"The VT is using an incorrect syntax for its " "copyright statement.",
"The VT is using an incorrect syntax for its copyright statement.",
results[0].message,
)

Expand All @@ -84,6 +84,6 @@ def test_copyright_error3(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertIn(
"The VT is using an incorrect syntax for its " "copyright statement.",
"The VT is using an incorrect syntax for its copyright statement.",
results[0].message,
)
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_nok(self):
results[0].message,
)
self.assertEqual(
"VT is is using a wrong syntax for script_tag(name:" '"last_modification".',
'VT is is using a wrong syntax for script_tag(name:"last_modification".',
results[1].message,
)

Expand All @@ -91,7 +91,7 @@ def test_old_nok(self):
results[0].message,
)
self.assertEqual(
"VT is is using a wrong syntax for script_tag(name:" '"last_modification".',
'VT is is using a wrong syntax for script_tag(name:"last_modification".',
results[1].message,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_script_xref_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_generic_invalid_url(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
'script_xref(name:"URL", value:"www.example.com");: Invalid URL' " value",
'script_xref(name:"URL", value:"www.example.com");: Invalid URL value',
results[0].message,
)

Expand Down
6 changes: 3 additions & 3 deletions tests/plugins/test_security_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_nok(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"VT is using a security_message or implementing" " function in a VT without severity",
"VT is using a security_message or implementing function in a VT without severity",
results[0].message,
)

Expand All @@ -106,7 +106,7 @@ def test_nok2(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"VT is using a security_message or implementing " "function in a VT without severity",
"VT is using a security_message or implementing function in a VT without severity",
results[0].message,
)

Expand All @@ -129,7 +129,7 @@ def test_nok3(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"VT is using a security_message or implementing" " function in a VT without severity",
"VT is using a security_message or implementing function in a VT without severity",
results[0].message,
)

Expand Down
1 change: 0 additions & 1 deletion tests/plugins/test_severity_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class CheckSeverityDateTestCase(PluginTestCase):

def test_severity_date_ok(self):
path = Path("some/file.nasl")
content = (
Expand Down
1 change: 0 additions & 1 deletion tests/plugins/test_severity_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class CheckSeverityFormatTestCase(PluginTestCase):

def test_cvss_3_0_vector_ok(self):
path = Path("some/file.nasl")
content = (
Expand Down
1 change: 0 additions & 1 deletion tests/plugins/test_severity_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class CheckSeverityOriginTestCase(PluginTestCase):

def test_severity_origin_nvd(self):
path = Path("some/file.nasl")
content = ' script_tag(name:"severity_origin", value:"NVD");\n'
Expand Down
1 change: 0 additions & 1 deletion tests/plugins/test_spaces_before_dots.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class TestSpacesBeforeDots(PluginTestCase):

def test_ok(self):
nasl_file = Path("/some/fake/directory/test.nasl")
content = """
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_using_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_using_comment_display(self):
def test_using_debug_if_display(self):
"""Test that display() inside a debug if statement is allowed"""
path = Path("some/file.nasl")
content = ' script_tag(name:"cvss_base", value:"4.0");\n' 'if (debug) display("FOO");\n'
content = ' script_tag(name:"cvss_base", value:"4.0");\nif (debug) display("FOO");\n'
fake_context = self.create_file_plugin_context(nasl_file=path, file_content=content)
plugin = CheckUsingDisplay(fake_context)

Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_vt_placement.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ def test_wrong_placement(self):
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], LinterError)
self.assertEqual(
"VT should be " f"placed in the root directory ({tempdir}).",
f"VT should be placed in the root directory ({tempdir}).",
results[0].message,
)
9 changes: 0 additions & 9 deletions tests/standalone_plugins/test_changed_creation_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@


class TestChangedCreationDate(unittest.TestCase):

@patch("troubadix.standalone_plugins.changed_creation_date.Path.exists")
@patch("troubadix.standalone_plugins.changed_creation_date.git")
def test_check_creation_date_ok(self, mock_git, mock_exists):

mock_git.return_value = (
'-script_tag(name:"creation_date",'
' value:"2025-03-04 10:00:00 +0200 (Tue, 04 Mar 2025)");\n'
Expand All @@ -40,7 +38,6 @@ def test_check_creation_date_ok(self, mock_git, mock_exists):
@patch("troubadix.standalone_plugins.changed_creation_date.Path.exists")
@patch("troubadix.standalone_plugins.changed_creation_date.git")
def test_check_creation_date_fail(self, mock_git, mock_exists):

mock_git.return_value = (
'-script_tag(name:"creation_date",'
' value:"2025-03-04 10:00:00 +0200 (Tue, 04 Mar 2025)");\n'
Expand All @@ -54,7 +51,6 @@ def test_check_creation_date_fail(self, mock_git, mock_exists):
@patch("troubadix.standalone_plugins.changed_creation_date.Path.exists")
@patch("troubadix.standalone_plugins.changed_creation_date.git")
def test_creation_date_not_modified_lines_added(self, mock_git, mock_exists):

mock_git.return_value = (
'-script_tag(name:"creation_date",'
' value:"2025-03-04 10:00:00 +0200 (Tue, 04 Mar 2025)");\n'
Expand All @@ -69,7 +65,6 @@ def test_creation_date_not_modified_lines_added(self, mock_git, mock_exists):
@patch("troubadix.standalone_plugins.changed_creation_date.Path.exists")
@patch("troubadix.standalone_plugins.changed_creation_date.git")
def test_creation_date_not_modified_lines_removed(self, mock_git, mock_exists):

mock_git.return_value = '-script_tag(name:"This got removed", value:"Nothing");'
mock_exists.return_value = True

Expand All @@ -78,7 +73,6 @@ def test_creation_date_not_modified_lines_removed(self, mock_git, mock_exists):
@patch("troubadix.standalone_plugins.changed_creation_date.Path.exists")
@patch("troubadix.standalone_plugins.changed_creation_date.git")
def test_creation_date_added_not_removed(self, mock_git, mock_exists):

mock_git.return_value = (
'+script_tag(name:"This got added", value:"Something");\n'
'+script_tag(name:"creation_date", '
Expand All @@ -98,7 +92,6 @@ def test_git_ok(self):
@patch("troubadix.standalone_plugins.changed_creation_date.git")
@patch("troubadix.standalone_plugins.changed_creation_date.ArgumentParser.parse_args")
def test_args_ok(self, mock_parse_args, mock_git):

mock_parse_args.return_value = Namespace(commit_range="main..test", files=[])
mock_git.return_value = "test1.nasl\ntest2.nasl\ntest3.txt"

Expand All @@ -121,7 +114,6 @@ def test_main_no_git_repository(self):
@patch("troubadix.standalone_plugins.changed_creation_date.os.chdir")
@patch("troubadix.standalone_plugins.changed_creation_date.git")
def test_main_check_creation_date_ok(self, mock_git, _, mock_check_creation_date, __):

mock_git.return_value = "test_directory"
mock_check_creation_date.return_value = 0

Expand All @@ -132,7 +124,6 @@ def test_main_check_creation_date_ok(self, mock_git, _, mock_check_creation_date
@patch("troubadix.standalone_plugins.changed_creation_date.os.chdir")
@patch("troubadix.standalone_plugins.changed_creation_date.git")
def test_main_check_creation_date_fail(self, mock_git, _, mock_check_creation_date, __):

mock_git.return_value = "test_directory"
mock_check_creation_date.return_value = 2

Expand Down
1 change: 0 additions & 1 deletion tests/standalone_plugins/test_dependency_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def test_parse_args_defaults(self):


class TestDependencyGraph(unittest.TestCase):

def setUp(self) -> None:
self.local_root = "tests/standalone_plugins/nasl"
self.script_content = """
Expand Down
Loading