aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJán Jančár2022-06-02 13:04:35 +0200
committerGitHub2022-06-02 13:04:35 +0200
commite8ee684c170c2a5aafb3fa9ded183da8b91fd6c8 (patch)
tree5210fad9721a24c2ebdfbd0c3b09d635a2739b66 /tests
parent0012910a551a8293415e67b00ac66da6cc518936 (diff)
downloadsec-certs-e8ee684c170c2a5aafb3fa9ded183da8b91fd6c8.tar.gz
sec-certs-e8ee684c170c2a5aafb3fa9ded183da8b91fd6c8.tar.zst
sec-certs-e8ee684c170c2a5aafb3fa9ded183da8b91fd6c8.zip
Add more regex rulesm, slightly refactor. (#224)
* Add more evaluation facilities to cert rules. * Add more crypto rules and split them into groups. * Rename rules_defenses to rules_side_channels. * Fix tests, use settings_test. * Fix import order. * Fix escape warning. * Fix pandas warning. * Flake8. * Add more TEE rules. * Optimize regex searching. * Add typehints to cert_rules. * Fix import order.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cc_heuristics.py12
-rw-r--r--tests/test_cc_oop.py9
2 files changed, 16 insertions, 5 deletions
diff --git a/tests/test_cc_heuristics.py b/tests/test_cc_heuristics.py
index d289a4ba..95a2c4fd 100644
--- a/tests/test_cc_heuristics.py
+++ b/tests/test_cc_heuristics.py
@@ -7,6 +7,7 @@ from unittest import TestCase
import tests.data.test_cc_heuristics
from sec_certs import constants
from sec_certs.cert_rules import SARS_IMPLIED_FROM_EAL
+from sec_certs.config.configuration import config
from sec_certs.dataset import CCDataset, CPEDataset, CVEDataset
from sec_certs.sample import CPE, CVE, SAR, CommonCriteriaCert, ProtectionProfile
@@ -23,6 +24,7 @@ class TestCommonCriteriaHeuristics(TestCase):
@classmethod
def setUpClass(cls) -> None:
+ config.load(cls.data_dir_path.parent / "settings_test.yaml")
cls.tmp_dir = tempfile.TemporaryDirectory()
shutil.copytree(cls.data_dir_path, cls.tmp_dir.name, dirs_exist_ok=True)
@@ -122,9 +124,9 @@ class TestCommonCriteriaHeuristics(TestCase):
def test_cpe_parsing(self):
potentially_problematic_cpes = {
- 'cpe:2.3:a:bayashi:dopvstar\::0091:*:*:*:*:*:*:*"': ("bayashi", "dopvstar:", "0091"), # noqa: W605
- "cpe:2.3:a:moundlabs:\:\:mound\:\::2.1.6:*:*:*:*:*:*:*": ("moundlabs", "::mound::", "2.1.6"), # noqa: W605
- "cpe:2.3:a:lemonldap-ng:lemonldap\:\::*:*:*:*:*:*:*:*": ( # noqa: W605
+ 'cpe:2.3:a:bayashi:dopvstar\\::0091:*:*:*:*:*:*:*"': ("bayashi", "dopvstar:", "0091"),
+ "cpe:2.3:a:moundlabs:\\:\\:mound\\:\\::2.1.6:*:*:*:*:*:*:*": ("moundlabs", "::mound::", "2.1.6"),
+ "cpe:2.3:a:lemonldap-ng:lemonldap\\:\\::*:*:*:*:*:*:*:*": (
"lemonldap-ng",
"lemonldap::",
constants.CPE_VERSION_NA,
@@ -239,8 +241,8 @@ class TestCommonCriteriaHeuristics(TestCase):
self.assertEqual(extracted_keywords["rules_security_assurance_components"]["ADV_FSP.3"], 1)
self.assertEqual(extracted_keywords["rules_security_assurance_components"]["ADV_TDS.2"], 1)
- self.assertTrue("rules_crypto_algs" in extracted_keywords)
- self.assertEqual(extracted_keywords["rules_crypto_algs"]["AES"], 2)
+ self.assertTrue("rules_symmetric_crypto" in extracted_keywords)
+ self.assertEqual(extracted_keywords["rules_symmetric_crypto"]["AES"], 2)
self.assertTrue("rules_block_cipher_modes" in extracted_keywords)
self.assertEqual(extracted_keywords["rules_block_cipher_modes"]["CBC"], 2)
diff --git a/tests/test_cc_oop.py b/tests/test_cc_oop.py
index 479d3b05..d2809fbe 100644
--- a/tests/test_cc_oop.py
+++ b/tests/test_cc_oop.py
@@ -5,15 +5,24 @@ import tempfile
from datetime import date, datetime
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
+from typing import ClassVar
from unittest import TestCase
import sec_certs.constants as constants
import sec_certs.helpers as helpers
+import tests.data.test_cc_oop
+from sec_certs.config.configuration import config
from sec_certs.dataset import CCDataset
from sec_certs.sample import CommonCriteriaCert, ProtectionProfile
class TestCommonCriteriaOOP(TestCase):
+ data_dir_path: ClassVar[Path] = Path(tests.data.test_cc_oop.__path__[0])
+
+ @classmethod
+ def setUpClass(cls):
+ config.load(cls.data_dir_path.parent / "settings_test.yaml")
+
def setUp(self):
self.test_data_dir = Path(__file__).parent / "data" / "test_cc_oop"
self.crt_one = CommonCriteriaCert(