MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / printCertCInfo

Function printCertCInfo

tools/get_checkers.py:946–968  ·  view source on GitHub ↗

Fetches CERT C rules information.

(content_subdir:str)

Source from the content-addressed store, hash-verified

944 return sorted(files)
945
946def printCertCInfo(content_subdir:str):
947 """Fetches CERT C rules information."""
948 paths = listCertFiles(content_subdir)
949 rules = {}
950 for path in tqdm(paths, total=len(paths), desc=f'Fetching {content_subdir}', file=sys.stderr):
951 raw = 'https://raw.githubusercontent.com/%s/%s/%s' % (CERT_REPO, CERT_BRANCH, path)
952 text = requests.get(raw, timeout=30).text
953 res = re.search(r'^#\s+([A-Z]{3}\d{2}-C(?:PP)?)\b', text, re.MULTILINE)
954 if res is None:
955 continue
956 head = re.search(r'^#{0,4}\s*Risk Assessments?\s*$', text, re.MULTILINE)
957 if head is None:
958 continue
959 section = text[head.end():]
960 nexthead = re.search(r'^#{1,4}\s+\S', section, re.MULTILINE)
961 if nexthead:
962 section = section[:nexthead.start()]
963 level = re.search(r'\bL[1-3]\b', section)
964 if level is None:
965 continue
966 rules[res.group(1)] = level.group(0)
967 for rule_id, level in dict(sorted(rules.items())).items():
968 print(' {"%s", "%s"},' % (rule_id, level))
969
970
971

Callers 1

get_checkers.pyFile · 0.85

Calls 4

listCertFilesFunction · 0.85
tqdmFunction · 0.85
getMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected