Skip to content

Commit 771a05e

Browse files
firewavedanmar
andcommitted
fixed #12517 - added initial safety guide [skip ci]
Co-authored-by: Daniel Marjamäki <daniel.marjamaki@gmail.com>
1 parent 61a4ae9 commit 771a05e

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

SAFETY.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Cppcheck Safety Notes
2+
3+
## Process Stability
4+
5+
### Note On Code Handling
6+
7+
The internal parsing of Cppcheck is very lenient and is able to handle code which will not be compilable. This is done so you can analyze code without providing all dependencies and code which is written for specific compilers.
8+
9+
### Providing Process Stability
10+
11+
The leniency means that code which is invalid will not be rejected outright. So it is possible to trigger an assertion or crash within Cppcheck causing the process to exit prematurely.
12+
13+
Since the analysis is by default performed in the main process such a failure will cause the analysis to abort without providing a result.
14+
15+
If you use `-j<n>` multiple jobs (up to the total amount of `n`) will be used to perform the analysis. On supported platforms a new process will be spawned for each file which is analyzed (this is currently only implemented on non-Windows platforms - see https://trac.cppcheck.net/ticket/12464). This will make sure the analysis will always finish and provide a result. Premature termination failures will be provided as `cppcheckError` findings.
16+
17+
If you encountered any such bugs please report them at https://trac.cppcheck.net/.
18+
19+
### Note On Handling Unknown/Untrusted Code
20+
21+
Triggering an abnormal process terminations is most likely caused by unknown/untrusted code (provided by e.g. a pull request). To reduce the chance of this happening you should invoke the analysis *after* that code has been successfully compiled. This might also limit the possibility of someone leveraging a known cause for a abnormal process termination for malicious purposes.
22+
23+
### Fuzzing
24+
25+
We are utilizing fuzzing based on libFuzzer and OSS-Fuzz to catch such issues. Currently this is mainly done off-tree and manually - see https://trac.cppcheck.net/ticket/12442 and https://github.com/danmar/simplecpp/issues/341 for details.
26+
27+
As those methods mostly result in non-sensical and invalid code there is also a plan to use a targeted approach which would be closer to examples of real-life invalid/incomplete code (like when used via an IDE integration). See https://trac.cppcheck.net/ticket/12357 for details.
28+
29+
## Code Execution
30+
31+
The analyzed code will only be parsed and/or compiled but no executable code is being generated. So there is no risk in analyzing code containing known exploits as it will never be executed.
32+
33+
## Required Permissions
34+
35+
By default you only need the permissions to read the files specified for analysis and the specified include paths. No administrator permissions should be necessary to perform the analysis.
36+
37+
Additional permissions might be necessary for specific options being provided. Those are lined out below.
38+
39+
## Process Elevation
40+
41+
No process elevation is being performed for any of the spawned processes. They currently use the same permissions as the main process.
42+
43+
See https://trac.cppcheck.net/ticket/14237 about a potential future improvement by reducing the permissions of spawned processes.
44+
45+
## Invoked executables
46+
47+
By default no additional external executables will be invoked by the analysis.
48+
49+
But there are some options which will utilize additional executables.
50+
51+
- `python`/`python3`<br/>
52+
Used for the execution of addons. Triggered by using the `--addon=<addon>` option or specifying addons in `cppcheck.cfg`.<br/>
53+
The executable will be looked for in `PATH` by default and can be configured by `--addon-python=<exe>` or the `python` field when passing a JSON to `--addon`.
54+
55+
- `clang-tidy`<br/>
56+
Used for invoking an additional analysis via Clang-Tidy. Triggered by the `--clang-tidy` option.<br/>
57+
The executable will be looked for in `PATH` by default. A versioned executable or absolute path can be specified by using `--clang-tidy=<exe>`.
58+
59+
- `clang`<br/>
60+
Used to generate a CLang AST instead of an internal one. Triggered by the `--clang` option.<br/>
61+
The executable will be looked for in `PATH` by default. A versioned executable or absolute path can be specified by using `--clang=<exe>`.
62+
63+
## Output Files
64+
65+
By default no files will be written.
66+
67+
But there are some options which will cause files to be written.
68+
69+
- `--cppcheck-build-dir=<dir>`<br/>
70+
Will create files inside the specified directory only - the specified directory needs to be created by the user before running the analysis
71+
72+
- `--dump`<br/>
73+
When `--cppcheck-build-dir` is *not* specified `<file>.dump` files will be created next to the files which are being analyzed
74+
75+
- `--plist-output=<dir>`<br/>
76+
Will create files inside the specified directory only - the specified directory needs to be created by the user before running the analysis
77+
78+
- `--addon=<addon>`<br/>
79+
When `--cppcheck-build-dir` is *not* specified a `<pid>.ctu-info` will be generated in the CWD and `<file>.<pid>.dump` files will be created next to the files which are being analyzed. All files will be deleted if the analysis is complete

0 commit comments

Comments
 (0)