Skip to content

Commit

Permalink
Fix change in CCportal links.
Browse files Browse the repository at this point in the history
  • Loading branch information
J08nY committed Jun 9, 2024
1 parent 3191333 commit b333fd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/sec_certs/sample/cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/sec_certs/utils/sanitization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b333fd2

Please sign in to comment.