foreman_openscap 0.7.1 → 0.7.2
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 +1 -1
- data/app/controllers/api/v2/compliance/policies_controller.rb +2 -2
- data/app/controllers/api/v2/compliance/scap_contents_controller.rb +1 -1
- data/app/controllers/api/v2/compliance/tailoring_files_controller.rb +1 -1
- data/app/controllers/arf_reports_controller.rb +9 -9
- data/app/controllers/concerns/foreman/controller/parameters/policy.rb +1 -1
- data/app/controllers/openscap_proxies_controller.rb +5 -5
- data/app/controllers/policies_controller.rb +16 -17
- data/app/controllers/policy_dashboard_controller.rb +2 -1
- data/app/controllers/scap_contents_controller.rb +2 -2
- data/app/controllers/tailoring_files_controller.rb +4 -4
- data/app/helpers/arf_report_dashboard_helper.rb +2 -3
- data/app/helpers/arf_reports_helper.rb +1 -1
- data/app/helpers/compliance_hosts_helper.rb +1 -2
- data/app/helpers/policies_helper.rb +4 -4
- data/app/helpers/policy_dashboard_helper.rb +2 -3
- data/app/lib/proxy_api/available_proxy.rb +2 -2
- data/app/lib/proxy_api/openscap.rb +1 -1
- data/app/mailers/foreman_openscap/policy_mailer.rb +1 -1
- data/app/models/concerns/foreman_openscap/compliance_status_scoped_search.rb +7 -8
- data/app/models/concerns/foreman_openscap/host_extensions.rb +44 -25
- data/app/models/concerns/foreman_openscap/log_extensions.rb +1 -1
- data/app/models/concerns/foreman_openscap/openscap_proxy_core_extensions.rb +3 -3
- data/app/models/foreman_openscap/arf_report.rb +34 -12
- data/app/models/foreman_openscap/policy.rb +19 -17
- data/app/models/foreman_openscap/scap_content.rb +4 -2
- data/app/services/foreman_openscap/arf_report_status_calculator.rb +1 -1
- data/app/services/foreman_openscap/host_report_dashboard/data.rb +2 -2
- data/app/services/foreman_openscap/policy_dashboard/data.rb +4 -3
- data/app/validators/foreman_openscap/data_stream_validator.rb +2 -2
- data/app/views/policy_dashboard/_policy_status_widget.html.erb +5 -5
- data/config/routes.rb +6 -6
- data/db/migrate/20141015115511_add_arf_report_unique_constraint.rb +1 -1
- data/db/migrate/20141113221054_create_scaptimony_scap_content_profiles.rb +1 -1
- data/db/migrate/20141116170632_remove_xccdf_profile_from_scaptimony_policies.rb +1 -1
- data/db/migrate/20141121120326_create_scaptimony_arf_report_breakdowns.rb +15 -15
- data/db/migrate/20141121164042_replace_arf_report_breakdown_view.rb +15 -15
- data/db/migrate/20141206211151_create_scaptimony_assets_policies.rb +1 -1
- data/db/migrate/20150115155947_add_scaptimony_scap_content_digest.rb +1 -1
- data/db/migrate/20150821100137_migrate_from_scaptimony.rb +1 -1
- data/db/migrate/20160830113437_remove_deleted_policy.rb +1 -1
- data/db/migrate/20160925213031_change_scap_widget_names.rb +8 -8
- data/db/migrate/20161223153249_add_permissions_to_arf_report.rb +4 -4
- data/db/seeds.d/75-job_templates.rb +6 -1
- data/db/seeds.d/openscap_feature.rb +1 -1
- data/lib/foreman_openscap/data_migration.rb +1 -2
- data/lib/foreman_openscap/engine.rb +33 -34
- data/lib/foreman_openscap/helper.rb +5 -7
- data/lib/foreman_openscap/message_cleaner.rb +32 -0
- data/lib/foreman_openscap/version.rb +1 -1
- data/lib/tasks/foreman_openscap_tasks.rake +12 -0
- data/locale/de/foreman_openscap.po +205 -43
- data/locale/en_GB/foreman_openscap.po +205 -43
- data/locale/es/foreman_openscap.po +205 -43
- data/locale/foreman_openscap.pot +418 -185
- data/locale/fr/foreman_openscap.po +205 -43
- data/locale/gl/foreman_openscap.po +205 -43
- data/locale/it/foreman_openscap.po +205 -43
- data/locale/ja/foreman_openscap.po +205 -43
- data/locale/ko/foreman_openscap.po +205 -43
- data/locale/pt_BR/foreman_openscap.po +205 -43
- data/locale/ru/foreman_openscap.po +205 -43
- data/locale/sv_SE/foreman_openscap.po +205 -43
- data/locale/zh_CN/foreman_openscap.po +205 -43
- data/locale/zh_TW/foreman_openscap.po +205 -43
- data/test/factories/arf_report_factory.rb +2 -2
- data/test/factories/asset_factory.rb +5 -0
- data/test/factories/compliance_host_factory.rb +4 -4
- data/test/factories/compliance_log_factory.rb +9 -4
- data/test/files/arf_report/arf_report.json +1 -0
- data/test/files/arf_report/arf_report_msg_desc_changed.json +1 -0
- data/test/files/arf_report/arf_report_msg_value_changed.json +1 -0
- data/test/functional/api/v2/compliance/arf_reports_controller_test.rb +111 -1
- data/test/functional/api/v2/compliance/policies_controller_test.rb +1 -1
- data/test/functional/api/v2/compliance/tailoring_files_controller_test.rb +4 -4
- data/test/test_plugin_helper.rb +4 -4
- data/test/unit/arf_report_test.rb +5 -5
- data/test/unit/concerns/host_extensions_test.rb +64 -4
- data/test/unit/message_cleaner_test.rb +31 -0
- data/test/unit/policy_mailer_test.rb +1 -2
- data/test/unit/scap_content_test.rb +3 -5
- data/test/unit/services/report_dashboard/data_test.rb +1 -1
- data/test/unit/services/tailoring_files_proxy_check_test.rb +4 -4
- metadata +12 -6
|
@@ -21,11 +21,11 @@ module ForemanOpenscap
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
assets_to_precompile =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end
|
|
24
|
+
Dir.chdir(root) do
|
|
25
|
+
Dir['app/assets/javascripts/foreman_openscap/**/*', 'app/assets/stylesheets/foreman_openscap/**/*'].map do |f|
|
|
26
|
+
f.split(File::SEPARATOR, 4).last
|
|
28
27
|
end
|
|
28
|
+
end
|
|
29
29
|
|
|
30
30
|
initializer 'foreman_openscap.assets.precompile' do |app|
|
|
31
31
|
app.config.assets.precompile += assets_to_precompile
|
|
@@ -33,7 +33,7 @@ module ForemanOpenscap
|
|
|
33
33
|
|
|
34
34
|
initializer 'foreman_openscap.configure_assets', :group => :assets do
|
|
35
35
|
SETTINGS[:foreman_openscap] =
|
|
36
|
-
|
|
36
|
+
{:assets => {:precompile => assets_to_precompile}}
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
initializer 'foreman_openscap.apipie' do
|
|
@@ -51,42 +51,42 @@ module ForemanOpenscap
|
|
|
51
51
|
|
|
52
52
|
# Add permissions
|
|
53
53
|
security_block :foreman_openscap do
|
|
54
|
-
permission :view_arf_reports, {:arf_reports =>
|
|
55
|
-
|
|
56
|
-
'api/v2/compliance/arf_reports' =>
|
|
54
|
+
permission :view_arf_reports, {:arf_reports => %i(index show parse_html show_html
|
|
55
|
+
parse_bzip auto_complete_search download_html),
|
|
56
|
+
'api/v2/compliance/arf_reports' => %i(index show download download_html),
|
|
57
57
|
:compliance_hosts => [:show]},
|
|
58
58
|
:resource_type => 'ForemanOpenscap::ArfReport'
|
|
59
|
-
permission :destroy_arf_reports, {:arf_reports =>
|
|
59
|
+
permission :destroy_arf_reports, {:arf_reports => %i(destroy delete_multiple submit_delete_multiple),
|
|
60
60
|
'api/v2/compliance/arf_reports' => [:destroy]},
|
|
61
61
|
:resource_type => 'ForemanOpenscap::ArfReport'
|
|
62
62
|
permission :create_arf_reports, {'api/v2/compliance/arf_reports' => [:create]},
|
|
63
63
|
:resource_type => 'ForemanOpenscap::ArfReport'
|
|
64
64
|
|
|
65
|
-
permission :view_policies, {:policies =>
|
|
65
|
+
permission :view_policies, {:policies => %i(index show parse auto_complete_search),
|
|
66
66
|
:policy_dashboard => [:index],
|
|
67
67
|
:compliance_dashboard => [:index],
|
|
68
|
-
'api/v2/compliance/policies' =>
|
|
68
|
+
'api/v2/compliance/policies' => %i(index show content)},
|
|
69
69
|
:resource_type => 'ForemanOpenscap::Policy'
|
|
70
|
-
permission :edit_policies, {:policies =>
|
|
70
|
+
permission :edit_policies, {:policies => %i(edit update scap_content_selected),
|
|
71
71
|
'api/v2/compliance/policies' => [:update]},
|
|
72
72
|
:resource_type => 'ForemanOpenscap::Policy'
|
|
73
|
-
permission :create_policies, {:policies =>
|
|
73
|
+
permission :create_policies, {:policies => %i(new create),
|
|
74
74
|
'api/v2/compliance/policies' => [:create]},
|
|
75
75
|
:resource_type => 'ForemanOpenscap::Policy'
|
|
76
76
|
permission :destroy_policies, {:policies => [:destroy],
|
|
77
77
|
'api/v2/compliance/policies' => [:destroy]},
|
|
78
78
|
:resource_type => 'ForemanOpenscap::Policy'
|
|
79
|
-
permission :assign_policies, {:policies =>
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
permission :assign_policies, {:policies => %i(select_multiple_hosts update_multiple_hosts
|
|
80
|
+
disassociate_multiple_hosts
|
|
81
|
+
remove_policy_from_multiple_hosts)},
|
|
82
82
|
:resource_type => 'ForemanOpenscap::Policy'
|
|
83
|
-
permission :view_scap_contents, {:scap_contents =>
|
|
84
|
-
'api/v2/compliance/scap_contents' =>
|
|
83
|
+
permission :view_scap_contents, {:scap_contents => %i(index show auto_complete_search),
|
|
84
|
+
'api/v2/compliance/scap_contents' => %i(index show xml)},
|
|
85
85
|
:resource_type => 'ForemanOpenscap::ScapContent'
|
|
86
|
-
permission :edit_scap_contents, {:scap_contents =>
|
|
86
|
+
permission :edit_scap_contents, {:scap_contents => %i(edit update),
|
|
87
87
|
'api/v2/compliance/scap_contents' => [:update]},
|
|
88
88
|
:resource_type => 'ForemanOpenscap::ScapContent'
|
|
89
|
-
permission :create_scap_contents, {:scap_contents =>
|
|
89
|
+
permission :create_scap_contents, {:scap_contents => %i(new create),
|
|
90
90
|
'api/v2/compliance/scap_contents' => [:create]},
|
|
91
91
|
:resource_type => 'ForemanOpenscap::ScapContent'
|
|
92
92
|
permission :destroy_scap_contents, {:scap_contents => [:destroy],
|
|
@@ -94,15 +94,15 @@ module ForemanOpenscap
|
|
|
94
94
|
:resource_type => 'ForemanOpenscap::ScapContent'
|
|
95
95
|
permission :edit_hosts, { :hosts => [:openscap_proxy_changed] }, :resource_type => "Host"
|
|
96
96
|
permission :edit_hostgroups, { :hostgroups => [:openscap_proxy_changed] }, :resource_type => "Hostgroup"
|
|
97
|
-
permission :create_tailoring_files, { :tailoring_files =>
|
|
97
|
+
permission :create_tailoring_files, { :tailoring_files => %i(create new),
|
|
98
98
|
'api/v2/compliance/tailoring_files' => [:create]},
|
|
99
99
|
:resource_type => 'ForemanOpenscap::TailoringFile'
|
|
100
|
-
permission :view_tailoring_files, { :tailoring_files =>
|
|
100
|
+
permission :view_tailoring_files, { :tailoring_files => %i(index auto_complete_search xml),
|
|
101
101
|
:policies => [:tailoring_file_selected],
|
|
102
|
-
'api/v2/compliance/tailoring_files' =>
|
|
102
|
+
'api/v2/compliance/tailoring_files' => %i(show xml index),
|
|
103
103
|
'api/v2/compliance/policies' => [:tailoring] },
|
|
104
104
|
:resource_type => 'ForemanOpenscap::TailoringFile'
|
|
105
|
-
permission :edit_tailoring_files, { :tailoring_files =>
|
|
105
|
+
permission :edit_tailoring_files, { :tailoring_files => %i(edit update),
|
|
106
106
|
'api/v2/compliance/tailoring_files' => [:update] },
|
|
107
107
|
:resource_type => 'ForemanOpenscap::TailoringFile'
|
|
108
108
|
permission :destroy_tailoring_files, { :tailoring_files => [:destroy],
|
|
@@ -112,12 +112,12 @@ module ForemanOpenscap
|
|
|
112
112
|
:resource_type => 'SmartProxy'
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
-
role "Compliance viewer",
|
|
116
|
-
role "Compliance manager",
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
role "Compliance viewer", %i(view_arf_reports view_policies view_scap_contents view_tailoring_files view_openscap_proxies)
|
|
116
|
+
role "Compliance manager", %i(view_arf_reports view_policies view_scap_contents
|
|
117
|
+
destroy_arf_reports edit_policies edit_scap_contents assign_policies
|
|
118
|
+
create_policies create_scap_contents destroy_policies destroy_scap_contents
|
|
119
|
+
create_tailoring_files view_tailoring_files edit_tailoring_files destroy_tailoring_files
|
|
120
|
+
view_openscap_proxies)
|
|
121
121
|
role "Create ARF report", [:create_arf_reports] # special as only Proxy can create
|
|
122
122
|
|
|
123
123
|
add_all_permissions_to_default_roles
|
|
@@ -150,8 +150,7 @@ module ForemanOpenscap
|
|
|
150
150
|
"dashboard link hosts in error state", "dashboard link good host reports",
|
|
151
151
|
"dashboard link hosts that had pending changes", "dashboard link out of sync hosts",
|
|
152
152
|
"dashboard link hosts with no reports", "dashboard link hosts with alerts disabled",
|
|
153
|
-
"widgets not in dashboard show up in list"]
|
|
154
|
-
})
|
|
153
|
+
"widgets not in dashboard show up in list"]})
|
|
155
154
|
# strong params
|
|
156
155
|
parameter_filter Host::Managed, :openscap_proxy_id, :openscap_proxy
|
|
157
156
|
parameter_filter Hostgroup, :openscap_proxy_id, :openscap_proxy
|
|
@@ -171,11 +170,11 @@ module ForemanOpenscap
|
|
|
171
170
|
end
|
|
172
171
|
|
|
173
172
|
add_controller_action_scope(::Api::V2::HostsController, :index) do |base_scope|
|
|
174
|
-
base_scope.
|
|
173
|
+
base_scope.preload(:policies)
|
|
175
174
|
end
|
|
176
175
|
|
|
177
176
|
add_controller_action_scope(::HostsController, :index) do |base_scope|
|
|
178
|
-
base_scope.
|
|
177
|
+
base_scope.preload(:policies)
|
|
179
178
|
end
|
|
180
179
|
end
|
|
181
180
|
end
|
|
@@ -6,22 +6,20 @@ module ForemanOpenscap::Helper
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def self.find_name_or_uuid_by_host(host)
|
|
9
|
-
|
|
9
|
+
host.respond_to?(:subscription_facet) && !host.subscription_facet.nil? ? host.subscription_facet.try(:uuid) : host.name
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
private
|
|
13
|
-
|
|
14
12
|
def self.find_host_by_name_or_uuid(cname)
|
|
15
13
|
if Facets.registered_facets.keys.include?(:subscription_facet)
|
|
16
|
-
host = Katello::Host::SubscriptionFacet.
|
|
17
|
-
host ||= Host.
|
|
14
|
+
host = Katello::Host::SubscriptionFacet.find_by(uuid: cname).try(:host)
|
|
15
|
+
host ||= Host.find_by(name: cname)
|
|
18
16
|
else
|
|
19
|
-
host = Host.
|
|
17
|
+
host = Host.find_by(name: cname)
|
|
20
18
|
end
|
|
21
19
|
|
|
22
20
|
unless host
|
|
23
21
|
Rails.logger.error "Could not find Host with name: #{cname}"
|
|
24
|
-
|
|
22
|
+
raise ActiveRecord::RecordNotFound
|
|
25
23
|
end
|
|
26
24
|
host
|
|
27
25
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module ForemanOpenscap
|
|
2
|
+
class MessageCleaner
|
|
3
|
+
def clean
|
|
4
|
+
ForemanOpenscap::Policy.unscoped.all.find_in_batches do |batch|
|
|
5
|
+
batch.each do |policy|
|
|
6
|
+
process_policy policy
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def process_policy(policy)
|
|
14
|
+
reports_of_policy = ForemanOpenscap::ArfReport.unscoped
|
|
15
|
+
.of_policy(policy)
|
|
16
|
+
.order("#{ForemanOpenscap::ArfReport.table_name}.created_at DESC")
|
|
17
|
+
latest = reports_of_policy.first
|
|
18
|
+
reports_of_policy.each do |report|
|
|
19
|
+
next if report == latest
|
|
20
|
+
report.logs.each do |log|
|
|
21
|
+
latest_log = latest.logs.find_by(:source_id => log.source_id)
|
|
22
|
+
next unless latest_log
|
|
23
|
+
next if log == latest_log
|
|
24
|
+
latest_message = latest_log.message
|
|
25
|
+
msg = log.message
|
|
26
|
+
log.update_attribute('message_id', latest_message.id)
|
|
27
|
+
msg.destroy! if msg.logs.empty?
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# Tasks
|
|
2
2
|
namespace :foreman_openscap do
|
|
3
3
|
require 'foreman_openscap/bulk_upload'
|
|
4
|
+
require 'foreman_openscap/message_cleaner'
|
|
5
|
+
|
|
4
6
|
namespace :bulk_upload do
|
|
5
7
|
desc 'Bulk upload SCAP content from directory'
|
|
6
8
|
task :directory, [:directory] => [:environment] do |task, args|
|
|
7
9
|
abort("# No such directory, please check the path you have provided. #") unless args[:directory].blank? || Dir.exist?(args[:directory])
|
|
10
|
+
User.current = User.anonymous_admin
|
|
8
11
|
ForemanOpenscap::BulkUpload.new.upload_from_directory(args[:directory])
|
|
9
12
|
end
|
|
10
13
|
|
|
@@ -13,10 +16,12 @@ namespace :foreman_openscap do
|
|
|
13
16
|
files_array.each do |file|
|
|
14
17
|
abort("# #{file} is a directory, expecting file. Try using 'rake foreman_openscap:bulk_upload:directory' with this directory. #") if File.directory?(file)
|
|
15
18
|
end
|
|
19
|
+
User.current = User.anonymous_admin
|
|
16
20
|
ForemanOpenscap::BulkUpload.new.upload_from_files(files_array)
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
task :default => [:environment] do
|
|
24
|
+
User.current = User.anonymous_admin
|
|
20
25
|
ForemanOpenscap::BulkUpload.new(true).generate_scap_default_content
|
|
21
26
|
end
|
|
22
27
|
end
|
|
@@ -44,6 +49,13 @@ namespace :foreman_openscap do
|
|
|
44
49
|
end
|
|
45
50
|
Rake::Task['rubocop_foreman_openscap'].invoke
|
|
46
51
|
end
|
|
52
|
+
|
|
53
|
+
desc "Clean duplicate messages for ArfReport"
|
|
54
|
+
task :clean_messages => :environment do
|
|
55
|
+
puts 'Searching for duplicated messages and merging them... this can take a long time'
|
|
56
|
+
ForemanOpenscap::MessageCleaner.new.clean
|
|
57
|
+
puts 'Done'
|
|
58
|
+
end
|
|
47
59
|
end
|
|
48
60
|
|
|
49
61
|
# Tests
|