diff options
| author | Adam Janovsky | 2025-01-27 16:11:32 +0100 |
|---|---|---|
| committer | J08nY | 2025-02-01 22:57:38 +0100 |
| commit | bcbb31e609c1f03f8b66b9e0bc0c27ce9cd7e562 (patch) | |
| tree | 35ab0ecb0a3c2fad7a62827e9eb51b5ebd2bb284 /src/sec_certs/sample | |
| parent | d0619fa3c71f78455cbcc0220af71f94ac1fef90 (diff) | |
| download | sec-certs-bcbb31e609c1f03f8b66b9e0bc0c27ce9cd7e562.tar.gz sec-certs-bcbb31e609c1f03f8b66b9e0bc0c27ce9cd7e562.tar.zst sec-certs-bcbb31e609c1f03f8b66b9e0bc0c27ce9cd7e562.zip | |
forbid empty PP links in ProtectionProfile objects
Diffstat (limited to 'src/sec_certs/sample')
| -rw-r--r-- | src/sec_certs/sample/protection_profile.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/sec_certs/sample/protection_profile.py b/src/sec_certs/sample/protection_profile.py index 36f13130..079c9319 100644 --- a/src/sec_certs/sample/protection_profile.py +++ b/src/sec_certs/sample/protection_profile.py @@ -19,7 +19,7 @@ from sec_certs.sample.certificate import Heuristics as BaseHeuristics from sec_certs.sample.certificate import PdfData as BasePdfData from sec_certs.sample.document_state import DocumentState from sec_certs.serialization.json import ComplexSerializableType -from sec_certs.utils import helpers +from sec_certs.utils import helpers, sanitization class ProtectionProfile( @@ -83,18 +83,23 @@ class ProtectionProfile( f"Unexpected number of <td> elements in PP html row. Expected: 6, actual: {len(cells)}" ) + pp_link = cls._html_row_get_link(cells[0]) + pp_name = cls._html_row_get_name(cells[0]) + if not sanitization.sanitize_cc_link(pp_link): + raise ValueError(f"pp_link for PP {pp_name} is empty, cannot create PP record") + # TODO: Parse maintenance div here. See CC parsing. return cls( category, status, False, - cls._html_row_get_name(cells[0]), + pp_name, cls._html_row_get_version(cells[1]), cls._html_row_get_security_level(cells[2]), cls._html_row_get_date(cells[3]), None if status == "active" else cls._html_row_get_date(cells[4]), cls._html_row_get_link(cells[-1]), - cls._html_row_get_link(cells[0]), + pp_link, cls._html_row_get_scheme(cells[-2]), [], ) @@ -107,17 +112,22 @@ class ProtectionProfile( f"Unexpected number of <td> elements in collaborative PP html row. Expected: 5, actual: {len(cells)}" ) + pp_link = cls._html_row_get_collaborative_pp_link(cells[0]) + pp_name = cls._html_row_get_collaborative_name(cells[0]) + if not sanitization.sanitize_cc_link(pp_link): + raise ValueError(f"pp_link for PP {pp_name} is empty, cannot create PP record") + return cls( category, "active", True, - cls._html_row_get_collaborative_name(cells[0]), + pp_name, cls._html_row_get_version(cells[1]), cls._html_row_get_security_level(cells[2]), cls._html_row_get_date(cells[3]), None, cls._html_row_get_link(cells[-1]), - cls._html_row_get_collaborative_pp_link(cells[0]), + pp_link, None, [], ) |
