foreman_openscap 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -3
  3. data/app/assets/javascript/policy_edit.js +14 -0
  4. data/app/controllers/scaptimony_arf_reports_controller.rb +31 -0
  5. data/app/controllers/scaptimony_dashboard_controller.rb +6 -0
  6. data/app/controllers/scaptimony_policies_controller.rb +58 -0
  7. data/app/controllers/scaptimony_scap_contents_controller.rb +54 -0
  8. data/app/helpers/arf_reports_helper.rb +16 -0
  9. data/app/helpers/scaptimony_policies_helper.rb +7 -0
  10. data/app/models/concerns/foreman_openscap/arf_report_extensions.rb +1 -2
  11. data/app/models/concerns/foreman_openscap/policy_extensions.rb +20 -0
  12. data/app/models/concerns/foreman_openscap/scap_content_extensions.rb +20 -0
  13. data/app/views/scaptimony_arf_reports/_list.html.erb +27 -0
  14. data/app/views/scaptimony_arf_reports/index.html.erb +4 -0
  15. data/app/views/scaptimony_policies/_form.html.erb +39 -0
  16. data/app/views/scaptimony_policies/_list.html.erb +34 -0
  17. data/app/views/scaptimony_policies/_scap_content_results.html.erb +10 -0
  18. data/app/views/scaptimony_policies/edit.html.erb +3 -0
  19. data/app/views/scaptimony_policies/index.html.erb +9 -0
  20. data/app/views/scaptimony_policies/new.html.erb +3 -0
  21. data/app/views/scaptimony_policies/welcome.html.erb +10 -0
  22. data/app/views/scaptimony_scap_contents/_form.html.erb +18 -0
  23. data/app/views/scaptimony_scap_contents/_list.html.erb +27 -0
  24. data/app/views/scaptimony_scap_contents/edit.html.erb +3 -0
  25. data/app/views/scaptimony_scap_contents/index.html.erb +5 -0
  26. data/app/views/scaptimony_scap_contents/new.html.erb +3 -0
  27. data/config/routes.rb +12 -1
  28. data/lib/foreman_openscap/engine.rb +34 -9
  29. data/lib/foreman_openscap/version.rb +1 -1
  30. metadata +25 -5
  31. data/app/controllers/arf_reports_controller.rb +0 -23
  32. data/app/views/arf_reports/_list.html.erb +0 -18
  33. data/app/views/arf_reports/index.html.erb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85d4887656fc8e0fdb1e995c64da16fde4a837cb
4
- data.tar.gz: 7e5dd3ca26c3e763c5701ba5e68dd3b812c38129
3
+ metadata.gz: 9099dd74d7cf2f5a4d208da949f2985b7e439b68
4
+ data.tar.gz: 86e35c42bd3592cd233cde1edb2e07447027f1d0
5
5
  SHA512:
6
- metadata.gz: 70f7f2cbeb0c2ce2ba0016646fe5cc58295d89326ffa0059155962640deeaeff931aa6b76017024550a54e47523b62aea42570b6e962c85afa9750516fd3b112
7
- data.tar.gz: 9584c879754e1ca0eecc0499fe273fd134a5e85735a05bd29eb907173a0430563c987250e577055f733d6e7d69dc10c19b59032b0c6ea08caa77f33ae9b6ed4e
6
+ metadata.gz: 36ddf368e83db6d1f6b155cbe63cd07addfa3bd48a302020878e9f02460b224753e9a26cbb077ed9a26031be89a1b2dbbf69cf45d216c575e4f8fb97d9c62f28
7
+ data.tar.gz: b5224b0a227ba97923cc6aed1e550a5e28bc291b2b11a70822585dcf5b3c2db1287cee865b60b884c7b1fa625f55f23566d5ad7d3570fcaaf02a19bfbc0cd243
data/README.md CHANGED
@@ -4,17 +4,21 @@ This plug-in enables automated vulnerability assessment and compliance audit
4
4
  of Foreman based infrastructure.
5
5
 
6
6
  + Current features:
7
+ + Centralized policy management
7
8
  + Collect & achieve OpenSCAP audit results from your infrastructure
8
- + Future features:
9
9
  + Display audit results
10
- + Set-up organization defined targeting (connect set of system, a policy and time schedule)
11
- + Set-up periodical audits
12
10
  + Search audit results
13
11
  + Search for non-compliant systems
