foreman_openscap 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: 11979e99299089fd2351b7226729bd04c22b28e6
4
- data.tar.gz: f6024f9b32f0692181a3b13f29b15a23d826c5f8
3
+ metadata.gz: 4fa6212889b88db1926a1167a196758e8be00c39
4
+ data.tar.gz: 936356cbe95d4e44a7bc93980a37d37cb5b55934
5
5
  SHA512:
6
- metadata.gz: 6848c203268a565c4db241fc1a61a4dbd42ad142f3b29835e3db1b560ee91106313e8cf18d9a9e9c9881274f1cef939e5288623b49352fc4c94d5366e90a9e20
7
- data.tar.gz: 6ff62df2218759cabd1fe823b7b4e7e9dfea66d8b8776b3e60603f83accfa2899aee3705c9246e91c59c40ca34897c6ef72e2f127b7bfb369084e839d2f008e4
6
+ metadata.gz: 880ec79e64d9501bdc9f80bbc1eec5d98dd6b622f1c84c56f032f461abc91760a427b87f7fb35d7b653e97b447514bd98822b3f7c5559559d0c2ab5708d5840b
7
+ data.tar.gz: 25358fba90e35c34445dcbdc4264faeecb64e58283018909099e527575d5b735ea78b68d315fcb572391a947787e4c1f4855fc686e231ace17c25d2d4338af48
@@ -1,5 +1,27 @@
1
+ function readFromCookie() {
2
+ try {
3
+ var r = $.cookie(cookieName);
4
+ if (r) {
5
+ return $.parseJSON(r);
6
+ }
7
+ return [];
8
+ } catch (err) {
9
+ removeCookie();
10
+ return [];
11
+ }
12
+ }
13
+
14
+ function removeCookie() {
15
+ $.removeCookie(cookieName);
16
+ }
17
+
18
+ var cookieName = `_ForemanSelected${window.location.pathname.replace(
19
+ /\//,
20
+ ''
21
+ )}`;
22
+
1
23
  function buildArfModal(element, url) {
2
- var url = url + "?" + $.param({arf_report_ids: $.foremanSelectedHosts});
24
+ var url = url + "?" + $.param({arf_report_ids: readFromCookie()});
3
25
  var title = $(element).attr('data-dialog-title');
4
26
  $('#confirmation-modal .modal-header h4').text(title);
5
27
  $("#confirmation-modal .modal-body").load(url + " #content",
@@ -24,6 +24,7 @@ module Api
24
24
 
25
25
  api :GET, '/compliance/arf_reports', N_('List ARF reports')
26
26
  param_group :search_and_pagination, ::Api::V2::BaseController
27
+ add_scoped_search_description_for(::ForemanOpenscap::ArfReport)
27
28
 
28
29
  def index
29
30
  @arf_reports = resource_scope_for_index(:permission => :view_arf_reports).includes(:openscap_proxy, :policy, :host)
@@ -24,6 +24,7 @@ module Api::V2
24
24
 
25
25
  api :GET, '/compliance/policies', N_('List Policies')
26
26
  param_group :search_and_pagination, ::Api::V2::BaseController
27
+ add_scoped_search_description_for(::ForemanOpenscap::Policy)
27
28
 
28
29
  def index
29
30
  @policies = resource_scope_for_index(:permission => :view_policies)
@@ -15,6 +15,7 @@ module Api::V2
15
15
 
16
16
  api :GET, '/compliance/scap_contents', N_('List SCAP contents')
17
17
  param_group :search_and_pagination, ::Api::V2::BaseController
18
+ add_scoped_search_description_for(::ForemanOpenscap::ScapContent)
18
19
 
19
20
  def index
20
21
  @scap_contents = resource_scope_for_index(:permission => :view_scap_contents)
@@ -16,6 +16,7 @@ module Api::V2
16
16
 
17
17
  api :GET, '/compliance/tailoring_files', N_('List Tailoring files')
18
18
  param_group :search_and_pagination, ::Api::V2::BaseController
19
+ add_scoped_search_description_for(::ForemanOpenscap::TailoringFile)
19
20
 
20
21
  def index
21
22
  @tailoring_files = resource_scope_for_index(:permission => :view_tailoring_files)
@@ -18,7 +18,7 @@ module ForemanOpenscap
18
18
  end
19
19
 
20
20
  def update_client_params(model_match, config)
21
- client_item = config.find_config_item self.public_send(config.collection_method)
21
+ client_item = config.find_config_item self.public_send(config.all_collection_method)
22
22
  return unless client_item
23
23
  lookup_keys = client_item.public_send(config.override_method_name)
24
24
  server_key = lookup_keys.find { |param| param.key == config.server_param }
@@ -65,7 +65,7 @@ module ForemanOpenscap
65
65
  end
66
66
 
67
67
  def openscap_proxy_has_feature
68
- errors.add(:openscap_proxy_id, _("must have Openscap feature")) if openscap_proxy_id && !openscap_proxy.has_feature?("Openscap")
68
+ errors.add(:openscap_proxy_id, _("must have Openscap feature")) if openscap_proxy && !openscap_proxy.has_feature?("Openscap")
69
69
  end
70
70
  end
71
71
  end
@@ -16,10 +16,10 @@ module ForemanOpenscap
16
16
  has_many :assets, :through => :asset_policies, :as => :assetable, :dependent => :destroy
17
17
 
18
18
  scoped_search :on => :name, :complete_value => true
19
- scoped_search :in => :scap_content, :on => :title, :rename => 'content', :complete_value => true
20
- scoped_search :in => :scap_content_profile, :on => :title, :rename => 'profile', :complete_value => true
21
- scoped_search :in => :tailoring_file, :on => :name, :rename => 'tailoring_file', :complete_value => true
22
- scoped_search :in => :tailoring_file_profile, :on => :title, :rename => 'tailoring_file_profile', :complete_value => true
19
+ scoped_search :relation => :scap_content, :on => :title, :rename => 'content', :complete_value => true
20
+ scoped_search :relation => :scap_content_profile, :on => :title, :rename => 'profile', :complete_value => true
21
+ scoped_search :relation => :tailoring_file, :on => :name, :rename => 'tailoring_file', :complete_value => true
22
+ scoped_search :relation => :tailoring_file_profile, :on => :title, :rename => 'tailoring_file_profile', :complete_value => true
23
23
  before_validation :update_period_attrs
24
24
 
25
25
  def self.deploy_by_variants
@@ -33,8 +33,14 @@ module ForemanOpenscap
33
33
  constants.config_item_class_name&.pluralize&.underscore
34
34
  end
35
35
 
36
+ def all_collection_method
37
+ "all_#{collection_method}".to_sym
38
+ end
39
+
36
40
  def find_config_item(scope = config_item_class_name.constantize)
37
- scope.find_by :name => config_item_name
41
+ return scope.find_by :name => config_item_name if scope.respond_to?(:find_by)
42
+ # all_puppetclasses, all_ansible_roles methods return Array, not ActiveRecord::Relation
43
+ scope.find { |item| item.name == config_item_name }
38
44
  end
39
45
  end
40
46
  end
@@ -1,8 +1,8 @@
1
- <%= javascript "host_checkbox", "foreman_openscap/arf_reports" %>
1
+ <%= javascript "foreman_openscap/arf_reports" %>
2
2
 
3
3
  <table class="<%= table_css_classes %>">
4
4
  <tr>
5
- <th class="ca" width="40px"><%= check_box_tag "check_all", "", false, { :onclick => "toggleCheck()", :'check-title' => _("Select all items in this page"), :'uncheck-title'=> _("items selected. Uncheck to Clear") } %></th>
5
+ <th class="ca" width="40px"><%= check_box_tag "check_all", "", false, { :onclick => "tfm.hosts.table.toggleCheck()", :'check-title' => _("Select all items in this page"), :'uncheck-title'=> _("items selected. Uncheck to Clear") } %></th>
6
6
  <th><%= sort :host %></th>
7
7
  <th><%= sort :reported, :as => _("Reported At") %></th>
8
8
  <th><%= sort :policy, :as => _("Policy") %></th>
@@ -21,7 +21,7 @@
21
21
  :id => "host_ids_#{arf_report.id}",
22
22
  :disabled => !authorized_for(:controller => :arf_reports, :action => :destroy),
23
23
  :class => 'host_select_boxes',
24
- :onclick => 'hostChecked(this)' %>
24
+ :onclick => 'tfm.hosts.table.hostChecked(this)' %>
25
25
  </td>
26
26
  <td class="elipsis"><%= name_column(arf_report.host) %></td>
27
27
  <td><%= display_link_if_authorized(date_time_relative_value(arf_report.reported_at), hash_for_arf_report_path(:id => arf_report.id)) %></td>
@@ -34,7 +34,7 @@
34
34
  <%= action_buttons(display_link_if_authorized(_("Full Report"), hash_for_show_html_arf_report_path(:id => arf_report.id
35
35
  )),
36
36
  display_delete_if_authorized(hash_for_arf_report_path(:id => arf_report.id),
37
- :confirm => _("Delete compliance report for %s?") % arf_report.host))
37
+ :data => { :confirm => _("Delete compliance report for %s?") % arf_report.host}))
38
38
  %>
39
39
  </td>
40
40
  </tr>
@@ -36,7 +36,7 @@
36
36
  display_link_if_authorized(_("Dashboard"), hash_for_policy_dashboard_policy_path(:id => policy.id)),
37
37
  display_link_if_authorized(_("Show Guide"), hash_for_policy_path(:id => policy.id)),
38
38
  display_delete_if_authorized(hash_for_policy_path(:id => policy.id),
39
- :confirm => _("Delete compliance policy %s with all of its reports?") % policy.name)
39
+ :data => {:confirm => _("Delete compliance policy %s with all of its reports?") % policy.name})
40
40
  ) %>
41
41
  </td>
42
42
  </tr>
@@ -16,7 +16,7 @@
16
16
  <%= action_buttons(
17
17
  display_link_if_authorized(_("Download"), hash_for_scap_content_path(:id => content.id), :data => { :no_turbolink => true }),
18
18
  display_delete_if_authorized(hash_for_scap_content_path(:id => content.id),
19
- :confirm => _("Delete scap content %s?") % content.title)
19
+ :data => {:confirm => _("Delete scap content %s?") % content.title})
20
20
  ) %>
21
21
  </td>
22
22
  </tr>
@@ -19,7 +19,7 @@
19
19
  <td>
20
20
  <%= action_buttons(
21
21
  display_delete_if_authorized(hash_for_tailoring_file_path(:id => file.id),
22
- :confirm => _("Delete tailoring file %s?") % file.name),
22
+ :data => {:confirm => _("Delete tailoring file %s?") % file.name}),
23
23
  display_link_if_authorized(_("Download"), hash_for_xml_tailoring_file_path(:id => file.id), :data => { :no_turbolink => true })
