foreman_openscap 0.6.1 → 0.6.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: 52ccf5d3a2cc3bae2f3c55710682384f2b61f014
4
- data.tar.gz: 2d5b7cc101b171f481fa245491d00770e47ba40c
3
+ metadata.gz: feef787c3ec3853ea3ea69ec359a943e81fed594
4
+ data.tar.gz: c2c279115757242903e06b02a38477bbc130762e
5
5
  SHA512:
6
- metadata.gz: 02cc5a12f0646e510c0b1eb5b637a796305adb0138f8dd6d61b715982a7e066385556b8dc91b10a8a2be9c57aa7b49a74ebcc2d560f508591e01ea563fc76dc5
7
- data.tar.gz: 6ce694688245b777a394284ab7412d13b53f2f4d0d2c19e9a9e70c895c8a918256bc764b2a629ac329bda51cfd9be2c54e3c3d7c78c069c54619cf6dc8165741
6
+ metadata.gz: 7cc362c03e631e6c5141baeb72513316e71681102dfb8e750ddbd2b1d54e1f54a8290c3a76182c490e3e0913dfc8613f3c971fc886bcdbd299c3c22a6cedb327
7
+ data.tar.gz: df71b007ba7183e3ff55b5a90158530c784568244aa3164130d8ef9c4bb91c59a1bf4ff7e489d449f62de19bcf4b75ea9480b6dcfd1142d1e45907c784e85ad3
@@ -1,13 +1,3 @@
1
- #
2
- # Copyright (c) 2014--2015 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
1
  require 'foreman_openscap/helper'
12
2
 
13
3
  module Api
@@ -31,9 +31,7 @@ class PoliciesController < ApplicationController
31
31
  end
32
32
 
33
33
  def create
34
- # we must call unscoped, otherwise taxonomix default scope gets mixed into taxable_taxonomies object
35
- # setting taxable_id, making them invalid
36
- @policy = ::ForemanOpenscap::Policy.unscoped.new(policy_params)
34
+ @policy = ::ForemanOpenscap::Policy.new(policy_params)
37
35
  if @policy.wizard_completed? && @policy.save
38
36
  process_success :success_redirect => policies_path
39
37
  else
@@ -1,13 +1,3 @@
1
- #
2
- # Copyright (c) 2014 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
1
  class PolicyDashboardController < ApplicationController
12
2
  before_filter :prefetch_data, :only => :index
13
3
 
@@ -1,13 +1,3 @@
1
- #
2
- # Copyright (c) 2014 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
1
  module ArfReportsHelper
12
2
  def report_arf_column(event, style = "")
13
3
  style = "label-default" if event == 0
@@ -1,13 +1,3 @@
1
- #
2
- # Copyright (c) 2014 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
1
  module ComplianceDashboardHelper
12
2
 
13
3
  def latest_compliance_headers
@@ -1,13 +1,3 @@
1
- #
2
- # Copyright (c) 2014 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
1
  module PolicyDashboardHelper
