Skip to content

Commit

Permalink
Improve Indian rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
J08nY committed Feb 5, 2024
1 parent 4fbb063 commit 520ce49
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/sec_certs/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ cc_cert_id:
# CSEC2019015
# CSEC 2019012
IN:
# India (IC3S/DEL01/VALIANT/EAL1/0317/0007/CR STQC/CC/14-15/12/ETR/0017 IC3S/MUM01/CISCO/cPP/0119/0016/CR)
# will miss STQC/CC/14-15/12/ETR/0017
- "(?:IC3S|STQC/CC)/[^ ]+? ?/CR"
- "IC3S/(?P<lab>[A-Z]+[0-9]+)/(?P<vendor>[a-zA-Z_]+)/(?P<level>[a-zA-Z0-9]+)/(?P<number1>[0-9]+)/(?P<number2>[0-9]+) ?(?:/CR)?"
# XXX: The cert IDs are often present only in the certificate and not in the report.
# The report often only has the report id, of the format "STQC/CC/1617/18/CR"
# Examples:
# IC3S/BG01/HALTDOS/EAL2/0317/0008/CR
# IC3S/KOL01/ADVA/EAL2/0520/0021/CR
# IC3S/MUM01/Symantec/NDcPP/0722/0032/CR
SG:
- "CSA_CC_(?P<year>[0-9]{2})(?P<counter>[0-9]{3})"
# Examples:
Expand Down
14 changes: 12 additions & 2 deletions src/sec_certs/sample/cc_certificate_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,17 @@ def _canonical_es(self) -> str:
return new_cert_id

def _canonical_in(self):
return self.clean.replace(" ", "")
new_cert_id = self.clean
for rule in rules["cc_cert_id"]["IN"]:
if match := re.match(rule, new_cert_id):
groups = match.groupdict()
lab = groups["lab"]
vendor = groups["vendor"]
level = groups["level"]
number1, number2 = groups["number1"], groups["number2"]
new_cert_id = f"IC3S/{lab}/{vendor}/{level}/{number1}/{number2}"
break
return new_cert_id

def _canonical_se(self):
new_cert_id = self.clean
Expand Down Expand Up @@ -232,7 +242,7 @@ def canonical(self) -> str:
"AU": self._canonical_au,
"KR": self._canonical_kr,
# SG is canonical by default
# IT is canonucal by default
# IT is canonical by default
}

if self.scheme in schemes:
Expand Down
2 changes: 1 addition & 1 deletion tests/cc/test_cc_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_canonicalize_es():


def test_canonicalize_in():
assert canonicalize("IC3S/KOL01/ADVA/EAL2/0520/0021 /CR", "IN") == "IC3S/KOL01/ADVA/EAL2/0520/0021/CR"
assert canonicalize("IC3S/KOL01/ADVA/EAL2/0520/0021 /CR", "IN") == "IC3S/KOL01/ADVA/EAL2/0520/0021"


def test_canonicalize_se():
Expand Down

0 comments on commit 520ce49

Please sign in to comment.