clangsa-sast: implement analyzer configuration
Problem to solve
Clang static analyzer can be tuned for performance and coverage, in particular by enabling/disabling checkers.
clangsa-sast should respect existing configuration mechanisms for Clang static analyzer, e.g. its config file as much as possible.
In addition, the list of checkers should be
- logged during run at the debug level
- set with a sensible default that is easy to manage
- modifiable by the user
Proposal
Initially, we can start with the default set of "sensible" CodeChecker checkers less those found to have very low precision while benchmarking.
Implementation plan
-
implement passthroughs - specification of "target" is an error - there is only one file that's either overwritten or appended to.
-
create a golang CodeCheckerConfig structto represent aCodeCheckerconfiguration- A
CodeCheckerconfiguration is a list of command line options for each subcommand. We only useanalyzeandparsesubcommands, so ignore any other subcommand lists. -
for each option (e.g. of analyze) determine whether repeats conform to a sensible behavior for passthrough append mode.- the last
--enable xor--disable xdetermines whether checkerxis enabled or disabled -
--checker-configuses theOrderedConfigActionaction, which ensures the list of config items accumulates instead of being overwritten with each new--checker-config
- the last
-
unmarshal from YAML and JSON CodeCheckerconfig file formats -
marshal to YAML -
add methods -
Disable(checker string)andEnable(checker string) -
Append(CodeCheckerConfig)
-
- A
-
create the default configuration that explicitly selects the set determined by benchmarking - the sensitiveprofile further filtered (with-t .051) for low FP rate. Some of the checkers with high FPs in the SARD set are due to peculiarities of the test cases, and shouldn't be filtered. We'll err on the side of adding FPs by keeping the initial list of checkers large. -
update the calls to CodeCheckerto use theconfig file fromconfiguredruleset.Config.TargetDirCodeCheckerConfig -
add LoadRulesetConfigtocommand.Config-
generate a CodeCheckerConfigby loading the default and parsing passthroughs -
parse disabled rules to translate fromthis is an optimization and requires id mappingcweidentifiers toclangsa_id/ checker names that can be disabled in a final "append passthrough" operation. -
write the file and useno needruleset.Config.TargetDirto store its location
-
Edited by Jason Leasure