From a57f67747453a23c97f13cedcf6b42ce71b45318 Mon Sep 17 00:00:00 2001 From: Pengyu Lv Date: Mon, 8 May 2023 18:07:28 +0800 Subject: [PATCH] cert_audit: Fix DER files missed from parsing Signed-off-by: Pengyu Lv --- tests/scripts/audit-validity-dates.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/scripts/audit-validity-dates.py b/tests/scripts/audit-validity-dates.py index ecde428450..5506e40e7f 100755 --- a/tests/scripts/audit-validity-dates.py +++ b/tests/scripts/audit-validity-dates.py @@ -302,12 +302,22 @@ class TestDataAuditor(Auditor): data = f.read() results = [] + # Try to parse all PEM blocks. + is_pem = False for idx, m in enumerate(re.finditer(X509Parser.PEM_REGEX, data, flags=re.S), 1): + is_pem = True result = self.parse_bytes(data[m.start():m.end()]) if result is not None: result.locations.append("{}#{}".format(filename, idx)) results.append(result) + # Might be DER format. + if not is_pem: + result = self.parse_bytes(data) + if result is not None: + result.locations.append("{}".format(filename)) + results.append(result) + return results