foreman_openscap 8.0.2 → 9.0.0

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.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/app/services/foreman_openscap/client_config/ansible.rb +1 -10
  4. data/config/initializers/inflections.rb +0 -2
  5. data/config/routes.rb +0 -15
  6. data/db/migrate/20240313111822_drop_oval.rb +17 -0
  7. data/lib/foreman_openscap/engine.rb +2 -56
  8. data/lib/foreman_openscap/version.rb +1 -1
  9. data/test/factories/compliance_host_factory.rb +0 -12
  10. data/test/test_plugin_helper.rb +0 -2
  11. data/webpack/global_index.js +0 -4
  12. metadata +7 -168
  13. data/app/controllers/api/v2/compliance/oval_contents_controller.rb +0 -72
  14. data/app/controllers/api/v2/compliance/oval_policies_controller.rb +0 -111
  15. data/app/controllers/api/v2/compliance/oval_reports_controller.rb +0 -47
  16. data/app/controllers/concerns/foreman/controller/parameters/oval_content.rb +0 -22
  17. data/app/controllers/concerns/foreman/controller/parameters/oval_policy.rb +0 -22
  18. data/app/graphql/mutations/oval_contents/delete.rb +0 -9
  19. data/app/graphql/mutations/oval_policies/create.rb +0 -33
  20. data/app/graphql/mutations/oval_policies/delete.rb +0 -9
  21. data/app/graphql/mutations/oval_policies/update.rb +0 -15
  22. data/app/graphql/types/cve.rb +0 -17
  23. data/app/graphql/types/oval_check.rb +0 -11
  24. data/app/graphql/types/oval_content.rb +0 -19
  25. data/app/graphql/types/oval_policy.rb +0 -24
  26. data/app/models/concerns/foreman_openscap/oval_facet_host_extensions.rb +0 -38
  27. data/app/models/concerns/foreman_openscap/oval_facet_hostgroup_extensions.rb +0 -31
  28. data/app/models/foreman_openscap/cve.rb +0 -23
  29. data/app/models/foreman_openscap/host/oval_facet.rb +0 -14
  30. data/app/models/foreman_openscap/host_cve.rb +0 -7
  31. data/app/models/foreman_openscap/hostgroup/oval_facet.rb +0 -14
  32. data/app/models/foreman_openscap/hostgroup_oval_facet_oval_policy.rb +0 -6
  33. data/app/models/foreman_openscap/oval_content.rb +0 -28
  34. data/app/models/foreman_openscap/oval_facet_oval_policy.rb +0 -6
  35. data/app/models/foreman_openscap/oval_policy.rb +0 -54
  36. data/app/models/foreman_openscap/oval_status.rb +0 -45
  37. data/app/services/foreman_openscap/oval/check_collection.rb +0 -45
  38. data/app/services/foreman_openscap/oval/configure.rb +0 -83
  39. data/app/services/foreman_openscap/oval/cves.rb +0 -41
  40. data/app/services/foreman_openscap/oval/setup.rb +0 -93
  41. data/app/services/foreman_openscap/oval/setup_check.rb +0 -58
  42. data/app/services/foreman_openscap/oval/sync_oval_contents.rb +0 -42
  43. data/app/views/api/v2/compliance/oval_contents/base.json.rabl +0 -6
  44. data/app/views/api/v2/compliance/oval_contents/create.json.rabl +0 -3
  45. data/app/views/api/v2/compliance/oval_contents/destroy.json.rabl +0 -3
  46. data/app/views/api/v2/compliance/oval_contents/index.json.rabl +0 -3
  47. data/app/views/api/v2/compliance/oval_contents/show.json.rabl +0 -3
  48. data/app/views/api/v2/compliance/oval_contents/sync.json.rabl +0 -3
  49. data/app/views/api/v2/compliance/oval_contents/sync_result.json.rabl +0 -11
  50. data/app/views/api/v2/compliance/oval_contents/update.json.rabl +0 -3
  51. data/app/views/api/v2/compliance/oval_policies/create.json.rabl +0 -3
  52. data/app/views/api/v2/compliance/oval_policies/index.json.rabl +0 -3
  53. data/app/views/api/v2/compliance/oval_policies/main.json.rabl +0 -15
  54. data/app/views/api/v2/compliance/oval_policies/show.json.rabl +0 -3
  55. data/app/views/job_templates/run_oval_scans.erb +0 -24
  56. data/locale/cs_CZ/foreman_openscap.edit.po +0 -1863
  57. data/locale/cs_CZ/foreman_openscap.po.time_stamp +0 -0
  58. data/locale/de/foreman_openscap.edit.po +0 -1873
  59. data/locale/de/foreman_openscap.po.time_stamp +0 -0
  60. data/locale/en/foreman_openscap.edit.po +0 -1863
  61. data/locale/en/foreman_openscap.po.time_stamp +0 -0
  62. data/locale/en_GB/foreman_openscap.edit.po +0 -1863
  63. data/locale/en_GB/foreman_openscap.po.time_stamp +0 -0
  64. data/locale/es/foreman_openscap.edit.po +0 -1868
  65. data/locale/es/foreman_openscap.po.time_stamp +0 -0
  66. data/locale/fr/foreman_openscap.edit.po +0 -1874
  67. data/locale/fr/foreman_openscap.po.time_stamp +0 -0
  68. data/locale/gl/foreman_openscap.edit.po +0 -1863
  69. data/locale/gl/foreman_openscap.po.time_stamp +0 -0
  70. data/locale/it/foreman_openscap.edit.po +0 -1865
  71. data/locale/it/foreman_openscap.po.time_stamp +0 -0
  72. data/locale/ja/foreman_openscap.edit.po +0 -1869
  73. data/locale/ja/foreman_openscap.po.time_stamp +0 -0
  74. data/locale/ka/foreman_openscap.edit.po +0 -1863
  75. data/locale/ka/foreman_openscap.po.time_stamp +0 -0
  76. data/locale/ko/foreman_openscap.edit.po +0 -1863
  77. data/locale/ko/foreman_openscap.po.time_stamp +0 -0
  78. data/locale/pt_BR/foreman_openscap.edit.po +0 -1873
  79. data/locale/pt_BR/foreman_openscap.po.time_stamp +0 -0
  80. data/locale/ru/foreman_openscap.edit.po +0 -1867
  81. data/locale/ru/foreman_openscap.po.time_stamp +0 -0
  82. data/locale/sv_SE/foreman_openscap.edit.po +0 -1863
  83. data/locale/sv_SE/foreman_openscap.po.time_stamp +0 -0
  84. data/locale/zh_CN/foreman_openscap.edit.po +0 -1868
  85. data/locale/zh_CN/foreman_openscap.po.time_stamp +0 -0
  86. data/locale/zh_TW/foreman_openscap.edit.po +0 -1864
  87. data/locale/zh_TW/foreman_openscap.po.time_stamp +0 -0
  88. data/test/factories/oval_content_factory.rb +0 -7
  89. data/test/factories/oval_policy_factory.rb +0 -9
  90. data/test/fixtures/cve_fixtures.rb +0 -104
  91. data/test/functional/api/v2/compliance/oval_contents_controller_test.rb +0 -39
  92. data/test/functional/api/v2/compliance/oval_policies_controller_test.rb +0 -141
  93. data/test/functional/api/v2/compliance/oval_reports_controller_test.rb +0 -32
  94. data/test/graphql/mutations/oval_policies/delete_mutation_test.rb +0 -63
  95. data/test/graphql/queries/oval_content_query_test.rb +0 -29
  96. data/test/graphql/queries/oval_contents_query_test.rb +0 -35
  97. data/test/graphql/queries/oval_policies_query_test.rb +0 -35
  98. data/test/unit/oval_host_test.rb +0 -45
  99. data/test/unit/oval_policy_test.rb +0 -133
  100. data/test/unit/oval_status_test.rb +0 -47
  101. data/test/unit/services/oval/cves_test.rb +0 -81
  102. data/test/unit/services/oval/setup_check_test.rb +0 -37
  103. data/test/unit/services/oval/setup_test.rb +0 -87
  104. data/webpack/graphql/mutations/createOvalPolicy.gql +0 -22
  105. data/webpack/graphql/mutations/deleteOvalContent.gql +0 -9
  106. data/webpack/graphql/mutations/deleteOvalPolicy.gql +0 -9
  107. data/webpack/graphql/mutations/updateOvalPolicy.gql +0 -14
  108. data/webpack/graphql/queries/currentUserAttributes.gql +0 -11
  109. data/webpack/graphql/queries/cves.gql +0 -23
  110. data/webpack/graphql/queries/hostgroups.gql +0 -14
  111. data/webpack/graphql/queries/ovalContent.gql +0 -8
  112. data/webpack/graphql/queries/ovalContents.gql +0 -19
  113. data/webpack/graphql/queries/ovalPolicies.gql +0 -20
  114. data/webpack/graphql/queries/ovalPolicy.gql +0 -29
  115. data/webpack/helpers/pathsHelper.js +0 -29
  116. data/webpack/routes/OvalContents/OvalContentsIndex/OvalContentsIndex.js +0 -71
  117. data/webpack/routes/OvalContents/OvalContentsIndex/OvalContentsTable.js +0 -83
  118. data/webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsDestroy.fixtures.js +0 -105
  119. data/webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsDestroy.test.js +0 -124
  120. data/webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsIndex.fixtures.js +0 -127
  121. data/webpack/routes/OvalContents/OvalContentsIndex/__tests__/OvalContentsIndex.test.js +0 -89
  122. data/webpack/routes/OvalContents/OvalContentsIndex/index.js +0 -13
  123. data/webpack/routes/OvalContents/OvalContentsNew/OvalContentsNew.js +0 -138
  124. data/webpack/routes/OvalContents/OvalContentsNew/OvalContentsNew.scss +0 -3
  125. data/webpack/routes/OvalContents/OvalContentsNew/OvalContentsNewHelper.js +0 -73
  126. data/webpack/routes/OvalContents/OvalContentsNew/__tests__/OvalContentsNew.test.js +0 -104
  127. data/webpack/routes/OvalContents/OvalContentsNew/index.js +0 -13
  128. data/webpack/routes/OvalContents/OvalContentsShow/OvalContentsShow.js +0 -62
  129. data/webpack/routes/OvalContents/OvalContentsShow/OvalContentsShow.test.js +0 -45
  130. data/webpack/routes/OvalContents/OvalContentsShow/OvalContentsShowHelper.js +0 -0
  131. data/webpack/routes/OvalContents/OvalContentsShow/index.js +0 -35
  132. data/webpack/routes/OvalPolicies/OvalPoliciesIndex/OvalPoliciesIndex.js +0 -62
  133. data/webpack/routes/OvalPolicies/OvalPoliciesIndex/OvalPoliciesTable.js +0 -74
  134. data/webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesDestroy.fixtures.js +0 -101
  135. data/webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesDestroy.test.js +0 -117
  136. data/webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesIndex.fixtures.js +0 -111
  137. data/webpack/routes/OvalPolicies/OvalPoliciesIndex/__tests__/OvalPoliciesIndex.test.js +0 -81
  138. data/webpack/routes/OvalPolicies/OvalPoliciesIndex/index.js +0 -13
  139. data/webpack/routes/OvalPolicies/OvalPoliciesNew/HostgroupSelect.js +0 -135
  140. data/webpack/routes/OvalPolicies/OvalPoliciesNew/NewOvalPolicyForm.js +0 -119
  141. data/webpack/routes/OvalPolicies/OvalPoliciesNew/NewOvalPolicyFormHelpers.js +0 -107
  142. data/webpack/routes/OvalPolicies/OvalPoliciesNew/OvalPoliciesNew.js +0 -32
  143. data/webpack/routes/OvalPolicies/OvalPoliciesNew/__tests__/OvalPoliciesNew.fixtures.js +0 -147
  144. data/webpack/routes/OvalPolicies/OvalPoliciesNew/__tests__/OvalPoliciesNew.test.js +0 -172
  145. data/webpack/routes/OvalPolicies/OvalPoliciesNew/index.js +0 -11
  146. data/webpack/routes/OvalPolicies/OvalPoliciesShow/CvesTab.js +0 -49
  147. data/webpack/routes/OvalPolicies/OvalPoliciesShow/CvesTable.js +0 -63
  148. data/webpack/routes/OvalPolicies/OvalPoliciesShow/DetailsTab.js +0 -87
  149. data/webpack/routes/OvalPolicies/OvalPoliciesShow/HostgroupsTab.js +0 -49
  150. data/webpack/routes/OvalPolicies/OvalPoliciesShow/HostgroupsTable.js +0 -38
  151. data/webpack/routes/OvalPolicies/OvalPoliciesShow/OvalPoliciesShow.js +0 -82
  152. data/webpack/routes/OvalPolicies/OvalPoliciesShow/OvalPoliciesShowHelper.js +0 -117
  153. data/webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesEdit.fixtures.js +0 -48
  154. data/webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesEdit.test.js +0 -202
  155. data/webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesShow.fixtures.js +0 -124
  156. data/webpack/routes/OvalPolicies/OvalPoliciesShow/__tests__/OvalPoliciesShow.test.js +0 -172
  157. data/webpack/routes/OvalPolicies/OvalPoliciesShow/index.js +0 -39
  158. data/webpack/routes/routes.js +0 -49
