diff --git a/tests/unit/rules/python/third_party/M2Crypto/test_m2crypto_weak_key.py b/tests/unit/rules/python/third_party/M2Crypto/test_m2crypto_weak_key.py index 07d7772d..d4bbbfd9 100644 --- a/tests/unit/rules/python/third_party/M2Crypto/test_m2crypto_weak_key.py +++ b/tests/unit/rules/python/third_party/M2Crypto/test_m2crypto_weak_key.py @@ -24,7 +24,7 @@ def setUp(self): "examples", ) - def test_pyopenssl_weak_key_rule_meta(self): + def test_m2crypto_weak_key_rule_meta(self): rule = Rule.get_by_id(self.rule_id) self.assertEqual(self.rule_id, rule.id) self.assertEqual("inadequate_encryption_strength", rule.name) diff --git a/tests/unit/rules/python/third_party/pandas/__init__.py b/tests/unit/rules/python/third_party/pandas/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/rules/python/third_party/pandas/examples/pandas_read_pickle.py b/tests/unit/rules/python/third_party/pandas/examples/pandas_read_pickle.py new file mode 100644 index 00000000..31ba45a1 --- /dev/null +++ b/tests/unit/rules/python/third_party/pandas/examples/pandas_read_pickle.py @@ -0,0 +1,13 @@ +# level: WARNING +# start_line: 13 +# end_line: 13 +# start_column: 0 +# end_column: 14 +import pickle + +import pandas as pd + + +df = pd.DataFrame({"col_A": [1, 2]}) +pick = pickle.dumps(df) +pd.read_pickle(pick) diff --git a/tests/unit/rules/python/third_party/pandas/test_pandas_read_pickle.py b/tests/unit/rules/python/third_party/pandas/test_pandas_read_pickle.py new file mode 100644 index 00000000..ae1ba37a --- /dev/null +++ b/tests/unit/rules/python/third_party/pandas/test_pandas_read_pickle.py @@ -0,0 +1,45 @@ +# 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 PandasReadPickleTests(test_case.TestCase): + def setUp(self): + super().setUp() + self.rule_id = "PRE0509" + self.parser = python.Python(enabled=[self.rule_id]) + self.base_path = os.path.join( + "tests", + "unit", + "rules", + "python", + "third_party", + "pandas", + "examples", + ) + + def test_pandas_read_pickle_rule_meta(self): + rule = Rule.get_by_id(self.rule_id) + self.assertEqual(self.rule_id, rule.id) + self.assertEqual("deserialization_of_untrusted_data", 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("502", rule.cwe.cwe_id) + + @parameterized.expand( + [ + "pandas_read_pickle", + ] + ) + def test(self, filename): + self.check(filename) 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 index 424d9c58..7cc2c7e8 100644 --- a/tests/unit/rules/python/third_party/pyghmi/test_pyghmi_cleartext.py +++ b/tests/unit/rules/python/third_party/pyghmi/test_pyghmi_cleartext.py @@ -9,7 +9,7 @@ from tests.unit.rules.python import test_case -class SslContextTests(test_case.TestCase): +class PyghmiCleartextTests(test_case.TestCase): def setUp(self): super().setUp() self.rule_id = "PRE0517" @@ -24,7 +24,7 @@ def setUp(self): "examples", ) - def test_ssl_context_rule_meta(self): + def test_pyghmi_cleartext_rule_meta(self): rule = Rule.get_by_id(self.rule_id) self.assertEqual(self.rule_id, rule.id) self.assertEqual("cleartext_transmission", rule.name)