diff --git a/src/sec_certs/sample/cc.py b/src/sec_certs/sample/cc.py index 28099f58..e753eb83 100644 --- a/src/sec_certs/sample/cc.py +++ b/src/sec_certs/sample/cc.py @@ -58,10 +58,10 @@ class MaintenanceReport(ComplexSerializableType): def __post_init__(self): super().__setattr__( - "maintenance_report_link", sec_certs.utils.sanitization.sanitize_link(self.maintenance_report_link) + "maintenance_report_link", sec_certs.utils.sanitization.sanitize_cc_link(self.maintenance_report_link) ) super().__setattr__( - "maintenance_st_link", sec_certs.utils.sanitization.sanitize_link(self.maintenance_st_link) + "maintenance_st_link", sec_certs.utils.sanitization.sanitize_cc_link(self.maintenance_st_link) ) super().__setattr__( "maintenance_title", sec_certs.utils.sanitization.sanitize_string(self.maintenance_title) @@ -430,9 +430,9 @@ def __init__( self.security_level = sec_certs.utils.sanitization.sanitize_security_levels(security_level) self.not_valid_before = sec_certs.utils.sanitization.sanitize_date(not_valid_before) self.not_valid_after = sec_certs.utils.sanitization.sanitize_date(not_valid_after) - self.report_link = sec_certs.utils.sanitization.sanitize_link(report_link) - self.st_link = sec_certs.utils.sanitization.sanitize_link(st_link) - self.cert_link = sec_certs.utils.sanitization.sanitize_link(cert_link) + self.report_link = sec_certs.utils.sanitization.sanitize_cc_link(report_link) + self.st_link = sec_certs.utils.sanitization.sanitize_cc_link(st_link) + self.cert_link = sec_certs.utils.sanitization.sanitize_cc_link(cert_link) self.manufacturer_web = sec_certs.utils.sanitization.sanitize_link(manufacturer_web) self.protection_profiles = protection_profiles self.maintenance_updates = maintenance_updates diff --git a/src/sec_certs/utils/sanitization.py b/src/sec_certs/utils/sanitization.py index 17e34362..741fa456 100644 --- a/src/sec_certs/utils/sanitization.py +++ b/src/sec_certs/utils/sanitization.py @@ -23,6 +23,16 @@ def sanitize_link(record: str | None) -> str | None: return record.replace(":443", "").replace(" ", "%20").replace("http://", "https://") +def sanitize_cc_link(record: str | None) -> str | None: + record = sanitize_link(record) + if not record: + return None + record = record.replace("nfs/ccpfiles/", "") + if record == "https://www.commoncriteriaportal.org/files/epfiles/": + return None + return record + + def sanitize_date(record: pd.Timestamp | date | np.datetime64) -> date | None: if pd.isnull(record): return None