diff --git a/tests/unit/rules/python/third_party/pyghmi/__init__.py b/tests/unit/rules/python/third_party/pyghmi/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/rules/python/third_party/pyghmi/examples/command_command.py b/tests/unit/rules/python/third_party/pyghmi/examples/command_command.py new file mode 100644 index 00000000..d11a0622 --- /dev/null +++ b/tests/unit/rules/python/third_party/pyghmi/examples/command_command.py @@ -0,0 +1,13 @@ +# level: ERROR +# start_line: 9 +# end_line: 9 +# start_column: 6 +# end_column: 21 +from pyghmi.ipmi import command + + +cmd = command.Command( + bmc="bmc", + userid="userid", + password="ZjE4ZjI0NTE4YmI2NGJjZDliOGY3ZmJiY2UyN2IzODQK", +) diff --git a/tests/unit/rules/python/third_party/pyghmi/examples/command_command_no_password.py b/tests/unit/rules/python/third_party/pyghmi/examples/command_command_no_password.py new file mode 100644 index 00000000..77e3a8ab --- /dev/null +++ b/tests/unit/rules/python/third_party/pyghmi/examples/command_command_no_password.py @@ -0,0 +1,9 @@ +# level: WARNING +# start_line: 9 +# end_line: 9 +# start_column: 6 +# end_column: 21 +from pyghmi.ipmi import command + + +cmd = command.Command(bmc="bmc") diff --git a/tests/unit/rules/python/third_party/pyghmi/examples/command_console.py b/tests/unit/rules/python/third_party/pyghmi/examples/command_console.py new file mode 100644 index 00000000..86df816f --- /dev/null +++ b/tests/unit/rules/python/third_party/pyghmi/examples/command_console.py @@ -0,0 +1,13 @@ +# level: ERROR +# start_line: 9 +# end_line: 9 +# start_column: 6 +# end_column: 21 +from pyghmi.ipmi import command + + +cmd = command.Console( + bmc="bmc", + userid="userid", + password="ZjE4ZjI0NTE4YmI2NGJjZDliOGY3ZmJiY2UyN2IzODQK", +) diff --git a/tests/unit/rules/python/third_party/pyghmi/examples/command_console_no_password.py b/tests/unit/rules/python/third_party/pyghmi/examples/command_console_no_password.py new file mode 100644 index 00000000..1f7cd3fb --- /dev/null +++ b/tests/unit/rules/python/third_party/pyghmi/examples/command_console_no_password.py @@ -0,0 +1,9 @@ +# level: WARNING +# start_line: 9 +# end_line: 9 +# start_column: 6 +# end_column: 21 +from pyghmi.ipmi import command + + +cmd = command.Console(bmc="bmc") diff --git a/tests/unit/rules/python/third_party/pyghmi/test_pyghmi_cleartext.py b/tests/unit/rules/python/third_party/pyghmi/test_pyghmi_cleartext.py new file mode 100644 index 00000000..424d9c58 --- /dev/null +++ b/tests/unit/rules/python/third_party/pyghmi/test_pyghmi_cleartext.py @@ -0,0 +1,48 @@ +# Copyright 2023 Secure Saurce LLC +import os + +from parameterized import parameterized + +from precli.core.level import Level +from precli.parsers import python +from precli.rules import Rule +from tests.unit.rules.python import test_case + + +class SslContextTests(test_case.TestCase): + def setUp(self): + super().setUp() + self.rule_id = "PRE0517" + self.parser = python.Python(enabled=[self.rule_id]) + self.base_path = os.path.join( + "tests", + "unit", + "rules", + "python", + "third_party", + "pyghmi", + "examples", + ) + + def test_ssl_context_rule_meta(self): + rule = Rule.get_by_id(self.rule_id) + self.assertEqual(self.rule_id, rule.id) + self.assertEqual("cleartext_transmission", rule.name) + self.assertEqual( + f"https://docs.securesauce.dev/rules/{self.rule_id}", rule.help_url + ) + self.assertEqual(True, rule.default_config.enabled) + self.assertEqual(Level.WARNING, rule.default_config.level) + self.assertEqual(-1.0, rule.default_config.rank) + self.assertEqual("319", rule.cwe.cwe_id) + + @parameterized.expand( + [ + "command_command", + "command_command_no_password", + "command_console", + "command_console_no_password", + ] + ) + def test(self, filename): + self.check(filename)