12
+ + Future features:
13
+ + Set-up organization defined targeting (connect set of system, a policy and time schedule)
14
+ + Set-up periodical audits
14
15
  + Search for not audited systems
15
16
  + Comparison of audit results
16
17
  + Waive known issues (one-time waivers, re-occurring, waivers)
17
18
  + Ad-hoc audit of given machine
19
+ + Support for PreupgradeAssistant evaluation
20
+ + Vulnerability Assessment (processing OVAL CVE streams)
21
+ + E-mail notifications
18
22
 
19
23
  ## Installation
20
24
 
@@ -0,0 +1,14 @@
1
+ function scap_content_selected(element){
2
+ var attrs = attribute_hash(['scap_content_id']);
3
+ var url = $(element).attr('data-url');
4
+ $(element).indicator_show();
5
+ $.ajax({
6
+ data: attrs,
7
+ type: 'post',
8
+ url: url,
9
+ complete: function() { $(element).indicator_hide();},
10
+ success: function(request) {
11
+ $('#scap_content_profile_select').html(request);
12
+ }
13
+ })
14
+ }
@@ -0,0 +1,31 @@
1
+ class ScaptimonyArfReportsController < ApplicationController
2
+ include Foreman::Controller::AutoCompleteSearch
3
+
4
+ before_filter :find_by_id, :only => [:show, :destroy]
5
+
6
+ def model_of_controller
7
+ ::Scaptimony::ArfReport
8
+ end
9
+
10
+ # GET /scaptimony/arf_reports
11
+ def index
12
+ @arf_reports = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page], :per_page => params[:per_page])
13
+ end
14
+
15
+ # GET /scaptimony/arf_reports/1
16
+ def show
17
+ self.response_body = @arf_report
18
+ end
19
+
20
+ def destroy
21
+ if @arf_report.destroy
22
+ process_success :success_redirect => scaptimony_arf_reports_path
23
+ else
24
+ process_error
25
+ end
26
+ end
27
+
28
+ def find_by_id
29
+ @arf_report = resource_base.find(params[:id])
30
+ end
31
+ end
@@ -0,0 +1,6 @@
1
+ class ScaptimonyDashboardController < ApplicationController
2
+ include Foreman::Controller::AutoCompleteSearch
3
+
4
+ def index
5
+ end
6
+ end
@@ -0,0 +1,58 @@
1
+ class ScaptimonyPoliciesController < ApplicationController
2
+ include Foreman::Controller::AutoCompleteSearch
3
+ before_filter :find_by_id, :only => [:show, :edit, :update, :destroy]
4
+
5
+ def model_of_controller
6
+ ::Scaptimony::Policy
7
+ end
8
+
9
+ # GET /scaptimony/policies
10
+ def index
11
+ @policies = resource_base.search_for(params[:search])
12
+ end
13
+
14
+ def new
15
+ @policy = ::Scaptimony::Policy.new
16
+ end
17
+
18
+ def show
19
+ self.response_body = ::Scaptimony::GuideGenerator.new @policy
20
+ end
21
+
22
+ def create
23
+ @policy = ::Scaptimony::Policy.new(params[:policy])
24
+ if @policy.save
25
+ process_success :success_redirect => scaptimony_policies_path
26
+ else
27
+ process_error
28
+ end
29
+ end
30
+
31
+ def update
32
+ if @policy.update_attributes(params[:policy])
33
+ process_success :success_redirect => scaptimony_policies_path
34
+ else
35
+ process_error
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ if @policy.destroy
41
+ process_success :success_redirect => scaptimony_policies_path
42
+ else
43
+ process_error
44
+ end
45
+ end
46
+
47
+ def scap_content_selected
48
+ if params[:scap_content_id] and @scap_content = ::Scaptimony::ScapContent.find(params[:scap_content_id])
49
+ @policy ||= ::Scaptimony::Policy.new
50
+ render :partial => 'scap_content_results', :locals => { :policy => @policy }
51
+ end
52
+ end
53
+
54
+ private
55
+ def find_by_id
56
+ @policy = resource_base.find(params[:id])
57
+ end
58
+ end
@@ -0,0 +1,54 @@
1
+ class ScaptimonyScapContentsController < ApplicationController
2
+ include Foreman::Controller::AutoCompleteSearch
3
+ before_filter :handle_file_upload, :only => [:create]
4
+ before_filter :find_by_id, :only => [:show, :edit, :update]
5
+
6
+ def model_of_controller
7
+ ::Scaptimony::ScapContent
8
+ end
9
+
10
+ # GET /scaptimony/scap_contents
11
+ def index
12
+ @contents = resource_base.search_for(params[:search])
13
+ end
14
+
15
+ def show
16
+ send_file @scaptimony_scap_content.path,
17
+ :type => "application/xml",
18
+ :filename => @scaptimony_scap_content.original_filename
19
+ end
20
+
21
+ def new
22
+ @scaptimony_scap_content = ::Scaptimony::ScapContent.new
23
+ end
24
+
25
+ # POST /scaptimony/scap_contents
26
+ def create
27
+ @scaptimony_scap_content = ::Scaptimony::ScapContent.new(params[:scap_content])
28
+ if @scaptimony_scap_content.store
29
+ process_success :success_redirect => scaptimony_scap_contents_path
30
+ else
31
+ process_error
32
+ end
33
+ end
34
+
35
+ def handle_file_upload
36
+ return unless params[:scap_content] and
37
+ t = params[:scap_content][:scap_file]
38
+ params[:scap_content][:original_filename] = t.original_filename
39
+ params[:scap_content][:scap_file] = t.read if t.respond_to?(:read)
40
+ end
41
+
42
+ def update
43
+ if @scaptimony_scap_content.update_attributes(params[:scap_content])
44
+ process_success :success_redirect => scaptimony_scap_contents_path
45
+ else
46
+ process_error
47
+ end
48
+ end
49
+
50
+ private
51
+ def find_by_id
52
+ @scaptimony_scap_content = resource_base.find(params[:id])
53
+ end
54
+ end
@@ -0,0 +1,16 @@
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
+ module ArfReportsHelper
12
+ def report_arf_column(event, style = "")
13
+ style = "label-default" if event == 0
14
+ content_tag(:span, event, :class=>'label ' + style)
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ module ScaptimonyPoliciesHelper
2
+ def profiles_selection
3
+ return @scap_content.scap_content_profiles unless @scap_content.blank?
4
+ return @policy.scap_content.scap_content_profiles unless @policy.scap_content.blank?
5
+ return []
6
+ end
7
+ end
@@ -14,8 +14,7 @@ module ForemanOpenscap
14
14
  module ArfReportExtensions
