foreman_openscap 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -32
- data/app/lib/proxy_api/openscap.rb +3 -2
- data/app/models/concerns/foreman_openscap/compliance_status_scoped_search.rb +10 -2
- data/app/models/foreman_openscap/arf_report.rb +14 -8
- data/app/views/arf_reports/_list.html.erb +1 -1
- data/app/views/arf_reports/_metrics.html.erb +1 -1
- data/app/views/arf_reports/_output.html.erb +1 -1
- data/app/views/arf_reports/delete_multiple.html.erb +1 -1
- data/app/views/dashboard/_compliance_host_reports_widget.html.erb +1 -1
- data/app/views/policies/_list.html.erb +1 -1
- data/app/views/policy_dashboard/_policy_reports.html.erb +2 -2
- data/app/views/scap_contents/_list.html.erb +1 -1
- data/app/views/tailoring_files/_list.html.erb +1 -1
- data/db/migrate/20171011134112_remove_arf_reports_without_policy.rb +5 -3
- data/lib/foreman_openscap/engine.rb +0 -1
- data/lib/foreman_openscap/version.rb +1 -1
- 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: e8f52d649074a7a24698aa4daa23ec072a154db1
|
4
|
+
data.tar.gz: 5b1bd3961f6757d2d3a0dac0339ea2f24bdf3e88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d444fb32f8c0c3dfbbd2e59bce1c89e3c39f966c21cc6daa26310b0338f555aa4b31480ec1a36428fa08a0e3fbc1dedc89316d23382af84afd097ff5abf42ae0
|
7
|
+
data.tar.gz: 823709a0c3872f547a65beabf94e431394b494936e46c732905da95e342b29c4bf48e1f01734b3db89a2afec88f4dbaab36a26af6730d47317e6d391e64c3dd7
|
data/README.md
CHANGED
@@ -99,47 +99,29 @@ Make sure that
|
|
99
99
|
3. Go to *Hosts -> Compliance -> Policies* page
|
100
100
|
4. Click the policy link to view dashboard and trend
|
101
101
|
|
102
|
-
## Installation
|
102
|
+
## Installation
|
103
103
|
|
104
|
-
-
|
104
|
+
- Follow the official guide on [theforeman.org](https://theforeman.org/plugins/foreman_openscap/0.8/index.html#2.Installation)
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
- Enable [isimluk/OpenSCAP](https://copr.fedoraproject.org/coprs/isimluk/OpenSCAP/) COPR repository
|
109
|
-
|
110
|
-
- Install Foreman_OpenSCAP
|
106
|
+
## Development setup
|
111
107
|
|
108
|
+
- set up Foreman for development, preferably using [forklift](https://github.com/theforeman/forklift)
|
109
|
+
- clone this repo
|
112
110
|
```
|
113
|
-
|
111
|
+
git clone https://github.com/theforeman/foreman_openscap.git
|
114
112
|
```
|
115
|
-
|
116
|
-
## Installation from upstream git
|
117
|
-
|
118
|
-
- Install Foreman from [upstream](http://theforeman.org/)
|
119
|
-
- Install SCAPtimony from [upstream](https://github.com/OpenSCAP/scaptimony)
|
120
|
-
- Install foreman-proxy_openscap to all your foreman-proxies from [upstream](https://github.com/OpenSCAP/foreman-proxy_openscap)
|
121
|
-
- Get foreman_openscap sources
|
122
|
-
|
113
|
+
- point foreman to your checkout
|
123
114
|
```
|
124
|
-
|
115
|
+
echo "gemspec :path => 'path/to/foreman_openscap'" >> foreman/bundler.d/Gemfile.local.rb
|
125
116
|
```
|
126
|
-
|
127
|
-
- Build foreman_openscap RPM (instructions for Red Hat Enterprise Linux 6)
|
128
|
-
|
129
|
-
```
|
130
|
-
$ cd foreman_openscap
|
131
|
-
$ gem build foreman_openscap.gemspec
|
132
|
-
# yum install yum-utils rpm-build scl-utils scl-utils-build ruby193-rubygems-devel ruby193-build ruby193
|
133
|
-
# yum-builddep extra/rubygem-foreman_openscap.spec
|
134
|
-
$ rpmbuild --define "_sourcedir `pwd`" --define "scl ruby193" -ba extra/rubygem-foreman_openscap.spec
|
135
|
-
```
|
136
|
-
|
137
|
-
- Install foreman_openscap RPM
|
138
|
-
|
117
|
+
- run bundler, migrations and seeds from foreman dir
|
139
118
|
```
|
140
|
-
|
141
|
-
|
119
|
+
cd foreman
|
120
|
+
bundle install
|
121
|
+
rake db:migrate
|
122
|
+
rake db:seed
|
142
123
|
```
|
124
|
+
- start your Rails server, verify openscap plugin is present
|
143
125
|
|
144
126
|
## Releasing
|
145
127
|
|
@@ -51,8 +51,9 @@ module ::ProxyAPI
|
|
51
51
|
begin
|
52
52
|
parse(delete("arf/#{report.id}/#{cname}/#{report.reported_at.to_i}/#{report.policy_arf_report.digest}"))
|
53
53
|
rescue => e
|
54
|
-
|
55
|
-
logger.
|
54
|
+
msg = "Failed to destroy arf report with id #{report.id} on Smart Proxy, cause: #{e.message}"
|
55
|
+
logger.error msg
|
56
|
+
report.errors.add(:base, msg)
|
56
57
|
false
|
57
58
|
end
|
58
59
|
end
|
@@ -9,6 +9,11 @@ module ForemanOpenscap
|
|
9
9
|
scoped_search options
|
10
10
|
end
|
11
11
|
|
12
|
+
def policy_search(search_alias)
|
13
|
+
scoped_search :relation => :policy, :on => :name, :complete_value => true, :rename => search_alias,
|
14
|
+
:only_explicit => true, :ext_method => :search_by_policy_name
|
15
|
+
end
|
16
|
+
|
12
17
|
def search_by_policy_name(_key, _operator, policy_name)
|
13
18
|
cond = sanitize_policy_name(policy_name)
|
14
19
|
{ :conditions => ArfReport.arel_table[:id].in(
|
@@ -67,8 +72,9 @@ module ForemanOpenscap
|
|
67
72
|
end
|
68
73
|
|
69
74
|
included do
|
70
|
-
|
71
|
-
|
75
|
+
policy_search :compliance_policy
|
76
|
+
|
77
|
+
policy_search :policy
|
72
78
|
|
73
79
|
scoped_search :on => :id, :rename => :last_for, :complete_value => { :host => 0, :policy => 1 },
|
74
80
|
:only_explicit => true, :ext_method => :search_by_last_for
|
@@ -82,6 +88,8 @@ module ForemanOpenscap
|
|
82
88
|
scoped_search :relation => :policy, :on => :name, :complete_value => true, :rename => :inconclusive_with,
|
83
89
|
:only_explicit => true, :operators => ['= '], :ext_method => :search_by_inconclusive_with
|
84
90
|
|
91
|
+
scoped_search :relation => :openscap_proxy, :on => :name, :complete_value => true, :only_explicit => true, :rename => :openscap_proxy
|
92
|
+
|
85
93
|
compliance_status_scoped_search 'passed', :on => :status, :rename => :compliance_passed
|
86
94
|
compliance_status_scoped_search 'failed', :on => :status, :rename => :compliance_failed
|
87
95
|
compliance_status_scoped_search 'othered', :on => :status, :rename => :compliance_othered
|
@@ -10,6 +10,8 @@ module ForemanOpenscap
|
|
10
10
|
BIT_NUM = 10
|
11
11
|
MAX = (1 << BIT_NUM) - 1
|
12
12
|
|
13
|
+
include ComplianceStatusScopedSearch
|
14
|
+
|
13
15
|
scoped_search :on => :status, :offset => 0, :word_size => 4 * BIT_NUM, :complete_value => { :true => true, :false => false }, :rename => :eventful
|
14
16
|
|
15
17
|
has_one :policy_arf_report
|
@@ -189,18 +191,22 @@ module ForemanOpenscap
|
|
189
191
|
end
|
190
192
|
|
191
193
|
def destroy_from_proxy
|
192
|
-
if host
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
end
|
194
|
+
if !host
|
195
|
+
destroy_from_proxy_warning "host"
|
196
|
+
elsif !policy
|
197
|
+
destroy_from_proxy_warning "policy"
|
198
|
+
elsif !openscap_proxy
|
199
|
+
destroy_from_proxy_warning "OpenSCAP proxy"
|
199
200
|
else
|
200
|
-
|
201
|
+
openscap_proxy_api.destroy_report(self, ForemanOpenscap::Helper::find_name_or_uuid_by_host(host))
|
201
202
|
end
|
202
203
|
end
|
203
204
|
|
205
|
+
def destroy_from_proxy_warning(associated)
|
206
|
+
logger.warn "Skipping deletion of report with id #{id} from proxy, no #{associated} associated with report"
|
207
|
+
true
|
208
|
+
end
|
209
|
+
|
204
210
|
def self.newline_to_space(string)
|
205
211
|
string.gsub(/ *\n+/, " ")
|
206
212
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= javascript "host_checkbox", "foreman_openscap/arf_reports" %>
|
2
2
|
|
3
|
-
<table class="
|
3
|
+
<table class="<%= table_css_classes %>">
|
4
4
|
<tr>
|
5
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>
|
6
6
|
<th><%= sort :host %></th>
|
@@ -1,8 +1,10 @@
|
|
1
1
|
class RemoveArfReportsWithoutPolicy < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
User.as_anonymous_admin do
|
4
|
+
ids_to_keep = ForemanOpenscap::ArfReport.unscoped.all.joins(:policy_arf_report).pluck(:id)
|
5
|
+
ForemanOpenscap::ArfReport.unscoped.where.not(:id => ids_to_keep).find_in_batches do |batch|
|
6
|
+
batch.map(&:destroy!)
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
@@ -204,7 +204,6 @@ module ForemanOpenscap
|
|
204
204
|
Hostgroup.send(:include, ForemanOpenscap::OpenscapProxyExtensions)
|
205
205
|
Hostgroup.send(:include, ForemanOpenscap::OpenscapProxyCoreExtensions)
|
206
206
|
Hostgroup.send(:include, ForemanOpenscap::HostgroupExtensions)
|
207
|
-
ForemanOpenscap::ArfReport.send(:include, ForemanOpenscap::ComplianceStatusScopedSearch)
|
208
207
|
SmartProxy.send(:include, ForemanOpenscap::SmartProxyExtensions)
|
209
208
|
HostsController.send(:prepend, ForemanOpenscap::HostsControllerExtensions)
|
210
209
|
Log.send(:include, ForemanOpenscap::LogExtensions)
|
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: 0.9.
|
4
|
+
version: 0.9.1
|
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: 2018-
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|