Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8647dd4

Browse files
committedNov 28, 2022
Add rule category to rule meta data
The category information enables evaluation time computation of the effective category of a rule. The effective category is determined by the rule's category and a possible recategorization through a Guideline Recategorization Plan. The effective category will be used to determine how to handle a deviation applied to a query implementing the rule.
1 parent 0291b4c commit 8647dd4

File tree

92 files changed

+1636
-903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1636
-903
lines changed
 

‎cpp/common/src/codingstandards/cpp/exclusions/RuleMetadata.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ newtype TQuery =
88

99
class Query extends TQuery {
1010
string getQueryId() {
11-
CPPRuleMetadata::isQueryMetadata(this, result, _) or
12-
CRuleMetadata::isQueryMetadata(this, result, _)
11+
CPPRuleMetadata::isQueryMetadata(this, result, _, _) or
12+
CRuleMetadata::isQueryMetadata(this, result, _, _)
1313
}
1414

1515
string getRuleId() {
16-
CPPRuleMetadata::isQueryMetadata(this, _, result) or
17-
CRuleMetadata::isQueryMetadata(this, _, result)
16+
CPPRuleMetadata::isQueryMetadata(this, _, result, _) or
17+
CRuleMetadata::isQueryMetadata(this, _, result, _)
18+
}
19+
20+
string getCategory() {
21+
CPPRuleMetadata::isQueryMetadata(this, _, _, result) or
22+
CRuleMetadata::isQueryMetadata(this, _, _, result)
1823
}
1924

2025
string toString() { result = getQueryId() }

‎cpp/common/src/codingstandards/cpp/exclusions/c/Banned.qll

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,158 +24,177 @@ newtype BannedQuery =
2424
TOctalConstantsUsedQuery() or
2525
TRestrictTypeQualifierUsedQuery()
2626

27-
predicate isBannedQueryMetadata(Query query, string queryId, string ruleId) {
27+
predicate isBannedQueryMetadata(Query query, string queryId, string ruleId, string category) {
2828
query =
2929
// `Query` instance for the `doNotCallSystem` query
3030
BannedPackage::doNotCallSystemQuery() and
3131
queryId =
3232
// `@id` for the `doNotCallSystem` query
3333
"c/cert/do-not-call-system" and
34-
ruleId = "ENV33-C"
34+
ruleId = "ENV33-C" and
35+
category = "rule"
3536
or
3637
query =
3738
// `Query` instance for the `commaOperatorShouldNotBeUsed` query
3839
BannedPackage::commaOperatorShouldNotBeUsedQuery() and
3940
queryId =
4041
// `@id` for the `commaOperatorShouldNotBeUsed` query
4142
"c/misra/comma-operator-should-not-be-used" and
42-
ruleId = "RULE-12-3"
43+
ruleId = "RULE-12-3" and
44+
category = "advisory"
4345
or
4446
query =
4547
// `Query` instance for the `featuresOfStdarghUsed` query
4648
BannedPackage::featuresOfStdarghUsedQuery() and
4749
queryId =
4850
// `@id` for the `featuresOfStdarghUsed` query
4951
"c/misra/features-of-stdargh-used" and
50-
ruleId = "RULE-17-1"
52+
ruleId = "RULE-17-1" and
53+
category = "required"
5154
or
5255
query =
5356
// `Query` instance for the `unionKeywordShouldNotBeUsed` query
5457
BannedPackage::unionKeywordShouldNotBeUsedQuery() and
5558
queryId =
5659
// `@id` for the `unionKeywordShouldNotBeUsed` query
5760
"c/misra/union-keyword-should-not-be-used" and
58-
ruleId = "RULE-19-2"
61+
ruleId = "RULE-19-2" and
62+
category = "advisory"
5963
or
6064
query =
6165
// `Query` instance for the `standardLibraryTimeAndDateFunctionsUsed` query
6266
BannedPackage::standardLibraryTimeAndDateFunctionsUsedQuery() and
6367
queryId =
6468
// `@id` for the `standardLibraryTimeAndDateFunctionsUsed` query
6569
"c/misra/standard-library-time-and-date-functions-used" and
66-
ruleId = "RULE-21-10"
70+
ruleId = "RULE-21-10" and
71+
category = "required"
6772
or
6873
query =
6974
// `Query` instance for the `standardHeaderFileTgmathhUsed` query
7075
BannedPackage::standardHeaderFileTgmathhUsedQuery() and
7176
queryId =
7277
// `@id` for the `standardHeaderFileTgmathhUsed` query
7378
"c/misra/standard-header-file-tgmathh-used" and
74-
ruleId = "RULE-21-11"
79+
ruleId = "RULE-21-11" and
80+
category = "required"
7581
or
7682
query =
7783
// `Query` instance for the `exceptionHandlingFeaturesOfFenvhUsed` query
7884
BannedPackage::exceptionHandlingFeaturesOfFenvhUsedQuery() and
7985
queryId =
8086
// `@id` for the `exceptionHandlingFeaturesOfFenvhUsed` query
8187
"c/misra/exception-handling-features-of-fenvh-used" and
82-
ruleId = "RULE-21-12"
88+
ruleId = "RULE-21-12" and
89+
category = "advisory"
8390
or
8491
query =
8592
// `Query` instance for the `systemOfStdlibhUsed` query
8693
BannedPackage::systemOfStdlibhUsedQuery() and
8794
queryId =
8895
// `@id` for the `systemOfStdlibhUsed` query
8996
"c/misra/system-of-stdlibh-used" and
90-
ruleId = "RULE-21-21"
97+
ruleId = "RULE-21-21" and
98+
category = "required"
9199
or
92100
query =
93101
// `Query` instance for the `memoryAllocDeallocFunctionsOfStdlibhUsed` query
94102
BannedPackage::memoryAllocDeallocFunctionsOfStdlibhUsedQuery() and
95103
queryId =
96104
// `@id` for the `memoryAllocDeallocFunctionsOfStdlibhUsed` query
97105
"c/misra/memory-alloc-dealloc-functions-of-stdlibh-used" and
98-
ruleId = "RULE-21-3"
106+
ruleId = "RULE-21-3" and
107+
category = "required"
99108
or
100109
query =
101110
// `Query` instance for the `standardHeaderFileUsedSetjmph` query
102111
BannedPackage::standardHeaderFileUsedSetjmphQuery() and
103112
queryId =
104113
// `@id` for the `standardHeaderFileUsedSetjmph` query
105114
"c/misra/standard-header-file-used-setjmph" and
106-
ruleId = "RULE-21-4"
115+
ruleId = "RULE-21-4" and
116+
category = "required"
107117
or
108118
query =
109119
// `Query` instance for the `standardHeaderFileUsedSignalh` query
110120
BannedPackage::standardHeaderFileUsedSignalhQuery() and
111121
queryId =
112122
// `@id` for the `standardHeaderFileUsedSignalh` query
113123
"c/misra/standard-header-file-used-signalh" and
114-
ruleId = "RULE-21-5"
124+
ruleId = "RULE-21-5" and
125+
category = "required"
115126
or
116127
query =
117128
// `Query` instance for the `standardLibraryInputoutputFunctionsUsed` query
118129
BannedPackage::standardLibraryInputoutputFunctionsUsedQuery() and
119130
queryId =
120131
// `@id` for the `standardLibraryInputoutputFunctionsUsed` query
121132
"c/misra/standard-library-inputoutput-functions-used" and
122-
ruleId = "RULE-21-6"
133+
ruleId = "RULE-21-6" and
134+
category = "required"
123135
or
124136
query =
125137
// `Query` instance for the `atofAtoiAtolAndAtollOfStdlibhUsed` query
126138
BannedPackage::atofAtoiAtolAndAtollOfStdlibhUsedQuery() and
127139
queryId =
128140
// `@id` for the `atofAtoiAtolAndAtollOfStdlibhUsed` query
129141
"c/misra/atof-atoi-atol-and-atoll-of-stdlibh-used" and
130-
ruleId = "RULE-21-7"
142+
ruleId = "RULE-21-7" and
143+
category = "required"
131144
or
132145
query =
133146
// `Query` instance for the `terminationFunctionsOfStdlibhUsed` query
134147
BannedPackage::terminationFunctionsOfStdlibhUsedQuery() and
135148
queryId =
136149
// `@id` for the `terminationFunctionsOfStdlibhUsed` query
137150
"c/misra/termination-functions-of-stdlibh-used" and
138-
ruleId = "RULE-21-8"
151+
ruleId = "RULE-21-8" and
152+
category = "required"
139153
or
140154
query =
141155
// `Query` instance for the `terminationMacrosOfStdlibhUsed` query
142156
BannedPackage::terminationMacrosOfStdlibhUsedQuery() and
143157
queryId =
144158
// `@id` for the `terminationMacrosOfStdlibhUsed` query
145159
"c/misra/termination-macros-of-stdlibh-used" and
146-
ruleId = "RULE-21-8"
160+
ruleId = "RULE-21-8" and
161+
category = "required"
147162
or
148163
query =
149164
// `Query` instance for the `bsearchAndQsortOfStdlibhUsed` query
150165
BannedPackage::bsearchAndQsortOfStdlibhUsedQuery() and
151166
queryId =
152167
// `@id` for the `bsearchAndQsortOfStdlibhUsed` query
153168
"c/misra/bsearch-and-qsort-of-stdlibh-used" and
154-
ruleId = "RULE-21-9"
169+
ruleId = "RULE-21-9" and
170+
category = "required"
155171
or
156172
query =
157173
// `Query` instance for the `stdLibDynamicMemoryAllocationUsed` query
158174
BannedPackage::stdLibDynamicMemoryAllocationUsedQuery() and
159175
queryId =
160176
// `@id` for the `stdLibDynamicMemoryAllocationUsed` query
161177
"c/misra/std-lib-dynamic-memory-allocation-used" and
162-
ruleId = "DIR-4-12"
178+
ruleId = "DIR-4-12" and
179+
category = "required"
163180
or
164181
query =
165182
// `Query` instance for the `octalConstantsUsed` query
166183
BannedPackage::octalConstantsUsedQuery() and
167184
queryId =
168185
// `@id` for the `octalConstantsUsed` query
169186
"c/misra/octal-constants-used" and
170-
ruleId = "RULE-7-1"
187+
ruleId = "RULE-7-1" and
188+
category = "required"
171189
or
172190
query =
173191
// `Query` instance for the `restrictTypeQualifierUsed` query
174192
BannedPackage::restrictTypeQualifierUsedQuery() and
175193
queryId =
176194
// `@id` for the `restrictTypeQualifierUsed` query
177195
"c/misra/restrict-type-qualifier-used" and
178-
ruleId = "RULE-8-14"
196+
ruleId = "RULE-8-14" and
197+
category = "required"
179198
}
180199

181200
module BannedPackage {

0 commit comments

Comments
 (0)