24
24
  ) %>
25
25
  </td>
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
@@ -1,12 +1,12 @@
1
1
  FactoryBot.define do
2
2
  factory :arf_report, :class => ::ForemanOpenscap::ArfReport do
3
- host_id 1
4
- policy nil
5
- policy_arf_report nil
3
+ host_id { 1 }
4
+ policy { nil }
5
+ policy_arf_report { nil }
6
6
  sequence(:reported_at) { |n| Time.new(1490 + n, 0o1, 13, 15, 24, 0o0) }
7
7
  sequence(:created_at) { |n| Time.new(1490 + n, 0o1, 13, 15, 24, 0o0) }
8
- status 0
9
- metrics({})
10
- openscap_proxy nil
8
+ status { 0 }
9
+ metrics { {} }
10
+ openscap_proxy { nil }
11
11
  end
12
12
  end
@@ -1,11 +1,11 @@
1
1
  FactoryBot.define do
2
2
  factory :asset, :class => ::ForemanOpenscap::Asset do |f|
3
3
  f.assetable_id { FactoryBot.create(:host).id }
4
- f.assetable_type 'Host::Base'
4
+ f.assetable_type { 'Host::Base' }
5
5
  end
6
6
 
7
7
  factory :asset_policy, :class => ForemanOpenscap::AssetPolicy do |f|
8
- f.asset_id nil
9
- f.policy_id nil
8
+ f.asset_id { nil }
9
+ f.policy_id { nil }
10
10
  end
11
11
  end
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :openscap_feature, :class => Feature do
3
- name 'Openscap'
3
+ name { 'Openscap' }
4
4
  end
5
5
 
6
6
  factory :openscap_proxy, :class => SmartProxy do
@@ -12,8 +12,8 @@ FactoryBot.define do
12
12
  factory :compliance_host, :class => Host::Managed do
13
13
  sequence(:name) { |n| "host#{n}" }
14
14
  sequence(:hostname) { |n| "hostname#{n}" }
15
- root_pass 'xybxa6JUkz63w'
15
+ root_pass { 'xybxa6JUkz63w' }
16
16
  openscap_proxy { SmartProxy.unscoped.with_features('Openscap').first || FactoryBot.create(:openscap_proxy) }
17
- policies []
17
+ policies { [] }
18
18
  end
19
19
  end
@@ -1,8 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :compliance_log, :class => :log do
3
- result "fail"
3
+ result { "fail" }
4
4
  association :report
5
- level_id 1
5
+ level_id { 1 }
6
6
  association :source
7
7
  association :message
8
8
  end
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :policy_arf_report, :class => ForemanOpenscap::PolicyArfReport do
3
- policy_id nil
4
- arf_report_id nil
3
+ policy_id { nil }
4
+ arf_report_id { nil }
5
5
  end
6
6
  end
@@ -1,16 +1,16 @@
1
1
  FactoryBot.define do
2
2
  factory :policy, :class => ::ForemanOpenscap::Policy do
3
3
  sequence(:name) { |n| "policy#{n}" }
4
- period 'weekly'
5
- weekday 'monday'
4
+ period { 'weekly' }
5
+ weekday { 'monday' }
6
6
  scap_content { FactoryBot.create(:scap_content) }
7
7
  scap_content_profile { FactoryBot.create(:scap_content_profile, :scap_content => scap_content) }
8
- tailoring_file nil
9
- tailoring_file_profile nil
10
- day_of_month nil
11
- cron_line nil
12
- hosts []
13
- assets []
14
- deploy_by 'manual'
8
+ tailoring_file { nil }
9
+ tailoring_file_profile { nil }
10
+ day_of_month { nil }
11
+ cron_line { nil }
12
+ hosts { [] }
13
+ assets { [] }
14
+ deploy_by { 'manual' }
15
15
  end
16
16
  end
@@ -3,20 +3,20 @@ include ActionDispatch::TestProcess
3
3
  FactoryBot.define do
4
4
  factory :scap_content, :class => ::ForemanOpenscap::ScapContent do |f|
5
5
  f.sequence(:title) { |n| "scap_content_title_#{n}" }
6
- f.original_filename 'fedora ds'
6
+ f.original_filename { 'fedora ds' }
7
7
  f.scap_file { File.new("#{ForemanOpenscap::Engine.root}/test/files/scap_contents/ssg-fedora-ds.xml", 'rb').read }
8
8
  end
9
9
 
10
10
  factory :scap_content_profile, :class => ::ForemanOpenscap::ScapContentProfile do |f|
11
11
  f.scap_content
12
- f.profile_id 'xccdf_org.test.common_test_profile'
13
- f.title 'test Profile for testing'
12
+ f.profile_id { 'xccdf_org.test.common_test_profile' }
13
+ f.title { 'test Profile for testing' }
14
14
  end
15
15
 
16
16
  factory :tailoring_file, :class => ForemanOpenscap::TailoringFile do |f|
17
17
  f.sequence(:name) { |n| "tailoring_file_#{n}" }
18
- f.original_filename 'original tailoring filename'
18
+ f.original_filename { 'original tailoring filename' }
19
19
  f.scap_file { File.new("#{ForemanOpenscap::Engine.root}/test/files/tailoring_files/ssg-firefox-ds-tailoring.xml", 'rb').read }
20
- f.scap_content_profiles []
20
+ f.scap_content_profiles { [] }
21
21
  end
22
22
  end
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: 1.0.1
4
+ version: 1.0.2
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-05-16 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface