forked from reviewdog/action-trivy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
to-rdjson.jq
42 lines (42 loc) · 1.11 KB
/
to-rdjson.jq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Convert trivy JSON output to Reviewdog Diagnostic Format (rdjson)
# https://github.com/reviewdog/reviewdog/blob/f577bd4b56e5973796eb375b4205e89bce214bd9/proto/rdf/reviewdog.proto
{
source: {
name: "trivy",
url: "https://github.com/aquasecurity/trivy"
},
diagnostics: [(.Results[]?
| .Target as $target
| .Misconfigurations[]?
| .Title as $title | .ID as $id | .PrimaryURL as $primaryURL | .Severity as $severity
| .CauseMetadata | {
message: $title,
code: {
value: $id,
url: $primaryURL,
} ,
location: {
path: $target,
range: {
start: {
line: .StartLine,
},
# Not in for tfsec
#end: {
# line: .EndLine,
#},
}
},
severity: (if $severity | startswith("CRITICAL") then
"ERROR"
elif $severity | startswith("HIGH") then
"ERROR"
elif $severity | startswith("MEDIUM") then
"WARNING"
elif $severity | startswith("LOW") then
"INFO"
else
null
end),
})]
}