aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJ08nY2024-02-05 13:50:58 +0100
committerJ08nY2024-02-05 13:50:58 +0100
commit4fbb063846eb2375ac735c88ca0abb7df7c11267 (patch)
treef60f41b33dc8f853295aaca3c2e9b59c9f379d75 /src
parent5e852ac4e42afaf7fb7a6f7b9493d276723fd7e7 (diff)
downloadsec-certs-4fbb063846eb2375ac735c88ca0abb7df7c11267.tar.gz
sec-certs-4fbb063846eb2375ac735c88ca0abb7df7c11267.tar.zst
sec-certs-4fbb063846eb2375ac735c88ca0abb7df7c11267.zip
Improve Korean rules.
Diffstat (limited to 'src')
-rw-r--r--src/sec_certs/rules.yaml8
-rw-r--r--src/sec_certs/sample/cc_certificate_id.py13
2 files changed, 18 insertions, 3 deletions
diff --git a/src/sec_certs/rules.yaml b/src/sec_certs/rules.yaml
index c0acd3d4..5e000144 100644
--- a/src/sec_certs/rules.yaml
+++ b/src/sec_certs/rules.yaml
@@ -58,10 +58,12 @@ cc_cert_id:
# 2020-34-INF-3784- v1
# 2019-20-INF-3379-v1
KR:
- # Korea
+ - "KECS[-‐](?P<word>ISIS|NISS|CISS)[-‐](?P<counter>[0-9]{2,4})[-‐](?P<year>[0-9]{4})"
# XXX: Do not use KECS-CR as those refer to the certificate report and do not represent the certificate id.
- # - "KECS[-‐]CR[-‐][0-9]+[-‐][0-9]+" # Korea KECS-CR-20-61
- - "KECS[-‐](?:ISIS|NISS|CISS)[-‐][0-9]+[-‐][0-9]{4}" # Korea KECS-ISIS-1234-2011
+ # Examples:
+ # KECS-ISIS-0579-2015
+ # KECS-NISS-0792-2017
+ # 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})"
diff --git a/src/sec_certs/sample/cc_certificate_id.py b/src/sec_certs/sample/cc_certificate_id.py
index 88e1f4a7..5facf1a5 100644
--- a/src/sec_certs/sample/cc_certificate_id.py
+++ b/src/sec_certs/sample/cc_certificate_id.py
@@ -163,6 +163,18 @@ class CertificateId:
break
return new_cert_id
+ def _canonical_kr(self):
+ new_cert_id = self.clean
+ for rule in rules["cc_cert_id"]["KR"]:
+ if match := re.match(rule, new_cert_id):
+ groups = match.groupdict()
+ word = groups["word"]
+ counter = int(groups["counter"])
+ year = _parse_year(groups["year"])
+ new_cert_id = f"KECS-{word}-{counter:04}-{year}"
+ break
+ return new_cert_id
+
def _canonical_no(self):
new_cert_id = self.clean
cert_num = int(new_cert_id.split("-")[1])
@@ -218,6 +230,7 @@ class CertificateId:
"NO": self._canonical_no,
"NL": self._canonical_nl,
"AU": self._canonical_au,
+ "KR": self._canonical_kr,
# SG is canonical by default
# IT is canonucal by default
}