-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.pp
157 lines (147 loc) · 4.18 KB
/
mod.pp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
mod "oci-powerpipe-diff-mod" {
title = "Powerpipe mod to run diff between 2 OCI compliance reports"
}
dashboard "oci_compliance_diff_report" {
title = "OCI compliance diff report"
container{
input "run_id_1" {
title = "Select first RunID:"
width = 3
sql = query.distinct_run_id.sql
type = "select"
}
input "run_id_2" {
title = "Select Next RunID:"
width = 3
type = "select"
sql = query.distinct_run_id.sql
}
}
container{
table{
title = "Stats for the first run"
width = 3
query = query.stats_per_run_id
args = {"run_id" = self.input.run_id_1.value}
}
chart {
width = 3
type = "bar"
query = query.stats_per_run_id
args = {"run_id" = self.input.run_id_1.value}
}
table{
title = "Stats for the next run"
width = 3
query = query.stats_per_run_id
args = {"run_id" = self.input.run_id_2.value}
}
chart {
width = 3
type = "column"
query = query.stats_per_run_id
args = {"run_id" = self.input.run_id_2.value}
}
}
container{
table{
title = "Resolved issues"
query = query.resolved_issues
args = {"run_id_1" = self.input.run_id_1.value,"run_id_2" = self.input.run_id_2.value,}
column "reason"{
wrap = "all"
}
column "control_title"{
wrap = "all"
}
column "resource"{
wrap = "all"
}
}
table{
title = "New issues"
query = query.new_issues
args = {"run_id_1" = self.input.run_id_1.value,"run_id_2" = self.input.run_id_2.value,}
column "reason"{
wrap = "all"
}
column "control_title"{
wrap = "all"
}
column "resource"{
wrap = "all"
}
}
table{
title = "Unresolved issues"
query = query.unresolved_issues
args = {"run_id_1" = self.input.run_id_1.value,"run_id_2" = self.input.run_id_2.value,}
column "reason"{
wrap = "all"
}
#column "title"{
# wrap = "all"
#}
column "control_title"{
wrap = "all"
}
column "resource"{
wrap = "all"
}
}
}
}
query "distinct_run_id" {
sql = <<-EOQ
select distinct run_id as label, run_id as value from public.report
EOQ
}
query "stats_per_run_id" {
sql = "select status,count(*) from public.report where run_id = $1 group by status ;"
param "run_id" {}
}
query "resolved_issues" {
sql = <<-EOQ
select run_id,
title,
control_title,
reason,
status,
resource,cis_type
from report
where run_id = $1 and status in ('alarm','error')
and (resource,status,cis_item_id) not in ( select resource,status,cis_item_id from report where run_id=$2);
EOQ
param "run_id_1" {}
param "run_id_2" {}
}
query "new_issues" {
sql = <<-EOQ
select run_id,
title,
--control_title,
reason,
status,
resource,cis_type
from report
where run_id = $2 and status in ('alarm','error')
and (resource,status,cis_item_id) not in ( select resource,status,cis_item_id from report where run_id=$1) order by title;
EOQ
param "run_id_1" {}
param "run_id_2" {}
}
query "unresolved_issues" {
sql = <<-EOQ
select run_id,
title,
control_title,
reason,
status,
resource,cis_type
from report
where run_id = $1 and status in ('alarm','error')
and (resource,status,cis_item_id) in ( select resource,status,cis_item_id from report where run_id=$2 and status != 'ok') order by title, control_title;
EOQ
param "run_id_1" {}
param "run_id_2" {}
}