diff options
| author | J08nY | 2024-02-03 19:27:40 +0100 |
|---|---|---|
| committer | J08nY | 2024-02-03 19:27:40 +0100 |
| commit | 7d56381b408dd6ab1ed7d7ebaa84d192419eb140 (patch) | |
| tree | 9d163866fcfa13ebb8b5ec44657b245d55c79c3c /src | |
| parent | 22fad93ad165e858d4fb55e2b9b0166aac6d32a3 (diff) | |
| download | sec-certs-7d56381b408dd6ab1ed7d7ebaa84d192419eb140.tar.gz sec-certs-7d56381b408dd6ab1ed7d7ebaa84d192419eb140.tar.zst sec-certs-7d56381b408dd6ab1ed7d7ebaa84d192419eb140.zip | |
Improve Singaporean and Australian rules.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sec_certs/rules.yaml | 14 | ||||
| -rw-r--r-- | src/sec_certs/sample/cc_certificate_id.py | 17 |
2 files changed, 26 insertions, 5 deletions
diff --git a/src/sec_certs/rules.yaml b/src/sec_certs/rules.yaml index b4e54d20..b2b4a979 100644 --- a/src/sec_certs/rules.yaml +++ b/src/sec_certs/rules.yaml @@ -92,13 +92,17 @@ cc_cert_id: # will miss STQC/CC/14-15/12/ETR/0017 - "(?:IC3S|STQC/CC)/[^ ]+? ?/CR" SG: - - "CSA_CC_[0-9]+" # Singapore (CSA_CC_19001) + - "CSA_CC_(?P<year>[0-9]{2})(?P<counter>[0-9]{3})" + # Examples: + # CSA_CC_19001 AU: - # Australia (EFS-T048 ETR 1.0, EFS-T056-ETR 1.0, DXC-EFC-T092-ETR 1.0) + - "(?:Certificate Number:|Certification Report) (?P<year>[0-9]{2,4})/(?P<counter>[0-9]+)" # XXX: Do not use Australian ETR numbers, they are not certificate id. - # - "(?:EFS|EFT|DXC-EFC)-T[0-9]+(?: |-)ETR [0-9]+.[0-9]+" - - "Certificate Number: [0-9]{1,4}/[0-9]{1,4}" - - "Certification Report [0-9]+/[0-9]+" + # Examples: + # Certification Report 2007/06 + # Certificate Number: 2010/67 + # Certificate Number: 37/2006 !mistake + # Certification Report 97/76 !short year ##### # Common Criteria protection profile IDs, grouped by certification body (e.g. BSI) diff --git a/src/sec_certs/sample/cc_certificate_id.py b/src/sec_certs/sample/cc_certificate_id.py index be30bcf5..7e0b7f4a 100644 --- a/src/sec_certs/sample/cc_certificate_id.py +++ b/src/sec_certs/sample/cc_certificate_id.py @@ -183,6 +183,21 @@ class CertificateId: new_cert_id = f"{new_cert_id}-CR" return new_cert_id + def _canonical_au(self): + new_cert_id = self.clean + for rule in rules["cc_cert_id"]["AU"]: + if match := re.match(rule, new_cert_id): + groups = match.groupdict() + counter = groups["counter"] + year_s = groups["year"] + if len(year_s) < len(counter): + # Hack for some mistakes in their ordering + year_s, counter = counter, year_s + year = _parse_year(year_s) + new_cert_id = f"Certificate Number: {year}/{counter}" + break + return new_cert_id + @property def clean(self) -> str: """ @@ -210,6 +225,8 @@ class CertificateId: "JP": self._canonical_jp, "NO": self._canonical_no, "NL": self._canonical_nl, + "AU": self._canonical_au, + # SG is canonical by default } if self.scheme in schemes: |
