diff options
| author | J08nY | 2024-02-07 10:09:54 +0100 |
|---|---|---|
| committer | J08nY | 2024-02-07 10:09:54 +0100 |
| commit | d1911fce8b9aa4006659d55740c22d3e8a40dbb5 (patch) | |
| tree | e3b1f03b81bffefc1faa14ff6b6d2c307540e17c /src | |
| parent | 2fc72fc0e3636cec4cc1cfb2809c050f787146dc (diff) | |
| download | sec-certs-d1911fce8b9aa4006659d55740c22d3e8a40dbb5.tar.gz sec-certs-d1911fce8b9aa4006659d55740c22d3e8a40dbb5.tar.zst sec-certs-d1911fce8b9aa4006659d55740c22d3e8a40dbb5.zip | |
Fix cert_id canonicalization.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sec_certs/rules.yaml | 4 | ||||
| -rw-r--r-- | src/sec_certs/sample/cc.py | 22 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/sec_certs/rules.yaml b/src/sec_certs/rules.yaml index 4305b8cd..250c45b9 100644 --- a/src/sec_certs/rules.yaml +++ b/src/sec_certs/rules.yaml @@ -70,7 +70,7 @@ cc_cert_id: # KECS-CISS-1210-2023 JP: - "(?:CRP|ACR)-C(?P<counter>[0-9]+)-(?P<digit>[0-9]+)" - - "JISEC-CC-CRP-C(?P<counter>[0-9]+)-(?P<digit>[0-9]+)-(?P<year>[0-9]{4})" + - "JISEC-CC-CRP-C(?P<counter>[0-9]+)(?:-(?P<digit>[0-9]{2}))?(?:-(?P<year>[0-9]{4}))?" - "Certification No. [cC](?P<counter>[0-9]+)" # Examples: # CRP-C0595-01 @@ -144,7 +144,7 @@ cc_filename_cert_id: ES: - "(?P<year>[0-9]{4})[-‐](?P<project>[0-9]+)[-‐]INF[-‐](?P<counter>[0-9]+)[ -‐_]{1,2}[vV](?P<version>[0-9])" KR: - - "(?P<word>ISIS|NISS|CISS)[-‐](?P<counter>[0-9]{2,4})(?:[-‐](?P<year>[0-9]{4}))?" + - "(?P<word>ISIS|NISS|CISS)[-‐](?P<counter>[0-9]{2,4})[-‐](?P<year>[0-9]{4})" JP: - "[cC](?P<counter>[0-9]+)" MY: diff --git a/src/sec_certs/sample/cc.py b/src/sec_certs/sample/cc.py index ef1ff984..904c794d 100644 --- a/src/sec_certs/sample/cc.py +++ b/src/sec_certs/sample/cc.py @@ -417,14 +417,28 @@ class CCCertificate( candidates: dict[str, float] = defaultdict(lambda: 0.0) # TODO: Add heuristic based on ordering of ids (and extracted year + increment) # TODO: Add heuristic based on length + # TODO: Add heuristic based on id "richness", we want to prefer IDs that have more components. + # If we cannot canonicalize, just skip that ID. for candidate, count in frontpage_id.items(): - candidates[canonicalize(candidate, scheme)] += count * 1.5 + try: + candidates[canonicalize(candidate, scheme)] += count * 1.5 + except Exception: + continue for candidate, count in metadata_id.items(): - candidates[canonicalize(candidate, scheme)] += count * 1.2 + try: + candidates[canonicalize(candidate, scheme)] += count * 1.2 + except Exception: + continue for candidate, count in keywords_id.items(): - candidates[canonicalize(candidate, scheme)] += count * 1.0 + try: + candidates[canonicalize(candidate, scheme)] += count * 1.0 + except Exception: + continue for candidate, count in filename_id.items(): - candidates[canonicalize(candidate, scheme)] += count * 1.0 + try: + candidates[canonicalize(candidate, scheme)] += count * 1.0 + except Exception: + continue return candidates @dataclass |
