Repository navigation
refactor(findings): name every reported rule through one catalogue - #35
Merged
Merged
Conversation
A rule's id, title, description and confidence were spread over the parser tables, inline ids in ParseFindings and the DescribeRule table, matched by string. A rule added to the parser and left out of DescribeRule shipped with no SARIF description and no confidence, and nothing failed. kRules is now the one catalogue. The parser tables, the one-line reports and the vtable fallback name their rule through RuleNamed, a consteval lookup into kRules, so a rule missing from the catalogue or a misspelled id does not compile. DescribeRule reads the same catalogue. The SARIF tests keep their own expected values. Closes #32
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #32.
Change
src/findings.cpponly, no change in what the analyzer reports.kRulesis the one catalogue of the rulesParseFindingsreports: id, title, description, confidence.kBoundsRules,kVtableRules, the double-free and memory-leak reports and thevtable-diagnosticfallback hold aconst CatalogueRule&obtained fromRuleNamed("<id>"), aconstevallookup intokRules.OneLineFindingtakes a catalogue entry instead of a string.DescribeRulereadskRules; its own table is gone.A rule the parser reports but the catalogue does not describe, or a misspelled id, no longer compiles. The tests in
unittests/sarif_test.cppkeep their expected values written out, not read back from the catalogue.Test first
This is a refactor with a compile-time guarantee, so the red step is a build failure. With
RuleNamed("double-free")misspelled asRuleNamed("double-fre"):With the ids right,
ctest --test-dir buildpasses 17/17 before and after the change;scripts/format-check.shis clean on the changed file.Independent of #34 (which only touches
unittests/sarif_test.cpp): either can merge first.