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.
Files changed (78) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/api/v2/compliance/arf_reports_controller.rb +11 -3
  3. data/app/controllers/api/v2/compliance/policies_controller.rb +2 -9
  4. data/app/controllers/api/v2/compliance/scap_content_profiles_controller.rb +15 -0
  5. data/app/controllers/api/v2/compliance/scap_contents_controller.rb +2 -8
  6. data/app/controllers/api/v2/compliance/tailoring_files_controller.rb +2 -8
  7. data/app/controllers/concerns/foreman_openscap/api/v2/scap_api_controller_extensions.rb +9 -0
  8. data/app/controllers/policies_controller.rb +1 -1
  9. data/app/helpers/compliance_hosts_helper.rb +23 -0
  10. data/app/helpers/concerns/foreman_openscap/hosts_helper_extensions.rb +0 -6
  11. data/app/models/concerns/foreman_openscap/host_extensions.rb +1 -1
  12. data/app/models/concerns/foreman_openscap/smart_proxy_extensions.rb +1 -1
  13. data/app/models/foreman_openscap/policy.rb +12 -0
  14. data/app/models/foreman_openscap/scap_content_profile.rb +3 -0
  15. data/app/services/foreman_openscap/lookup_key_overrider.rb +3 -2
  16. data/app/views/api/v2/compliance/scap_content_profiles/base.json.rabl +3 -0
  17. data/app/views/api/v2/compliance/scap_content_profiles/index.json.rabl +3 -0
  18. data/app/views/api/v2/compliance/scap_content_profiles/main.json.rabl +9 -0
  19. data/app/views/arf_reports/_list.html.erb +1 -1
  20. data/app/views/arf_reports/welcome.html.erb +2 -0
  21. data/app/views/hosts/select_multiple_openscap_proxy.html.erb +1 -1
  22. data/app/views/policies/disassociate_multiple_hosts.html.erb +1 -1
  23. data/app/views/policies/select_multiple_hosts.html.erb +1 -1
  24. data/config/routes.rb +2 -0
  25. data/db/migrate/20150929152345_move_arf_reports_to_reports_table.rb +0 -2
  26. data/db/migrate/20200117135424_migrate_port_overrides_to_int.rb +24 -0
  27. data/lib/foreman_openscap/engine.rb +15 -10
  28. data/lib/foreman_openscap/helper.rb +1 -1
  29. data/lib/foreman_openscap/version.rb +1 -1
  30. data/locale/action_names.rb +1 -1
  31. data/locale/de/LC_MESSAGES/foreman_openscap.mo +0 -0
  32. data/locale/de/foreman_openscap.po +244 -241
  33. data/locale/en_GB/LC_MESSAGES/foreman_openscap.mo +0 -0
  34. data/locale/en_GB/foreman_openscap.po +38 -38
  35. data/locale/es/LC_MESSAGES/foreman_openscap.mo +0 -0
  36. data/locale/es/foreman_openscap.po +285 -283
  37. data/locale/foreman_openscap.pot +119 -120
  38. data/locale/fr/LC_MESSAGES/foreman_openscap.mo +0 -0
  39. data/locale/fr/foreman_openscap.po +292 -284
  40. data/locale/gl/LC_MESSAGES/foreman_openscap.mo +0 -0
  41. data/locale/gl/foreman_openscap.po +49 -49
  42. data/locale/it/LC_MESSAGES/foreman_openscap.mo +0 -0
  43. data/locale/it/foreman_openscap.po +74 -73
  44. data/locale/ja/LC_MESSAGES/foreman_openscap.mo +0 -0
  45. data/locale/ja/foreman_openscap.po +284 -282
  46. data/locale/ko/LC_MESSAGES/foreman_openscap.mo +0 -0
  47. data/locale/ko/foreman_openscap.po +155 -155
  48. data/locale/pt_BR/LC_MESSAGES/foreman_openscap.mo +0 -0
  49. data/locale/pt_BR/foreman_openscap.po +287 -280
  50. data/locale/ru/LC_MESSAGES/foreman_openscap.mo +0 -0
  51. data/locale/ru/foreman_openscap.po +163 -160
  52. data/locale/sv_SE/LC_MESSAGES/foreman_openscap.mo +0 -0
  53. data/locale/sv_SE/foreman_openscap.po +49 -49
  54. data/locale/zh_CN/LC_MESSAGES/foreman_openscap.mo +0 -0
  55. data/locale/zh_CN/foreman_openscap.po +284 -281
  56. data/locale/zh_TW/LC_MESSAGES/foreman_openscap.mo +0 -0
  57. data/locale/zh_TW/foreman_openscap.po +151 -150
  58. data/test/functional/api/v2/compliance/arf_reports_controller_test.rb +0 -3
  59. data/test/functional/api/v2/compliance/scap_content_profiles_controller_test.rb +15 -0
  60. data/test/test_plugin_helper.rb +2 -2
  61. data/test/unit/concerns/host_extensions_test.rb +7 -0
  62. data/test/unit/policy_test.rb +19 -0
  63. metadata +24 -32
  64. data/app/overrides/hosts/overview/host_compliance_status.rb +0 -4
  65. data/app/views/compliance_hosts/_compliance_status.erb +0 -6
  66. data/locale/de/foreman_openscap.edit.po +0 -0
  67. data/locale/en_GB/foreman_openscap.edit.po +0 -0
  68. data/locale/es/foreman_openscap.edit.po +0 -0
  69. data/locale/fr/foreman_openscap.edit.po +0 -0
  70. data/locale/gl/foreman_openscap.edit.po +0 -0
  71. data/locale/it/foreman_openscap.edit.po +0 -0
  72. data/locale/ja/foreman_openscap.edit.po +0 -0
  73. data/locale/ko/foreman_openscap.edit.po +0 -0
  74. data/locale/pt_BR/foreman_openscap.edit.po +0 -0
  75. data/locale/ru/foreman_openscap.edit.po +0 -0
  76. data/locale/sv_SE/foreman_openscap.edit.po +0 -0
  77. data/locale/zh_CN/foreman_openscap.edit.po +0 -0
  78. 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
@@ -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.select { |result| result == 'pass' }.count,
59
- 'failed' => rule_results.select { |result| result == 'fail' }.count,
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
@@ -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: 1.0.10
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: 2019-11-13 00:00:00.000000000 Z
11
+ date: 2020-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: deface
14
+ name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :runtime
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: '2.0'
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
- rubyforge_project:
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/helpers/arf_report_dashboard_helper_test.rb
407
- - test/helpers/policy_dashboard_helper_test.rb
399
+ - test/test_plugin_helper.rb
@@ -1,4 +0,0 @@
1
- Deface::Override.new(:virtual_path => "hosts/show",
2
- :name => "add_compliance_link_to_host",
3
- :insert_bottom => 'td:last',
4
- :partial => 'compliance_hosts/compliance_status')
@@ -1,6 +0,0 @@
1
- <%= link_to(
2
- _('Compliance'),
3
- compliance_host_path(@host.id),
4
- :title => _("Host compliance details"),
5
- :class => 'btn btn-default') if @host.arf_reports.any?
6
- %>
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