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 a247a03

Browse filesBrowse files
committed
Add guideline recategorization plan description
1 parent 7099595 commit a247a03
Copy full SHA for a247a03

File tree

Expand file treeCollapse file tree

1 file changed

+57
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+57
-6
lines changed

‎docs/user_manual.md

Copy file name to clipboardExpand all lines: docs/user_manual.md
+57-6Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
| 0.10.0 | 2022-02-28 | Remco Vermeulen | Describe database correctness in the Hazard and Risk Analysis (HARA). |
1919
| 0.11.0 | 2022-02-28 | Remco Vermeulen | Updated version to 1.1.0 |
2020
| 0.12.0 | 2022-11-03 | Remco Vermeulen | Add missing deviation analysis report tables to section 'Producing an analysis report'. |
21+
| 0.13.0 | 2022-11-03 | Remco Vermeulen | Add guideline recategorization plan. |
2122

2223
## Release information
2324

@@ -50,10 +51,10 @@ The _CodeQL Coding Standards_ product is a set of CodeQL queries for identifying
5051
| [CERT-C++](https://resources.sei.cmu.edu/downloads/secure-coding/assets/sei-cert-cpp-coding-standard-2016-v01.pdf) | 2016 | 83 | 83 | Implemented |
5152

5253
Not all rules in these standards are amenable to static analysis by CodeQL - some rules require external or domain specific knowledge to validate, or refer to properties which are not present in the our representation of the codebase under analysis. For each rule we therefore identify whether it is supportable or not. Furthermore, a rule can be supported in two ways:
53-
54+
5455
- **Automated** - the queries for the rule find contraventions directly.
5556
- **Audit only** - the queries for the rule does not find contraventions directly, but instead report a list of _candidates_ that can be used as input into a manual audit. For example, `A10-0-1` (_Public inheritance shall be used to implement 'is-a' relationship_) is not directly amenable to static analysis, but CodeQL can be used to produce a list of all the locations that use public inheritance so they can be manually reviewed.
56-
57+
5758
Each supported rule is implemented as one or more CodeQL queries, with each query covering an aspect of the rule. In many coding standards, the rules cover non-trivial semantic properties of the codebase under analysis.
5859

5960
The datasheet _"CodeQL Coding Standards: supported rules"_, provided with each release, lists which rules are supported for that particular release, and the _scope of analysis_ for that rule.
@@ -93,7 +94,7 @@ In addition, the machine which performs the analysis must be able to complete a
9394
### Analysis report requirements
9495

9596
The Coding Standards ships with scripts to generate reports that summarizes:
96-
97+
9798
- The integrity and validity of the CodeQL database created for the project.
9899
- The findings reported by the default queries for the selected Coding Standards, grouped by categories as specified by MISRA Compliance 2020.
99100
- The CodeQL dependencies used for the analysis, and whether they comply with the stated requirements.
@@ -114,7 +115,7 @@ This section describes how to operate the "CodeQL Coding Standards".
114115
You must download a compatible version of the CodeQL CLI and CodeQL Standard Library for C++.
115116

116117
**Option 1:** Use the CodeQL CLI bundle, which includes both required components:
117-
1. Download the CodeQL CLI bundle from the [`github/codeql-action` releases page](https://github.com/github/codeql-action/releases).
118+
1. Download the CodeQL CLI bundle from the [`github/codeql-action` releases page](https://github.com/github/codeql-action/releases).
118119
2. Expand the compressed archive to a specified location on your machine.
119120
3. [Optional] Add the CodeQL CLI to your user or system path.
120121

@@ -135,7 +136,7 @@ In order to run the Coding Standards queries you must first build a CodeQL datab
135136

136137
The database can be created using the CodeQL CLI like so:
137138

138-
```codeql
139+
```bash
139140
codeql database create --language cpp --command <build_command> <output_database_name>
140141
```
141142

@@ -230,6 +231,7 @@ This will produce a directory (`<output_directory>`) containing the following re
230231
The CodeQL Coding Standards supports the following features from the [MISRA Compliance 2020](https://www.misra.org.uk/app/uploads/2021/06/MISRA-Compliance-2020.pdf) document:
231232
- _Deviation records_ - an entry that states a particular instance, or set of instances, of a rule should be considered permitted.
232233
- _Deviation permit_ - an entry that provides authorization to apply a deviation to a project.
234+
- _Guideline recategorization plan_ - an agreement on how the guidelines are applied. Whether a guideline may be violated, deviated from, or must always be applied.
233235

234236
##### Deviation records
235237

@@ -286,7 +288,7 @@ The activation of the deviation mechanism requires an extra step in the database
286288
This extra step is the invocation of the Python script `path/to/codeql-coding-standards/scripts/configuration/process_coding_standards_config.py` that is part of the coding standards code scanning pack.
287289
The script should be invoked as follows:
288290

289-
```codeql
291+
```bash
290292
codeql database create --language cpp --command 'python3 path/to/codeql-coding-standards/scripts/configuration/process_coding_standards_config.py' --command <build_command> <output_database_name>
291293
```
292294

@@ -354,6 +356,55 @@ Unlike _deviation records_ their location in the source directory does not impac
354356

355357
This means that _deviation permits_ can be made available at build time by any means available.
356358
An example of importing _deviation permits_ is through a [Git Submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) that contains a repository of allowed _deviation permits_.
359+
360+
##### Guideline recategorization plan
361+
362+
The current implementation supports a _guideline recategorization plan_ as described in the [MISRA Compliance:2020](https://www.misra.org.uk/app/uploads/2021/06/MISRA-Compliance-2020.pdf) section *5 The guideline re-categorization plan*.
363+
364+
A recategorization plan provides a mechanism to adjust the policy associated with a guideline that determines whether it may be violated or not and if it may be violated whether a deviation is required.
365+
Each guideline recategorization **must** be specified in the `guideline-recategorizations` section of a `coding-standards.yml` file that **must** be anywhere in the source repository.
366+
367+
A guideline recategorization specification **must** specify a `rule-id`, an identifier for the coding standards rule the recategorization applies to, and a `category`, a category that can be any of `disapplied`, `advisory`, `required`, or `mandatory`.
368+
369+
An example guideline recategorization section is:
370+
371+
```yaml
372+
guideline-recategorizations:
373+
- rule-id: "A0-1-1"
374+
category: "mandatory"
375+
- rule-id: "A0-1-6"
376+
category: "disapplied"
377+
- rule-id: "A11-0-1"
378+
category: "mandatory"
379+
```
380+
381+
Application of the guideline recategorization plan to the analysis results requires an additional post-processing step.
382+
The post-processing step is implemented by the Python script `path/to/codeql-coding-standards/scripts/guideline_recategorization/recategorize.py`.
383+
The script will update the `external/<standard>/obligation/<category>` tag for each query implementing a recategorized guideline such that `<category>` is equal to the new category and
384+
add the tag `external/<standard>/original-obligation/<category` to each query implementing a recategorized guideline such that `<category>` reflects the orignal category.
385+
386+
The script should be invoked as follows:
387+
388+
```bash
389+
python3 path/to/codeql-coding-standards/scripts/guideline_recategorization/recategorize.py coding_standards_config_file <sarif_in> <sarif_out>
390+
```
391+
392+
The `recategorize.py` scripts has a dependencies on the following Python packages that can be installed with the command `pip install -r path/to/codeql-coding-standards/scripts/guideline_recategorization/requirements.txt`:
393+
394+
- Jsonpath-ng==1.5.3
395+
- Jsonschema
396+
- Jsonpatch
397+
- Jsonpointer
398+
- PyYAML
399+
- Pytest
400+
401+
and the schema files:
402+
403+
- `path/to/codeql-coding-standards/schemas/coding-standards-schema-1.0.0.json`
404+
- `path/to/codeql-coding-standards/schemas/sarif-schema-2.1.0.json`
405+
406+
The schema files **must** be available in the same directory as the `recategorize.py` file or in any ancestor directory.
407+
357408
### GitHub Advanced Security and LGTM
358409

359410
The only use cases that will be certified under ISO 26262 are those listed above. CodeQL Coding Standards is also compatible with, but not certified for, the following use cases:

0 commit comments

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