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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8860c02972d0a7286d2d44f6a23c02a79a540ad1
4
- data.tar.gz: a0789f0a6842b9609f688208e9a7e9dc7289ba1f
3
+ metadata.gz: e8f52d649074a7a24698aa4daa23ec072a154db1
4
+ data.tar.gz: 5b1bd3961f6757d2d3a0dac0339ea2f24bdf3e88
5
5
  SHA512:
6
- metadata.gz: 6f5c7ba56f44c5db6828ffa2d5f6d02fb470e910c8614a11ec68121962f04c96472b5edf6e35e4abd20b29b68b012f3c67c0b192268c98b517f7ee8b63b4286c
7
- data.tar.gz: 2b495b6833ec1362dc7dcc386d83e1a3c076c742db55bce19b80301f793b961e8db16535abaf41478d28815086305447dff21ed6c15d5a40626260b4eb7b7f54
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 from RPMS
102
+ ## Installation
103
103
 
104
- - Install Foreman from [upstream](http://theforeman.org/)
104
+ - Follow the official guide on [theforeman.org](https://theforeman.org/plugins/foreman_openscap/0.8/index.html#2.Installation)
105
105
 
106
- - Install foreman-proxy_openscap to all your foreman-proxies from [upstream](https://github.com/OpenSCAP/foreman-proxy_openscap)
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
- yum install rubygem-foreman_openscap ruby193-rubygem-foreman_openscap
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
- $ git clone https://github.com/OpenSCAP/foreman_openscap.git
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
- # yum localinstall ~/rpmbuild/RPMS/noarch/ruby193-rubygem-foreman_openscap-*.noarch.rpm
141
- # service foreman restart
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
- logger.error "Failed to destroy arf report with id #{report.id} on Smart Proxy"
55
- logger.debug e.backtrace.join("\n\t")
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
- scoped_search :relation => :policy, :on => :name, :complete_value => true, :rename => :compliance_policy,
71
- :only_explicit => true, :ext_method => :search_by_policy_name
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
- begin
194
- openscap_proxy_api.destroy_report(self, ForemanOpenscap::Helper::find_name_or_uuid_by_host(host))
195
- rescue Foreman::Exception => e
196
- logger.error "Failed to delete report with id #{id} from proxy, cause: #{e.message}"
197
- logger.debug e.backtrace.join("\n\t")
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
- logger.error "Failed to delete report with id #{id} from proxy, no host associated with report"
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="table table-bordered table-striped">
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>
@@ -14,7 +14,7 @@
14
14
  </div>
15
15
  </div>
16
16
  <div class="col-md-4">
17
- <table class='table table-bordered table-striped'>
17
+ <table class='<%= table_css_classes %>'>
18
18
  <tbody>
19
19
  <% metrics.sort.each do |title, value|%>
20
20
  <tr>
@@ -1,4 +1,4 @@
1
- <table id='report_log' class="table table-bordered table-striped">
1
+ <table id='report_log' class="<%= table_css_classes %>">
2
2
  <thead>
3
3
  <tr>
4
4
  <th><%= _("Severity") %></th>
@@ -1,6 +1,6 @@
1
1
  <div class="row">
2
2
  <div class="col-md-8">
3
- <table class="table table-bordered table-striped">
3
+ <table class="<%= table_css_classes %>">
4
4
  <thead>
5
5
  <tr>
6
6
  <th>
@@ -3,7 +3,7 @@
3
3
  <% if latest_reports.empty? %>
4
4
  <p class="ca"><%= _("No reports available") %></p>
5
5
  <% else %>
6
- <table class="table table-striped table-fixed">
6
+ <table class="<%= table_css_classes('table-fixed') %>">
7
7
  <tr>
8
8
  <%= latest_compliance_headers %>
9
9
  </tr>
@@ -1,4 +1,4 @@
1
- <table class="table table-bordered table-striped table-fixed">
1
+ <table class="<%= table_css_classes('table-fixed') %>">
2
2
  <tr>
3
3
  <th><%= _('Name') %></th>
4
4
  <th><%= _('Content') %></th>
@@ -1,4 +1,4 @@
1
- <table class="table table-bordered table-striped ellipsis">
1
+ <table class="<%= table_css_classes('ellipsis') %>">
2
2
  <tr>
3
3
  <th><%= _('Host') %></th>
4
4
  <th><%= _("Date") %></th>
@@ -21,4 +21,4 @@
21
21
  </td>
22
22
  </tr>
23
23
  <% end %>
24
- </table>
24
+ </table>
@@ -1,4 +1,4 @@
1
- <table class="table table-bordered table-striped table-two-pane table-fixed">
1
+ <table class="<%= table_css_classes('table-two-pane table-fixed') %>">
2
2
  <tr>
3
3
  <th class="col-md-4">Title</th>
4
4
  <th class="col-md-4">Filename</th>
@@ -1,4 +1,4 @@
1
- <table class="table table-bordered table-striped table-fixed">
1
+ <table class="<%= table_css_classes('table-fixed') %>">
2
2
  <tr>
3
3
  <th class="col-md-4"><%= _('Name')%></th>
4
4
  <th class="col-md-4"><%= _('Filename') %></th>
@@ -1,8 +1,10 @@
1
1
  class RemoveArfReportsWithoutPolicy < ActiveRecord::Migration[4.2]
2
2
  def up
3
- ids_to_keep = ForemanOpenscap::ArfReport.unscoped.all.joins(:policy_arf_report).pluck(:id)
4
- ForemanOpenscap::ArfReport.unscoped.where.not(:id => ids_to_keep).find_in_batches do |batch|
5
- batch.map(&:destroy!)
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)
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "0.9.0".freeze
2
+ VERSION = "0.9.1".freeze
3
3
  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: 0.9.0
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-01-11 00:00:00.000000000 Z
11
+ date: 2018-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface