foreman_openscap 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -6
- data/app/assets/javascript/foreman_openscap/period_selector.js +3 -0
- data/app/assets/javascript/foreman_openscap/policy_edit.js +37 -0
- data/app/assets/stylesheets/foreman_openscap/policy.css.scss +7 -0
- data/app/controllers/api/v2/{openscap → compliance}/arf_reports_controller.rb +6 -5
- data/app/controllers/scaptimony_arf_reports_controller.rb +9 -6
- data/app/controllers/scaptimony_policies_controller.rb +72 -11
- data/app/{models/scaptimony/asset.rb → controllers/scaptimony_policy_dashboard_controller.rb} +8 -9
- data/app/controllers/scaptimony_scap_contents_controller.rb +25 -16
- data/app/helpers/concerns/foreman_openscap/hosts_helper_extensions.rb +3 -4
- data/app/helpers/scaptimony_policies_helper.rb +22 -0
- data/app/helpers/scaptimony_policy_dashboard_helper.rb +43 -0
- data/app/helpers/scaptimony_report_dashboard_helper.rb +20 -0
- data/app/models/concerns/foreman_openscap/arf_report_extensions.rb +30 -1
- data/app/models/concerns/foreman_openscap/asset_extensions.rb +34 -0
- data/app/models/concerns/foreman_openscap/host_extensions.rb +38 -7
- data/app/models/concerns/foreman_openscap/policy_extensions.rb +214 -3
- data/app/models/concerns/foreman_openscap/scap_content_extensions.rb +21 -1
- data/app/overrides/hosts/index/host_arf_report.rb +5 -0
- data/app/services/scaptimony/policy_dashboard/data.rb +30 -0
- data/app/services/scaptimony/policy_dashboard/loader.rb +20 -0
- data/app/services/scaptimony/policy_dashboard/manager.rb +32 -0
- data/app/services/scaptimony/report_dashboard/data.rb +37 -0
- data/app/views/dashboard/_foreman_openscap_host_reports_widget.html.erb +24 -0
- data/app/views/dashboard/_foreman_openscap_reports_breakdown_widget.html.erb +3 -0
- data/app/views/scaptimony_arf_reports/_host_report.html.erb +8 -0
- data/app/views/scaptimony_arf_reports/_list.html.erb +2 -2
- data/app/views/scaptimony_arf_reports/show.html.erb +3 -0
- data/app/views/scaptimony_policies/_form.html.erb +23 -4
- data/app/views/scaptimony_policies/_list.html.erb +2 -4
- data/app/views/scaptimony_policies/create.html.erb +2 -0
- data/app/views/scaptimony_policies/edit.html.erb +1 -2
- data/app/views/scaptimony_policies/index.html.erb +1 -1
- data/app/views/scaptimony_policies/new.html.erb +1 -2
- data/app/views/scaptimony_policies/select_multiple_hosts.html.erb +8 -0
- data/app/views/scaptimony_policies/show.html.erb +3 -0
- data/app/views/scaptimony_policies/steps/_create_policy_form.html.erb +5 -0
- data/app/views/scaptimony_policies/steps/_hostgroups_form.html.erb +7 -0
- data/app/views/scaptimony_policies/steps/_locations_form.html.erb +13 -0
- data/app/views/scaptimony_policies/steps/_organizations_form.html.erb +13 -0
- data/app/views/scaptimony_policies/steps/_scap_content_form.html.erb +21 -0
- data/app/views/scaptimony_policies/steps/_schedule_form.html.erb +11 -0
- data/app/views/scaptimony_policies/steps/_step_form.html.erb +11 -0
- data/app/views/scaptimony_policy_dashboard/_policy_chart_widget.html.erb +4 -0
- data/app/views/scaptimony_policy_dashboard/_policy_reports.html.erb +24 -0
- data/app/views/scaptimony_policy_dashboard/_policy_status_widget.html.erb +12 -0
- data/app/views/scaptimony_policy_dashboard/index.html.erb +26 -0
- data/app/views/scaptimony_scap_contents/_form.html.erb +8 -0
- data/app/views/scaptimony_scap_contents/_list.html.erb +8 -6
- data/config/routes.rb +24 -6
- data/db/seeds.d/openscap_feature.rb +2 -0
- data/lib/foreman_openscap/engine.rb +18 -12
- data/lib/foreman_openscap/helper.rb +1 -7
- data/lib/foreman_openscap/version.rb +1 -1
- metadata +57 -31
- data/app/assets/javascript/policy_edit.js +0 -14
- data/app/overrides/dashboard/index/sample_override.html.erb.deface +0 -4
- data/db/migrate/20141017172055_create_scaptimony_auditable_hosts.rb +0 -9
@@ -7,12 +7,20 @@
|
|
7
7
|
|
8
8
|
<ul class="nav nav-tabs" data-tabs="tabs">
|
9
9
|
<li class="active"><a href="#primary" data-toggle="tab"><%= _("File Upload") %></a></li>
|
10
|
+
<% if show_location_tab? %>
|
11
|
+
<li><a href='#locations' data-toggle='tab'><%= _('Locations') %></a></li>
|
12
|
+
<% end %>
|
13
|
+
<% if show_organization_tab? %>
|
14
|
+
<li><a href='#organizations' data-toggle='tab'><%= _('Organizations') %></a></li>
|
15
|
+
<% end %>
|
10
16
|
</ul>
|
11
17
|
<div class="tab-content">
|
12
18
|
<div class="tab-pane active" id="primary">
|
13
19
|
<%= text_f(f, :title) %>
|
14
20
|
<%= file_field_f f, :scap_file, :help_block => _("Upload SCAP DataStream file") %>
|
21
|
+
<p class="alert alert-info"><%= (_('Notice: You need to %s OpenSCAP on your hosts, and upload this content to the hosts as well.') % link_to(_('install'), 'http://www.open-scap.org/page/Documentation#Installation', :target => '_blank')).html_safe %></p>
|
15
22
|
</div>
|
23
|
+
<%= render 'taxonomies/loc_org_tabs', :f => f, :obj => @scaptimony_scap_content %>
|
16
24
|
<%= submit_or_cancel f %>
|
17
25
|
</div>
|
18
26
|
<% end %>
|
@@ -5,21 +5,23 @@
|
|
5
5
|
<th>Created</th>
|
6
6
|
<th></th>
|
7
7
|
</tr>
|
8
|
-
<% for
|
8
|
+
<% for content in @contents %>
|
9
9
|
<tr>
|
10
10
|
<td>
|
11
|
-
<%=
|
11
|
+
<%= content.title %>
|
12
12
|
</td>
|
13
13
|
<td>
|
14
|
-
<%=
|
14
|
+
<%= content.original_filename %>
|
15
15
|
</td>
|
16
16
|
<td>
|
17
|
-
<%= _("%s ago") % time_ago_in_words(
|
17
|
+
<%= _("%s ago") % time_ago_in_words(content.created_at.getlocal) %>
|
18
18
|
</td>
|
19
19
|
<td>
|
20
20
|
<%= action_buttons(
|
21
|
-
link_to_if_authorized(_("Edit"), hash_for_edit_scaptimony_scap_content_path(:id =>
|
22
|
-
link_to_if_authorized(_("Download"), hash_for_scaptimony_scap_content_path(:id =>
|
21
|
+
link_to_if_authorized(_("Edit"), hash_for_edit_scaptimony_scap_content_path(:id => content.id)),
|
22
|
+
link_to_if_authorized(_("Download"), hash_for_scaptimony_scap_content_path(:id => content.id)),
|
23
|
+
display_delete_if_authorized(hash_for_scaptimony_scap_content_path(:id => content.id),
|
24
|
+
:confirm => _("Delete compliance policy %s with all the reports?") % content.title)
|
23
25
|
) %>
|
24
26
|
</td>
|
25
27
|
</tr>
|
data/config/routes.rb
CHANGED
@@ -1,24 +1,42 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
|
3
|
-
scope '/
|
3
|
+
scope '/compliance' do
|
4
4
|
resources :arf_reports, :only => [:index, :show, :destroy],
|
5
|
-
:as => :scaptimony_arf_reports, :controller => :scaptimony_arf_reports
|
5
|
+
:as => :scaptimony_arf_reports, :controller => :scaptimony_arf_reports do
|
6
|
+
member do
|
7
|
+
match 'parse', :to => 'scaptimony_arf_reports#parse'
|
8
|
+
end
|
9
|
+
collection do
|
10
|
+
get 'auto_complete_search'
|
11
|
+
end
|
12
|
+
end
|
6
13
|
match 'dashboard', :to => 'scaptimony_dashboard#index', :as => "scaptimony_dashboard"
|
7
14
|
resources :policies, :only => [:index, :new, :show, :create, :edit, :update, :destroy],
|
8
15
|
:as => :scaptimony_policies, :controller => :scaptimony_policies do
|
16
|
+
member do
|
17
|
+
match 'parse', :to => 'scaptimony_policies#parse'
|
18
|
+
match 'dashboard', :to => 'scaptimony_policy_dashboard#index', :as => 'scaptimony_policy_dashboard'
|
19
|
+
end
|
9
20
|
collection do
|
21
|
+
get 'auto_complete_search'
|
10
22
|
post 'scap_content_selected'
|
23
|
+
get 'select_multiple_hosts'
|
24
|
+
post 'update_multiple_hosts'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
resources :scap_contents,
|
28
|
+
:as => :scaptimony_scap_contents, :controller => :scaptimony_scap_contents do
|
29
|
+
collection do
|
30
|
+
get 'auto_complete_search'
|
11
31
|
end
|
12
32
|
end
|
13
|
-
resources :scap_contents, :only => [:index, :show, :new, :create, :edit, :update],
|
14
|
-
:as => :scaptimony_scap_contents, :controller => :scaptimony_scap_contents
|
15
33
|
end
|
16
34
|
|
17
35
|
namespace :api do
|
18
36
|
scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'},
|
19
37
|
:apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
|
20
|
-
namespace :
|
21
|
-
post 'arf_reports/:cname/:
|
38
|
+
namespace :compliance do
|
39
|
+
post 'arf_reports/:cname/:policy_id/:date', \
|
22
40
|
:constraints => { :cname => /[^\/]+/ }, :to => 'arf_reports#create'
|
23
41
|
end
|
24
42
|
end
|
@@ -17,13 +17,17 @@ module ForemanOpenscap
|
|
17
17
|
|
18
18
|
initializer 'foreman_openscap.assets.precompile' do |app|
|
19
19
|
app.config.assets.precompile += %w(
|
20
|
-
'foreman_openscap/policy_edit.js'
|
20
|
+
'foreman_openscap/policy_edit.js',
|
21
|
+
'foreman_openscap/period_selector.js',
|
22
|
+
'foreman_openscap/policy.css'
|
21
23
|
)
|
22
24
|
end
|
23
25
|
|
24
26
|
initializer 'foreman_openscap.configure_assets', :group => :assets do
|
25
27
|
SETTINGS[:foreman_openscap] =
|
26
|
-
|
28
|
+
{:assets => {:precompile => ['foreman_openscap/policy_edit.js',
|
29
|
+
'foreman_openscap/period_selector.js',
|
30
|
+
'foreman_openscap/policy.css']}}
|
27
31
|
end
|
28
32
|
|
29
33
|
initializer 'foreman_openscap.register_plugin', :after=> :finisher_hook do |app|
|
@@ -37,7 +41,8 @@ module ForemanOpenscap
|
|
37
41
|
:scaptimony_scap_contents => [:index, :show],
|
38
42
|
}
|
39
43
|
permission :edit_compliance, {:scaptimony_arf_reports => [:destroy],
|
40
|
-
:scaptimony_policies => [:new, :create, :edit, :update, :destroy
|
44
|
+
:scaptimony_policies => [:new, :create, :edit, :update, :destroy,
|
45
|
+
:select_multiple_hosts, :upldate_multiple_hosts],
|
41
46
|
:scaptimony_scap_contents => [:new, :create, :edit, :update]
|
42
47
|
}
|
43
48
|
end
|
@@ -56,20 +61,21 @@ module ForemanOpenscap
|
|
56
61
|
menu :top_menu, :compliance_reports, :caption => N_('Reports'),
|
57
62
|
:url_hash => {:controller => :'scaptimony_arf_reports', :action => :index },
|
58
63
|
:parent => :hosts_menu
|
64
|
+
|
65
|
+
# add dashboard widget
|
66
|
+
widget 'foreman_openscap_host_reports_widget', :name => N_('OpenSCAP Host reports widget'), :sizex => 4, :sizey =>1
|
67
|
+
widget 'foreman_openscap_reports_breakdown_widget', :name => N_('OpenSCAP Host reports widget'), :sizex => 4, :sizey =>1
|
59
68
|
end
|
60
69
|
end
|
61
70
|
|
62
71
|
#Include concerns in this config.to_prepare block
|
63
72
|
config.to_prepare do
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
rescue => e
|
71
|
-
puts "ForemanOpenscap: skipping engine hook (#{e.to_s})"
|
72
|
-
end
|
73
|
+
Host::Managed.send(:include, ForemanOpenscap::HostExtensions)
|
74
|
+
HostsHelper.send(:include, ForemanOpenscap::HostsHelperExtensions)
|
75
|
+
::Scaptimony::ArfReport.send(:include, ForemanOpenscap::ArfReportExtensions)
|
76
|
+
::Scaptimony::Asset.send(:include, ForemanOpenscap::AssetExtensions)
|
77
|
+
::Scaptimony::Policy.send(:include, ForemanOpenscap::PolicyExtensions)
|
78
|
+
::Scaptimony::ScapContent.send(:include, ForemanOpenscap::ScapContentExtensions)
|
73
79
|
end
|
74
80
|
|
75
81
|
rake_tasks do
|
@@ -10,12 +10,6 @@
|
|
10
10
|
|
11
11
|
module ForemanOpenscap::Helper
|
12
12
|
def self.get_asset(cname)
|
13
|
-
|
14
|
-
if host.auditable_host.nil?
|
15
|
-
# TODO:RAILS-4.0: This should become: asset = Asset.find_or_create_by!(name: cname)
|
16
|
-
asset = Scaptimony::Asset.first_or_create!(:name => cname)
|
17
|
-
host.auditable_host = Scaptimony::AuditableHost.where(:asset_id => asset.id, :host_id => host.id).first_or_create
|
18
|
-
end
|
19
|
-
return host.auditable_host.asset
|
13
|
+
Host.find_by_name!(cname).get_asset
|
20
14
|
end
|
21
15
|
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: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Šimon Lukašík
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -45,48 +45,75 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- app/
|
49
|
-
- app/
|
50
|
-
- app/
|
51
|
-
- app/
|
52
|
-
- app/
|
53
|
-
- app/
|
54
|
-
- app/models/concerns/foreman_openscap/scap_content_extensions.rb
|
55
|
-
- app/models/concerns/foreman_openscap/host_extensions.rb
|
56
|
-
- app/models/concerns/foreman_openscap/policy_extensions.rb
|
57
|
-
- app/models/concerns/foreman_openscap/arf_report_extensions.rb
|
58
|
-
- app/controllers/scaptimony_policies_controller.rb
|
59
|
-
- app/controllers/scaptimony_dashboard_controller.rb
|
60
|
-
- app/controllers/api/v2/openscap/arf_reports_controller.rb
|
61
|
-
- app/controllers/scaptimony_scap_contents_controller.rb
|
62
|
-
- app/controllers/scaptimony_arf_reports_controller.rb
|
63
|
-
- app/views/scaptimony_scap_contents/index.html.erb
|
48
|
+
- app/views/scaptimony_arf_reports/show.html.erb
|
49
|
+
- app/views/scaptimony_arf_reports/_host_report.html.erb
|
50
|
+
- app/views/scaptimony_arf_reports/index.html.erb
|
51
|
+
- app/views/scaptimony_arf_reports/_list.html.erb
|
52
|
+
- app/views/dashboard/_foreman_openscap_host_reports_widget.html.erb
|
53
|
+
- app/views/dashboard/_foreman_openscap_reports_breakdown_widget.html.erb
|
64
54
|
- app/views/scaptimony_scap_contents/_form.html.erb
|
65
|
-
- app/views/scaptimony_scap_contents/_list.html.erb
|
66
55
|
- app/views/scaptimony_scap_contents/new.html.erb
|
56
|
+
- app/views/scaptimony_scap_contents/index.html.erb
|
57
|
+
- app/views/scaptimony_scap_contents/_list.html.erb
|
67
58
|
- app/views/scaptimony_scap_contents/edit.html.erb
|
68
|
-
- app/views/
|
69
|
-
- app/views/
|
70
|
-
- app/views/
|
71
|
-
- app/views/
|
59
|
+
- app/views/scaptimony_policy_dashboard/_policy_reports.html.erb
|
60
|
+
- app/views/scaptimony_policy_dashboard/index.html.erb
|
61
|
+
- app/views/scaptimony_policy_dashboard/_policy_status_widget.html.erb
|
62
|
+
- app/views/scaptimony_policy_dashboard/_policy_chart_widget.html.erb
|
63
|
+
- app/views/scaptimony_policies/welcome.html.erb
|
72
64
|
- app/views/scaptimony_policies/_form.html.erb
|
73
|
-
- app/views/scaptimony_policies/
|
65
|
+
- app/views/scaptimony_policies/select_multiple_hosts.html.erb
|
66
|
+
- app/views/scaptimony_policies/show.html.erb
|
74
67
|
- app/views/scaptimony_policies/new.html.erb
|
68
|
+
- app/views/scaptimony_policies/steps/_organizations_form.html.erb
|
69
|
+
- app/views/scaptimony_policies/steps/_hostgroups_form.html.erb
|
70
|
+
- app/views/scaptimony_policies/steps/_locations_form.html.erb
|
71
|
+
- app/views/scaptimony_policies/steps/_scap_content_form.html.erb
|
72
|
+
- app/views/scaptimony_policies/steps/_schedule_form.html.erb
|
73
|
+
- app/views/scaptimony_policies/steps/_create_policy_form.html.erb
|
74
|
+
- app/views/scaptimony_policies/steps/_step_form.html.erb
|
75
|
+
- app/views/scaptimony_policies/create.html.erb
|
76
|
+
- app/views/scaptimony_policies/index.html.erb
|
77
|
+
- app/views/scaptimony_policies/_list.html.erb
|
78
|
+
- app/views/scaptimony_policies/_scap_content_results.html.erb
|
75
79
|
- app/views/scaptimony_policies/edit.html.erb
|
76
|
-
- app/
|
80
|
+
- app/overrides/hosts/index/host_arf_report.rb
|
81
|
+
- app/helpers/scaptimony_policies_helper.rb
|
82
|
+
- app/helpers/scaptimony_report_dashboard_helper.rb
|
83
|
+
- app/helpers/scaptimony_policy_dashboard_helper.rb
|
84
|
+
- app/helpers/concerns/foreman_openscap/hosts_helper_extensions.rb
|
85
|
+
- app/helpers/arf_reports_helper.rb
|
86
|
+
- app/controllers/scaptimony_policy_dashboard_controller.rb
|
87
|
+
- app/controllers/scaptimony_policies_controller.rb
|
88
|
+
- app/controllers/scaptimony_scap_contents_controller.rb
|
89
|
+
- app/controllers/api/v2/compliance/arf_reports_controller.rb
|
90
|
+
- app/controllers/scaptimony_dashboard_controller.rb
|
91
|
+
- app/controllers/scaptimony_arf_reports_controller.rb
|
92
|
+
- app/assets/javascript/foreman_openscap/period_selector.js
|
93
|
+
- app/assets/javascript/foreman_openscap/policy_edit.js
|
94
|
+
- app/assets/stylesheets/foreman_openscap/policy.css.scss
|
95
|
+
- app/services/scaptimony/policy_dashboard/data.rb
|
96
|
+
- app/services/scaptimony/policy_dashboard/manager.rb
|
97
|
+
- app/services/scaptimony/policy_dashboard/loader.rb
|
98
|
+
- app/services/scaptimony/report_dashboard/data.rb
|
99
|
+
- app/models/concerns/foreman_openscap/arf_report_extensions.rb
|
100
|
+
- app/models/concerns/foreman_openscap/host_extensions.rb
|
101
|
+
- app/models/concerns/foreman_openscap/policy_extensions.rb
|
102
|
+
- app/models/concerns/foreman_openscap/scap_content_extensions.rb
|
103
|
+
- app/models/concerns/foreman_openscap/asset_extensions.rb
|
77
104
|
- config/routes.rb
|
78
|
-
- db/
|
105
|
+
- db/seeds.d/openscap_feature.rb
|
106
|
+
- lib/tasks/foreman_openscap_tasks.rake
|
79
107
|
- lib/foreman_openscap/engine.rb
|
80
108
|
- lib/foreman_openscap/helper.rb
|
81
109
|
- lib/foreman_openscap/version.rb
|
82
110
|
- lib/foreman_openscap.rb
|
83
|
-
- lib/tasks/foreman_openscap_tasks.rake
|
84
111
|
- LICENSE
|
85
112
|
- Rakefile
|
86
113
|
- README.md
|
87
114
|
- test/unit/foreman_openscap_test.rb
|
88
|
-
- test/factories/foreman_openscap_factories.rb
|
89
115
|
- test/test_plugin_helper.rb
|
116
|
+
- test/factories/foreman_openscap_factories.rb
|
90
117
|
homepage: https://github.com/OpenSCAP/foreman_openscap
|
91
118
|
licenses:
|
92
119
|
- GPL-3.0
|
@@ -107,12 +134,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
134
|
version: '0'
|
108
135
|
requirements: []
|
109
136
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.1.11
|
111
138
|
signing_key:
|
112
139
|
specification_version: 4
|
113
140
|
summary: Foreman plug-in for displaying OpenSCAP audit reports
|
114
141
|
test_files:
|
115
142
|
- test/unit/foreman_openscap_test.rb
|
116
|
-
- test/factories/foreman_openscap_factories.rb
|
117
143
|
- test/test_plugin_helper.rb
|
118
|
-
|
144
|
+
- test/factories/foreman_openscap_factories.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
function scap_content_selected(element){
|
2
|
-
var attrs = attribute_hash(['scap_content_id']);
|
3
|
-
var url = $(element).attr('data-url');
|
4
|
-
$(element).indicator_show();
|
5
|
-
$.ajax({
|
6
|
-
data: attrs,
|
7
|
-
type: 'post',
|
8
|
-
url: url,
|
9
|
-
complete: function() { $(element).indicator_hide();},
|
10
|
-
success: function(request) {
|
11
|
-
$('#scap_content_profile_select').html(request);
|
12
|
-
}
|
13
|
-
})
|
14
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
class CreateScaptimonyAuditableHosts < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table :scaptimony_auditable_hosts, :id => false do |t|
|
4
|
-
t.references :asset, :null => false
|
5
|
-
t.references :host, :null => false
|
6
|
-
end
|
7
|
-
add_index :scaptimony_auditable_hosts, [:asset_id, :host_id], :unique => true
|
8
|
-
end
|
9
|
-
end
|