12
2
  COLORS = {
13
3
  :compliant_hosts => ArfReportDashboardHelper::COLORS[:passed],
@@ -20,7 +20,7 @@ module ForemanOpenscap
20
20
  :complete_value => {:compliant => ::ForemanOpenscap::ComplianceStatus::COMPLIANT,
21
21
  :incompliant => ::ForemanOpenscap::ComplianceStatus::INCOMPLIANT,
22
22
  :inconclusive => ::ForemanOpenscap::ComplianceStatus::INCONCLUSIVE}
23
- after_update :puppetrun!, :if => ->(host) { Setting[:puppetrun] && host.openscap_proxy_id_changed? }
23
+ after_update :puppetrun!, :if => ->(host) { Setting[:puppetrun] && host.changed.include?('openscap_proxy_id') }
24
24
 
25
25
  scope :comply_with, lambda { |policy|
26
26
  joins(:arf_reports).merge(ArfReport.latest_of_policy policy).merge(ArfReport.passed)
@@ -67,7 +67,7 @@ module ForemanOpenscap
67
67
  end
68
68
 
69
69
  def scap_client_class_present
70
- if openscap_proxy_id_changed? && openscap_proxy_id
70
+ if changed.include?('openscap_proxy_id') && self.respond_to?(:openscap_proxy_id) && openscap_proxy_id
71
71
  errors.add(:openscap_proxy_id, _("Puppet class 'foreman_scap_client' not found, make sure it is imported from Puppet master")) unless find_scap_client
72
72
  end
73
73
  end
@@ -20,11 +20,13 @@ module ForemanOpenscap
20
20
 
21
21
  before_validation :update_period_attrs
22
22
 
23
- validates :name, :presence => true, :uniqueness => true
23
+ validates :name, :presence => true, :uniqueness => true, :length => { :maximum => 255 }
24
24
  validate :ensure_needed_puppetclasses
25
25
  validates :period, :inclusion => {:in => %w(weekly monthly custom), :message => _('is not a valid value')},
26
26
  :if => Proc.new { |policy| policy.should_validate?('Schedule') }
27
27
 
28
+ validates :scap_content_id, presence: true, if: Proc.new { |policy| policy.should_validate?('SCAP Content') }
29
+ validates :scap_content_profile_id, presence: true, if: Proc.new { |policy| policy.should_validate?('SCAP Content') }
28
30
 
29
31
  validate :valid_cron_line, :valid_weekday, :valid_day_of_month
30
32
 
@@ -1,4 +1,4 @@
1
- <table class="table table-bordered table-striped">
1
+ <table class="table table-bordered table-striped table-fixed">
2
2
  <tr>
3
3
  <th>Name</th>
4
4
  <th>Content</th>
@@ -7,7 +7,7 @@
7
7
  </tr>
8
8
  <% for policy in @policies %>
9
9
  <tr>
10
- <td>
10
+ <td class="ellipsis">
11
11
  <%= link_to_if_authorized(policy.name.to_s, hash_for_policy_dashboard_policy_path(:id => policy.id)) %>
12
12
  </td>
13
13
  <td>
@@ -1,18 +1,14 @@
1
- <table class="table table-bordered table-striped table-two-pane">
1
+ <table class="table table-bordered table-striped table-two-pane table-fixed">
2
2
  <tr>
3
- <th>Title</th>
4
- <th>Filename</th>
5
- <th>Created</th>
6
- <th></th>
3
+ <th class="col-md-4">Title</th>
4
+ <th class="col-md-4">Filename</th>
5
+ <th class="col-md-3">Created</th>
6
+ <th class="col-md-1"></th>
7
7
  </tr>
8
8
  <% for content in @contents %>
9
9
  <tr>
10
- <td>
11
- <%= content.title %>
12
- </td>
13
- <td>
14
- <%= content.original_filename %>
15
- </td>
10
+ <td class="ellipsis"><%= content.title %></td>
11
+ <td class="ellipsis"><%= content.original_filename %></td>
16
12
  <td>
17
13
  <%= _("%s ago") % time_ago_in_words(content.created_at.getlocal) %>
18
14
  </td>
@@ -41,7 +41,7 @@ module ForemanOpenscap
41
41
 
42
42
  initializer 'foreman_openscap.register_plugin', :before => :finisher_hook do |app|
43
43
  Foreman::Plugin.register :foreman_openscap do
44
- requires_foreman '>= 1.11'
44
+ requires_foreman '>= 1.13'
45
45
 
46
46
  apipie_documented_controllers ["#{ForemanOpenscap::Engine.root}/app/controllers/api/v2/compliance/*.rb"]
47
47
 
@@ -1,13 +1,3 @@
1
- #
2
- # Copyright (c) 2014 Red Hat Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public License,
5
- # version 3 (GPLv3). There is NO WARRANTY for this software, express or
6
- # implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
8
- # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt
9
- #
10
-
11
1
  module ForemanOpenscap::Helper
12
2
  def self.get_asset(cname, policy_id)
13
3
  asset = find_host_by_name_or_uuid(cname).get_asset
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -122,4 +122,22 @@ class PolicyTest < ActiveSupport::TestCase
122
122
  p.day_of_month = nil
123
123
  assert p.save
124
124
  end
125
+
126
+ test "should not create policy without SCAP content" do
127
+ p = ForemanOpenscap::Policy.new(:name => "custom_policy",
128
+ :scap_content_profile_id => @scap_profile.id,
129
+ :period => 'monthly',
130
+ :day_of_month => '5')
131
+ refute p.save
132
+ assert p.errors[:scap_content_id].include?("can't be blank")
133
+ end
134
+
135
+ test "should not create policy without SCAP content profile" do
136
+ p = ForemanOpenscap::Policy.new(:name => "custom_policy",
137
+ :scap_content_id => @scap_content.id,
138
+ :period => 'monthly',
139
+ :day_of_month => '5')
140
+ refute p.save
141
+ assert p.errors[:scap_content_profile_id].include?("can't be blank")
142
+ end
125
143
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_openscap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Šimon Lukašík"
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-09-06 00:00:00.000000000 Z
14
+ date: 2016-09-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: deface