foreman_openscap 0.6.1 → 0.6.2
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.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/compliance/arf_reports_controller.rb +0 -10
- data/app/controllers/policies_controller.rb +1 -3
- data/app/controllers/policy_dashboard_controller.rb +0 -10
- data/app/helpers/arf_reports_helper.rb +0 -10
- data/app/helpers/compliance_dashboard_helper.rb +0 -10
- data/app/helpers/policy_dashboard_helper.rb +0 -10
- data/app/models/concerns/foreman_openscap/host_extensions.rb +1 -1
- data/app/models/concerns/foreman_openscap/openscap_proxy_core_extensions.rb +1 -1
- data/app/models/foreman_openscap/policy.rb +3 -1
- data/app/views/policies/_list.html.erb +2 -2
- data/app/views/scap_contents/_list.html.erb +7 -11
- data/lib/foreman_openscap/engine.rb +1 -1
- data/lib/foreman_openscap/helper.rb +0 -10
- data/lib/foreman_openscap/version.rb +1 -1
- data/test/unit/policy_test.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feef787c3ec3853ea3ea69ec359a943e81fed594
|
4
|
+
data.tar.gz: c2c279115757242903e06b02a38477bbc130762e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.
|
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
|
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
|
-
|
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.
|
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
|
data/test/unit/policy_test.rb
CHANGED
@@ -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.
|
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-
|
14
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: deface
|