foreman_openscap 4.0.1 → 4.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afb07ec68598ddfebdea1a16d50489cb5ca88cd7e5e0eb0294591704ac41d06d
4
- data.tar.gz: 2c9aeed9bd9244263002370796e1439801dbe29183f4f19c99bc33d5aa5168b3
3
+ metadata.gz: 16f34489dc20040b64ef5ccc88b54eb90d3456a4c4e268ace1b87738eb28bd99
4
+ data.tar.gz: 9c078065dea24a60c4fcba9edc1d13476fbb2edf149d14aaf3a1067c3bdcdd6b
5
5
  SHA512:
6
- metadata.gz: 93afb936e476d4b8ddc3c616ec5820b7609cf8fefc59478ac7011b78edef1e33946d194ba4a47dde89acf19dcbc6d6fd74f6e5ba501502ae9a1ef7663e1b77ed
7
- data.tar.gz: c5aeec2a9ceee0c88d40e279dda82316e4a13eeb5e4b31856fa2625b20e994cf10e13b338286b5550e6d9ba107c78de0049d6587610404c31d2c3d5ecbc7b85f
6
+ metadata.gz: 17d7c741b79378a605fe7cb898a211bfbdad4d5afffed07be5a03818051fbaf169408eb85e8173896115f465a716b66e9f169cdc3b8fbd5ba669b0f24bdf68b5
7
+ data.tar.gz: efeac51619216fbe985ab12db6c6790c323654aa9a69c38d9fae15503ed59b4aa1cbd77353b0bba75811667aaa9727be46d710e5d0de870cc92f648b59d93829
@@ -22,18 +22,10 @@ module ForemanOpenscap
22
22
  end
23
23
 
24
24
  def inherited_openscap_proxy_id
25
- inherited_ancestry_attribute(:openscap_proxy_id)
26
- end
27
-
28
- unless defined?(Katello::System)
29
- private
30
-
31
- def inherited_ancestry_attribute(attribute)
32
- if ancestry.present?
33
- self[attribute] || self.class.sort_by_ancestry(ancestors.where("#{attribute} is not NULL")).last.try(attribute)
34
- else
35
- self.send(attribute)
36
- end
25
+ if ancestry.present?
26
+ self[:openscap_proxy_id] || self.class.sort_by_ancestry(ancestors.where.not(openscap_proxy_id: nil)).last.try(:openscap_proxy_id)
27
+ else
28
+ self.send(:openscap_proxy_id)
37
29
  end
38
30
  end
39
31
  end
@@ -33,10 +33,6 @@ module ForemanOpenscap
33
33
  end
34
34
  end
35
35
 
36
- def inherited_openscap_proxy_id
37
- inherited_ancestry_attribute(:openscap_proxy_id)
38
- end
39
-
40
36
  private
41
37
 
42
38
  def scap_client_lookup_values_for(lookup_keys, model_match)
@@ -312,7 +312,7 @@ module ForemanOpenscap
312
312
  end
313
313
 
314
314
  def assign_ids(ids, class_name)
315
- new_assets = ids.reject { |id| id.respond_to?(:empty?) && id.empty? }.reduce([]) do |memo, id|
315
+ new_assets = ids.uniq.reject { |id| id.respond_to?(:empty?) && id.empty? }.reduce([]) do |memo, id|
316
316
  memo << assets.where(:assetable_type => class_name, :assetable_id => id).first_or_initialize
317
317
  end
318
318
  complimentary_class_name = class_name == 'Host::Base' ? 'Hostgroup' : 'Host::Base'
@@ -0,0 +1,34 @@
1
+ class MigratePortOverridesForAnsible < ActiveRecord::Migration[6.0]
2
+ def up
3
+ transform_lookup_values :to_i
4
+ end
5
+
6
+ def down
7
+ transform_lookup_values :to_s
8
+ end
9
+
10
+ private
11
+
12
+ def transform_lookup_values(method)
13
+ return unless defined?(ForemanAnsible)
14
+ role = AnsibleRole.find_by :name => 'theforeman.foreman_scap_client'
15
+ return unless role
16
+ port_key = role.ansible_variables.find_by :key => 'foreman_scap_client_port'
17
+ return unless port_key
18
+ if method == :to_i
19
+ port_key.key_type = "integer"
20
+ port_key.default_value = 8080
21
+ else
22
+ port_key.key_type == "string"
23
+ port_key.default_value = ""
24
+ end
25
+
26
+ port_key.save
27
+ port_key.lookup_values.in_batches do |batch|
28
+ batch.each do |lookup_value|
29
+ lookup_value.value = lookup_value.value.send(method)
30
+ lookup_value.save
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ class UpdatePuppetPortParamType < ActiveRecord::Migration[6.0]
2
+ def up
3
+ update_port_type :to_i
4
+ end
5
+
6
+ def down
7
+ update_port_type :to_s
8
+ end
9
+
10
+ private
11
+
12
+ def update_port_type(method)
13
+ puppet_class = Puppetclass.find_by :name => 'foreman_scap_client'
14
+ return unless puppet_class
15
+ port_key = puppet_class.class_params.find_by :key => 'port'
16
+ return unless port_key
17
+
18
+ if method == :to_i
19
+ port_key.update_columns(:key_type => "integer", :default_value => port_key.default_value.to_i)
20
+ else
21
+ port_key.update_columns(:key_type => "string", :default_value => port_key.default_value.to_s)
22
+ end
23
+ end
24
+ end
@@ -7,9 +7,9 @@ if ForemanOpenscap.with_remote_execution?
7
7
  sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