15
15
  extend ActiveSupport::Concern
16
16
  included do
17
- scoped_search :on => :date, :complete_value => true
18
- scoped_search :on => :digest
17
+ scoped_search :in => :asset, :on => :name, :complete_value => :true, :rename => "host"
19
18
  end
20
19
  end
21
20
  end
@@ -0,0 +1,20 @@
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
+ require 'scaptimony/policy'
12
+
13
+ module ForemanOpenscap
14
+ module PolicyExtensions
15
+ extend ActiveSupport::Concern
16
+ included do
17
+ scoped_search :on => :name, :complete_value => true
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
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
+ require 'scaptimony/scap_content'
12
+
13
+ module ForemanOpenscap
14
+ module ScapContentExtensions
15
+ extend ActiveSupport::Concern
16
+ included do
17
+ scoped_search :on => :digest
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ <table class="table table-bordered table-striped ellipsis">
2
+ <tr>
3
+ <th><%= sort :host %></th>
4
+ <th><%= sort :date, :as => _("Date") %></th>
5
+ <th><%= sort :passed, :as => _("Passed") %></th>
6
+ <th><%= sort :failed, :as => _("Failed") %></th>
7
+ <th><%= sort :othered, :as => _("Other") %></th>
8
+ <th></th>
9
+ </tr>
10
+ <% for arf_report in @arf_reports %>
11
+ <tr>
12
+ <td><%= name_column(arf_report.asset.host) %></td>
13
+ <td><%= _("%s ago") % time_ago_in_words(arf_report.date.getlocal) %></td>
14
+ <td><%= report_arf_column(arf_report.passed, "label-info") %></th>
15
+ <td><%= report_arf_column(arf_report.failed, "label-danger") %></th>
16
+ <td><%= report_arf_column(arf_report.othered, "label-warning") %></th>
17
+ <td>
18
+ <%= action_buttons(
19
+ link_to(_("View Report"), hash_for_scaptimony_arf_report_path(:id => arf_report.id)),
20
+ display_delete_if_authorized(hash_for_scaptimony_arf_report_path(:id => arf_report.id),
21
+ :confirm => _("Delete compliance report for %s?") % arf_report.asset.host)
22
+ ) %>
23
+ </td>
24
+ </tr>
25
+ <% end %>
26
+ </table>
27
+ <%= will_paginate_with_info @arf_reports %>
@@ -0,0 +1,4 @@
1
+ <% title _("Compliance Reports") %>
2
+
3
+ <%= render :partial => 'list' %>
4
+
@@ -0,0 +1,39 @@
1
+ <%= javascript 'policy_edit' %>
2
+ <%= form_for @policy,
3
+ :url => (@policy.id? ? scaptimony_policy_path(:id => @policy.id) : scaptimony_policies_path) do |f| %>
4
+ <%= base_errors_for @policy %>
5
+
6
+ <ul class="nav nav-tabs" data-tabs="tabs">
7
+ <li class="active"><a href="#primary" data-toggle="tab"><%= _("General") %></a></li>
8
+ <li><a href="#scap_content" data-toggle="tab"><%= _("SCAP Content") %></a></li>
9
+ <li><a href="#scap_schedule" data-toggle="tab"><%= _("Schedule") %></a></li>
10
+ </ul>
11
+ <div class="tab-content">
12
+ <div class="tab-pane active" id="primary">
13
+ <%= text_f(f, :name) %>
14
+ <%= text_f(f, :description, :size => "col-md-8" ) %>
15
+ </div>
16
+ <div class="tab-pane" id="scap_content">
17
+ <%= select_f f, :scap_content_id, Scaptimony::ScapContent.all, :id, :title,
18
+ {:include_blank => _("Choose existing SCAP Content")},
19
+ {:label => _("SCAP Content"),
20
+ :onchange => 'scap_content_selected(this);',
21
+ :'data-url' => method_path('scap_content_selected')}
22
+ %>
23
+ <span id="scap_content_profile_select">
24
+ <%= select_f f, :scap_content_profile_id, profiles_selection, :id, :title,
25
+ {:selected => @policy.scap_content_profile_id,
26
+ :include_blank => _("Default XCCDF profile")},
27
+ {:label => _("XCCDF Profile"),
28
+ :disabled => profiles_selection.empty? ? true : false,
29
+ :help_inline => :indicator}
30
+ %>
31
+ </span>
32
+ </div>
33
+ <div class="tab-pane" id="scap_schedule">
34
+ <%= text_f(f, :period) %>
35
+ <%= text_f(f, :weekday) %>
36
+ </div>
37
+ <%= submit_or_cancel f %>
38
+ </div>
39
+ <% end %>
@@ -0,0 +1,34 @@
1
+ <table class="table table-bordered table-striped table-two-pane">
2
+ <tr>
3
+ <th>Name</th>
4
+ <th>Content</th>
5
+ <th>Profile</th>
6
+ <th></th>
7
+ </tr>
8
+ <% for policy in @policies %>
9
+ <tr>
10
+ <td>
11
+ <%= link_to_if_authorized policy.name,
12
+ hash_for_edit_scaptimony_policy_path(:id => policy).merge(
13
+ :auth_object => policy, :authorizer => authorizer) %>
14
+ </td>
15
+ <td>
16
+ <% if !policy.scap_content.nil? %>
17
+ <%= link_to_if_authorized policy.scap_content.title,
18
+ hash_for_edit_scaptimony_scap_content_path(:id => policy.scap_content) %>
19
+ <% end %>
20
+ </td>
21
+ <td>
22
+ <%= policy.scap_content_profile.nil? ? "Default" : policy.scap_content_profile.title %>
23
+ </td>
24
+ <td>
25
+ <%= action_buttons(
26
+ link_to_if_authorized(_("Show Guide"), hash_for_scaptimony_policy_path(:id => policy.id)),
27
+ link_to_if_authorized(_("Edit"), hash_for_edit_scaptimony_policy_path(:id => policy.id)),
28
+ display_delete_if_authorized(hash_for_scaptimony_policy_path(:id => policy.id),
29
+ :confirm => _("Delete compliance policy %s with all the reports?") % policy.name)
30
+ ) %>
31
+ </td>
32
+ </tr>
33
+ <% end %>
34
+ </table>
@@ -0,0 +1,10 @@
1
+ <%= fields_for @policy do |f| %>
2
+ <%= select_f f, :scap_content_profile_id, profiles_selection, :id, :title,
3
+ {:selected => @policy.scap_content_profile_id,
4
+ :include_blank => _("Default XCCDF profile")},
5
+ {:label => _("XCCDF Profile"),
6
+ :disabled => profiles_selection.empty? ? true : false,
7
+ :help_inline => :indicator}
8
+ %>
9
+ <% end %>
10
+
@@ -0,0 +1,3 @@
1
+ <% title _("Edit Compliance Policy") %>
2
+
3
+ <%= render :partial => 'form' %>
@@ -0,0 +1,9 @@
1
+ <%= javascript 'policy_edit' %>
2
+ <% title _("Compliance Policies") %>
3
+
4
+ <% title_actions(
5
+ display_link_if_authorized(_("New Compliance Policy"), hash_for_new_scaptimony_policy_path),
6
+ link_to(_("Help"), :action => "welcome")
7
+ ) %>
8
+
9
+ <%= render :partial => 'list' %>
@@ -0,0 +1,3 @@
1
+ <% title _("New Compliance Policy") %>
2
+
3
+ <%= render :partial => 'form' %>
@@ -0,0 +1,10 @@
1
+ <% title_actions display_link_if_authorized(_("New Compliance policy"), hash_for_new_scaptimony_policy_path) %>
2
+
3
+ <% title _("Compliance policy configuration") %>
4
+ <div id="welcome">
5
+ <p>
6
+ <%= _('A compliance policy is defined by security professionals who specify desired settings (often in the form of a checklist) that are to be used in the computing environment. Compliance audit is a process of figuring out whether a given object follows all the rules written out in a compliance policy.') %>
7
+
8
+ <%= _('In order to define compliance policy, you need to prepare checklist (SCAP content), list of systems and time schedule') %>
9
+ </p>
10
+ </div>
@@ -0,0 +1,18 @@
1
+ <%= form_for @scaptimony_scap_content,
2
+ :url => (@scaptimony_scap_content.id? ?
3
+ scaptimony_scap_content_path(:id => @scaptimony_scap_content.id) : scaptimony_scap_contents_path),
4
+ :html => { :multipart => true } do |f| %>
5
+
6
+ <%= base_errors_for @scaptimony_scap_content %>
7
+
8
+ <ul class="nav nav-tabs" data-tabs="tabs">
9
+ <li class="active"><a href="#primary" data-toggle="tab"><%= _("File Upload") %></a></li>
10
+ </ul>
11
+ <div class="tab-content">
12
+ <div class="tab-pane active" id="primary">
13
+ <%= text_f(f, :title) %>
14
+ <%= file_field_f f, :scap_file, :help_block => _("Upload SCAP DataStream file") %>
15
+ </div>
16
+ <%= submit_or_cancel f %>
17
+ </div>
18
+ <% end %>
@@ -0,0 +1,27 @@
1
+ <table class="table table-bordered table-striped table-two-pane">
2
+ <tr>
3
+ <th>Title</th>
4
+ <th>Filename</th>
5
+ <th>Created</th>
6
+ <th></th>
7
+ </tr>
8
+ <% for c in @contents %>
9
+ <tr>
10
+ <td>
11
+ <%= c.title %>
12
+ </td>
13
+ <td>
14
+ <%= c.original_filename %>
15
+ </td>
16
+ <td>
17
+ <%= _("%s ago") % time_ago_in_words(c.created_at.getlocal) %>
18
+ </td>
19
+ <td>
20
+ <%= action_buttons(
21
+ link_to_if_authorized(_("Edit"), hash_for_edit_scaptimony_scap_content_path(:id => c.id)),
22
+ link_to_if_authorized(_("Download"), hash_for_scaptimony_scap_content_path(:id => c.id))
23
+ ) %>
24
+ </td>
25
+ </tr>
26
+ <% end %>
27
+ </table>
@@ -0,0 +1,3 @@
1
+ <% title _("Edit SCAP Content") %>
2
+
3
+ <%= render :partial => 'form' %>
@@ -0,0 +1,5 @@
1
+ <% title _("SCAP Contents") %>
2
+
3
+ <% title_actions display_link_if_authorized(_("Upload New SCAP Content"), hash_for_new_scaptimony_scap_content_path) %>
4
+
5
+ <%= render :partial => 'list' %>
@@ -0,0 +1,3 @@
1
+ <% title _("Upload new SCAP content file") %>
2
+
3
+ <%= render :partial => 'form' %>
@@ -1,6 +1,17 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
- resources :arf_reports, :only => [:index, :show] do
3
+ scope '/scaptimony' do
4
+ resources :arf_reports, :only => [:index, :show, :destroy],
5
+ :as => :scaptimony_arf_reports, :controller => :scaptimony_arf_reports
6
+ match 'dashboard', :to => 'scaptimony_dashboard#index', :as => "scaptimony_dashboard"
7
+ resources :policies, :only => [:index, :new, :show, :create, :edit, :update, :destroy],
8
+ :as => :scaptimony_policies, :controller => :scaptimony_policies do
9
+ collection do
10
+ post 'scap_content_selected'
11
+ end
12
+ end
13
+ resources :scap_contents, :only => [:index, :show, :new, :create, :edit, :update],
14
+ :as => :scaptimony_scap_contents, :controller => :scaptimony_scap_contents
4
15
  end
5
16
 
6
17
  namespace :api do
@@ -15,24 +15,47 @@ module ForemanOpenscap
15
15
  app.config.paths['db/migrate'] += ForemanOpenscap::Engine.paths['db/migrate'].existent
16
16
  end
17
17
 
18
+ initializer 'foreman_openscap.assets.precompile' do |app|
19
+ app.config.assets.precompile += %w(
20
+ 'foreman_openscap/policy_edit.js'
21
+ )
22
+ end
23
+
24
+ initializer 'foreman_openscap.configure_assets', :group => :assets do
25
+ SETTINGS[:foreman_openscap] =
26
+ { :assets => { :precompile => ['foreman_openscap/policy_edit.js']}}
27
+ end
28
+
18
29
  initializer 'foreman_openscap.register_plugin', :after=> :finisher_hook do |app|
19
30
  Foreman::Plugin.register :foreman_openscap do
20
31
  requires_foreman '>= 1.5'
21
32
 
22
33
  # Add permissions
23
34
  security_block :foreman_openscap do
24
- permission :view_arf_reports, {:arf_reports => [:index, :show] }
35
+ permission :view_arf_reports, {:scaptimony_arf_reports => [:index, :show],
36
+ :scaptimony_policies => [:index, :show],
37
+ :scaptimony_scap_contents => [:index, :show],
38
+ }
39
+ permission :edit_compliance, {:scaptimony_arf_reports => [:destroy],
40
+ :scaptimony_policies => [:new, :create, :edit, :update, :destroy],
41
+ :scaptimony_scap_contents => [:new, :create, :edit, :update]
42
+ }
25
43
  end
26
44
 
27
- # Add a new role called 'Discovery' if it doesn't exist
28
- role "OpenSCAP reports view", [:view_arf_reports]
45
+ role "View compliance reports", [:view_arf_reports]
46
+ role "Edit compliance policies", [:edit_compliance]
29
47
 
30
- #add menu entry
31
- menu :top_menu, :template,
32
- :url_hash => {:controller => :'arf_reports', :action => :index },
33
- :caption => 'OpenSCAP Scans',
34
- :parent => :hosts_menu,
35
- :after => :hosts
48
+ #add menu entries
49
+ divider :top_menu, :caption => N_('Compliance'), :parent => :hosts_menu
50
+ menu :top_menu, :compliance_policies, :caption => N_('Policies'),
51
+ :url_hash => {:controller => :'scaptimony_policies', :action => :index },
52
+ :parent => :hosts_menu
53
+ menu :top_menu, :compliance_contents, :caption => N_('SCAP contents'),
54
+ :url_hash => {:controller => :'scaptimony_scap_contents', :action => :index },
55
+ :parent => :hosts_menu
56
+ menu :top_menu, :compliance_reports, :caption => N_('Reports'),
57
+ :url_hash => {:controller => :'scaptimony_arf_reports', :action => :index },
58
+ :parent => :hosts_menu
36
59
  end
37
60
  end
38
61
 
@@ -42,6 +65,8 @@ module ForemanOpenscap
42
65
  Host::Managed.send(:include, ForemanOpenscap::HostExtensions)
43
66
  HostsHelper.send(:include, ForemanOpenscap::HostsHelperExtensions)
44
67
  ::Scaptimony::ArfReport.send(:include, ForemanOpenscap::ArfReportExtensions)
68
+ ::Scaptimony::Policy.send(:include, ForemanOpenscap::PolicyExtensions)
69
+ ::Scaptimony::ScapContent.send(:include, ForemanOpenscap::ScapContentExtensions)
45
70
  rescue => e
46
71
  puts "ForemanOpenscap: skipping engine hook (#{e.to_s})"
47
72
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanOpenscap
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Šimon Lukašík
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -31,14 +31,34 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - app/views/arf_reports/index.html.erb
35
- - app/views/arf_reports/_list.html.erb
34
+ - app/views/scaptimony_arf_reports/index.html.erb
35
+ - app/views/scaptimony_arf_reports/_list.html.erb
36
+ - app/views/scaptimony_scap_contents/_form.html.erb
37
+ - app/views/scaptimony_scap_contents/new.html.erb
38
+ - app/views/scaptimony_scap_contents/index.html.erb
39
+ - app/views/scaptimony_scap_contents/_list.html.erb
40
+ - app/views/scaptimony_scap_contents/edit.html.erb
41
+ - app/views/scaptimony_policies/welcome.html.erb
42
+ - app/views/scaptimony_policies/_form.html.erb
43
+ - app/views/scaptimony_policies/new.html.erb
44
+ - app/views/scaptimony_policies/index.html.erb
45
+ - app/views/scaptimony_policies/_list.html.erb
46
+ - app/views/scaptimony_policies/_scap_content_results.html.erb
47
+ - app/views/scaptimony_policies/edit.html.erb
36
48
  - app/overrides/dashboard/index/sample_override.html.erb.deface
