Created
May 1, 2023 07:03
-
-
Save arm000/39a08694b3b3b01dbc8f0f1cb9f28de2 to your computer and use it in GitHub Desktop.
Run cov-analyze scanner on each CERT rule separately
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
import subprocess | |
checkers = [ | |
'ARR30-C', | |
'ARR36-C', | |
'ARR37-C', | |
'CON31-C', | |
'CON33-C', | |
'CON34-C', | |
'DCL37-C', | |
'DCL40-C', | |
'ERR30-C', | |
'ERR33-C', | |
'EXP33-C', | |
'EXP34-C', | |
'EXP36-C', | |
'EXP37-C', | |
'EXP39-C', | |
'EXP40-C', | |
'EXP42-C', | |
'EXP44-C', | |
'EXP46-C', | |
'EXP47-C', | |
'FIO32-C', | |
'FLP30-C', | |
'FLP32-C', | |
'FLP34-C', | |
'FLP36-C', | |
'INT30-C', | |
'INT31-C', | |
'INT32-C', | |
'INT33-C', | |
'INT34-C', | |
'INT36-C', | |
'MEM30-C', | |
'MEM31-C', | |
'MEM35-C', | |
'POS54-C', | |
'STR30-C', | |
'STR31-C', | |
'STR34-C' | |
] | |
def generate_config(rule): | |
deviations = [] | |
for checker in checkers: | |
if checker == rule: | |
continue | |
deviation = {} | |
deviation['deviation'] = checker | |
deviation['reason'] = 'This rule is currently disabled in the analysis configuration.' | |
deviations.append(deviation) | |
cfg = {} | |
cfg['version'] = '2.0' | |
cfg['standard'] = 'cert-c' | |
cfg['title'] = 'CERT C' | |
cfg['deviations'] = deviations | |
return json.dumps(cfg, indent=2) | |
for checker in checkers: | |
with open('cert.config', 'w') as fp: | |
fp.write(generate_config(checker)) | |
result = subprocess.run(['cov-analyze', | |
'--dir=.', | |
'--disable-default', | |
'--coding-standard-config=cert.config'], | |
capture_output=True, | |
text=True, | |
check=True) | |
print(result.stderr) | |
print(result.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment