From e782b52dfcf588ac68bde3f449886cfa375f3147 Mon Sep 17 00:00:00 2001 From: William Jakobsson Date: Tue, 2 Jun 2026 13:27:03 +0200 Subject: [PATCH 1/3] updated to fetch data from new github wiki --- tools/get_checkers.py | 75 ++++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/tools/get_checkers.py b/tools/get_checkers.py index 4594b773dc2..d405710eb74 100644 --- a/tools/get_checkers.py +++ b/tools/get_checkers.py @@ -908,44 +908,67 @@ def print_checkers(glob_pattern:str): }; """) +# SEI CERT is available as markdown files at +# https://github.com/cmu-sei/secure-coding-standards +CERT_REPO = 'cmu-sei/secure-coding-standards' +CERT_BRANCH = 'main' -def getCertCInfo(main_url:str): +# Cache git tree +_cert_tree = None + +def listCertFiles(content_subdir:str): + """Lists the rules and recommendation files for one part of the standard.""" + global _cert_tree + if _cert_tree is None: + url = 'https://api.github.com/repos/%s/git/trees/%s?recursive=1' % (CERT_REPO, CERT_BRANCH) + _cert_tree = requests.get(url, timeout=50).json()['tree'] + prefix = 'content/' + content_subdir + files = [] + for entry in _cert_tree: + path = entry['path'] + if entry['type'] != 'blob' or not path.startswith(prefix) or not path.endswith('.md'): + continue + if 'index' in path.rsplit('/', 1)[-1].lower(): + continue + files.append(path) + return sorted(files) + +def printCertCInfo(content_subdir:str): """Fetches CERT C rules information.""" # Fetching the CERT C rules page - r = requests.get(main_url, timeout=30) - mainpage = r.text - for line in mainpage.split('\n'): - res = re.search(r'(Rule|Rec.) \d\d[.] [A-Za-z ]+ [(][A-Z][A-Z][A-Z][)]', line) + rules = {} + for path in listCertFiles(content_subdir): + raw = 'https://raw.githubusercontent.com/%s/%s/%s' % (CERT_REPO, CERT_BRANCH, path) + text = requests.get(raw, timeout=30).text + res = re.search(r'^#\s+([A-Z]{3}\d{2}-C(?:PP)?)\b', text, re.MULTILINE) if res is None: continue - r = requests.get('https://wiki.sei.cmu.edu' + res.group(1), timeout=30) - text = r.text.replace('\n', '').replace('', '\n').replace('', '\n') - rules = [] - for line in text.split('\n'): - if not line.startswith(']+>([A-Z][A-Z][A-Z][0-9][0-9]-CP*)<.*>(L[1-3])<.+', line) - if res: - if res.group(1) == 'EXP40-C' and 'EXP39-C' not in rules: - print(' {"EXP39-C", "L2"},') - print(' {"%s", "%s"},' % (res.group(1), res.group(2))) - rules.append(res.group(1)) - if 'EXP45-C' in rules: - if 'EXP46-C' not in rules: - print(' {"EXP46-C", "L2"},') - if 'EXP47-C' not in rules: - print(' {"EXP47-C", "L2"},') + # Find risk assessment section. + head = re.search(r'^#{0,4}\s*Risk Assessments?\s*$', text, re.MULTILINE) + if head is None: + continue + # Look in section + section = text[head.end():] + nexthead = re.search(r'^#{1,4}\s+\S', section, re.MULTILINE) + if nexthead: + section = section[:nexthead.start()] + level = re.search(r'\bL[1-3]\b', section, re.MULTILINE) + if level is None: + continue + rules[res.group(1)] = level.group(0) + for rule_id, level in dict(sorted(rules.items())).items(): + print(' {"%s", "%s"},' % (rule_id, level)) + print('std::vector checkers::certCInfo{') -getCertCInfo('https://wiki.sei.cmu.edu/confluence/display/c/2+Rules') +printCertCInfo('4.sei-cert-c-coding-standard/03.rules/') print(' // Recommendations') -getCertCInfo('https://wiki.sei.cmu.edu/confluence/display/c/3+Recommendations') +printCertCInfo('4.sei-cert-c-coding-standard/08.recommendations/') print('};') print('') print('std::vector checkers::certCppInfo{') -getCertCInfo('https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=88046682') +printCertCInfo('5.sei-cert-cpp-coding-standard/3.rules/') print('};') print('') From 32a2b888d81291e748adcfd0ca9ceb8b3cf8f340 Mon Sep 17 00:00:00 2001 From: William Jakobsson Date: Tue, 2 Jun 2026 14:13:44 +0200 Subject: [PATCH 2/3] updated checker.py and checkers.cpp --- lib/checkers.cpp | 375 ++++++++++++++++++++++-------------------- tools/get_checkers.py | 18 +- 2 files changed, 206 insertions(+), 187 deletions(-) diff --git a/lib/checkers.cpp b/lib/checkers.cpp index f7d7f913da6..3b425926b9e 100644 --- a/lib/checkers.cpp +++ b/lib/checkers.cpp @@ -109,7 +109,7 @@ namespace checkers { {"CheckMemoryLeakNoVar::check",""}, {"CheckMemoryLeakNoVar::checkForUnsafeArgAlloc",""}, {"CheckMemoryLeakStructMember::check",""}, - {"CheckNullPointer::analyseWholeProgram","unusedfunctions"}, + {"CheckNullPointer::analyseWholeProgram",""}, {"CheckNullPointer::arithmetic",""}, {"CheckNullPointer::nullConstantDereference",""}, {"CheckNullPointer::nullPointer",""}, @@ -1677,9 +1677,25 @@ std::vector checkers::autosarInfo{ }; std::vector checkers::certCInfo{ - {"PRE30-C", "L3"}, - {"PRE31-C", "L3"}, - {"PRE32-C", "L3"}, + {"ARR30-C", "L2"}, + {"ARR32-C", "L2"}, + {"ARR36-C", "L3"}, + {"ARR37-C", "L2"}, + {"ARR38-C", "L2"}, + {"ARR39-C", "L2"}, + {"CON30-C", "L3"}, + {"CON31-C", "L3"}, + {"CON32-C", "L3"}, + {"CON33-C", "L3"}, + {"CON34-C", "L3"}, + {"CON35-C", "L3"}, + {"CON36-C", "L3"}, + {"CON37-C", "L3"}, + {"CON38-C", "L3"}, + {"CON39-C", "L3"}, + {"CON40-C", "L2"}, + {"CON41-C", "L3"}, + {"CON43-C", "L3"}, {"DCL30-C", "L2"}, {"DCL31-C", "L3"}, {"DCL36-C", "L2"}, @@ -1688,6 +1704,15 @@ std::vector checkers::certCInfo{ {"DCL39-C", "L3"}, {"DCL40-C", "L3"}, {"DCL41-C", "L2"}, + {"ENV30-C", "L3"}, + {"ENV31-C", "L3"}, + {"ENV32-C", "L1"}, + {"ENV33-C", "L1"}, + {"ENV34-C", "L3"}, + {"ERR30-C", "L1"}, + {"ERR32-C", "L3"}, + {"ERR33-C", "L1"}, + {"ERR34-C", "L2"}, {"EXP30-C", "L2"}, {"EXP32-C", "L2"}, {"EXP33-C", "L1"}, @@ -1695,7 +1720,7 @@ std::vector checkers::certCInfo{ {"EXP35-C", "L2"}, {"EXP36-C", "L3"}, {"EXP37-C", "L3"}, - {"EXP39-C", "L2"}, + {"EXP39-C", "L3"}, {"EXP40-C", "L3"}, {"EXP42-C", "L1"}, {"EXP43-C", "L3"}, @@ -1703,36 +1728,6 @@ std::vector checkers::certCInfo{ {"EXP45-C", "L2"}, {"EXP46-C", "L2"}, {"EXP47-C", "L2"}, - {"INT30-C", "L2"}, - {"INT31-C", "L1"}, - {"INT32-C", "L1"}, - {"INT33-C", "L2"}, - {"INT34-C", "L3"}, - {"INT35-C", "L3"}, - {"INT36-C", "L3"}, - {"FLP30-C", "L2"}, - {"FLP32-C", "L1"}, - {"FLP34-C", "L3"}, - {"FLP36-C", "L3"}, - {"FLP37-C", "L3"}, - {"ARR30-C", "L2"}, - {"ARR32-C", "L2"}, - {"ARR36-C", "L3"}, - {"ARR37-C", "L2"}, - {"ARR38-C", "L2"}, - {"ARR39-C", "L2"}, - {"STR30-C", "L2"}, - {"STR31-C", "L2"}, - {"STR32-C", "L1"}, - {"STR34-C", "L2"}, - {"STR37-C", "L3"}, - {"STR38-C", "L1"}, - {"MEM30-C", "L2"}, - {"MEM31-C", "L3"}, - {"MEM33-C", "L3"}, - {"MEM34-C", "L2"}, - {"MEM35-C", "L2"}, - {"MEM36-C", "L3"}, {"FIO30-C", "L1"}, {"FIO32-C", "L3"}, {"FIO34-C", "L1"}, @@ -1746,32 +1741,24 @@ std::vector checkers::certCInfo{ {"FIO45-C", "L2"}, {"FIO46-C", "L3"}, {"FIO47-C", "L2"}, - {"ENV30-C", "L3"}, - {"ENV31-C", "L3"}, - {"ENV32-C", "L1"}, - {"ENV33-C", "L1"}, - {"ENV34-C", "L3"}, - {"SIG30-C", "L1"}, - {"SIG31-C", "L1"}, - {"SIG34-C", "L3"}, - {"SIG35-C", "L3"}, - {"ERR30-C", "L1"}, - {"ERR32-C", "L3"}, - {"ERR33-C", "L1"}, - {"ERR34-C", "L2"}, - {"CON30-C", "L3"}, - {"CON31-C", "L3"}, - {"CON32-C", "L3"}, - {"CON33-C", "L3"}, - {"CON34-C", "L3"}, - {"CON35-C", "L3"}, - {"CON36-C", "L3"}, - {"CON37-C", "L3"}, - {"CON38-C", "L3"}, - {"CON39-C", "L3"}, - {"CON40-C", "L2"}, - {"CON41-C", "L3"}, - {"CON43-C", "L3"}, + {"FLP30-C", "L2"}, + {"FLP32-C", "L1"}, + {"FLP34-C", "L3"}, + {"FLP36-C", "L3"}, + {"FLP37-C", "L3"}, + {"INT30-C", "L2"}, + {"INT31-C", "L1"}, + {"INT32-C", "L1"}, + {"INT33-C", "L2"}, + {"INT34-C", "L3"}, + {"INT35-C", "L3"}, + {"INT36-C", "L3"}, + {"MEM30-C", "L2"}, + {"MEM31-C", "L3"}, + {"MEM33-C", "L3"}, + {"MEM34-C", "L2"}, + {"MEM35-C", "L2"}, + {"MEM36-C", "L3"}, {"MSC30-C", "L3"}, {"MSC32-C", "L1"}, {"MSC33-C", "L2"}, @@ -1796,21 +1783,42 @@ std::vector checkers::certCInfo{ {"POS52-C", "L3"}, {"POS53-C", "L2"}, {"POS54-C", "L1"}, + {"PRE30-C", "L3"}, + {"PRE31-C", "L3"}, + {"PRE32-C", "L3"}, + {"SIG30-C", "L1"}, + {"SIG31-C", "L1"}, + {"SIG34-C", "L3"}, + {"SIG35-C", "L3"}, + {"STR30-C", "L2"}, + {"STR31-C", "L2"}, + {"STR32-C", "L1"}, + {"STR34-C", "L2"}, + {"STR37-C", "L3"}, + {"STR38-C", "L1"}, {"WIN30-C", "L3"}, // Recommendations - {"PRE00-C", "L3"}, - {"PRE01-C", "L1"}, - {"PRE02-C", "L1"}, - {"PRE04-C", "L3"}, - {"PRE05-C", "L3"}, - {"PRE06-C", "L3"}, - {"PRE07-C", "L3"}, - {"PRE08-C", "L3"}, - {"PRE09-C", "L1"}, - {"PRE10-C", "L1"}, - {"PRE11-C", "L2"}, - {"PRE12-C", "L3"}, - {"PRE13-C", "L3"}, + {"API00-C", "L3"}, + {"API01-C", "L1"}, + {"API02-C", "L1"}, + {"API03-C", "L3"}, + {"API04-C", "L3"}, + {"API05-C", "L1"}, + {"API07-C", "L3"}, + {"API09-C", "L3"}, + {"API10-C", "L3"}, + {"ARR00-C", "L2"}, + {"ARR01-C", "L1"}, + {"ARR02-C", "L2"}, + {"CON01-C", "L3"}, + {"CON02-C", "L3"}, + {"CON03-C", "L3"}, + {"CON04-C", "L3"}, + {"CON05-C", "L3"}, + {"CON06-C", "L3"}, + {"CON07-C", "L2"}, + {"CON08-C", "L3"}, + {"CON09-C", "L3"}, {"DCL00-C", "L3"}, {"DCL01-C", "L3"}, {"DCL02-C", "L3"}, @@ -1834,6 +1842,16 @@ std::vector checkers::certCInfo{ {"DCL21-C", "L3"}, {"DCL22-C", "L3"}, {"DCL23-C", "L2"}, + {"ENV01-C", "L2"}, + {"ENV02-C", "L3"}, + {"ENV03-C", "L2"}, + {"ERR00-C", "L3"}, + {"ERR01-C", "L2"}, + {"ERR02-C", "L3"}, + {"ERR04-C", "L3"}, + {"ERR05-C", "L2"}, + {"ERR06-C", "L3"}, + {"ERR07-C", "L1"}, {"EXP00-C", "L2"}, {"EXP02-C", "L3"}, {"EXP03-C", "L3"}, @@ -1850,44 +1868,6 @@ std::vector checkers::certCInfo{ {"EXP16-C", "L2"}, {"EXP19-C", "L1"}, {"EXP20-C", "L1"}, - {"INT00-C", "L3"}, - {"INT01-C", "L2"}, - {"INT02-C", "L3"}, - {"INT04-C", "L1"}, - {"INT05-C", "L2"}, - {"INT07-C", "L1"}, - {"INT08-C", "L3"}, - {"INT09-C", "L3"}, - {"INT10-C", "L3"}, - {"INT12-C", "L3"}, - {"INT13-C", "L2"}, - {"INT14-C", "L3"}, - {"INT15-C", "L2"}, - {"INT16-C", "L3"}, - {"INT17-C", "L3"}, - {"INT18-C", "L1"}, - {"FLP00-C", "L3"}, - {"FLP01-C", "L3"}, - {"FLP02-C", "L3"}, - {"FLP03-C", "L3"}, - {"FLP04-C", "L3"}, - {"FLP05-C", "L3"}, - {"FLP06-C", "L3"}, - {"FLP07-C", "L3"}, - {"ARR00-C", "L2"}, - {"ARR01-C", "L1"}, - {"ARR02-C", "L2"}, - {"STR00-C", "L3"}, - {"STR01-C", "L3"}, - {"STR02-C", "L2"}, - {"STR03-C", "L3"}, - {"STR04-C", "L3"}, - {"STR05-C", "L3"}, - {"STR06-C", "L2"}, - {"STR08-C", "L2"}, - {"STR09-C", "L3"}, - {"STR10-C", "L3"}, - {"STR11-C", "L2"}, {"FIO01-C", "L1"}, {"FIO02-C", "L3"}, {"FIO03-C", "L3"}, @@ -1908,36 +1888,41 @@ std::vector checkers::certCInfo{ {"FIO22-C", "L3"}, {"FIO23-C", "L3"}, {"FIO24-C", "L3"}, - {"ENV01-C", "L2"}, - {"ENV02-C", "L3"}, - {"ENV03-C", "L2"}, - {"SIG00-C", "L2"}, - {"SIG01-C", "L3"}, - {"SIG02-C", "L2"}, - {"ERR00-C", "L3"}, - {"ERR01-C", "L2"}, - {"ERR02-C", "L3"}, - {"ERR04-C", "L3"}, - {"ERR05-C", "L2"}, - {"ERR06-C", "L3"}, - {"ERR07-C", "L1"}, - {"API00-C", "L3"}, - {"API01-C", "L1"}, - {"API02-C", "L1"}, - {"API03-C", "L3"}, - {"API04-C", "L3"}, - {"API05-C", "L1"}, - {"API07-C", "L3"}, - {"API09-C", "L3"}, - {"API10-C", "L3"}, - {"CON01-C", "L3"}, - {"CON02-C", "L3"}, - {"CON04-C", "L3"}, - {"CON05-C", "L3"}, - {"CON06-C", "L3"}, - {"CON07-C", "L2"}, - {"CON08-C", "L3"}, - {"CON09-C", "L3"}, + {"FLP00-C", "L3"}, + {"FLP01-C", "L3"}, + {"FLP02-C", "L3"}, + {"FLP03-C", "L3"}, + {"FLP04-C", "L3"}, + {"FLP05-C", "L3"}, + {"FLP06-C", "L3"}, + {"FLP07-C", "L3"}, + {"INT00-C", "L3"}, + {"INT01-C", "L2"}, + {"INT02-C", "L3"}, + {"INT04-C", "L1"}, + {"INT05-C", "L2"}, + {"INT07-C", "L1"}, + {"INT08-C", "L3"}, + {"INT09-C", "L3"}, + {"INT10-C", "L3"}, + {"INT12-C", "L3"}, + {"INT13-C", "L2"}, + {"INT14-C", "L3"}, + {"INT15-C", "L2"}, + {"INT16-C", "L3"}, + {"INT17-C", "L3"}, + {"INT18-C", "L1"}, + {"MEM00-C", "L1"}, + {"MEM01-C", "L2"}, + {"MEM02-C", "L3"}, + {"MEM03-C", "L3"}, + {"MEM04-C", "L2"}, + {"MEM05-C", "L2"}, + {"MEM06-C", "L3"}, + {"MEM07-C", "L2"}, + {"MEM10-C", "L3"}, + {"MEM11-C", "L3"}, + {"MEM12-C", "L3"}, {"MSC00-C", "L3"}, {"MSC01-C", "L3"}, {"MSC04-C", "L3"}, @@ -1964,6 +1949,32 @@ std::vector checkers::certCInfo{ {"POS02-C", "L2"}, {"POS04-C", "L3"}, {"POS05-C", "L3"}, + {"PRE00-C", "L3"}, + {"PRE01-C", "L1"}, + {"PRE02-C", "L1"}, + {"PRE04-C", "L3"}, + {"PRE05-C", "L3"}, + {"PRE06-C", "L3"}, + {"PRE07-C", "L3"}, + {"PRE08-C", "L3"}, + {"PRE09-C", "L1"}, + {"PRE10-C", "L1"}, + {"PRE11-C", "L2"}, + {"PRE12-C", "L3"}, + {"PRE13-C", "L3"}, + {"SIG00-C", "L2"}, + {"SIG01-C", "L3"}, + {"SIG02-C", "L2"}, + {"STR00-C", "L3"}, + {"STR01-C", "L3"}, + {"STR02-C", "L2"}, + {"STR03-C", "L3"}, + {"STR04-C", "L3"}, + {"STR05-C", "L3"}, + {"STR06-C", "L2"}, + {"STR09-C", "L3"}, + {"STR10-C", "L3"}, + {"STR11-C", "L2"}, {"WIN00-C", "L2"}, {"WIN01-C", "L1"}, {"WIN02-C", "L1"}, @@ -1972,6 +1983,22 @@ std::vector checkers::certCInfo{ }; std::vector checkers::certCppInfo{ + {"CON50-CPP", "L3"}, + {"CON51-CPP", "L2"}, + {"CON52-CPP", "L3"}, + {"CON53-CPP", "L3"}, + {"CON54-CPP", "L3"}, + {"CON55-CPP", "L3"}, + {"CON56-CPP", "L3"}, + {"CTR50-CPP", "L2"}, + {"CTR51-CPP", "L2"}, + {"CTR52-CPP", "L2"}, + {"CTR53-CPP", "L2"}, + {"CTR54-CPP", "L3"}, + {"CTR55-CPP", "L2"}, + {"CTR56-CPP", "L2"}, + {"CTR57-CPP", "L3"}, + {"CTR58-CPP", "L2"}, {"DCL50-CPP", "L1"}, {"DCL51-CPP", "L3"}, {"DCL52-CPP", "L3"}, @@ -1983,6 +2010,19 @@ std::vector checkers::certCppInfo{ {"DCL58-CPP", "L2"}, {"DCL59-CPP", "L3"}, {"DCL60-CPP", "L2"}, + {"ERR50-CPP", "L3"}, + {"ERR51-CPP", "L2"}, + {"ERR52-CPP", "L3"}, + {"ERR53-CPP", "L3"}, + {"ERR54-CPP", "L1"}, + {"ERR55-CPP", "L2"}, + {"ERR56-CPP", "L2"}, + {"ERR57-CPP", "L3"}, + {"ERR58-CPP", "L2"}, + {"ERR59-CPP", "L2"}, + {"ERR60-CPP", "L3"}, + {"ERR61-CPP", "L3"}, + {"ERR62-CPP", "L3"}, {"EXP50-CPP", "L2"}, {"EXP51-CPP", "L3"}, {"EXP52-CPP", "L3"}, @@ -1997,20 +2037,9 @@ std::vector checkers::certCppInfo{ {"EXP61-CPP", "L2"}, {"EXP62-CPP", "L1"}, {"EXP63-CPP", "L2"}, + {"FIO50-CPP", "L2"}, + {"FIO51-CPP", "L3"}, {"INT50-CPP", "L3"}, - {"CTR50-CPP", "L2"}, - {"CTR51-CPP", "L2"}, - {"CTR52-CPP", "L2"}, - {"CTR53-CPP", "L2"}, - {"CTR54-CPP", "L3"}, - {"CTR55-CPP", "L2"}, - {"CTR56-CPP", "L2"}, - {"CTR57-CPP", "L3"}, - {"CTR58-CPP", "L2"}, - {"STR50-CPP", "L2"}, - {"STR51-CPP", "L1"}, - {"STR52-CPP", "L2"}, - {"STR53-CPP", "L3"}, {"MEM50-CPP", "L2"}, {"MEM51-CPP", "L2"}, {"MEM52-CPP", "L1"}, @@ -2019,21 +2048,11 @@ std::vector checkers::certCppInfo{ {"MEM55-CPP", "L2"}, {"MEM56-CPP", "L2"}, {"MEM57-CPP", "L3"}, - {"FIO50-CPP", "L2"}, - {"FIO51-CPP", "L3"}, - {"ERR50-CPP", "L3"}, - {"ERR51-CPP", "L2"}, - {"ERR52-CPP", "L3"}, - {"ERR53-CPP", "L3"}, - {"ERR54-CPP", "L1"}, - {"ERR55-CPP", "L2"}, - {"ERR56-CPP", "L2"}, - {"ERR57-CPP", "L3"}, - {"ERR58-CPP", "L2"}, - {"ERR59-CPP", "L2"}, - {"ERR60-CPP", "L3"}, - {"ERR61-CPP", "L3"}, - {"ERR62-CPP", "L3"}, + {"MSC50-CPP", "L3"}, + {"MSC51-CPP", "L1"}, + {"MSC52-CPP", "L2"}, + {"MSC53-CPP", "L3"}, + {"MSC54-CPP", "L2"}, {"OOP50-CPP", "L3"}, {"OOP51-CPP", "L3"}, {"OOP52-CPP", "L3"}, @@ -2043,17 +2062,9 @@ std::vector checkers::certCppInfo{ {"OOP56-CPP", "L3"}, {"OOP57-CPP", "L1"}, {"OOP58-CPP", "L2"}, - {"CON50-CPP", "L3"}, - {"CON51-CPP", "L2"}, - {"CON52-CPP", "L3"}, - {"CON53-CPP", "L3"}, - {"CON54-CPP", "L3"}, - {"CON55-CPP", "L3"}, - {"CON56-CPP", "L3"}, - {"MSC50-CPP", "L3"}, - {"MSC51-CPP", "L1"}, - {"MSC52-CPP", "L2"}, - {"MSC53-CPP", "L3"}, - {"MSC54-CPP", "L2"}, + {"STR50-CPP", "L2"}, + {"STR51-CPP", "L1"}, + {"STR52-CPP", "L2"}, + {"STR53-CPP", "L3"}, }; diff --git a/tools/get_checkers.py b/tools/get_checkers.py index d405710eb74..3cc895ebbc7 100644 --- a/tools/get_checkers.py +++ b/tools/get_checkers.py @@ -2,8 +2,18 @@ import glob import os import re +import sys import requests +try: + from tqdm import tqdm +except ImportError: + # Fallback: passthrough iterator if tqdm is not installed + def tqdm(iterable, total=None, desc=None, **kwargs): + if desc: + print(desc, file=sys.stderr) + return iterable + def print_checkers(glob_pattern:str): checkers = {} for filename in glob.glob(glob_pattern): @@ -935,24 +945,22 @@ def listCertFiles(content_subdir:str): def printCertCInfo(content_subdir:str): """Fetches CERT C rules information.""" - # Fetching the CERT C rules page + paths = listCertFiles(content_subdir) rules = {} - for path in listCertFiles(content_subdir): + for path in tqdm(paths, desc=f'Fetching {content_subdir}', file=sys.stderr): raw = 'https://raw.githubusercontent.com/%s/%s/%s' % (CERT_REPO, CERT_BRANCH, path) text = requests.get(raw, timeout=30).text res = re.search(r'^#\s+([A-Z]{3}\d{2}-C(?:PP)?)\b', text, re.MULTILINE) if res is None: continue - # Find risk assessment section. head = re.search(r'^#{0,4}\s*Risk Assessments?\s*$', text, re.MULTILINE) if head is None: continue - # Look in section section = text[head.end():] nexthead = re.search(r'^#{1,4}\s+\S', section, re.MULTILINE) if nexthead: section = section[:nexthead.start()] - level = re.search(r'\bL[1-3]\b', section, re.MULTILINE) + level = re.search(r'\bL[1-3]\b', section) if level is None: continue rules[res.group(1)] = level.group(0) From a559a710648fcad8856ce4ec7034d1e7f43651dd Mon Sep 17 00:00:00 2001 From: William Jakobsson Date: Tue, 2 Jun 2026 14:37:45 +0200 Subject: [PATCH 3/3] fix --- tools/get_checkers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/get_checkers.py b/tools/get_checkers.py index 3cc895ebbc7..48455200fb5 100644 --- a/tools/get_checkers.py +++ b/tools/get_checkers.py @@ -947,7 +947,7 @@ def printCertCInfo(content_subdir:str): """Fetches CERT C rules information.""" paths = listCertFiles(content_subdir) rules = {} - for path in tqdm(paths, desc=f'Fetching {content_subdir}', file=sys.stderr): + for path in tqdm(paths, total=len(paths), desc=f'Fetching {content_subdir}', file=sys.stderr): raw = 'https://raw.githubusercontent.com/%s/%s/%s' % (CERT_REPO, CERT_BRANCH, path) text = requests.get(raw, timeout=30).text res = re.search(r'^#\s+([A-Z]{3}\d{2}-C(?:PP)?)\b', text, re.MULTILINE)