foreman_openscap 0.6.2 → 0.6.3
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/controllers/api/v2/compliance/arf_reports_controller.rb +22 -2
- data/app/views/arf_reports/_list.html.erb +1 -1
- data/app/views/arf_reports/show.html.erb +1 -1
- data/app/views/dashboard/_compliance_host_reports_widget.html.erb +1 -1
- data/app/views/dashboard/_compliance_reports_breakdown_widget.html.erb +2 -2
- data/config/routes.rb +5 -1
- data/db/migrate/20160925213031_change_scap_widget_names.rb +15 -0
- data/lib/foreman_openscap/engine.rb +3 -3
- data/lib/foreman_openscap/version.rb +1 -1
- data/test/files/arf_report/arf_report.bz2 +0 -0
- data/test/functional/api/v2/compliance/arf_reports_controller_test.rb +11 -0
- metadata +22 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6beda936505b017451aaf916fc4295f10f323be1
|
4
|
+
data.tar.gz: f696a2b12c6861fd6fbc934e9451b2d77fb3879d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e786d37b5a9980b2351f6b49f854a794270ab8ac4099dc15931fe7236cd823f4a97717632627b3ddde8fa1cc9a23b476dbee8c4d27f631bfb67185a4a7ddf3fb
|
7
|
+
data.tar.gz: e967277fca2f7f84855637cedeab78a9e4ea488e9111841a141f3cd3833f342e23b0ef14b9cd240cf1595eabad521f73c0a1868bc5185f70329acc822d1c9268
|
@@ -10,7 +10,8 @@ module Api
|
|
10
10
|
|
11
11
|
add_smart_proxy_filters :create, :features => 'Openscap'
|
12
12
|
|
13
|
-
before_filter :find_resource, :only => %w(show destroy)
|
13
|
+
before_filter :find_resource, :only => %w(show destroy download)
|
14
|
+
skip_after_filter :log_response_body, :only => %w(download)
|
14
15
|
|
15
16
|
def resource_name
|
16
17
|
'::ForemanOpenscap::ArfReport'
|
@@ -33,7 +34,7 @@ module Api
|
|
33
34
|
def show
|
34
35
|
end
|
35
36
|
|
36
|
-
api :DELETE, '/compliance/arf_reports/:id', N_('
|
37
|
+
api :DELETE, '/compliance/arf_reports/:id', N_('Delete an ARF Report')
|
37
38
|
param :id, :identifier, :required => true
|
38
39
|
|
39
40
|
def destroy
|
@@ -52,12 +53,31 @@ module Api
|
|
52
53
|
render :json => { :result => :OK, :id => arf_report.id.to_s }
|
53
54
|
end
|
54
55
|
|
56
|
+
api :GET, "/compliance/arf_reports/:id/download/", N_("Download bzipped ARF report")
|
57
|
+
param :id, :identifier, :required => true
|
58
|
+
|
59
|
+
def download
|
60
|
+
response = @arf_report.to_bzip
|
61
|
+
send_data response, :filename => "#{@arf_report.id}_arf_report.bz2"
|
62
|
+
rescue => e
|
63
|
+
render_error 'standard_error', :status => :internal_error, :locals => { :exception => e }
|
64
|
+
end
|
65
|
+
|
55
66
|
private
|
56
67
|
|
57
68
|
def find_resource
|
58
69
|
not_found and return if params[:id].blank?
|
59
70
|
instance_variable_set("@arf_report", resource_scope.find(params[:id]))
|
60
71
|
end
|
72
|
+
|
73
|
+
def action_permission
|
74
|
+
case params[:action]
|
75
|
+
when 'download'
|
76
|
+
:view
|
77
|
+
else
|
78
|
+
super
|
79
|
+
end
|
80
|
+
end
|
61
81
|
end
|
62
82
|
end
|
63
83
|
end
|
@@ -12,5 +12,5 @@
|
|
12
12
|
display_delete_if_authorized(hash_for_arf_report_path(:id => @arf_report), :class=> "btn btn-danger"),
|
13
13
|
link_to(_("Host details"), @arf_report.host, :class => "btn btn-default"),
|
14
14
|
link_to(_("View full report"), show_html_arf_report_path(:id => @arf_report.id), :class => "btn btn-default"),
|
15
|
-
link_to(_("Download XML in bzip"), parse_bzip_arf_report_path(:id => @arf_report.id), :class => "btn btn-default")
|
15
|
+
link_to(_("Download XML in bzip"), parse_bzip_arf_report_path(:id => @arf_report.id), :class => "btn btn-default", :data => { :no_turbolink => true })
|
16
16
|
%>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<h4 class="header ca"><%= _('Compliance
|
1
|
+
<h4 class="header ca"><%= _('Compliance Reports Breakdown') %></h4>
|
2
2
|
<% report = ForemanOpenscap::ReportDashboard::Data.new().report %>
|
3
|
-
<%= reports_breakdown_chart(report, :class => 'statistics-pie small') %>
|
3
|
+
<%= reports_breakdown_chart(report, :class => 'statistics-pie small') %>
|
data/config/routes.rb
CHANGED
@@ -55,7 +55,11 @@ Rails.application.routes.draw do
|
|
55
55
|
get 'content'
|
56
56
|
end
|
57
57
|
end
|
58
|
-
resources :arf_reports, :only => [:index, :show, :destroy]
|
58
|
+
resources :arf_reports, :only => [:index, :show, :destroy] do
|
59
|
+
member do
|
60
|
+
get 'download'
|
61
|
+
end
|
62
|
+
end
|
59
63
|
post 'arf_reports/:cname/:policy_id/:date', \
|
60
64
|
:constraints => { :cname => /[^\/]+/ }, :to => 'arf_reports#create'
|
61
65
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ChangeScapWidgetNames < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Widget.where(:name => 'OpenSCAP Host reports widget').\
|
4
|
+
update_all(:name => 'Latest Compliance Reports')
|
5
|
+
Widget.where(:name => 'OpenSCAP Reports breakdown widget').\
|
6
|
+
update_all(:name => 'Compliance Reports Breakdown')
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
Widget.where(:name => 'Latest Compliance Reports').\
|
11
|
+
update_all(:name => 'OpenSCAP Host reports widget')
|
12
|
+
Widget.where(:name => 'Compliance Reports Breakdown').\
|
13
|
+
update_all(:name => 'OpenSCAP Reports breakdown widget')
|
14
|
+
end
|
15
|
+
end
|
@@ -52,7 +52,7 @@ module ForemanOpenscap
|
|
52
52
|
security_block :foreman_openscap do
|
53
53
|
permission :view_arf_reports, {:arf_reports => [:index, :show, :parse_html, :show_html,
|
54
54
|
:parse_bzip, :auto_complete_search],
|
55
|
-
'api/v2/compliance/arf_reports' => [:index, :show],
|
55
|
+
'api/v2/compliance/arf_reports' => [:index, :show, :download],
|
56
56
|
:compliance_hosts => [:show]}
|
57
57
|
permission :destroy_arf_reports, {:arf_reports => [:destroy, :delete_multiple, :submit_delete_multiple],
|
58
58
|
'api/v2/compliance/arf_reports' => [:destroy]}
|
@@ -112,9 +112,9 @@ module ForemanOpenscap
|
|
112
112
|
|
113
113
|
# add dashboard widget
|
114
114
|
widget 'compliance_host_reports_widget',
|
115
|
-
:name => N_('
|
115
|
+
:name => N_('Latest Compliance Reports'), :sizex => 6, :sizey => 1
|
116
116
|
widget 'compliance_reports_breakdown_widget',
|
117
|
-
:name => N_('
|
117
|
+
:name => N_('Compliance Reports Breakdown'), :sizex => 6, :sizey => 1
|
118
118
|
|
119
119
|
# As 'arf_report_breakdowns' is a view and does not appear in schema.rb, db:test:prepare will not create the view
|
120
120
|
# which will make the following tests fail.
|
Binary file
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'test_plugin_helper'
|
2
|
+
require 'tmpdir'
|
2
3
|
|
3
4
|
class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
4
5
|
setup do
|
@@ -24,4 +25,14 @@ class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
|
24
25
|
refute response['othered'].blank?
|
25
26
|
assert_response :success
|
26
27
|
end
|
28
|
+
|
29
|
+
test "should download report" do
|
30
|
+
bzipped_report = File.open "#{ForemanOpenscap::Engine.root}/test/files/arf_report/arf_report.bz2", &:read
|
31
|
+
ForemanOpenscap::ArfReport.any_instance.stubs(:to_bzip).returns(bzipped_report)
|
32
|
+
get :download, { :id => @report.to_param }, set_session_user
|
33
|
+
t = Tempfile.new('tmp_report')
|
34
|
+
t.write @response.body
|
35
|
+
t.close
|
36
|
+
refute t.size.zero?
|
37
|
+
end
|
27
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_openscap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Šimon Lukašík"
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-10-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: deface
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- db/migrate/20151119155419_add_arf_fields_to_message.rb
|
192
192
|
- db/migrate/20151120090851_add_openscap_proxy_to_host_and_hostgroup.rb
|
193
193
|
- db/migrate/20160830113437_remove_deleted_policy.rb
|
194
|
+
- db/migrate/20160925213031_change_scap_widget_names.rb
|
194
195
|
- db/seeds.d/openscap_feature.rb
|
195
196
|
- db/seeds.d/openscap_policy_notification.rb
|
196
197
|
- lib/foreman_openscap.rb
|
@@ -236,6 +237,7 @@ files:
|
|
236
237
|
- test/factories/policy_arf_report_factory.rb
|
237
238
|
- test/factories/policy_factory.rb
|
238
239
|
- test/factories/scap_content_related.rb
|
240
|
+
- test/files/arf_report/arf_report.bz2
|
239
241
|
- test/files/scap_contents/ssg-fedora-ds.xml
|
240
242
|
- test/functional/api/v2/compliance/arf_reports_controller_test.rb
|
241
243
|
- test/functional/api/v2/compliance/policies_controller_test.rb
|
@@ -272,31 +274,32 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
274
|
version: '0'
|
273
275
|
requirements: []
|
274
276
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.4.
|
277
|
+
rubygems_version: 2.4.6
|
276
278
|
signing_key:
|
277
279
|
specification_version: 4
|
278
280
|
summary: Foreman plug-in for displaying OpenSCAP audit reports
|
279
281
|
test_files:
|
280
|
-
- test/lib/foreman_openscap/bulk_upload_test.rb
|
281
|
-
- test/unit/scap_content_test.rb
|
282
|
-
- test/unit/concerns/openscap_proxy_extenstions_test.rb
|
283
|
-
- test/unit/openscap_host_test.rb
|
284
|
-
- test/unit/policy_test.rb
|
285
|
-
- test/unit/compliance_status_test.rb
|
286
|
-
- test/unit/arf_report_status_calculator_test.rb
|
287
|
-
- test/unit/policy_mailer_test.rb
|
288
|
-
- test/unit/services/report_dashboard/data_test.rb
|
289
|
-
- test/unit/arf_report_test.rb
|
290
|
-
- test/test_plugin_helper.rb
|
291
|
-
- test/functional/arf_reports_controller_test.rb
|
292
|
-
- test/functional/api/v2/compliance/arf_reports_controller_test.rb
|
293
|
-
- test/functional/api/v2/compliance/scap_contents_controller_test.rb
|
294
282
|
- test/functional/api/v2/compliance/policies_controller_test.rb
|
283
|
+
- test/functional/api/v2/compliance/scap_contents_controller_test.rb
|
284
|
+
- test/functional/api/v2/compliance/arf_reports_controller_test.rb
|
285
|
+
- test/functional/arf_reports_controller_test.rb
|
295
286
|
- test/factories/asset_factory.rb
|
287
|
+
- test/factories/compliance_host_factory.rb
|
288
|
+
- test/factories/scap_content_related.rb
|
296
289
|
- test/factories/compliance_log_factory.rb
|
297
290
|
- test/factories/arf_report_factory.rb
|
298
|
-
- test/factories/scap_content_related.rb
|
299
|
-
- test/factories/compliance_host_factory.rb
|
300
291
|
- test/factories/policy_arf_report_factory.rb
|
301
292
|
- test/factories/policy_factory.rb
|
293
|
+
- test/files/arf_report/arf_report.bz2
|
302
294
|
- test/files/scap_contents/ssg-fedora-ds.xml
|
295
|
+
- test/lib/foreman_openscap/bulk_upload_test.rb
|
296
|
+
- test/test_plugin_helper.rb
|
297
|
+
- test/unit/arf_report_status_calculator_test.rb
|
298
|
+
- test/unit/compliance_status_test.rb
|
299
|
+
- test/unit/arf_report_test.rb
|
300
|
+
- test/unit/policy_mailer_test.rb
|
301
|
+
- test/unit/openscap_host_test.rb
|
302
|
+
- test/unit/scap_content_test.rb
|
303
|
+
- test/unit/concerns/openscap_proxy_extenstions_test.rb
|
304
|
+
- test/unit/services/report_dashboard/data_test.rb
|
305
|
+
- test/unit/policy_test.rb
|