8
8
  # import! was renamed to import_raw! around 1.3.1
9
9
  if JobTemplate.respond_to?('import_raw!')
10
- template = JobTemplate.import_raw!(File.read(template), :default => true, :locked => true, :update => sync)
10
+ template = JobTemplate.import_raw!(File.read(template), :default => true, :lock => true, :update => sync)
11
11
  else
12
- template = JobTemplate.import!(File.read(template), :default => true, :locked => true, :update => sync)
12
+ template = JobTemplate.import!(File.read(template), :default => true, :lock => true, :update => sync)
13
13
  end
14
14
  template.organizations = organizations if SETTINGS[:organizations_enabled] && template.present?
15
15
  template.locations = locations if SETTINGS[:locations_enabled] && template.present?
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "4.0.1".freeze
2
+ VERSION = "4.0.6".freeze
3
3
  end
@@ -37,6 +37,15 @@ class PolicyTest < ActiveSupport::TestCase
37
37
  assert_equal hostgroup, policy.hostgroups.first
38
38
  end
39
39
 
40
+ test "should not raise when assiging same host by id" do
41
+ host1 = FactoryBot.create(:compliance_host)
42
+ asset = FactoryBot.create(:asset, :assetable_id => host1.id, :assetable_type => 'Host::Base')
43
+ policy = FactoryBot.create(:policy, :assets => [asset], :scap_content => @scap_content, :scap_content_profile => @scap_profile)
44
+ policy.host_ids = [host1, host1].map(&:id)
45
+ policy.save!
46
+ assert_equal 1, policy.hosts.count
47
+ end
48
+
40
49
  test "should remove associated hostgroup" do
41
50
  hg = FactoryBot.create(:hostgroup)
42
51
  asset = FactoryBot.create(:asset, :assetable_id => hg.id, :assetable_type => 'Hostgroup')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_openscap
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.6
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: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -244,6 +244,8 @@ files:
244
244
  - db/migrate/20171016125613_add_content_title_unique_constraint.foreman_openscap.rb
245
245
  - db/migrate/20190103093409_add_deployment_option_to_policy.foreman_openscap.rb
246
246
  - db/migrate/20200117135424_migrate_port_overrides_to_int.rb
247
+ - db/migrate/20200803065041_migrate_port_overrides_for_ansible.rb
248
+ - db/migrate/20201202110213_update_puppet_port_param_type.rb
247
249
  - db/seeds.d/75-job_templates.rb
248
250
  - db/seeds.d/openscap_feature.rb
249
251
  - db/seeds.d/openscap_policy_notification.rb
@@ -356,10 +358,10 @@ test_files:
356
358
  - test/factories/arf_report_factory.rb
357
359
  - test/factories/asset_factory.rb
358
360
  - test/factories/compliance_host_factory.rb
359
- - test/factories/compliance_log_factory.rb
360
361
  - test/factories/policy_arf_report_factory.rb
361
362
  - test/factories/policy_factory.rb
362
363
  - test/factories/scap_content_related.rb
364
+ - test/factories/compliance_log_factory.rb
363
365
  - test/files/arf_report/arf_report.bz2
364
366
  - test/files/arf_report/arf_report.html
365
367
  - test/files/arf_report/arf_report.json
@@ -368,11 +370,11 @@ test_files:
368
370
  - test/files/scap_contents/ssg-fedora-ds.xml
369
371
  - test/files/tailoring_files/ssg-firefox-ds-tailoring-2.xml
370
372
  - test/files/tailoring_files/ssg-firefox-ds-tailoring.xml
371
- - test/functional/api/v2/compliance/arf_reports_controller_test.rb
372
373
  - test/functional/api/v2/compliance/policies_controller_test.rb
373
374
  - test/functional/api/v2/compliance/scap_content_profiles_controller_test.rb
374
375
  - test/functional/api/v2/compliance/scap_contents_controller_test.rb
375
376
  - test/functional/api/v2/compliance/tailoring_files_controller_test.rb
377
+ - test/functional/api/v2/compliance/arf_reports_controller_test.rb
376
378
  - test/functional/api/v2/hosts_controller_test.rb
377
379
  - test/functional/arf_reports_controller_test.rb
378
380
  - test/functional/openscap_proxies_controller_test.rb