You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/design/guideline_recategorization.md
+15-15
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ The document [MISRA Compliance:2020](https://www.misra.org.uk/app/uploads/2021/0
30
30
- Required guidelines - guidelines which can only be violated when supported by a deviation.
31
31
- Advisory guidelines - recommendations for which violations are identified but are not required to be supported by a deviation.
32
32
33
-
Guideline recategorization is possible by means of a Guideline Recategorization Plan (GRP). A GRP is a contract between the acquirer and supplier to determine how guidelines are applied.
33
+
Guideline recategorization is possible by means of a guideline recategorization plan (GRP). A GRP is a contract between the acquirer and supplier to determine how guidelines are applied.
34
34
The GRP defines the additional category Disapplied to be used for Advisory guidelines which are to be ignored. Any other category can be recategorized into stricter categories to ensure that a guideline adheres to the associated policy.
35
35
The following table summarizes the possible recategorizations.
36
36
@@ -40,11 +40,11 @@ The following table summarizes the possible recategorizations.
40
40
| Required | Mandatory |
41
41
| Advisory | Disapplied, Required, Mandatory |
42
42
43
-
Other recategorizations, from here on denoted as invalid recategorizations, are not applied and are to be reported to the user.
43
+
Other recategorizations are invalid, not applied, and reported to the user.
44
44
45
45
## Design
46
46
47
-
Our design includes a Guideline Recategorization Plan specification, logic to apply the category policy to associated guidelines, and a SARIF result rewriter to reflect the new category in the results.
47
+
CodeQL Coding Standards includes a GRP, logic to apply the category policy to associated guidelines, and a SARIF result rewriter to reflect the new category in the results.
48
48
The application of a policy will modify the behavior of a CodeQL queries implementing guidelines as follows:
49
49
50
50
| Category | Effect |
@@ -54,14 +54,14 @@ The application of a policy will modify the behavior of a CodeQL queries impleme
54
54
| Advisory | Violations are reported unless there exists an applicable deviation. |
55
55
| Disapplied | Violations are not reported. |
56
56
57
-
The SARIF rewriting will update the category of a guideline in a SARIF result file by updating the necessary tag information of a query.
57
+
The SARIF rewrite updates the guideline category in a SARIF result file by updating the query's tag information.
58
58
59
-
### Guideline Recategorization Plan specification
59
+
### Guideline Recategorization Plan
60
60
61
-
The Guideline Recategorization Plan specification will build upon the configuration specification introduced for deviations by adding the additional primary section `guideline-recategorizations` to the `codeql-standards.yml` configuration file.
61
+
The GRE builds upon the configuration specification introduced for deviations by adding the additional primary section `guideline-recategorizations` to the `codeql-standards.yml` configuration file.
62
62
The `guideline-recategorizations` section will be a series of compact mappings in YAML with the keys:
63
63
64
-
-`rule-id` - the rule identifier that is recategorized.
64
+
-`rule-id` - the recategorized rule identifier.
65
65
-`category` - the category assigned to the rule identified by rule-id
66
66
67
67
Note: We specify the recategorization based on the rule-id instead of the query-id. This can be revised if feedback requires more fine-grained recategorization.
@@ -80,9 +80,9 @@ This section discusses the implementation of the [design](#design).
80
80
81
81
### Specification and deviation
82
82
83
-
The implementation will rely on the existing rule meta-data and query exclusion mechanisms to apply policies associated with a rule’s category.
83
+
The implementation relies on the existing rule meta-data and query exclusion mechanisms to apply policies associated with a rule’s category.
84
84
The rule meta-data already includes both the `query-id` and `rule-id` associated with a query and is available during query evaluation.
85
-
The rule meta-data needs to be extended with a category that contains the guideline’s category.
85
+
The rule meta-data must be extended with a category that contains the guideline’s category.
86
86
87
87
For example:
88
88
@@ -97,17 +97,17 @@ For example:
97
97
category = “required”
98
98
```
99
99
100
-
The category defined by the rule meta-data and the category defined in the `guideline-recategorizations` of the applicable `codeql-standards.yml` configuration file is used to determine the *effective category* of a query.
100
+
The category defined by the rule meta-data and the category defined in the `guideline-recategorizations` of the applicable `codeql-standards.yml` configuration file specifies the *effective category* of a query.
101
101
The *effective category* is the category whose policy is applied during the evaluation of a query.
102
102
The policy of a category dictates if a result can be deviated from and implements the effect described in the design section.
103
103
The existing exclusion mechanism implemented in the predicate `isExcluded` defined in the `Exclusions.qll` library will be updated to consider the applicable policy of a guideline.
104
104
105
-
Note: This will change the behavior of deviations which will no longer have an impact on Mandatory guidelines! This, however, will only impact MISRA C rules because there are no MISRA C++ Guidelines with a Mandatory category.
105
+
Note: This changes the behavior of deviations which will no longer have an impact on Mandatory guidelines! However, this will only affect MISRA C rules because there are no MISRA C++ Guidelines with a Mandatory category.
106
106
107
107
### Specification validation
108
108
109
-
To assist users with correctly specifying a Guideline Recategorization Plan (GRP) specification we can implement two validations mechanisms that validate the specification at two different points in a GRP life cycle.
110
-
The first validation mechanism will perform syntax validation of the specification provided in the guideline-recategorizations section of a `codeql-standards.yml` configuration file and can provide feedback in any editor that supports JSON schemas published at the [JSON schema store](https://www.schemastore.org/json/).
109
+
To assist users with correctly specifying a GRP specification we can implement two validations mechanisms that validate the specification at two different points in a GRP life cycle.
110
+
The first validation mechanism performs syntax validation of the specification provided in the guideline-recategorizations section of a `codeql-standards.yml` configuration file and can provide feedback in any editor that supports JSON schemas published at the [JSON schema store](https://www.schemastore.org/json/).
111
111
A schema for `codeql-standards.yml` can be extended with the definition of `guideline-category` and the property `guideline-recategorizations`:
112
112
113
113
```json
@@ -151,9 +151,9 @@ A schema for `codeql-standards.yml` can be extended with the definition of `guid
151
151
152
152
The second validation mechanism is the generation of a `guideline-recategorization-plan-report.md` containing alerts on semantically incorrect recategorizations.
153
153
That is, possible recategorizations that are not described as valid in the introduction.
154
-
Semantically invalid recategorizations will be detected by looking at a query’s categorization and its effective categorization (i.e., its applied recategorization).
154
+
Semantically invalid recategorizations are detected by examining a query’s categorization and its effective categorization (i.e., its applied recategorization).
155
155
156
-
In addition, an update to the `deviations_report.md` report’s invalidate deviations table will provide feedback to users that apply deviations to guidelines with an effective category equal to `mandatory` which cannot be deviated from.
156
+
In addition, an update to the `deviations_report.md` report’s invalidate deviations table provides feedback to users that apply deviations to guidelines with an effective category equal to `mandatory` which cannot be deviated from.
157
157
The changes to generate the new report and update the existing report will be made in the report generation script `scripts/reports/analysis_report.py`.
0 commit comments