Skip to content

Commit 85ae3f4

Browse files
Re-add dropped query in json
1 parent 410895c commit 85ae3f4

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

cpp/common/src/codingstandards/cpp/exclusions/cpp/Undefined.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ newtype UndefinedQuery =
1111
TPossibleDataRaceBetweenThreadsQuery() or
1212
TDivisionByZeroUndefinedBehaviorQuery() or
1313
TDeallocationTypeMismatchQuery() or
14-
TStringLiteralPossiblyModifiedAuditQuery()
14+
TStringLiteralPossiblyModifiedAuditQuery() or
15+
TOutOfRangeEnumCastCriticalUnspecifiedBehaviorQuery()
1516

1617
predicate isUndefinedQueryMetadata(Query query, string queryId, string ruleId, string category) {
1718
query =
@@ -85,6 +86,15 @@ predicate isUndefinedQueryMetadata(Query query, string queryId, string ruleId, s
8586
"cpp/misra/string-literal-possibly-modified-audit" and
8687
ruleId = "RULE-4-1-3" and
8788
category = "required"
89+
or
90+
query =
91+
// `Query` instance for the `outOfRangeEnumCastCriticalUnspecifiedBehavior` query
92+
UndefinedPackage::outOfRangeEnumCastCriticalUnspecifiedBehaviorQuery() and
93+
queryId =
94+
// `@id` for the `outOfRangeEnumCastCriticalUnspecifiedBehavior` query
95+
"cpp/misra/out-of-range-enum-cast-critical-unspecified-behavior" and
96+
ruleId = "RULE-4-1-3" and
97+
category = "required"
8898
}
8999

90100
module UndefinedPackage {
@@ -143,4 +153,11 @@ module UndefinedPackage {
143153
// `Query` type for `stringLiteralPossiblyModifiedAudit` query
144154
TQueryCPP(TUndefinedPackageQuery(TStringLiteralPossiblyModifiedAuditQuery()))
145155
}
156+
157+
Query outOfRangeEnumCastCriticalUnspecifiedBehaviorQuery() {
158+
//autogenerate `Query` type
159+
result =
160+
// `Query` type for `outOfRangeEnumCastCriticalUnspecifiedBehavior` query
161+
TQueryCPP(TUndefinedPackageQuery(TOutOfRangeEnumCastCriticalUnspecifiedBehaviorQuery()))
162+
}
146163
}

rule_packages/cpp/Undefined.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@
109109
"scope/system",
110110
"external/misra/audit"
111111
]
112+
},
113+
{
114+
"description": "Casting to an enumeration value outside the range of the enumeration's values results in critical unspecified behavior.",
115+
"kind": "problem",
116+
"name": "Out-of-range enumeration cast leads to critical unspecified behavior",
117+
"precision": "high",
118+
"severity": "error",
119+
"shared_implementation_short_name": "DoNotCastToAnOutOfRangeEnumerationValueShared",
120+
"short_name": "OutOfRangeEnumCastCriticalUnspecifiedBehavior",
121+
"tags": [
122+
"correctness",
123+
"scope/system"
124+
]
112125
}
113126
],
114127
"title": "There shall be no occurrence of undefined or critical unspecified behaviour"

0 commit comments

Comments
 (0)