49
+ - app/helpers/scaptimony_policies_helper.rb
37
50
  - app/helpers/concerns/foreman_openscap/hosts_helper_extensions.rb
38
- - app/controllers/arf_reports_controller.rb
51
+ - app/helpers/arf_reports_helper.rb
52
+ - app/controllers/scaptimony_policies_controller.rb
53
+ - app/controllers/scaptimony_scap_contents_controller.rb
39
54
  - app/controllers/api/v2/openscap/arf_reports_controller.rb
55
+ - app/controllers/scaptimony_dashboard_controller.rb
56
+ - app/controllers/scaptimony_arf_reports_controller.rb
57
+ - app/assets/javascript/policy_edit.js
40
58
  - app/models/concerns/foreman_openscap/arf_report_extensions.rb
41
59
  - app/models/concerns/foreman_openscap/host_extensions.rb
60
+ - app/models/concerns/foreman_openscap/policy_extensions.rb
61
+ - app/models/concerns/foreman_openscap/scap_content_extensions.rb
42
62
  - app/models/scaptimony/asset.rb
43
63
  - config/routes.rb
44
64
  - db/migrate/20141017172055_create_scaptimony_auditable_hosts.rb
@@ -1,23 +0,0 @@
1
- class ArfReportsController < ApplicationController
2
- include Foreman::Controller::AutoCompleteSearch
3
-
4
- before_filter :find_by_id, :only => [:show]
5
-
6
- def model_of_controller
7
- ::Scaptimony::ArfReport
8
- end
9
-
10
- # GET /arf_reports
11
- def index
12
- @arf_reports = resource_base.search_for(params[:search])
13
- end
14
-
15
- # GET /arf_reports/1
16
- def show
17
- self.response_body = @arf_report
18
- end
19
-
20
- def find_by_id
21
- @arf_report = resource_base.find(params[:id])
22
- end
23
- end
@@ -1,18 +0,0 @@
1
- <table class="table table-bordered table-striped ellipsis">
2
- <tr>
3
- <th><%= sort :host %></th>
4
- <th><%= sort :policy, :as => _("Policy") %></th>
5
- <th><%= sort :date, :as => _("Date") %></th>
6
- <th></th>
7
- </tr>
8
- <% for arf_report in @arf_reports %>
9
- <tr>
10
- <td><%= name_column(arf_report.asset.host) %></td>
11
- <td><%= arf_report.policy.name %></td>
12
- <td><%= _("%s ago") % time_ago_in_words(arf_report.date.getlocal) %></td>
13
- <td>
14
- <%= action_buttons( link_to(_("View Report"), hash_for_arf_report_path(:id => arf_report.id))) %>
15
- </td>
16
- </tr>
17
- <% end %>
18
- </table>
@@ -1,4 +0,0 @@
1
- <% title _("OpenSCAP Reports") %>
2
-
3
- <%= render :partial => 'list' %>
4
-