facebook / facebook/infer

Is there anyway to print CWE ID (Common Weakness Enumeration) in Infer?

Open
#1,140 0 comments 4 reactions 0 assignees View on GitHub
question
Dominant language
OCaml
Stars
15.7k
Forks
2.1k
Avg merge
19h 36m
Merged PRs (30d)
13

Description

- [ ] I am using `infer --0.17.0`.
- [ ] My OS is Ubuntu 18.04
- [ ] My command was `infer run -- g++ test.cpp`
My `test.cpp` file looks like this -
```c++
#include
using namespace std ;

int main()
{
int i ;
int j ;
i = 5;
j = 6;
j = i ;
int a[4];
a[6] = 0;
}

```
- [ ] The output looks like this -
```json
[{
"bug_type": "DEAD_STORE",
"qualifier": "The value written to &j (type int) is never used.",
"severity": "ERROR",
"line": 9,
"column": 5,
"procedure": "main",
"procedure_start_line": 4,
"file": "a.cpp",
"bug_trace": [{
"level": 0,
"filename": "a.cpp",
"line_number": 9,
"column_number": 5,
"description": "Write of unused value"
}],
"key": "a.cpp|main|DEAD_STORE",
"hash": "2450f50b11f2b0e0cc6d3bd7d1d6ef77",
"bug_type_hum": "Dead Store"
}, {
"bug_type": "DEAD_STORE",
"qualifier": "The value written to &j (type int) is never used.",
"severity": "ERROR",
"line": 10,
"column": 5,
"procedure": "main",
"procedure_start_line": 4,
"file": "a.cpp",
"bug_trace": [{
"level": 0,
"filename": "a.cpp",
"line_number": 10,
"column_number": 5,
"description": "Write of unused value"
}],
"key": "a.cpp|main|DEAD_STORE",
"hash": "2450f50b11f2b0e0cc6d3bd7d1d6ef77",
"bug_type_hum": "Dead Store"
}]
```
# My questions are -
### As you can see here is no CWE IDs related to the errors. They have name but no CWE ID. Is there anyway to print or get CWE ID using Infer?
### Another question is, In this code, `a[6] = 0` line should give `Array Index Out Of Bound` error or at least warning. Why isn't it giving it? Am I missing something?

# Any help would be appreciated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.