Skip to content

Commit be42568

Browse files
committed
parser-cov: accept the [important] flag in checker line
... in case someone pastes the text directly from a web browser. For now the parser discards the information about presence of the flag rather than propagating it. This is justified by the fact that the parser should be fed by the data produced by `writer-cov`, which does not produce such a flag. Resolves: https://issues.redhat.com/browse/OSH-682 Closes: #186
1 parent 4c3e321 commit be42568

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

src/lib/parser-cov.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <boost/algorithm/string.hpp>
3333

3434
#define RE_CHECKER_LINE_ANNOT " *\\([^)]+\\)"
35-
#define RE_CHECKER_LINE_SUFFIX "(?: \\[#def[0-9]+\\])?"
35+
#define RE_CHECKER_LINE_SUFFIX "(?: \\[#def[0-9]+\\])?(?: \\[important\\])?"
3636

3737
namespace CovParserImpl {
3838

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--mode=json
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Error: SIGMA.container_requesting_net_raw (CWE-269): [#def1] [important]
2+
unpacked_remote_sources/cachito-gomod-with-deps/app/vertical-pod-autoscaler/hack/e2e/k8s-metrics-server.yaml:184: Sigma main event: The Kubernetes container requests the `NET_RAW` capability, either explicitly or by default, granting access to the host's network interfaces.
3+
unpacked_remote_sources/cachito-gomod-with-deps/app/vertical-pod-autoscaler/hack/e2e/k8s-metrics-server.yaml:184: remediation: Explicitly remove the `NET_RAW` capability for a container by adding either `NET_RAW` or `ALL` to the `securityContext.capabilities.drop` list, avoid adding the `NET_RAW` capability to the `securityContext.capabilities.add` list.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"defects": [
3+
{
4+
"checker": "SIGMA.container_requesting_net_raw",
5+
"cwe": 269,
6+
"tool": "coverity",
7+
"key_event_idx": 0,
8+
"events": [
9+
{
10+
"file_name": "unpacked_remote_sources/cachito-gomod-with-deps/app/vertical-pod-autoscaler/hack/e2e/k8s-metrics-server.yaml",
11+
"line": 184,
12+
"event": "Sigma main event",
13+
"message": "The Kubernetes container requests the `NET_RAW` capability, either explicitly or by default, granting access to the host's network interfaces.",
14+
"verbosity_level": 0
15+
},
16+
{
17+
"file_name": "unpacked_remote_sources/cachito-gomod-with-deps/app/vertical-pod-autoscaler/hack/e2e/k8s-metrics-server.yaml",
18+
"line": 184,
19+
"event": "remediation",
20+
"message": "Explicitly remove the `NET_RAW` capability for a container by adding either `NET_RAW` or `ALL` to the `securityContext.capabilities.drop` list, avoid adding the `NET_RAW` capability to the `securityContext.capabilities.add` list.",
21+
"verbosity_level": 1
22+
}
23+
]
24+
}
25+
]
26+
}

tests/csgrep/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,4 @@ test_csgrep("0122-json-parser-cov-v10-column" )
169169
test_csgrep("0123-csgrep-hash-v1" )
170170
test_csgrep("0124-sarif-writer-imp" )
171171
test_csgrep("0125-sarif-parser-bom" )
172+
test_csgrep("0126-cov-parser-imp-flag" )

0 commit comments

Comments
 (0)