foreman_openscap 1.0.10 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/api/v2/compliance/arf_reports_controller.rb +11 -3
- data/app/controllers/api/v2/compliance/policies_controller.rb +2 -9
- data/app/controllers/api/v2/compliance/scap_content_profiles_controller.rb +15 -0
- data/app/controllers/api/v2/compliance/scap_contents_controller.rb +2 -8
- data/app/controllers/api/v2/compliance/tailoring_files_controller.rb +2 -8
- data/app/controllers/concerns/foreman_openscap/api/v2/scap_api_controller_extensions.rb +9 -0
- data/app/controllers/policies_controller.rb +1 -1
- data/app/helpers/compliance_hosts_helper.rb +23 -0
- data/app/helpers/concerns/foreman_openscap/hosts_helper_extensions.rb +0 -6
- data/app/models/concerns/foreman_openscap/host_extensions.rb +1 -1
- data/app/models/concerns/foreman_openscap/smart_proxy_extensions.rb +1 -1
- data/app/models/foreman_openscap/policy.rb +12 -0
- data/app/models/foreman_openscap/scap_content_profile.rb +3 -0
- data/app/services/foreman_openscap/lookup_key_overrider.rb +3 -2
- data/app/views/api/v2/compliance/scap_content_profiles/base.json.rabl +3 -0
- data/app/views/api/v2/compliance/scap_content_profiles/index.json.rabl +3 -0
- data/app/views/api/v2/compliance/scap_content_profiles/main.json.rabl +9 -0
- data/app/views/arf_reports/_list.html.erb +1 -1
- data/app/views/arf_reports/welcome.html.erb +2 -0
- data/app/views/hosts/select_multiple_openscap_proxy.html.erb +1 -1
- data/app/views/policies/disassociate_multiple_hosts.html.erb +1 -1
- data/app/views/policies/select_multiple_hosts.html.erb +1 -1
- data/config/routes.rb +2 -0
- data/db/migrate/20150929152345_move_arf_reports_to_reports_table.rb +0 -2
- data/db/migrate/20200117135424_migrate_port_overrides_to_int.rb +24 -0
- data/lib/foreman_openscap/engine.rb +15 -10
- data/lib/foreman_openscap/helper.rb +1 -1
- data/lib/foreman_openscap/version.rb +1 -1
- data/locale/action_names.rb +1 -1
- data/locale/de/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/de/foreman_openscap.po +244 -241
- data/locale/en_GB/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/en_GB/foreman_openscap.po +38 -38
- data/locale/es/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/es/foreman_openscap.po +285 -283
- data/locale/foreman_openscap.pot +119 -120
- data/locale/fr/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/fr/foreman_openscap.po +292 -284
- data/locale/gl/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/gl/foreman_openscap.po +49 -49
- data/locale/it/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/it/foreman_openscap.po +74 -73
- data/locale/ja/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/ja/foreman_openscap.po +284 -282
- data/locale/ko/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/ko/foreman_openscap.po +155 -155
- data/locale/pt_BR/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/pt_BR/foreman_openscap.po +287 -280
- data/locale/ru/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/ru/foreman_openscap.po +163 -160
- data/locale/sv_SE/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/sv_SE/foreman_openscap.po +49 -49
- data/locale/zh_CN/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/zh_CN/foreman_openscap.po +284 -281
- data/locale/zh_TW/LC_MESSAGES/foreman_openscap.mo +0 -0
- data/locale/zh_TW/foreman_openscap.po +151 -150
- data/test/functional/api/v2/compliance/arf_reports_controller_test.rb +0 -3
- data/test/functional/api/v2/compliance/scap_content_profiles_controller_test.rb +15 -0
- data/test/test_plugin_helper.rb +2 -2
- data/test/unit/concerns/host_extensions_test.rb +7 -0
- data/test/unit/policy_test.rb +19 -0
- metadata +24 -32
- data/app/overrides/hosts/overview/host_compliance_status.rb +0 -4
- data/app/views/compliance_hosts/_compliance_status.erb +0 -6
- data/locale/de/foreman_openscap.edit.po +0 -0
- data/locale/en_GB/foreman_openscap.edit.po +0 -0
- data/locale/es/foreman_openscap.edit.po +0 -0
- data/locale/fr/foreman_openscap.edit.po +0 -0
- data/locale/gl/foreman_openscap.edit.po +0 -0
- data/locale/it/foreman_openscap.edit.po +0 -0
- data/locale/ja/foreman_openscap.edit.po +0 -0
- data/locale/ko/foreman_openscap.edit.po +0 -0
- data/locale/pt_BR/foreman_openscap.edit.po +0 -0
- data/locale/ru/foreman_openscap.edit.po +0 -0
- data/locale/sv_SE/foreman_openscap.edit.po +0 -0
- data/locale/zh_CN/foreman_openscap.edit.po +0 -0
- data/locale/zh_TW/foreman_openscap.edit.po +0 -0
@@ -3,9 +3,6 @@ require 'tmpdir'
|
|
3
3
|
|
4
4
|
class Api::V2::Compliance::ArfReportsControllerTest < ActionController::TestCase
|
5
5
|
setup do
|
6
|
-
# required for mysql where database cleaner does not cleanup things properly
|
7
|
-
# because of arf_create does explicit transaction commit
|
8
|
-
Message.delete_all
|
9
6
|
# override validation of policy (puppetclass, lookup_key overrides)
|
10
7
|
ForemanOpenscap::Policy.any_instance.stubs(:valid?).returns(true)
|
11
8
|
@host = FactoryBot.create(:compliance_host)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class Api::V2::Compliance::ScapContentProfilesControllerTest < ActionController::TestCase
|
4
|
+
test "should get index" do
|
5
|
+
2.times do
|
6
|
+
FactoryBot.create(:scap_content_profile)
|
7
|
+
end
|
8
|
+
FactoryBot.create(:scap_content, :scap_content_profiles => [ForemanOpenscap::ScapContentProfile.first])
|
9
|
+
FactoryBot.create(:tailoring_file, :scap_content_profiles => [ForemanOpenscap::ScapContentProfile.last])
|
10
|
+
get :index, :session => set_session_user
|
11
|
+
response = ActiveSupport::JSON.decode(@response.body)
|
12
|
+
assert response['results'].any?
|
13
|
+
assert_response :success
|
14
|
+
end
|
15
|
+
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -55,8 +55,8 @@ module ScapTestCommon
|
|
55
55
|
def create_report_with_rules(host, rule_names, rule_results)
|
56
56
|
raise "rule_names and rule_results should have the same length!" if rule_names.size != rule_results.size
|
57
57
|
metrics = {
|
58
|
-
'passed' => rule_results.
|
59
|
-
'failed' => rule_results.
|
58
|
+
'passed' => rule_results.count { |result| result == 'pass' },
|
59
|
+
'failed' => rule_results.count { |result| result == 'fail' },
|
60
60
|
'othered' => rule_results.reject { |result| result == 'fail' || result == 'pass' }.count
|
61
61
|
}
|
62
62
|
report = FactoryBot.create(:arf_report, :host_id => host.id, :metrics => metrics, :status => metrics)
|
@@ -164,6 +164,13 @@ class HostExtensionsTest < ActiveSupport::TestCase
|
|
164
164
|
assert_equal host.errors.full_messages.first, "Openscap proxy with id #{proxy.id} doesn't exist or is not assigned to proper organization and/or location"
|
165
165
|
end
|
166
166
|
|
167
|
+
test 'should delete asset together with host' do
|
168
|
+
host = FactoryBot.create(:compliance_host)
|
169
|
+
FactoryBot.create(:asset_policy, :asset => host.asset, :policy => @policy)
|
170
|
+
assert host.destroy
|
171
|
+
assert_empty ForemanOpenscap::Asset.where(:assetable_id => host.id, :assetable_type => 'Host::Base')
|
172
|
+
end
|
173
|
+
|
167
174
|
private
|
168
175
|
|
169
176
|
def setup_hosts_with_policy
|
data/test/unit/policy_test.rb
CHANGED
@@ -279,4 +279,23 @@ class PolicyTest < ActiveSupport::TestCase
|
|
279
279
|
refute policy.hostgroups.empty?
|
280
280
|
refute policy.hosts.empty?
|
281
281
|
end
|
282
|
+
|
283
|
+
test "should change deploy type" do
|
284
|
+
policy = FactoryBot.create(:policy, :scap_content => @scap_content, :scap_content_profile => @scap_profile)
|
285
|
+
setup_puppet_class
|
286
|
+
policy.change_deploy_type({ :deploy_by => 'puppet' })
|
287
|
+
refute policy.errors.any?
|
288
|
+
policy.reload
|
289
|
+
assert 'puppet', policy.deploy_by
|
290
|
+
end
|
291
|
+
|
292
|
+
test 'should not change any attributes when cannot change deploy_by' do
|
293
|
+
name = 'my-policy'
|
294
|
+
policy = FactoryBot.create(:policy, :name => name, :scap_content => @scap_content, :scap_content_profile => @scap_profile)
|
295
|
+
policy.change_deploy_type({ :name => 'salty policy', :deploy_by => 'salt' })
|
296
|
+
assert policy.errors.any?
|
297
|
+
policy.reload
|
298
|
+
assert_equal policy.deploy_by, 'manual'
|
299
|
+
assert_equal policy.name, name
|
300
|
+
end
|
282
301
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_openscap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
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:
|
11
|
+
date: 2020-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
description: Foreman plug-in for managing security compliance reports
|
28
28
|
email:
|
29
29
|
- slukasik@redhat.com
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- app/assets/stylesheets/foreman_openscap/scap_breakdown_chart.css
|
47
47
|
- app/controllers/api/v2/compliance/arf_reports_controller.rb
|
48
48
|
- app/controllers/api/v2/compliance/policies_controller.rb
|
49
|
+
- app/controllers/api/v2/compliance/scap_content_profiles_controller.rb
|
49
50
|
- app/controllers/api/v2/compliance/scap_contents_controller.rb
|
50
51
|
- app/controllers/api/v2/compliance/tailoring_files_controller.rb
|
51
52
|
- app/controllers/arf_reports_controller.rb
|
@@ -56,6 +57,7 @@ files:
|
|
56
57
|
- app/controllers/concerns/foreman/controller/parameters/scap_content.rb
|
57
58
|
- app/controllers/concerns/foreman/controller/parameters/tailoring_file.rb
|
58
59
|
- app/controllers/concerns/foreman_openscap/api/v2/hosts_controller_extensions.rb
|
60
|
+
- app/controllers/concerns/foreman_openscap/api/v2/scap_api_controller_extensions.rb
|
59
61
|
- app/controllers/concerns/foreman_openscap/arf_reports_controller_common_extensions.rb
|
60
62
|
- app/controllers/concerns/foreman_openscap/body_log_extensions.rb
|
61
63
|
- app/controllers/concerns/foreman_openscap/hosts_and_hostgroups_controller_extensions.rb
|
@@ -96,7 +98,6 @@ files:
|
|
96
98
|
- app/models/foreman_openscap/scap_content.rb
|
97
99
|
- app/models/foreman_openscap/scap_content_profile.rb
|
98
100
|
- app/models/foreman_openscap/tailoring_file.rb
|
99
|
-
- app/overrides/hosts/overview/host_compliance_status.rb
|
100
101
|
- app/services/foreman_openscap/arf_report_status_calculator.rb
|
101
102
|
- app/services/foreman_openscap/client_config/ansible.rb
|
102
103
|
- app/services/foreman_openscap/client_config/base.rb
|
@@ -125,6 +126,9 @@ files:
|
|
125
126
|
- app/views/api/v2/compliance/policies/index.json.rabl
|
126
127
|
- app/views/api/v2/compliance/policies/main.json.rabl
|
127
128
|
- app/views/api/v2/compliance/policies/show.json.rabl
|
129
|
+
- app/views/api/v2/compliance/scap_content_profiles/base.json.rabl
|
130
|
+
- app/views/api/v2/compliance/scap_content_profiles/index.json.rabl
|
131
|
+
- app/views/api/v2/compliance/scap_content_profiles/main.json.rabl
|
128
132
|
- app/views/api/v2/compliance/scap_contents/base.json.rabl
|
129
133
|
- app/views/api/v2/compliance/scap_contents/create.json.rabl
|
130
134
|
- app/views/api/v2/compliance/scap_contents/index.json.rabl
|
@@ -146,7 +150,6 @@ files:
|
|
146
150
|
- app/views/arf_reports/show.html.erb
|
147
151
|
- app/views/arf_reports/show_html.html.erb
|
148
152
|
- app/views/arf_reports/welcome.html.erb
|
149
|
-
- app/views/compliance_hosts/_compliance_status.erb
|
150
153
|
- app/views/compliance_hosts/show.html.erb
|
151
154
|
- app/views/dashboard/_compliance_host_reports_widget.html.erb
|
152
155
|
- app/views/dashboard/_compliance_reports_breakdown_widget.html.erb
|
@@ -240,6 +243,7 @@ files:
|
|
240
243
|
- db/migrate/20171011134112_remove_arf_reports_without_policy.rb
|
241
244
|
- db/migrate/20171016125613_add_content_title_unique_constraint.foreman_openscap.rb
|
242
245
|
- db/migrate/20190103093409_add_deployment_option_to_policy.foreman_openscap.rb
|
246
|
+
- db/migrate/20200117135424_migrate_port_overrides_to_int.rb
|
243
247
|
- db/seeds.d/75-job_templates.rb
|
244
248
|
- db/seeds.d/openscap_feature.rb
|
245
249
|
- db/seeds.d/openscap_policy_notification.rb
|
@@ -254,45 +258,32 @@ files:
|
|
254
258
|
- locale/Makefile
|
255
259
|
- locale/action_names.rb
|
256
260
|
- locale/de/LC_MESSAGES/foreman_openscap.mo
|
257
|
-
- locale/de/foreman_openscap.edit.po
|
258
261
|
- locale/de/foreman_openscap.po
|
259
262
|
- locale/en_GB/LC_MESSAGES/foreman_openscap.mo
|
260
|
-
- locale/en_GB/foreman_openscap.edit.po
|
261
263
|
- locale/en_GB/foreman_openscap.po
|
262
264
|
- locale/es/LC_MESSAGES/foreman_openscap.mo
|
263
|
-
- locale/es/foreman_openscap.edit.po
|
264
265
|
- locale/es/foreman_openscap.po
|
265
266
|
- locale/foreman_openscap.pot
|
266
267
|
- locale/fr/LC_MESSAGES/foreman_openscap.mo
|
267
|
-
- locale/fr/foreman_openscap.edit.po
|
268
268
|
- locale/fr/foreman_openscap.po
|
269
269
|
- locale/gl/LC_MESSAGES/foreman_openscap.mo
|
270
|
-
- locale/gl/foreman_openscap.edit.po
|
271
270
|
- locale/gl/foreman_openscap.po
|
272
271
|
- locale/it/LC_MESSAGES/foreman_openscap.mo
|
273
|
-
- locale/it/foreman_openscap.edit.po
|
274
272
|
- locale/it/foreman_openscap.po
|
275
273
|
- locale/ja/LC_MESSAGES/foreman_openscap.mo
|
276
|
-
- locale/ja/foreman_openscap.edit.po
|
277
274
|
- locale/ja/foreman_openscap.po
|
278
275
|
- locale/ko/LC_MESSAGES/foreman_openscap.mo
|
279
|
-
- locale/ko/foreman_openscap.edit.po
|
280
276
|
- locale/ko/foreman_openscap.po
|
281
277
|
- locale/pt_BR/LC_MESSAGES/foreman_openscap.mo
|
282
|
-
- locale/pt_BR/foreman_openscap.edit.po
|
283
278
|
- locale/pt_BR/foreman_openscap.po
|
284
279
|
- locale/ru/LC_MESSAGES/foreman_openscap.mo
|
285
|
-
- locale/ru/foreman_openscap.edit.po
|
286
280
|
- locale/ru/foreman_openscap.po
|
287
281
|
- locale/sv_SE/LC_MESSAGES/foreman_openscap.mo
|
288
|
-
- locale/sv_SE/foreman_openscap.edit.po
|
289
282
|
- locale/sv_SE/foreman_openscap.po
|
290
283
|
- locale/zanata.xml
|
291
284
|
- locale/zh_CN/LC_MESSAGES/foreman_openscap.mo
|
292
|
-
- locale/zh_CN/foreman_openscap.edit.po
|
293
285
|
- locale/zh_CN/foreman_openscap.po
|
294
286
|
- locale/zh_TW/LC_MESSAGES/foreman_openscap.mo
|
295
|
-
- locale/zh_TW/foreman_openscap.edit.po
|
296
287
|
- locale/zh_TW/foreman_openscap.po
|
297
288
|
- test/factories/arf_report_factory.rb
|
298
289
|
- test/factories/asset_factory.rb
|
@@ -311,6 +302,7 @@ files:
|
|
311
302
|
- test/files/tailoring_files/ssg-firefox-ds-tailoring.xml
|
312
303
|
- test/functional/api/v2/compliance/arf_reports_controller_test.rb
|
313
304
|
- test/functional/api/v2/compliance/policies_controller_test.rb
|
305
|
+
- test/functional/api/v2/compliance/scap_content_profiles_controller_test.rb
|
314
306
|
- test/functional/api/v2/compliance/scap_contents_controller_test.rb
|
315
307
|
- test/functional/api/v2/compliance/tailoring_files_controller_test.rb
|
316
308
|
- test/functional/api/v2/hosts_controller_test.rb
|
@@ -356,19 +348,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
356
348
|
- !ruby/object:Gem::Version
|
357
349
|
version: '0'
|
358
350
|
requirements: []
|
359
|
-
|
360
|
-
rubygems_version: 2.6.14
|
351
|
+
rubygems_version: 3.1.2
|
361
352
|
signing_key:
|
362
353
|
specification_version: 4
|
363
354
|
summary: Foreman plug-in for displaying OpenSCAP audit reports
|
364
355
|
test_files:
|
365
356
|
- test/factories/arf_report_factory.rb
|
366
357
|
- test/factories/asset_factory.rb
|
358
|
+
- test/factories/compliance_host_factory.rb
|
367
359
|
- test/factories/compliance_log_factory.rb
|
368
360
|
- test/factories/policy_arf_report_factory.rb
|
369
361
|
- test/factories/policy_factory.rb
|
370
362
|
- test/factories/scap_content_related.rb
|
371
|
-
- test/factories/compliance_host_factory.rb
|
372
363
|
- test/files/arf_report/arf_report.bz2
|
373
364
|
- test/files/arf_report/arf_report.html
|
374
365
|
- test/files/arf_report/arf_report.json
|
@@ -379,19 +370,23 @@ test_files:
|
|
379
370
|
- test/files/tailoring_files/ssg-firefox-ds-tailoring.xml
|
380
371
|
- test/functional/api/v2/compliance/arf_reports_controller_test.rb
|
381
372
|
- test/functional/api/v2/compliance/policies_controller_test.rb
|
373
|
+
- test/functional/api/v2/compliance/scap_content_profiles_controller_test.rb
|
382
374
|
- test/functional/api/v2/compliance/scap_contents_controller_test.rb
|
383
375
|
- test/functional/api/v2/compliance/tailoring_files_controller_test.rb
|
384
376
|
- test/functional/api/v2/hosts_controller_test.rb
|
385
377
|
- test/functional/arf_reports_controller_test.rb
|
386
378
|
- test/functional/openscap_proxies_controller_test.rb
|
387
379
|
- test/functional/tailoring_files_controller_test.rb
|
380
|
+
- test/helpers/arf_report_dashboard_helper_test.rb
|
381
|
+
- test/helpers/policy_dashboard_helper_test.rb
|
388
382
|
- test/lib/foreman_openscap/bulk_upload_test.rb
|
389
|
-
- test/test_plugin_helper.rb
|
390
383
|
- test/unit/arf_report_status_calculator_test.rb
|
384
|
+
- test/unit/arf_report_test.rb
|
391
385
|
- test/unit/compliance_status_test.rb
|
392
|
-
- test/unit/concerns/openscap_proxy_extenstions_test.rb
|
393
386
|
- test/unit/concerns/host_extensions_test.rb
|
387
|
+
- test/unit/concerns/openscap_proxy_extenstions_test.rb
|
394
388
|
- test/unit/message_cleaner_test.rb
|
389
|
+
- test/unit/openscap_host_test.rb
|
395
390
|
- test/unit/policy_mailer_test.rb
|
396
391
|
- test/unit/scap_content_test.rb
|
397
392
|
- test/unit/services/config_name_service_test.rb
|
@@ -400,8 +395,5 @@ test_files:
|
|
400
395
|
- test/unit/services/report_dashboard/data_test.rb
|
401
396
|
- test/unit/services/tailoring_files_proxy_check_test.rb
|
402
397
|
- test/unit/tailoring_file_test.rb
|
403
|
-
- test/unit/arf_report_test.rb
|
404
|
-
- test/unit/openscap_host_test.rb
|
405
398
|
- test/unit/policy_test.rb
|
406
|
-
- test/
|
407
|
-
- test/helpers/policy_dashboard_helper_test.rb
|
399
|
+
- test/test_plugin_helper.rb
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|