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,45 +0,0 @@
1
- module ForemanOpenscap
2
- class OvalStatus < ::HostStatus::Status
3
- PATCHED = 0
4
- VULNERABLE = 1
5
- PATCH_AVAILABLE = 2
6
-
7
- def self.status_name
8
- N_('OVAL scan')
9
- end
10
-
11
- def to_label(options = {})
12
- case to_status
13
- when PATCHED
14
- N_('No Vulnerabilities found')
15
- when VULNERABLE
16
- N_("%s vulnerabilities found") % host.cves_without_errata.count
17
- when PATCH_AVAILABLE
18
- N_("%s vulnerabilities with available patch found") % host.cves_with_errata.count
19
- else
20
- N_('Unknown OVAL status')
21
- end
22
- end
23
-
24
- def to_global(options = {})
25
- case to_status
26
- when PATCHED
27
- ::HostStatus::Global::OK
28
- when VULNERABLE
29
- ::HostStatus::Global::WARN
30
- when PATCH_AVAILABLE
31
- ::HostStatus::Global::ERROR
32
- end
33
- end
34
-
35
- def relevant?(options = {})
36
- host.combined_oval_policies.any?
37
- end
38
-
39
- def to_status(options = {})
40
- return PATCH_AVAILABLE if host.cves_with_errata.any?
41
- return VULNERABLE if host.cves_without_errata.any?
42
- PATCHED
43
- end
44
- end
45
- end
@@ -1,45 +0,0 @@
1
- module ForemanOpenscap
2
- module Oval
3
- class CheckCollection
4
- attr_reader :checks
5
-
6
- def initialize(initial_check_attrs = [])
7
- @checks = initial_check_attrs.map { |hash| SetupCheck.new hash }
8
- end
9
-
10
- def all_passed?
11
- @checks.all?(&:passed?)
12
- end
13
-
14
- def find_check(check_id)
15
- @checks.find { |item| item.id == check_id }
16
- end
17
-
18
- def find_failed
19
- @checks.select(&:failed?)
20
- end
21
-
22
- def fail_check(check_id, error_data = nil)
23
- find_check(check_id).fail_with! error_data
24
- end
25
-
26
- def pass_check(check_id)
27
- find_check(check_id).pass!
28
- end
29
-
30
- def add_check(check)
31
- @checks << check
32
- self
33
- end
34
-
35
- def merge(other)
36
- @checks = @checks.concat other.checks
37
- self
38
- end
39
-
40
- def to_h
41
- @checks.map(&:to_h)
42
- end
43
- end
44
- end
45
- end
@@ -1,83 +0,0 @@
1
- module ForemanOpenscap
2
- module Oval
3
- class Configure
4
- include ::ForemanOpenscap::HostgroupOverriderCommon
5
-
6
- def initialize
7
- @config = ForemanOpenscap::ClientConfig::Ansible.new(::ForemanOpenscap::OvalPolicy)
8
- end
9
-
10
- def assign(oval_policy, ids, model_class)
11
- check_collection = ::ForemanOpenscap::Oval::Setup.new.run
12
- return check_collection unless check_collection.all_passed?
13
-
14
- ansible_role = @config.find_config_item
15
-
16
- if model_class == ::Hostgroup
17
- roles_method = :inherited_and_own_ansible_roles
18
- ids_setter = :hostgroup_ids=
19
- check_id = :hostgroups_without_proxy
20
- elsif model_class == ::Host::Managed
21
- roles_method = :all_ansible_roles
22
- ids_setter = :host_ids=
23
- check_id = :hosts_without_proxy
24
- else
25
- raise "Unexpected model_class, expected ::Hostgroup or ::Host::Managed, got: #{model_class}"
26
- end
27
-
28
- items_with_proxy, items_without_proxy = openscap_proxy_associated(ids, model_class)
29
-
30
-
31
- if items_without_proxy.any?
32
- return without_proxy_to_check items_without_proxy, check_id
33
- end
34
-
35
- oval_policy.send(ids_setter, items_with_proxy.pluck(:id))
36
-
37
- unless oval_policy.save
38
- return check_collection.add_check model_to_check(oval_policy, :oval_policy_errors)
39
- end
40
-
41
- check_collection.merge modify_items(items_with_proxy, oval_policy, ansible_role, roles_method)
42
- end
43
-
44
- private
45
-
46
- def openscap_proxy_associated(ids, model_class)
47
- model_class.where(:id => ids).partition(&:openscap_proxy)
48
- end
49
-
50
- def modify_items(items, oval_policy, ansible_role, roles_method)
51
- items.reduce(CheckCollection.new) do |memo, item|
52
- role_ids = item.ansible_role_ids + [ansible_role.id]
53
- item.ansible_role_ids = role_ids unless item.send(roles_method).include? ansible_role
54
- item.save if item.changed?
55
- memo.add_check model_to_check(item, item.is_a?(::Hostgroup) ? 'hostgroup' : 'host')
56
- add_overrides ansible_role.ansible_variables, item, @config
57
- memo
58
- end
59
- end
60
-
61
- def without_proxy_to_check(items, check_id)
62
- items.reduce(CheckCollection.new) do |memo, item|
63
- memo.add_check(
64
- SetupCheck.new(
65
- :title => (_("Was %s configured successfully?") % item.class.name),
66
- :fail_msg => (_("Assign openscap_proxy to %s before proceeding.") % item.name),
67
- :id => check_id
68
- ).fail!
69
- )
70
- end
71
- end
72
-
73
- def model_to_check(model, check_id)
74
- check = SetupCheck.new(
75
- :title => (_("Was %{model_name} %{name} configured successfully?") % { :model_name => model.class.name, :name => model.name }),
76
- :errors => model.errors.to_h,
77
- :id => check_id
78
- )
79
- model.errors.any? ? check.fail! : check.pass!
80
- end
81
- end
82
- end
83
- end
@@ -1,41 +0,0 @@
1
- module ForemanOpenscap
2
- module Oval
3
- class Cves
4
- def create(host, cve_data)
5
- policy_id = cve_data['oval_policy_id']
6
-
7
- incoming_cves = cve_data['oval_results'].reduce([]) do |memo, data|
8
- next memo unless data['result'] == 'true'
9
- cves, errata = data['references'].partition { |ref| ref['ref_id'].start_with?('CVE') }
10
-
11
- cves.map do |cve|
12
- memo << ::ForemanOpenscap::Cve.find_or_create_by(
13
- :ref_id => cve['ref_id'],
14
- :ref_url => cve['ref_url'],
15
- :has_errata => !errata.empty?,
16
- :definition_id => data['definition_id']
17
- )
18
- end
19
- memo
20
- end
21
-
22
- current = ForemanOpenscap::Cve.of_oval_policy(policy_id).of_host(host.id)
23
- to_delete = current - incoming_cves
24
- to_create = incoming_cves - current
25
-
26
- ::ForemanOpenscap::HostCve.where(:host_id => host.id, :oval_policy_id => policy_id, :cve_id => to_delete.pluck(:id)).destroy_all
27
- host.host_cves.build(to_create.map { |cve| { :host_id => host.id, :oval_policy_id => policy_id, :cve_id => cve.id } })
28
-
29
- delete_orphaned_cves to_delete.pluck(:id) if host.save
30
- host
31
- end
32
-
33
- private
34
-
35
- def delete_orphaned_cves(ids)
36
- associated_ids = ::ForemanOpenscap::HostCve.where(:cve_id => ids).select(:cve_id).distinct.pluck(:cve_id)
37
- ::ForemanOpenscap::Cve.where(:id => ids - associated_ids).destroy_all
38
- end
39
- end
40
- end
41
- end
@@ -1,93 +0,0 @@
1
- module ForemanOpenscap
2
- module Oval
3
- class Setup
4
- include ::ForemanOpenscap::LookupKeyOverridesCommon
5
-
6
- def initialize
7
- @config = ForemanOpenscap::ClientConfig::Ansible.new(::ForemanOpenscap::OvalPolicy)
8
- @check_collection = CheckCollection.new initial_check_attrs
9
- end
10
-
11
- def run
12
- override @config
13
- @check_collection
14
- end
15
-
16
- def handle_config_not_available(config)
17
- return @check_collection.pass_check :foreman_ansible_present if config.available?
18
- fail_check :foreman_ansible_present
19
- end
20
-
21
- def handle_config_item_not_available(config, item)
22
- return @check_collection.pass_check :foreman_scap_client_role_present if item
23
- fail_check :foreman_scap_client_role_present
24
- end
25
-
26
- def handle_missing_lookup_keys(config, key_names)
27
- return @check_collection.pass_check :foreman_scap_client_vars_present if key_names.empty?
28
- fail_check :foreman_scap_client_vars_present, :missing_vars => key_names
29
- end
30
-
31
- def handle_server_param_override(config, param)
32
- handle_param_override :foreman_scap_client_server_overriden, config, param
33
- end
34
-
35
- def handle_port_param_override(config, param)
36
- handle_param_override :foreman_scap_client_port_overriden, config, param
37
- end
38
-
39
- def handle_policies_param_override(config, param)
40
- handle_param_override :foreman_scap_client_policies_overriden, config, param
41
- end
42
-
43
- def handle_param_override(check_id, config, param)
44
- return fail_check check_id if param.changed? && !param.save
45
- @check_collection.pass_check check_id
46
- end
47
-
48
- def fail_check(check_id, error_data = nil)
49
- @check_collection.fail_check(check_id, error_data)
50
- false
51
- end
52
-
53
- private
54
-
55
- def initial_check_attrs
56
- override_msg = _("Could not update Ansible Variables with override: true")
57
-
58
- [
59
- {
60
- :id => :foreman_ansible_present,
61
- :title => _("Is foreman_ansible present?"),
62
- :fail_msg => _("foreman_ansible plugin not found, please install it before running this action again.")
63
- },
64
- {
65
- :id => :foreman_scap_client_role_present,
66
- :title => _("Is theforeman.foreman_scap_client present?"),
67
- :fail_msg => @config.ansible_role_missing_msg
68
- },
69
- {
70
- :id => :foreman_scap_client_vars_present,
71
- :title => _("Are required variables for theforeman.foreman_scap_client present?"),
72
- :fail_msg => ->(hash) { _("The following Ansible Variables were not found: %{missing_vars}, please import them before running this action again.") % hash }
73
- },
74
- {
75
- :id => :foreman_scap_client_server_overriden,
76
- :title => _("Is %s param set to be overriden?") % @config.server_param,
77
- :fail_msg => override_msg
78
- },
79
- {
80
- :id => :foreman_scap_client_port_overriden,
81
- :title => _("Is %s param set to be overriden?") % @config.port_param,
82
- :fail_msg => override_msg
83
- },
84
- {
85
- :id => :foreman_scap_client_policies_overriden,
86
- :title => _("Is %s param set to be overriden?") % @config.policies_param,
87
- :fail_msg => override_msg
88
- }
89
- ]
90
- end
91
- end
92
- end
93
- end
@@ -1,58 +0,0 @@
1
- module ForemanOpenscap
2
- module Oval
3
- class SetupCheck
4
- attr_reader :result, :id, :title, :errors
5
-
6
- def initialize(hash)
7
- @id = hash[:id]
8
- @title = hash[:title]
9
- @fail_msg = hash[:fail_msg]
10
- @errors = hash[:errors]
11
- @result = :skip
12
- end
13
-
14
- def fail_with!(fail_data)
15
- @fail_msg_data = fail_data
16
- fail!
17
- end
18
-
19
- def fail!
20
- raise 'Cannot fail a check that expects fail message data, use fail_with! method instead' if @fail_msg.respond_to?(:call) && @fail_msg_data.empty?
21
- @result = :fail
22
- self
23
- end
24
-
25
- def pass!
26
- @result = :pass
27
- self
28
- end
29
-
30
- def failed?
31
- @result == :fail
32
- end
33
-
34
- def passed?
35
- @result == :pass
36
- end
37
-
38
- def skipped?
39
- @result == :skip
40
- end
41
-
42
- def fail_msg
43
- return unless failed?
44
- return @fail_msg.call(@fail_msg_data) if @fail_msg.respond_to?(:call) && @fail_msg_data
45
- @fail_msg
46
- end
47
-
48
- def to_h
49
- {
50
- :title => @title,
51
- :result => @result,
52
- :fail_message => failed? ? fail_msg : nil,
53
- :errors => @errors
54
- }
55
- end
56
- end
57
- end
58
- end
@@ -1,42 +0,0 @@
1
- module ForemanOpenscap
2
- module Oval
3
- class SyncOvalContents
4
- def sync(oval_content)
5
- begin
6
- content_blob = fetch_content_blob(oval_content.url)
7
- rescue StandardError => e
8
- oval_content.errors.add(:base, "#{fail_msg oval_content}, " + _("cause: ") + e.message)
9
- return oval_content
10
- end
11
-
12
- unless content_blob
13
- oval_content.errors.add(:base, fail_msg(oval_content))
14
- return oval_content
15
- end
16
- oval_content.scap_file = content_blob
17
- oval_content
18
- end
19
-
20
- def sync_all
21
- to_sync = ForemanOpenscap::OvalContent.where.not(:url => nil)
22
- to_sync.map { |content| content.tap { |item| sync(item).save } }
23
- end
24
-
25
- private
26
-
27
- def fail_msg(content)
28
- _("Failed to fetch content file from %s") % content.url
29
- end
30
-
31
- def fetch_content_blob(url)
32
- response = fetch url
33
- return unless response.code == 200
34
- response.body
35
- end
36
-
37
- def fetch(url)
38
- RestClient.get(url)
39
- end
40
- end
41
- end
42
- end
@@ -1,6 +0,0 @@
1
- object @oval_content
2
-
3
- extends "api/v2/compliance/common/org"
4
- extends "api/v2/compliance/common/loc"
5
-
6
- attributes :id, :name, :original_filename, :digest, :created_at, :updated_at, :url
@@ -1,3 +0,0 @@
1
- object @oval_content
2
-
3
- extends "api/v2/compliance/oval_contents/base"
@@ -1,3 +0,0 @@
1
- object @oval_content
2
-
3
- extends "api/v2/compliance/oval_contents/base"
@@ -1,3 +0,0 @@
1
- collection @oval_contents
2
-
3
- extends "api/v2/compliance/oval_contents/base"
@@ -1,3 +0,0 @@
1
- object @oval_content
2
-
3
- extends "api/v2/compliance/oval_contents/base"
@@ -1,3 +0,0 @@
1
- collection @oval_contents
2
-
3
- extends "api/v2/compliance/oval_contents/sync_result"
@@ -1,11 +0,0 @@
1
- object @oval_content
2
-
3
- attributes :id, :name
4
-
5
- node(:errors) do |content|
6
- content.errors.to_hash
7
- end
8
-
9
- node(:full_messages) do |content|
10
- content.errors.full_messages
11
- end
@@ -1,3 +0,0 @@
1
- object @oval_content
2
-
3
- extends "api/v2/compliance/oval_contents/base"
@@ -1,3 +0,0 @@
1
- object @oval_policy
2
-
3
- extends "api/v2/compliance/oval_policies/main"
@@ -1,3 +0,0 @@
1
- collection @oval_policies
2
-
3
- extends "api/v2/compliance/oval_policies/main"
@@ -1,15 +0,0 @@
1
- object @oval_policy
2
-
3
- extends "api/v2/compliance/common/org"
4
- extends "api/v2/compliance/common/loc"
5
- extends "api/v2/compliance/policies_common/attrs"
6
-
7
- attributes :created_at, :updated_at, :oval_content_id
8
-
9
- child :hosts => :hosts do |host|
10
- attributes :id, :name
11
- end
12
-
13
- child :hostgroups => :hostgroups do |hg|
14
- attributes :id, :name
15
- end
@@ -1,3 +0,0 @@
1
- object @oval_policy
2
-
3
- extends "api/v2/compliance/oval_policies/main"
@@ -1,24 +0,0 @@
1
- <%#
2
- name: Run OVAL scans
3
- job_category: OpenSCAP
4
- description_format: Run scan for specified OVAL Policies
5
- feature: foreman_openscap_run_oval_scans
6
- provider_type: SSH
7
- snippet: false
8
- provider_type: SSH
9
- kind: job_template
10
- template_inputs:
11
- - name: oval_policies
12
- description: Comma separated OVAL Policy Ids to run
13
- input_type: user
14
- advanced: true
15
- -%>
16
- <% unless input('oval_policies').blank? -%>
17
- <% input('oval_policies').split(',').map do |id| -%>
18
- /usr/bin/foreman_scap_client oval <%= id %>
19
- <% end -%>
20
- <% else -%>
21
- <% @host.oval_policies_enc_raw.map do |policy| -%>
22
- /usr/bin/foreman_scap_client oval <%= policy['id'] %>
23
- <% end -%>
24
- <% end -%>