@@ -1,133 +0,0 @@
1
- require 'test_plugin_helper'
2
-
3
- class OvalPolicyTest < ActiveSupport::TestCase
4
- setup do
5
- @oval_content = FactoryBot.create(:oval_content)
6
- end
7
-
8
- test "should not create OVAL policy with custom period" do
9
- policy = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
10
- :period => 'custom',
11
- :cron_line => 'aaa',
12
- :oval_content => @oval_content)
13
- refute policy.save
14
- assert policy.errors[:cron_line].include?("does not consist of 5 parts separated by space")
15
- end
16
-
17
- test "should create OVAL policy with weekly period" do
18
- policy = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
19
- :period => 'weekly',
20
- :weekday => 'monday',
21
- :oval_content => @oval_content)
22
- assert policy.save
23
- end
24
-
25
- test "should not create OVAL policy with weekly period" do
26
- policy = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
27
- :period => 'weekly',
28
- :weekday => 'someday',
29
- :oval_content => @oval_content)
30
- refute policy.save
31
- assert policy.errors[:weekday].include?("is not a valid value")
32
- end
33
-
34
- test "should create OVAL policy with monthly period" do
35
- policy = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
36
- :period => 'monthly',
37
- :day_of_month => '1',
38
- :oval_content => @oval_content)
39
- assert policy.save
40
- end
41
-
42
- test "should not create OVAL policy with monthly period" do
43
- policy = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
44
- :period => 'monthly',
45
- :day_of_month => '0',
46
- :oval_content => @oval_content)
47
- refute policy.save
48
- assert policy.errors[:day_of_month].include?("must be between 1 and 31")
49
- end
50
-
51
- test "should not create OVAL policy when attributes do not correspond to selected period in new record" do
52
- policy_0 = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
53
- :period => 'monthly',
54
- :weekday => 'tuesday',
55
- :cron_line => "0 0 0 0 0",
56
- :oval_content => @oval_content)
57
- policy_1 = ForemanOpenscap::OvalPolicy.new(:name => "test policy",
58
- :period => 'custom',
59
- :weekday => 'tuesday',
60
- :day_of_month => "15",
61
- :oval_content => @oval_content)
62
- refute policy_0.save
63
- refute policy_1.save
64
- end
65
-
66
- test "should update OVAL policy period" do
67
- policy = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
68
- :period => 'monthly',
69
- :day_of_month => '5',
70
- :oval_content => @oval_content)
71
- assert policy.save
72
- policy.period = 'weekly'
73
- policy.weekday = 'monday'
74
- policy.day_of_month = nil
75
- assert policy.save
76
- end
77
-
78
- test "should add and remove hosts for OVAL policy" do
79
- host = FactoryBot.create(:oval_host)
80
- policy = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
81
- :period => 'monthly',
82
- :day_of_month => '5',
83
- :host_ids => [host.id],
84
- :oval_content => @oval_content)
85
-
86
- assert policy.save
87
- assert policy.reload.hosts.include?(host)
88
-
89
- policy.host_ids = []
90
- assert policy.save
91
- refute policy.reload.hosts.include?(host)
92
- end
93
-
94
- test "should add and remove hostgroups for OVAL policy" do
95
- hostgroup = FactoryBot.create(:hostgroup)
96
- policy = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
97
- :period => 'monthly',
98
- :day_of_month => '5',
99
- :hostgroup_ids => [hostgroup.id],
100
- :oval_content => @oval_content)
101
- assert policy.save
102
- assert policy.reload.hostgroups.include?(hostgroup)
103
-
104
- policy.hostgroup_ids = []
105
- assert policy.save
106
- refute policy.reload.hostgroups.include?(hostgroup)
107
- end
108
-
109
- test "should add and remove inherited OVAL policy" do
110
- hostgroup = FactoryBot.create(:hostgroup)
111
- host = FactoryBot.create(:oval_host, :hostgroup => hostgroup)
112
- policy_1 = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy",
113
- :period => 'monthly',
114
- :day_of_month => '5',
115
- :hostgroup_ids => [hostgroup.id],
116
- :oval_content => @oval_content)
117
- policy_2 = ForemanOpenscap::OvalPolicy.new(:name => "custom_policy_again",
118
- :period => 'monthly',
119
- :day_of_month => '6',
120
- :host_ids => [host.id],
121
- :oval_content => @oval_content)
122
- assert policy_1.save
123
- assert policy_2.save
124
-
125
- assert host.reload.combined_oval_policies.include?(policy_1)
126
- assert host.combined_oval_policies.include?(policy_2)
127
-
128
- policy_1.hostgroup_ids = []
129
- assert policy_1.save
130
- refute host.reload.combined_oval_policies.include?(policy_1)
131
- assert host.combined_oval_policies.include?(policy_2)
132
- end
133
- end
@@ -1,47 +0,0 @@
1
- require 'test_plugin_helper'
2
-
3
- class OvalStatusTest < ActiveSupport::TestCase
4
- setup do
5
- @policy = FactoryBot.create(:oval_policy, :oval_content => FactoryBot.create(:oval_content))
6
- end
7
-
8
- test 'should have no vulnerabilities' do
9
- host = FactoryBot.create(:oval_host)
10
- FactoryBot.create(:oval_facet, :host => host, :oval_policies => [@policy])
11
-
12
- status = ForemanOpenscap::OvalStatus.new
13
- status.host = host
14
- assert_equal 0, status.to_status
15
- assert_equal ::HostStatus::Global::OK, status.to_global
16
- assert status.relevant?
17
- end
18
-
19
- test 'should have vulnerabilities with available patch' do
20
- host = FactoryBot.create(:oval_host, :cves => [FactoryBot.create(:cve, :has_errata => false), FactoryBot.create(:cve, :has_errata => true)])
21
- FactoryBot.create(:oval_facet, :host => host, :oval_policies => [@policy])
22
-
23
- status = ForemanOpenscap::OvalStatus.new
24
- status.host = host
25
- assert_equal 2, status.to_status
26
- assert_equal ::HostStatus::Global::ERROR, status.to_global
27
- assert status.relevant?
28
- end
29
-
30
- test 'should have vulnerabilities without available patch' do
31
- host = FactoryBot.create(:oval_host, :cves => [FactoryBot.create(:cve, :has_errata => false), FactoryBot.create(:cve, :has_errata => false)])
32
- FactoryBot.create(:oval_facet, :host => host, :oval_policies => [@policy])
33
-
34
- status = ForemanOpenscap::OvalStatus.new
35
- status.host = host
36
- assert_equal 1, status.to_status
37
- assert_equal ::HostStatus::Global::WARN, status.to_global
38
- assert status.relevant?
39
- end
40
-
41
- test 'should not be relevant without oval policy' do
42
- host = FactoryBot.create(:oval_host, :cves => [FactoryBot.create(:cve)])
43
- status = ForemanOpenscap::OvalStatus.new
44
- status.host = host
45
- refute status.relevant?
46
- end
47
- end
@@ -1,81 +0,0 @@
1
- require 'test_plugin_helper'
2
-
3
- class ForemanOpenscap::Oval::CvesTest < ActiveSupport::TestCase
4
- setup do
5
- @fxs = ForemanOpenscap::CveFixtures.new
6
- @instance = ForemanOpenscap::Oval::Cves.new
7
- end
8
-
9
- test "should add CVEs to host" do
10
- oval_data = create_cve_data @fxs.one
11
- host = FactoryBot.create(:host)
12
- assert_empty host.cves
13
- @instance.create host, oval_data
14
- refute_empty host.cves
15
-
16
- assert_equal host.cves, host.cves.distinct
17
- end
18
-
19
- test "should filter out CVEs that do not affect the host" do
20
- oval_data = create_cve_data @fxs.two
21
- host = FactoryBot.create(:host)
22
- assert_empty host.cves
23
- @instance.create host, oval_data
24
- refute_empty host.cves
25
-
26
- assert_equal host.cves, ForemanOpenscap::Cve.where(:ref_id => @fxs.ids_from(@fxs.res_two))
27
- end
28
-
29
- test "should update host with a new set of CVEs" do
30
- oval_data = create_cve_data @fxs.one
31
- host = FactoryBot.create(:host)
32
- assert_empty host.cves
33
- @instance.create host, oval_data
34
- refute_empty host.cves
35
-
36
- cve_ids_before = host.reload.cve_ids
37
- new_oval_data = create_cve_data @fxs.two
38
- @instance.create host, new_oval_data
39
-
40
- refute_equal host.reload.cve_ids, cve_ids_before
41
- assert_equal host.cves, ForemanOpenscap::Cve.where(:ref_id => @fxs.ids_from(@fxs.res_two))
42
-
43
- @fxs.ids_from(@fxs.res_three).map do |ref_id|
44
- refute ForemanOpenscap::Cve.find_by :ref_id => ref_id
45
- end
46
- end
47
-
48
- test "should not delete CVEs associated to another host" do
49
- oval_data = create_cve_data @fxs.one
50
- host = FactoryBot.create(:host)
51
- @instance.create host, oval_data
52
- refute_empty host.cves
53
-
54
- cves_before = host.reload.cves
55
-
56
- oval_data_2 = create_cve_data @fxs.two
57
- host_2 = FactoryBot.create(:host)
58
- @instance.create host_2, oval_data_2
59
-
60
- assert_equal host.reload.cves, cves_before
61
- end
62
-
63
- test "should not delete CVEs associated to another policy" do
64
- oval_data = create_cve_data [@fxs.res_three]
65
- host = FactoryBot.create(:host)
66
- assert_empty host.cves
67
- @instance.create host, oval_data
68
- refute_empty host.cves
69
-
70
- cve_ids_before = host.reload.cve_ids
71
- new_oval_data = create_cve_data [@fxs.res_four], 2
72
- @instance.create host, new_oval_data
73
-
74
- refute_equal host.reload.cve_ids, cve_ids_before
75
- assert_equal host.cves, ForemanOpenscap::Cve.where(:ref_id => @fxs.ids_from(@fxs.res_three).concat(@fxs.ids_from(@fxs.res_four)))
76
- end
77
-
78
- def create_cve_data(fixture, policy_id = 1)
79
- { 'oval_results' => fixture, 'oval_policy_id' => policy_id }
80
- end
81
- end
@@ -1,37 +0,0 @@
1
- require 'test_plugin_helper'
2
-
3
- class ForemanOpenscap::Oval::SetupCheckTest < ActiveSupport::TestCase
4
- test 'should show error message with filled in data' do
5
- check = ::ForemanOpenscap::Oval::SetupCheck.new(
6
- :id => :test_check,
7
- :title => _("Will it pass?"),
8
- :fail_msg => ->(hash) { "There was an error in #{hash[:name]}, you need to #{hash[:action]}" }
9
- )
10
-
11
- check.fail_with!(:name => 'your engine', :action => 'run')
12
- assert_equal 'There was an error in your engine, you need to run', check.fail_msg
13
- end
14
-
15
- test 'should show error message when it is a string' do
16
- msg = "Do not panic"
17
- check = ::ForemanOpenscap::Oval::SetupCheck.new(
18
- :id => :test_check,
19
- :title => _("Will it pass?"),
20
- :fail_msg => msg
21
- )
22
- check.fail!
23
- assert_equal msg, check.fail_msg
24
- end
25
-
26
- test 'should not show error message when check not failed' do
27
- check = ::ForemanOpenscap::Oval::SetupCheck.new(
28
- :id => :test_check,
29
- :title => _("Will it pass?"),
30
- :fail_msg => 'foo'
31
- )
32
-
33
- assert_nil check.fail_msg
34
- check.fail!
35
- assert_not_nil check.fail_msg
36
- end
37
- end
@@ -1,87 +0,0 @@
1
- require 'test_plugin_helper'
2
-
3
- class ForemanOpenscap::Oval::SetupTest < ActiveSupport::TestCase
4
- setup do
5
- @config = ForemanOpenscap::ClientConfig::Ansible.new(::ForemanOpenscap::OvalPolicy)
6
- end
7
-
8
- test "should fail check when Ansible not available" do
9
- ForemanOpenscap::ClientConfig::Ansible.any_instance.stubs(:available?).returns(false)
10
-
11
- check_collection = ForemanOpenscap::Oval::Setup.new.run
12
- assert check_collection.find_check(:foreman_ansible_present).failed?
13
- assert check_collection.checks.reject { |res| res.id == :foreman_ansible_present }.all?(&:skipped?)
14
- end
15
-
16
- test "should fail check when Ansible role for client not imported" do
17
- ForemanOpenscap::ClientConfig::Ansible.any_instance.stubs(:find_config_item).returns(nil)
18
-
19
- check_collection = ForemanOpenscap::Oval::Setup.new.run
20
- assert check_collection.find_check(:foreman_ansible_present).passed?
21
- assert check_collection.find_check(:foreman_scap_client_role_present).failed?
22
-
23
- assert check_collection.checks
24
- .select { |res| res.id != :foreman_ansible_present && res.id != :foreman_scap_client_role_present }
25
- .all?(&:skipped?)
26
- end
27
-
28
- test "should fail check when required Ansible variables are not imported" do
29
- FactoryBot.create(:ansible_role, :name => @config.ansible_role_name)
30
- check_collection = ForemanOpenscap::Oval::Setup.new.run
31
- assert check_collection.find_check(:foreman_ansible_present).passed?
32
- assert check_collection.find_check(:foreman_scap_client_role_present).passed?
33
-
34
- res = check_collection.find_check(:foreman_scap_client_vars_present)
35
- assert res.failed?
36
- msg = "The following Ansible Variables were not found: foreman_scap_client_oval_policies, foreman_scap_client_port, foreman_scap_client_server, please import them before running this action again."
37
- assert res.fail_msg, msg
38
- assert override_results(check_collection.checks).all?(&:skipped?)
39
- end
40
-
41
- test "should fail check when fails to override a variable" do
42
- role = FactoryBot.create(:ansible_role, :name => @config.ansible_role_name)
43
- FactoryBot.create(:ansible_variable, :key => @config.port_param, :ansible_role => role)
44
- FactoryBot.create(:ansible_variable, :key => @config.server_param, :ansible_role => role)
45
- FactoryBot.create(:ansible_variable, :key => @config.policies_param, :ansible_role => role)
46
- AnsibleVariable.any_instance.stubs(:save).returns(false)
47
- AnsibleVariable.any_instance.stubs(:changed?).returns(true)
48
- check_collection = ForemanOpenscap::Oval::Setup.new.run
49
- assert check_collection.find_check(:foreman_ansible_present).passed?
50
- assert check_collection.find_check(:foreman_scap_client_role_present).passed?
51
- assert check_collection.find_check(:foreman_scap_client_vars_present).passed?
52
- assert override_results(check_collection.checks).all?(&:failed?)
53
- end
54
-
55
- test "should pass all checks" do
56
- role = FactoryBot.create(:ansible_role, :name => @config.ansible_role_name)
57
- port_param = FactoryBot.create(:ansible_variable, :key => @config.port_param, :ansible_role => role)
58
- server_param = FactoryBot.create(:ansible_variable, :key => @config.server_param, :ansible_role => role)
59
- policies_param = FactoryBot.create(:ansible_variable, :key => @config.policies_param, :ansible_role => role)
60
- check_collection = ForemanOpenscap::Oval::Setup.new.run
61
-
62
- [policies_param, port_param, server_param].map(&:reload)
63
-
64
- assert check_collection.all_passed?
65
-
66
- assert @config.policies_param_default_value, policies_param.default_value
67
- assert_equal 'array', policies_param.key_type
68
- refute policies_param.hidden_value?
69
- assert policies_param.override
70
-
71
- refute port_param.value
72
- assert_equal 'integer', port_param.key_type
73
- assert port_param.override
74
-
75
- refute server_param.hidden_value?
76
- assert_equal 'string', server_param.key_type
77
- assert server_param.override
78
- end
79
-
80
- def override_results(checks)
81
- checks.select do |res|
82
- res.id == :foreman_scap_client_server_overriden ||
83
- res.id == :foreman_scap_client_port_overriden ||
84
- res.id == :foreman_scap_client_policies_overriden
85
- end
86
- end
87
- end
@@ -1,22 +0,0 @@
1
- mutation CreateOvalPolicy($name: String!, $period: String!, $cronLine: String, $ovalContentId: Int!, $hostgroupIds: [Int!]) {
2
- createOvalPolicy(input: {name: $name, period: $period, cronLine: $cronLine, ovalContentId: $ovalContentId, hostgroupIds: $hostgroupIds}) {
3
- ovalPolicy {
4
- name
5
- id
6
- period
7
- cronLine
8
- hostgroups {
9
- nodes {
10
- name
11
- id
12
- }
13
- }
14
- }
15
- checkCollection {
16
- id
17
- errors
18
- failMsg
19
- result
20
- }
21
- }
22
- }
@@ -1,9 +0,0 @@
1
- mutation DeleteOvalContent($id: ID!) {
2
- deleteOvalContent(input: { id: $id }) {
3
- id
4
- errors {
5
- path
6
- message
7
- }
8
- }
9
- }
@@ -1,9 +0,0 @@
1
- mutation DeleteOvalPolicy($id: ID!) {
2
- deleteOvalPolicy(input: { id: $id }) {
3
- id
4
- errors {
5
- path
6
- message
7
- }
8
- }
9
- }
@@ -1,14 +0,0 @@
1
- mutation UpdateOvalPolicy($id: ID!, $name: String, $description: String, $cronLine: String) {
2
- updateOvalPolicy(input:{ id:$id, name:$name, description: $description, cronLine: $cronLine }) {
3
- ovalPolicy {
4
- id
5
- name
6
- description
7
- cronLine
8
- }
9
- errors {
10
- path
11
- message
12
- }
13
- }
14
- }
@@ -1,11 +0,0 @@
1
- fragment CurrentUserAttributes on User {
2
- id
3
- login
4
- admin
5
- permissions {
6
- nodes {
7
- id
8
- name
9
- }
10
- }
11
- }
@@ -1,23 +0,0 @@
1
- #import "./currentUserAttributes.gql"
2
-
3
- query($search: String, $first: Int, $last: Int) {
4
- cves(search: $search, first: $first, last: $last) {
5
- totalCount
6
- nodes {
7
- id
8
- refId
9
- refUrl
10
- hasErrata
11
- definitionId
12
- hosts {
13
- nodes {
14
- id
15
- name
16
- }
17
- }
18
- }
19
- }
20
- currentUser {
21
- ...CurrentUserAttributes
22
- }
23
- }
@@ -1,14 +0,0 @@
1
- #import "./currentUserAttributes.gql"
2
-
3
- query($search: String, $first: Int, $last: Int) {
4
- hostgroups(search: $search, first: $first, last: $last) {
5
- totalCount
6
- nodes {
7
- id
8
- name
9
- }
10
- }
11
- currentUser {
12
- ...CurrentUserAttributes
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- query($id: String!) {
2
- ovalContent(id: $id) {
3
- id
4
- name
5
- url
6
- originalFilename
7
- }
8
- }
@@ -1,19 +0,0 @@
1
- #import "./currentUserAttributes.gql"
2
-
3
- query($first: Int, $last: Int) {
4
- ovalContents(first: $first, last: $last) {
5
- totalCount
6
- nodes {
7
- id
8
- name
9
- url
10
- originalFilename
11
- meta {
12
- canDestroy
13
- }
14
- }
15
- }
16
- currentUser {
17
- ...CurrentUserAttributes
18
- }
19
- }
@@ -1,20 +0,0 @@
1
- #import "./currentUserAttributes.gql"
2
-
3
- query($first: Int, $last: Int) {
4
- ovalPolicies(first: $first, last: $last) {
5
- totalCount
6
- nodes {
7
- id
8
- name
9
- meta {
10
- canDestroy
11
- }
12
- ovalContent {
13
- name
14
- }
15
- }
16
- }
17
- currentUser {
18
- ...CurrentUserAttributes
19
- }
20
- }
@@ -1,29 +0,0 @@
1
- #import "./currentUserAttributes.gql"
2
-
3
- query($id: String!) {
4
- ovalPolicy(id: $id) {
5
- id
6
- name
7
- period
8
- cronLine
9
- weekday
10
- dayOfMonth
11
- description
12
- meta {
13
- canEdit
14
- }
15
- hostgroups {
16
- nodes {
17
- id
18
- descendants {
19
- nodes {
20
- id
21
- }
22
- }
23
- }
24
- }
25
- }
26
- currentUser {
27
- ...CurrentUserAttributes
28
- }
29
- }
@@ -1,29 +0,0 @@
1
- import { decodeModelId } from './globalIdHelper';
2
-
3
- const experimental = path => `/experimental${path}`;
4
-
5
- const showPath = path => `${path}/:id`;
6
- const newPath = path => `${path}/new`;
7
-
8
- export const modelPath = (basePath, model) =>
9
- `${basePath}/${decodeModelId(model)}`;
10
-
11
- // react-router uses path-to-regexp, should we use it as well in a future?
12
- // https://github.com/pillarjs/path-to-regexp/tree/v1.7.0#compile-reverse-path-to-regexp
13
- export const resolvePath = (path, params) =>
14
- Object.entries(params).reduce(
15
- (memo, [key, value]) => memo.replace(key, value),
16
- path
17
- );
18
-
19
- export const ovalContentsApiPath = '/api/v2/compliance/oval_contents';
20
-
21
- export const ovalContentsPath = experimental('/compliance/oval_contents');
22
- export const ovalContentsShowPath = showPath(ovalContentsPath);
23
- export const ovalContentsNewPath = newPath(ovalContentsPath);
24
- export const ovalPoliciesPath = experimental('/compliance/oval_policies');
25
- export const ovalPoliciesShowPath = `${showPath(ovalPoliciesPath)}/:tab?`;
26
- export const ovalPoliciesNewPath = newPath(ovalPoliciesPath);
27
- export const hostsPath = '/hosts';
28
- export const newJobPath = newPath('/job_invocations');
29
- export const hostsShowPath = showPath(hostsPath);
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { useQuery } from '@apollo/client';
4
- import { translate as __ } from 'foremanReact/common/I18n';
5
-
6
- import IndexLayout from '../../../components/IndexLayout';
7
- import LinkButton from '../../../components/LinkButton';
8
- import OvalContentsTable from './OvalContentsTable';
9
- import { ovalContentsNewPath } from '../../../helpers/pathsHelper';
10
- import {
11
- useParamsToVars,
12
- useCurrentPagination,
13
- } from '../../../helpers/pageParamsHelper';
14
-
15
- import { submitDelete, prepareMutation } from '../../../helpers/mutationHelper';
16
- import ovalContentsQuery from '../../../graphql/queries/ovalContents.gql';
17
- import deleteOvalContentMutation from '../../../graphql/mutations/deleteOvalContent.gql';
18
-
19
- const OvalContentsIndex = props => {
20
- const useFetchFn = componentProps =>
21
- useQuery(ovalContentsQuery, {
22
- variables: useParamsToVars(componentProps.history),
23
- });
24
-
25
- const renameData = data => ({
26
- ovalContents: data.ovalContents.nodes,
27
- totalCount: data.ovalContents.totalCount,
28
- });
29
-
30
- const pagination = useCurrentPagination(props.history);
31
-
32
- return (
33
- <IndexLayout pageTitle={__('OVAL Contents')}>
34
- <OvalContentsTable
35
- {...props}
36
- fetchFn={useFetchFn}
37
- renameData={renameData}
38
- resultPath="ovalContents.nodes"
39
- pagination={pagination}
40
- emptyStateTitle={__('No OVAL Contents found.')}
41
- permissions={['view_oval_contents']}
42
- confirmDeleteTitle={__('Delete OVAL Content')}
43
- submitDelete={submitDelete}
44
- prepareMutation={prepareMutation(
45
- props.history,
46
- props.showToast,
47
- ovalContentsQuery,
48
- 'deleteOvalContent',
49
- __('OVAL Content successfully deleted.'),
50
- deleteOvalContentMutation,
51
- __('OVAL Content')
52
- )}
53
- primaryButton={
54
- <LinkButton
55
- path={ovalContentsNewPath}
56
- btnText={__('Create OVAL Content')}
57
- />
58
- }
59
- shouldRefetch={props.location?.state?.refreshOvalContents}
60
- />
61
- </IndexLayout>
62
- );
63
- };
64
-
65
- OvalContentsIndex.propTypes = {
66
- history: PropTypes.object.isRequired,
67
- showToast: PropTypes.func.isRequired,
68
- location: PropTypes.object.isRequired,
69
- };
70
-
71
- export default OvalContentsIndex;