foreman_openscap 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/foreman_openscap/scap_hosts_show.js +1 -1
- data/app/assets/stylesheets/foreman_openscap/scap_breakdown_chart.css +26 -0
- data/app/helpers/arf_report_dashboard_helper.rb +22 -7
- data/app/helpers/compliance_hosts_helper.rb +13 -17
- data/app/helpers/policy_dashboard_helper.rb +9 -9
- data/app/views/arf_reports/_metrics.html.erb +10 -8
- data/app/views/compliance_hosts/show.html.erb +8 -3
- data/app/views/policy_dashboard/_policy_chart_widget.html.erb +4 -1
- data/lib/foreman_openscap/version.rb +1 -1
- data/test/helpers/arf_report_dashboard_helper_test.rb +33 -0
- data/test/helpers/policy_dashboard_helper_test.rb +21 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629a167f8a2ea481556fa422d375bc3a85ad1c9a2ed78d3976796d7a1631c7f1
|
4
|
+
data.tar.gz: bed0c059fae8275515b39faa672553a805e6a4b91612e4b1d0b9b8bd6ed4ba30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25197b4a417ebfdb3f1a757015caab03dba232e2a2e667b01e84a4f666a8d3dea713aab3bd6794ed0809e1e147d9306e830318f75f7a46f57126914e572f4f5d
|
7
|
+
data.tar.gz: 136a1b268b7164ae19ba5daf4f13dac82fdc08f20697370b8820d6ff49cb6f28189af63821cc91c0097177cb22fa766774a18d944ebc8e4d4f6a55b966a30e6f
|
@@ -0,0 +1,26 @@
|
|
1
|
+
.scap-breakdown-chart {
|
2
|
+
margin: 25px auto 12px;
|
3
|
+
width: 240px;
|
4
|
+
}
|
5
|
+
|
6
|
+
#arf-report-breakdown-chart {
|
7
|
+
margin-top: 58px;
|
8
|
+
padding-bottom: 50px;
|
9
|
+
}
|
10
|
+
|
11
|
+
.scap-breakdown-chart-col {
|
12
|
+
min-width: 340px;
|
13
|
+
}
|
14
|
+
|
15
|
+
.arf-report-rule-chart-col {
|
16
|
+
min-width: 440px;
|
17
|
+
}
|
18
|
+
|
19
|
+
.metrics-stats-row {
|
20
|
+
padding-top: 20px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#arf-report-rule-chart .bar-chart-pf {
|
24
|
+
max-width: fit-content;
|
25
|
+
margin: auto;
|
26
|
+
}
|
@@ -5,13 +5,28 @@ module ArfReportDashboardHelper
|
|
5
5
|
:othered => '#DB843D',
|
6
6
|
}.freeze
|
7
7
|
|
8
|
-
def
|
9
|
-
data = []
|
10
|
-
|
11
|
-
[:passed, _('Passed')],
|
12
|
-
[:othered, _('Othered')],].each do |i|
|
13
|
-
data << { :label => i[1], :data => report[i[0]], :color => COLORS[i[0]] }
|
8
|
+
def breakdown_chart_data(categories, report, colors = COLORS)
|
9
|
+
data = categories.reduce([]) do |memo, (key, value)|
|
10
|
+
memo << [value, report[key], colors[key]]
|
14
11
|
end
|
15
|
-
|
12
|
+
|
13
|
+
data.to_json
|
14
|
+
end
|
15
|
+
|
16
|
+
def donut_breakdown_chart_data(report)
|
17
|
+
categories = {
|
18
|
+
:failed => _('Failed'),
|
19
|
+
:passed => _('Passed'),
|
20
|
+
:othered => _('Other')
|
21
|
+
}
|
22
|
+
breakdown_chart_data categories, report
|
23
|
+
end
|
24
|
+
|
25
|
+
def arf_report_status_chart_data(status)
|
26
|
+
{
|
27
|
+
:data => status.to_a,
|
28
|
+
:yAxisLabel => _("Number of Events"),
|
29
|
+
:xAxisLabel => _("Rule Results"),
|
30
|
+
}.to_json
|
16
31
|
end
|
17
32
|
end
|
@@ -1,25 +1,21 @@
|
|
1
1
|
module ComplianceHostsHelper
|
2
|
-
def
|
3
|
-
data = []
|
4
|
-
[[:passed, _('Passed')],
|
5
|
-
[:failed, _('Failed')],
|
6
|
-
[:othered, _('Other')],].each do |i|
|
7
|
-
data << { :label => i[1], :data => report[i[0]], :color => ArfReportDashboardHelper::COLORS[i[0]] }
|
8
|
-
end
|
9
|
-
flot_pie_chart 'overview', _('Compliance reports breakdown'), data, options
|
10
|
-
end
|
11
|
-
|
12
|
-
def host_arf_reports_chart(policy_id)
|
2
|
+
def host_arf_reports_chart_data(policy_id)
|
13
3
|
passed = []
|
14
4
|
failed = []
|
15
5
|
othered = []
|
6
|
+
date = []
|
16
7
|
@host.arf_reports.of_policy(policy_id).each do |report|
|
17
|
-
passed <<
|
18
|
-
failed <<
|
19
|
-
othered <<
|
8
|
+
passed << report.passed
|
9
|
+
failed << report.failed
|
10
|
+
othered << report.othered
|
11
|
+
date << report.created_at.to_i * 1000
|
20
12
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
data = [
|
14
|
+
[_("Passed"), passed, ArfReportDashboardHelper::COLORS[:passed]],
|
15
|
+
[_("Failed"), failed, ArfReportDashboardHelper::COLORS[:failed]],
|
16
|
+
[_("Othered"), othered, ArfReportDashboardHelper::COLORS[:othered]],
|
17
|
+
['dates', date, nil]
|
18
|
+
]
|
19
|
+
{ :data => data, :xAxisDataLabel => 'dates', :config => 'timeseries' }.to_json
|
24
20
|
end
|
25
21
|
end
|
@@ -6,15 +6,15 @@ module PolicyDashboardHelper
|
|
6
6
|
:report_missing => '#92A8CD',
|
7
7
|
}.freeze
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
def policy_breakdown_chart_data(report)
|
10
|
+
categories = {
|
11
|
+
:compliant_hosts => _('Compliant hosts'),
|
12
|
+
:incompliant_hosts => _('Incompliant hosts'),
|
13
|
+
:inconclusive_hosts => _('Inconclusive'),
|
14
|
+
:report_missing => _('Not audited'),
|
15
|
+
}
|
16
|
+
|
17
|
+
breakdown_chart_data categories, report, COLORS
|
18
18
|
end
|
19
19
|
|
20
20
|
def status_link(name, label, path)
|
@@ -1,19 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% stylesheet 'foreman_openscap/scap_breakdown_chart' %>
|
2
|
+
|
3
|
+
<div class="row metrics-stats-row">
|
4
|
+
<div class="col-md-5 scap-breakdown-chart-col">
|
3
5
|
<div class="stats-well">
|
4
6
|
<h4 class="ca" ><%= _('Report Metrics') %></h4>
|
5
|
-
<div
|
6
|
-
|
7
|
-
</div>
|
7
|
+
<div id="arf-report-breakdown-chart" class="scap-breakdown-chart"></div>
|
8
|
+
<%= mount_react_component('DonutChart', "#arf-report-breakdown-chart", donut_breakdown_chart_data(metrics)) %>
|
8
9
|
</div>
|
9
10
|
</div>
|
10
|
-
<div class="col-md-
|
11
|
+
<div class="col-md-5 arf-report-rule-chart-col">
|
11
12
|
<div class="stats-well">
|
12
13
|
<h4 class="ca" ><%= _('Report Status') %></h4>
|
13
|
-
|
14
|
+
<div id="arf-report-rule-chart"></div>
|
15
|
+
<%= mount_react_component('BarChart', "#arf-report-rule-chart", arf_report_status_chart_data(status), :flatten_data => true) %>
|
14
16
|
</div>
|
15
17
|
</div>
|
16
|
-
<div class="col-md-
|
18
|
+
<div class="col-md-2">
|
17
19
|
<table class='<%= table_css_classes %>'>
|
18
20
|
<tbody>
|
19
21
|
<% metrics.sort.each do |title, value|%>
|
@@ -1,4 +1,5 @@
|
|
1
|
-
<% javascript 'charts', '
|
1
|
+
<% javascript 'charts', 'foreman_openscap/scap_hosts_show' %>
|
2
|
+
<% stylesheet 'foreman_openscap/scap_breakdown_chart' %>
|
2
3
|
|
3
4
|
<%= breadcrumbs(:resource_url => api_hosts_path,
|
4
5
|
:resource_filter => "is_compliance_host = true",
|
@@ -23,14 +24,18 @@
|
|
23
24
|
hash_for_arf_report_path(:id => data.latest_report.id)
|
24
25
|
.merge(:auth_object => data.latest_report)) %></h4>
|
25
26
|
<% report = data.report %>
|
26
|
-
|
27
|
+
<% id = "host-policy-breakdown-chart-#{policy.id}" %>
|
28
|
+
<div id="<%= id %>" class="scap-breakdown-chart"></div>
|
29
|
+
<%= mount_react_component('DonutChart', "##{id}", donut_breakdown_chart_data(report)) %>
|
27
30
|
</div>
|
28
31
|
</div>
|
29
32
|
|
30
33
|
<div class="col-md-8">
|
31
34
|
<div class="stats-well">
|
32
35
|
<h4 class="ca"><%= _("%s reports over time") % policy %></h4>
|
33
|
-
|
36
|
+
<% reports_graph_id = "arf-reports-over-time-#{policy.id}" %>
|
37
|
+
<div id="<%= reports_graph_id %>"></div>
|
38
|
+
<%= mount_react_component('LineChart', "##{reports_graph_id}", host_arf_reports_chart_data(policy.id), :flatten_data => true) %>
|
34
39
|
</div>
|
35
40
|
</div>
|
36
41
|
<% else %>
|
@@ -1,4 +1,7 @@
|
|
1
|
+
<% stylesheet 'foreman_openscap/scap_breakdown_chart'%>
|
2
|
+
|
1
3
|
<div id='status-chart'>
|
2
4
|
<h4 class="header ca"><%= _('Host Breakdown Chart') %></h4>
|
3
|
-
|
5
|
+
<div id="policy-breakdown-chart" class="scap-breakdown-chart"></div>
|
6
|
+
<%= mount_react_component('DonutChart', "#policy-breakdown-chart", policy_breakdown_chart_data(@report)) %>
|
4
7
|
</div>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class ArfReportDashboardHelperTest < ActionView::TestCase
|
4
|
+
include ArfReportDashboardHelper
|
5
|
+
|
6
|
+
test 'should return breakdown chart data with custom colors as json' do
|
7
|
+
categories = { :passed => 'passed', :failed => 'failed' }
|
8
|
+
report = { :passed => 23, :failed => 24 }
|
9
|
+
colors = { :passed => '#FFF', :failed => '#000' }
|
10
|
+
res = JSON.parse(breakdown_chart_data(categories, report, colors))
|
11
|
+
assert_equal ["passed", 23, "#FFF"], res.first
|
12
|
+
assert_equal ["failed", 24, "#000"], res.last
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'should return breakdown chart data for donut as json' do
|
16
|
+
report = { :passed => 4, :failed => 7, :othered => 5 }
|
17
|
+
res = JSON.parse(donut_breakdown_chart_data(report))
|
18
|
+
assert_equal 3, res.size
|
19
|
+
assert_include res, ["Passed", 4, ArfReportDashboardHelper::COLORS[:passed]]
|
20
|
+
assert_include res, ["Failed", 7, ArfReportDashboardHelper::COLORS[:failed]]
|
21
|
+
assert_include res, ["Other", 5, ArfReportDashboardHelper::COLORS[:othered]]
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'should return data for report status chart' do
|
25
|
+
res = JSON.parse(arf_report_status_chart_data(:passed => 6, :failed => 7, :othered => 8))
|
26
|
+
assert_equal "Number of Events", res['yAxisLabel']
|
27
|
+
assert_equal "Rule Results", res['xAxisLabel']
|
28
|
+
assert_equal 3, res['data'].size
|
29
|
+
assert_include res['data'], ["passed", 6]
|
30
|
+
assert_include res['data'], ["failed", 7]
|
31
|
+
assert_include res['data'], ["othered", 8]
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class PolicyDashboardHelperTest < ActionView::TestCase
|
4
|
+
include ArfReportDashboardHelper
|
5
|
+
include PolicyDashboardHelper
|
6
|
+
|
7
|
+
test 'should return data for policy breakdown chart' do
|
8
|
+
report = {
|
9
|
+
:compliant_hosts => 5,
|
10
|
+
:incompliant_hosts => 6,
|
11
|
+
:inconclusive_hosts => 7,
|
12
|
+
:report_missing => 8
|
13
|
+
}
|
14
|
+
res = JSON.parse(policy_breakdown_chart_data(report))
|
15
|
+
assert_equal 4, res.size
|
16
|
+
assert_include res, ['Compliant hosts', 5, PolicyDashboardHelper::COLORS[:compliant_hosts]]
|
17
|
+
assert_include res, ['Incompliant hosts', 6, PolicyDashboardHelper::COLORS[:incompliant_hosts]]
|
18
|
+
assert_include res, ['Inconclusive', 7, PolicyDashboardHelper::COLORS[:inconclusive_hosts]]
|
19
|
+
assert_include res, ['Not audited', 8, PolicyDashboardHelper::COLORS[:report_missing]]
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_openscap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- slukasik@redhat.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- app/assets/stylesheets/foreman_openscap/policy.css
|
44
44
|
- app/assets/stylesheets/foreman_openscap/policy_dashboard.css
|
45
45
|
- app/assets/stylesheets/foreman_openscap/reports.css
|
46
|
+
- app/assets/stylesheets/foreman_openscap/scap_breakdown_chart.css
|
46
47
|
- app/controllers/api/v2/compliance/arf_reports_controller.rb
|
47
48
|
- app/controllers/api/v2/compliance/policies_controller.rb
|
48
49
|
- app/controllers/api/v2/compliance/scap_contents_controller.rb
|
@@ -329,6 +330,8 @@ files:
|
|
329
330
|
- test/functional/arf_reports_controller_test.rb
|
330
331
|
- test/functional/openscap_proxies_controller_test.rb
|
331
332
|
- test/functional/tailoring_files_controller_test.rb
|
333
|
+
- test/helpers/arf_report_dashboard_helper_test.rb
|
334
|
+
- test/helpers/policy_dashboard_helper_test.rb
|
332
335
|
- test/lib/foreman_openscap/bulk_upload_test.rb
|
333
336
|
- test/test_plugin_helper.rb
|
334
337
|
- test/unit/arf_report_status_calculator_test.rb
|
@@ -371,6 +374,8 @@ signing_key:
|
|
371
374
|
specification_version: 4
|
372
375
|
summary: Foreman plug-in for displaying OpenSCAP audit reports
|
373
376
|
test_files:
|
377
|
+
- test/helpers/arf_report_dashboard_helper_test.rb
|
378
|
+
- test/helpers/policy_dashboard_helper_test.rb
|
374
379
|
- test/lib/foreman_openscap/bulk_upload_test.rb
|
375
380
|
- test/unit/message_cleaner_test.rb
|
376
381
|
- test/unit/scap_content_test.rb
|