-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Eric Brown <eric.brown@securesauce.dev>
- Loading branch information
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
13 changes: 13 additions & 0 deletions
13
tests/unit/rules/python/third_party/pyghmi/examples/command_command.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
) |
9 changes: 9 additions & 0 deletions
9
tests/unit/rules/python/third_party/pyghmi/examples/command_command_no_password.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
13 changes: 13 additions & 0 deletions
13
tests/unit/rules/python/third_party/pyghmi/examples/command_console.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
) |
9 changes: 9 additions & 0 deletions
9
tests/unit/rules/python/third_party/pyghmi/examples/command_console_no_password.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
48 changes: 48 additions & 0 deletions
48
tests/unit/rules/python/third_party/pyghmi/test_pyghmi_cleartext.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |