Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 68ad087

Browse filesBrowse files
authored
Merge pull request #53 from rvermeulen/update-rule-package-schema
Update rule package schema to include the standards CERT-C and MISRA C 2012. In addition, we resolve any violations in our rule package descriptions.
2 parents 39f1fa6 + 4f1e46c commit 68ad087
Copy full SHA for 68ad087

21 files changed

+126
-31
lines changed

‎c/cert/src/rules/ENV33-C/DoNotCallSystem.ql

Copy file name to clipboardExpand all lines: c/cert/src/rules/ENV33-C/DoNotCallSystem.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @problem.severity error
88
* @tags external/cert/id/env33-c
99
* security
10-
* external/cert/obligtion/rule
10+
* external/cert/obligation/rule
1111
*/
1212

1313
import cpp

‎c/cert/src/rules/EXP37-C/CallPOSIXOpenWithCorrectArgumentCount.md

Copy file name to clipboardExpand all lines: c/cert/src/rules/EXP37-C/CallPOSIXOpenWithCorrectArgumentCount.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# EXP37-C: Pass the correct number of arguments to the POSIX open function.
1+
# EXP37-C: Pass the correct number of arguments to the POSIX open function
22

33
This query implements the CERT-C rule EXP37-C:
44

‎c/cert/src/rules/EXP37-C/CallPOSIXOpenWithCorrectArgumentCount.ql

Copy file name to clipboardExpand all lines: c/cert/src/rules/EXP37-C/CallPOSIXOpenWithCorrectArgumentCount.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @id c/cert/call-posix-open-with-correct-argument-count
3-
* @name EXP37-C: Pass the correct number of arguments to the POSIX open function.
3+
* @name EXP37-C: Pass the correct number of arguments to the POSIX open function
44
* @description A third argument should be passed to the POSIX function open() when and only when
55
* creating a new file.
66
* @kind problem

‎c/cert/src/rules/EXP37-C/DoNotCallFunctionsWithIncompatibleArguments.md

Copy file name to clipboardExpand all lines: c/cert/src/rules/EXP37-C/DoNotCallFunctionsWithIncompatibleArguments.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# EXP37-C: Do not pass arguments with an incompatible count or type to a function.
1+
# EXP37-C: Do not pass arguments with an incompatible count or type to a function
22

33
This query implements the CERT-C rule EXP37-C:
44

‎c/cert/src/rules/EXP37-C/DoNotCallFunctionsWithIncompatibleArguments.ql

Copy file name to clipboardExpand all lines: c/cert/src/rules/EXP37-C/DoNotCallFunctionsWithIncompatibleArguments.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @id c/cert/do-not-call-functions-with-incompatible-arguments
3-
* @name EXP37-C: Do not pass arguments with an incompatible count or type to a function.
3+
* @name EXP37-C: Do not pass arguments with an incompatible count or type to a function
44
* @description The arguments passed to a function must be compatible with the function's
55
* parameters.
66
* @kind problem

‎c/cert/src/rules/FIO39-C/DoNotAlternatelyIOFromAStreamWithoutPositioning.ql

Copy file name to clipboardExpand all lines: c/cert/src/rules/FIO39-C/DoNotAlternatelyIOFromAStreamWithoutPositioning.ql
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* @id c/cert/do-not-alternately-io-from-a-stream-without-positioning
33
* @name FIO39-C: Do not alternately input and output from a stream without an intervening flush or positioning call
4-
* @description
4+
* @description Do not alternately input and output from a stream without an intervening flush or
5+
* positioning call. This may result in undefined behavior.
56
* @kind problem
67
* @precision very-high
78
* @problem.severity error

‎c/cert/src/rules/FIO42-C/CloseFilesWhenTheyAreNoLongerNeeded.ql

Copy file name to clipboardExpand all lines: c/cert/src/rules/FIO42-C/CloseFilesWhenTheyAreNoLongerNeeded.ql
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* @id c/cert/close-files-when-they-are-no-longer-needed
33
* @name FIO42-C: Close files when they are no longer needed
4-
* @description
4+
* @description Open files must be closed before the lifetime of the last pointer to the file-object
5+
* has ended to prevent resource exhaustion and data loss issues.
56
* @kind problem
67
* @precision very-high
78
* @problem.severity error

‎c/cert/src/rules/FIO46-C/UndefinedBehaviorAccessingAClosedFile.ql

Copy file name to clipboardExpand all lines: c/cert/src/rules/FIO46-C/UndefinedBehaviorAccessingAClosedFile.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @id c/cert/undefined-behavior-accessing-a-closed-file
33
* @name FIO46-C: Do not access a closed file
4-
* @description Do not access a closed file
4+
* @description Do not access a closed file.
55
* @kind problem
66
* @precision high
77
* @problem.severity error

‎c/misra/src/rules/RULE-13-3/SideEffectAndCrementInFullExpression.ql

Copy file name to clipboardExpand all lines: c/misra/src/rules/RULE-13-3/SideEffectAndCrementInFullExpression.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @name RULE-13-3: A full expression containing an increment (++) or decrement (--) operator should have no other
44
* @description A full expression containing an increment (++) or decrement (--) operator should
55
* have no other potential side effects other than that caused by the increment or
6-
* decrement operator
6+
* decrement operator.
77
* @kind problem
88
* @precision very-high
99
* @problem.severity warning

‎c/misra/src/rules/RULE-22-6/FileUsedAfterClosed.ql

Copy file name to clipboardExpand all lines: c/misra/src/rules/RULE-22-6/FileUsedAfterClosed.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @id c/misra/file-used-after-closed
33
* @name RULE-22-6: The value of a pointer to a FILE shall not be used after the associated stream has been closed
4-
* @description A closed FILE is accessed
4+
* @description A closed FILE is accessed.
55
* @kind problem
66
* @precision very-high
77
* @problem.severity error

‎c/misra/src/rules/RULE-22-7/EofShallBeComparedWithUnmodifiedReturnValues.ql

Copy file name to clipboardExpand all lines: c/misra/src/rules/RULE-22-7/EofShallBeComparedWithUnmodifiedReturnValues.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @id c/misra/eof-shall-be-compared-with-unmodified-return-values
33
* @name RULE-22-7: The macro EOF shall only be compared with the unmodified return value from any Standard Library
44
* @description The macro EOF shall only be compared with the unmodified return value from any
5-
* Standard Library function capable of returning EOF
5+
* Standard Library function capable of returning EOF.
66
* @kind problem
77
* @precision high
88
* @problem.severity error

‎c/misra/src/rules/RULE-4-12/StdLibDynamicMemoryAllocationUsed.ql

Copy file name to clipboardExpand all lines: c/misra/src/rules/RULE-4-12/StdLibDynamicMemoryAllocationUsed.ql
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @name RULE-4-12: Dynamic memory allocation shall not be used
44
* @description Using dynamic memory allocation and deallocation can result to undefined behavior.
55
* This query is for the Standard Library Implementation. Any implementation outside it
6-
* will require a separate query under the same directive
6+
* will require a separate query under the same directive.
77
* @kind problem
88
* @precision very-high
99
* @problem.severity error

‎c/misra/src/rules/RULE-4-8/ObjectWithNoPointerDereferenceShouldBeOpaque.ql

Copy file name to clipboardExpand all lines: c/misra/src/rules/RULE-4-8/ObjectWithNoPointerDereferenceShouldBeOpaque.ql
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
* @tags external/misra/id/rule-4-8
1111
* readability
1212
* maintainability
13-
* readability
1413
* external/misra/obligation/advisory
1514
*/
1615

‎rule_packages/c/Banned.json

Copy file name to clipboardExpand all lines: rule_packages/c/Banned.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"CERT-C": {
33
"ENV33-C": {
44
"properties": {
5-
"obligtion": "rule"
5+
"obligation": "rule"
66
},
77
"queries": [
88
{
@@ -310,7 +310,7 @@
310310
},
311311
"queries": [
312312
{
313-
"description": "Using dynamic memory allocation and deallocation can result to undefined behavior. This query is for the Standard Library Implementation. Any implementation outside it will require a separate query under the same directive",
313+
"description": "Using dynamic memory allocation and deallocation can result to undefined behavior. This query is for the Standard Library Implementation. Any implementation outside it will require a separate query under the same directive.",
314314
"kind": "problem",
315315
"name": "Dynamic memory allocation shall not be used",
316316
"precision": "very-high",

‎rule_packages/c/Expressions.json

Copy file name to clipboardExpand all lines: rule_packages/c/Expressions.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{
2323
"description": "The arguments passed to a function must be compatible with the function's parameters.",
2424
"kind": "problem",
25-
"name": "Do not pass arguments with an incompatible count or type to a function.",
25+
"name": "Do not pass arguments with an incompatible count or type to a function",
2626
"precision": "high",
2727
"severity": "error",
2828
"short_name": "DoNotCallFunctionsWithIncompatibleArguments",
@@ -33,7 +33,7 @@
3333
{
3434
"description": "A third argument should be passed to the POSIX function open() when and only when creating a new file.",
3535
"kind": "problem",
36-
"name": "Pass the correct number of arguments to the POSIX open function.",
36+
"name": "Pass the correct number of arguments to the POSIX open function",
3737
"precision": "high",
3838
"severity": "error",
3939
"short_name": "CallPOSIXOpenWithCorrectArgumentCount",

‎rule_packages/c/IO1.json

Copy file name to clipboardExpand all lines: rule_packages/c/IO1.json
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
},
6666
"queries": [
6767
{
68-
"description": "",
68+
"description": "Do not alternately input and output from a stream without an intervening flush or positioning call. This may result in undefined behavior.",
6969
"kind": "problem",
7070
"name": "Do not alternately input and output from a stream without an intervening flush or positioning call",
7171
"precision": "very-high",
@@ -88,7 +88,7 @@
8888
},
8989
"queries": [
9090
{
91-
"description": "",
91+
"description": "Open files must be closed before the lifetime of the last pointer to the file-object has ended to prevent resource exhaustion and data loss issues.",
9292
"kind": "problem",
9393
"name": "Close files when they are no longer needed",
9494
"precision": "very-high",
@@ -111,7 +111,7 @@
111111
},
112112
"queries": [
113113
{
114-
"description": "Do not access a closed file",
114+
"description": "Do not access a closed file.",
115115
"kind": "problem",
116116
"name": "Do not access a closed file",
117117
"precision": "high",
@@ -136,7 +136,7 @@
136136
},
137137
"queries": [
138138
{
139-
"description": "A closed FILE is accessed",
139+
"description": "A closed FILE is accessed.",
140140
"kind": "problem",
141141
"name": "The value of a pointer to a FILE shall not be used after the associated stream has been closed",
142142
"precision": "very-high",

‎rule_packages/c/IO3.json

Copy file name to clipboardExpand all lines: rule_packages/c/IO3.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
},
114114
"queries": [
115115
{
116-
"description": "The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF",
116+
"description": "The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF.",
117117
"kind": "problem",
118118
"name": "The macro EOF shall only be compared with the unmodified return value from any Standard Library",
119119
"precision": "high",

‎rule_packages/c/Pointers1.json

Copy file name to clipboardExpand all lines: rule_packages/c/Pointers1.json
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@
308308
"short_name": "ObjectWithNoPointerDereferenceShouldBeOpaque",
309309
"tags": [
310310
"readability",
311-
"maintainability",
312-
"readability"
311+
"maintainability"
313312
],
314313
"implementation_scope": {
315314
"description": "This rule considers all cases where a structure or union is referenced as a pointer but has no FieldAccess within a translation unit. Further excluded from this rule are translation units in which the structure or union is declared as a non-pointer variable."

‎rule_packages/c/SideEffects2.json

Copy file name to clipboardExpand all lines: rule_packages/c/SideEffects2.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"queries": [
88
{
9-
"description": "A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator",
9+
"description": "A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator.",
1010
"kind": "problem",
1111
"name": "A full expression containing an increment (++) or decrement (--) operator should have no other",
1212
"precision": "very-high",

‎schemas/rule-package.schema.json

Copy file name to clipboardExpand all lines: schemas/rule-package.schema.json
+100-5Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"type": "string",
4646
"enum": [
4747
"required",
48-
"rule",
4948
"advisory"
5049
]
5150
}
@@ -67,6 +66,7 @@
6766
"type": "string"
6867
}
6968
},
69+
"additionalProperties": false,
7070
"required": [
7171
"properties",
7272
"queries",
@@ -85,6 +85,100 @@
8585
"type": "object",
8686
"patternProperties": {
8787
"^\\w+\\d+-CPP": {
88+
"description": "A coding standard rule",
89+
"type": "object",
90+
"properties": {
91+
"properties": {
92+
"type": "object",
93+
"properties": {
94+
"obligation": {
95+
"type": "string",
96+
"enum": [
97+
"rule"
98+
]
99+
}
100+
},
101+
"required": [
102+
"obligation"
103+
]
104+
},
105+
"queries": {
106+
"type": "array",
107+
"uniqueItems": true,
108+
"items": {
109+
"$ref": "#/$defs/query"
110+
}
111+
},
112+
"title": {
113+
"type": "string"
114+
}
115+
},
116+
"required": [
117+
"properties",
118+
"queries",
119+
"title"
120+
],
121+
"additionalProperties": false
122+
}
123+
},
124+
"minProperties": 1
125+
}
126+
}
127+
},
128+
{
129+
"properties": {
130+
"CERT-C": {
131+
"description": "Rules part of the CERT-C standard",
132+
"type": "object",
133+
"patternProperties": {
134+
"^\\w+\\d+-C": {
135+
"description": "A coding standard rule",
136+
"type": "object",
137+
"properties": {
138+
"properties": {
139+
"type": "object",
140+
"properties": {
141+
"obligation": {
142+
"type": "string",
143+
"enum": [
144+
"rule"
145+
]
146+
}
147+
},
148+
"required": [
149+
"obligation"
150+
]
151+
},
152+
"queries": {
153+
"type": "array",
154+
"uniqueItems": true,
155+
"items": {
156+
"$ref": "#/$defs/query"
157+
}
158+
},
159+
"title": {
160+
"type": "string"
161+
}
162+
},
163+
"required": [
164+
"properties",
165+
"queries",
166+
"title"
167+
],
168+
"additionalProperties": false
169+
}
170+
},
171+
"minProperties": 1
172+
}
173+
}
174+
},
175+
{
176+
"properties": {
177+
"MISRA-C-2012": {
178+
"description": "Rules part of the MISRA C 2012 standard",
179+
"type": "object",
180+
"patternProperties": {
181+
"^RULE-\\d+-\\d+": {
88182
"description": "A coding standard rule",
89183
"type": "object",
90184
"properties": {
@@ -95,8 +189,8 @@
95189
"type": "string",
96190
"enum": [
97191
"required",
98-
"rule",
99-
"advisory"
192+
"advisory",
193+
"mandatory"
100194
]
101195
}
102196
},
@@ -119,7 +213,8 @@
119213
"properties",
120214
"queries",
121215
"title"
122-
]
216+
],
217+
"additionalProperties": false
123218
}
124219
},
125220
"minProperties": 1
@@ -128,7 +223,7 @@
128223
}
129224
],
130225
"minProperties": 1,
131-
"maxProperties": 2,
226+
"maxProperties": 4,
132227
"$defs": {
133228
"query": {
134229
"$id": "/schemas/query",

‎scripts/requirements.txt

Copy file name to clipboardExpand all lines: scripts/requirements.txt
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ soupsieve==2.0.1
1212
urllib3==1.26.5
1313
pyyaml==5.4
1414
wheel==0.37.0
15-
jsonschema==3.2.0
15+
jsonschema==4.9.1
1616
marko==1.2.1

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.