foreman_openscap 0.6.3 → 0.6.4
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/README.md +4 -0
- data/app/assets/javascripts/foreman_openscap/openscap_proxy.js +7 -0
- data/app/assets/javascripts/foreman_openscap/policy_edit.js +15 -0
- data/app/controllers/api/v2/compliance/arf_reports_controller.rb +2 -2
- data/app/controllers/api/v2/compliance/policies_controller.rb +16 -4
- data/app/controllers/api/v2/compliance/scap_contents_controller.rb +2 -2
- data/app/controllers/api/v2/compliance/tailoring_files_controller.rb +92 -0
- data/app/controllers/concerns/foreman/controller/parameters/policy_api.rb +2 -2
- data/app/controllers/concerns/foreman/controller/parameters/tailoring_file.rb +15 -0
- data/app/controllers/openscap_proxies_controller.rb +31 -0
- data/app/controllers/policies_controller.rb +14 -15
- data/app/controllers/scap_contents_controller.rb +0 -10
- data/app/controllers/tailoring_files_controller.rb +75 -0
- data/app/helpers/compliance_dashboard_helper.rb +2 -2
- data/app/helpers/policies_helper.rb +29 -1
- data/app/helpers/tailoring_files_helper.rb +5 -0
- data/app/lib/proxy_api/openscap.rb +18 -2
- data/app/models/concerns/foreman_openscap/data_stream_content.rb +43 -0
- data/app/models/concerns/foreman_openscap/host_extensions.rb +1 -1
- data/app/models/concerns/foreman_openscap/hostgroup_extensions.rb +8 -0
- data/app/models/foreman_openscap/policy.rb +28 -3
- data/app/models/foreman_openscap/scap_content.rb +4 -72
- data/app/models/foreman_openscap/scap_content_profile.rb +2 -0
- data/app/models/foreman_openscap/tailoring_file.rb +19 -0
- data/app/services/foreman_openscap/openscap_proxy_version_check.rb +63 -0
- data/app/validators/foreman_openscap/data_stream_validator.rb +44 -0
- data/app/views/api/v2/compliance/policies/base.json.rabl +2 -1
- data/app/views/api/v2/compliance/tailoring_files/base.json.rabl +6 -0
- data/app/views/api/v2/compliance/tailoring_files/index.json.rabl +3 -0
- data/app/views/api/v2/compliance/tailoring_files/main.json.rabl +5 -0
- data/app/views/api/v2/compliance/tailoring_files/show.json.rabl +7 -0
- data/app/views/arf_reports/_list.html.erb +3 -2
- data/app/views/dashboard/_compliance_host_reports_widget.html.erb +3 -3
- data/app/views/policies/_form.html.erb +9 -0
- data/app/views/policies/_list.html.erb +16 -4
- data/app/views/policies/_tailoring_file_selected.html.erb +3 -0
- data/app/views/policies/steps/_scap_content_form.html.erb +8 -0
- data/app/views/policies/welcome.html.erb +12 -13
- data/app/views/scap_contents/_list.html.erb +1 -1
- data/app/views/scap_contents/welcome.html.erb +14 -13
- data/app/views/smart_proxies/_openscap_spool.html.erb +9 -0
- data/app/views/smart_proxies/plugins/_openscap.html.erb +12 -0
- data/app/views/tailoring_files/_form.html.erb +25 -0
- data/app/views/tailoring_files/_list.html.erb +29 -0
- data/app/views/tailoring_files/edit.html.erb +3 -0
- data/app/views/tailoring_files/index.html.erb +3 -0
- data/app/views/tailoring_files/new.html.erb +3 -0
- data/app/views/tailoring_files/welcome.html.erb +21 -0
- data/config/routes.rb +22 -0
- data/db/migrate/20161109155255_create_tailoring_files.rb +23 -0
- data/db/migrate/20161223153249_add_permissions_to_arf_report.rb +11 -0
- data/lib/foreman_openscap/engine.rb +30 -5
- data/lib/foreman_openscap/version.rb +1 -1
- data/test/factories/policy_factory.rb +2 -0
- data/test/factories/scap_content_related.rb +7 -0
- data/test/files/tailoring_files/ssg-firefox-ds-tailoring-2.xml +23 -0
- data/test/files/tailoring_files/ssg-firefox-ds-tailoring.xml +31 -0
- data/test/functional/api/v2/compliance/policies_controller_test.rb +35 -8
- data/test/functional/api/v2/compliance/scap_contents_controller_test.rb +1 -1
- data/test/functional/api/v2/compliance/tailoring_files_controller_test.rb +63 -0
- data/test/functional/openscap_proxies_controller_test.rb +14 -0
- data/test/functional/tailoring_files_controller_test.rb +38 -0
- data/test/test_plugin_helper.rb +18 -24
- data/test/unit/openscap_host_test.rb +11 -1
- data/test/unit/policy_test.rb +26 -0
- data/test/unit/services/tailoring_files_proxy_check_test.rb +27 -0
- data/test/unit/tailoring_file_test.rb +26 -0
- metadata +59 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e87dce0b8251a238c5e9893119aa4a98db7a3a0
|
4
|
+
data.tar.gz: ed41c816b9194e86b8c6a7a4fc627e0a205a9680
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeea587bb391f44a7f1d1a645c9060850e9a408df25f141d671f7ab48c8fb3e0d298ab02ee795f17661e56d1cea8f2085052dc2faefedf256ef112c4a0346d42
|
7
|
+
data.tar.gz: 37deb96efe064794ae14ba33876509598baaf5a3c73a32604134f074492144ee4656010da49c21770dee01c1d26511fb54847574b6d5e70d73ff063497d79acf
|
data/README.md
CHANGED
@@ -155,6 +155,10 @@ if you have commit permissions, the commit and the tag gets pushed to origin rem
|
|
155
155
|
|
156
156
|
if you're the gem owner, gem is built and uploaded to rubygems.org
|
157
157
|
|
158
|
+
## Found a bug?
|
159
|
+
|
160
|
+
We use the issue tracker at [http://projects.theforeman.org/projects/foreman_openscap/issues](http://projects.theforeman.org/projects/foreman_openscap/issues), it supports github SSO so it's straightforward to open new issues there. If you think you found a bug, please take search through existing issues and if you haven't found any, free free to open a new one. Thank you.
|
161
|
+
|
158
162
|
## Copyright
|
159
163
|
|
160
164
|
Copyright (c) 2014--2015 Red Hat, Inc.
|
@@ -13,6 +13,21 @@ function scap_content_selected(element){
|
|
13
13
|
})
|
14
14
|
}
|
15
15
|
|
16
|
+
function tailoring_file_selected(element) {
|
17
|
+
var attrs = attribute_hash(['tailoring_file_id']);
|
18
|
+
var url = $(element).attr('data-url');
|
19
|
+
tfm.tools.showSpinner();
|
20
|
+
$.ajax({
|
21
|
+
data: attrs,
|
22
|
+
type: 'post',
|
23
|
+
url: url,
|
24
|
+
complete: function() { reloadOnAjaxComplete($(element));},
|
25
|
+
success: function(request) {
|
26
|
+
$('#tailoring_file_profile_select').html(request);
|
27
|
+
}
|
28
|
+
})
|
29
|
+
}
|
30
|
+
|
16
31
|
function previous_step(previous) {
|
17
32
|
$('#policy_current_step').val(previous);
|
18
33
|
$('#new_policy').submit();
|
@@ -17,8 +17,8 @@ module Api
|
|
17
17
|
'::ForemanOpenscap::ArfReport'
|
18
18
|
end
|
19
19
|
|
20
|
-
def get_resource
|
21
|
-
instance_variable_get :"@arf_report" or fail
|
20
|
+
def get_resource(message = 'no resource loaded')
|
21
|
+
instance_variable_get :"@arf_report" or fail message
|
22
22
|
end
|
23
23
|
|
24
24
|
api :GET, '/compliance/arf_reports', N_('List ARF reports')
|
@@ -4,7 +4,7 @@ module Api::V2
|
|
4
4
|
include Foreman::Controller::SmartProxyAuth
|
5
5
|
include Foreman::Controller::Parameters::PolicyApi
|
6
6
|
|
7
|
-
add_smart_proxy_filters :content, :features => 'Openscap'
|
7
|
+
add_smart_proxy_filters [:content, :tailoring], :features => 'Openscap'
|
8
8
|
|
9
9
|
before_filter :find_resource, :except => %w(index create)
|
10
10
|
|
@@ -14,8 +14,8 @@ module Api::V2
|
|
14
14
|
'::ForemanOpenscap::Policy'
|
15
15
|
end
|
16
16
|
|
17
|
-
def get_resource
|
18
|
-
instance_variable_get :"@policy" or fail
|
17
|
+
def get_resource(message = 'no resource loaded')
|
18
|
+
instance_variable_get :"@policy" or fail message
|
19
19
|
end
|
20
20
|
|
21
21
|
def policy_url(policy = nil)
|
@@ -46,6 +46,8 @@ module Api::V2
|
|
46
46
|
param :day_of_month, Integer, :desc => N_('Policy schedule day of month (only if period == "monthly")')
|
47
47
|
param :cron_line, String, :desc => N_('Policy schedule cron line (only if period == "custom")')
|
48
48
|
param :hostgroup_ids, Array, :desc => N_('Apply policy to host groups')
|
49
|
+
param :tailoring_file_id, Integer, :desc => N_('Tailoring file ID')
|
50
|
+
param :tailoring_file_profile_id, Integer, :desc => N_('Tailoring file profile ID')
|
49
51
|
param_group :taxonomies, ::Api::V2::BaseController
|
50
52
|
end
|
51
53
|
end
|
@@ -83,6 +85,16 @@ module Api::V2
|
|
83
85
|
:filename => @scap_content.original_filename
|
84
86
|
end
|
85
87
|
|
88
|
+
api :GET, '/compliance/policies/:id/tailoring', N_("Show a policy's Tailoring file")
|
89
|
+
param :id, :identifier, :required => true
|
90
|
+
|
91
|
+
def tailoring
|
92
|
+
@tailoring_file = @policy.tailoring_file
|
93
|
+
send_data @tailoring_file.scap_file,
|
94
|
+
:type => 'application/xml',
|
95
|
+
:filename => @tailoring_file.original_filename
|
96
|
+
end
|
97
|
+
|
86
98
|
private
|
87
99
|
def find_resource
|
88
100
|
not_found and return if params[:id].blank?
|
@@ -91,7 +103,7 @@ module Api::V2
|
|
91
103
|
|
92
104
|
def action_permission
|
93
105
|
case params[:action]
|
94
|
-
when 'content'
|
106
|
+
when 'content', 'tailoring'
|
95
107
|
:view
|
96
108
|
else
|
97
109
|
super
|
@@ -8,8 +8,8 @@ module Api::V2
|
|
8
8
|
'::ForemanOpenscap::ScapContent'
|
9
9
|
end
|
10
10
|
|
11
|
-
def get_resource
|
12
|
-
instance_variable_get :"@scap_content" or fail
|
11
|
+
def get_resource(message = 'no resource loaded')
|
12
|
+
instance_variable_get :"@scap_content" or fail message
|
13
13
|
end
|
14
14
|
|
15
15
|
api :GET, '/compliance/scap_contents', N_('List SCAP contents')
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Api::V2
|
2
|
+
module Compliance
|
3
|
+
class TailoringFilesController < ::Api::V2::BaseController
|
4
|
+
include Foreman::Controller::Parameters::TailoringFile
|
5
|
+
before_filter :find_resource, :except => %w(index create)
|
6
|
+
before_filter :openscap_proxy_check, :only => %w(create)
|
7
|
+
|
8
|
+
def resource_name
|
9
|
+
'::ForemanOpenscap::TailoringFile'
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_resource(message = 'no resource loaded')
|
13
|
+
instance_variable_get :"@tailoring_file" or fail message
|
14
|
+
end
|
15
|
+
|
16
|
+
api :GET, '/compliance/tailoring_files', N_('List Tailoring files')
|
17
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
18
|
+
|
19
|
+
def index
|
20
|
+
@tailoring_files = resource_scope_for_index(:permission => :view_tailoring_files)
|
21
|
+
end
|
22
|
+
|
23
|
+
api :GET, '/compliance/tailoring_files/:id/xml', N_('Show a Tailoring file as XML')
|
24
|
+
param :id, :identifier, :required => true
|
25
|
+
|
26
|
+
def xml
|
27
|
+
send_data @tailoring_file.scap_file,
|
28
|
+
:type => 'application/xml',
|
29
|
+
:filename => @tailoring_file.original_filename || "#{@tailoring_file.name}.xml"
|
30
|
+
end
|
31
|
+
|
32
|
+
api :GET, '/compliance/tailoring_files/:id', N_('Show a Tailoring file')
|
33
|
+
param :id, :identifier, :required => true
|
34
|
+
def show
|
35
|
+
end
|
36
|
+
|
37
|
+
def_param_group :tailoring_file do
|
38
|
+
param :tailoring_file, Hash, :required => true, :action_aware => true do
|
39
|
+
param :name, String, :required => true, :desc => N_('Tailoring file name')
|
40
|
+
param :scap_file, String, :required => true, :desc => N_('XML containing tailoring file')
|
41
|
+
param :original_filename, String, :desc => N_('Original file name of the XML file')
|
42
|
+
param_group :taxonomies, ::Api::V2::BaseController
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
api :POST, '/compliance/tailoring_files', N_('Create a Tailoring file')
|
47
|
+
param_group :tailoring_file, :as => :create
|
48
|
+
|
49
|
+
def create
|
50
|
+
@tailoring_file = ForemanOpenscap::TailoringFile.new(tailoring_file_params)
|
51
|
+
process_response @tailoring_file.save
|
52
|
+
end
|
53
|
+
|
54
|
+
api :PUT, '/compliance/tailoring_files/:id', N_('Update a Tailoring file')
|
55
|
+
param :id, :identifier, :required => true
|
56
|
+
param_group :tailoring_file
|
57
|
+
|
58
|
+
def update
|
59
|
+
process_response @tailoring_file.update_attributes(tailoring_file_params)
|
60
|
+
end
|
61
|
+
|
62
|
+
api :DELETE, '/compliance/tailoring_files/:id', N_('Deletes a Tailoring file')
|
63
|
+
param :id, :identifier, :required => true
|
64
|
+
|
65
|
+
def destroy
|
66
|
+
process_response @tailoring_file.destroy
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
def find_resource
|
71
|
+
not_found and return if params[:id].blank?
|
72
|
+
instance_variable_set("@tailoring_file", resource_scope.find(params[:id]))
|
73
|
+
end
|
74
|
+
|
75
|
+
def action_permission
|
76
|
+
case params[:action]
|
77
|
+
when 'xml'
|
78
|
+
:view
|
79
|
+
else
|
80
|
+
super
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def openscap_proxy_check
|
85
|
+
unless ForemanOpenscap::TailoringFile.any?
|
86
|
+
check = ForemanOpenscap::OpenscapProxyVersionCheck.new.run
|
87
|
+
render_error :custom_error, :status => :unprocessable_entity, :locals => { :message => check.message } unless check.pass?
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -4,8 +4,8 @@ module Foreman::Controller::Parameters::PolicyApi
|
|
4
4
|
class_methods do
|
5
5
|
def filter_params_list
|
6
6
|
[:description, :name, :period, :scap_content_id, :scap_content_profile_id,
|
7
|
-
:weekday, :day_of_month, :cron_line, :
|
8
|
-
:hostgroup_ids => []]
|
7
|
+
:weekday, :day_of_month, :cron_line, :tailoring_file_id, :tailoring_file_profile_id,
|
8
|
+
:location_ids => [], :organization_ids => [], :hostgroup_ids => []]
|
9
9
|
end
|
10
10
|
|
11
11
|
def policy_params_filter
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Foreman::Controller::Parameters::TailoringFile
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
class_methods do
|
5
|
+
def tailoring_file_params_filter
|
6
|
+
Foreman::ParameterFilter.new(::ForemanOpenscap::TailoringFile).tap do |filter|
|
7
|
+
filter.permit :name, :scap_file, :original_filename, :location_ids => [], :organization_ids => []
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def tailoring_file_params
|
13
|
+
self.class.tailoring_file_params_filter.filter_params(params, parameter_filter_context)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class OpenscapProxiesController < ApplicationController
|
2
|
+
before_action :find_proxy, :only => [:openscap_spool]
|
3
|
+
|
4
|
+
def openscap_spool
|
5
|
+
last_error = @smart_proxy ? find_spool_error : nil
|
6
|
+
render :partial => 'smart_proxies/openscap_spool', :locals => { :last_error => last_error }
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def action_permission
|
12
|
+
case params[:action]
|
13
|
+
when 'openscap_spool'
|
14
|
+
:view
|
15
|
+
else
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_proxy
|
21
|
+
@smart_proxy = SmartProxy.find params[:id]
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_spool_error
|
25
|
+
@smart_proxy.statuses[:logs].
|
26
|
+
logs.
|
27
|
+
log_entries.
|
28
|
+
reverse.
|
29
|
+
find { |entry| entry["level"] == "ERROR" && entry["message"].start_with?("Failed to parse Arf Report") }
|
30
|
+
end
|
31
|
+
end
|
@@ -4,16 +4,16 @@ class PoliciesController < ApplicationController
|
|
4
4
|
|
5
5
|
before_filter :find_by_id, :only => [:show, :edit, :update, :parse, :destroy]
|
6
6
|
before_filter :find_multiple, :only => [:select_multiple_hosts, :update_multiple_hosts, :disassociate_multiple_hosts, :remove_policy_from_multiple_hosts]
|
7
|
+
before_filter :find_tailoring_file, :only => [:tailoring_file_selected]
|
7
8
|
|
8
9
|
def model_of_controller
|
9
10
|
::ForemanOpenscap::Policy
|
10
11
|
end
|
11
12
|
|
12
13
|
def index
|
13
|
-
@policies = resource_base
|
14
|
-
|
15
|
-
|
16
|
-
.includes(:scap_content, :scap_content_profile)
|
14
|
+
@policies = resource_base.search_for(params[:search], :order => params[:order]).
|
15
|
+
paginate(:page => params[:page], :per_page => params[:per_page]).
|
16
|
+
includes(:scap_content, :scap_content_profile, :tailoring_file)
|
17
17
|
if @policies.empty? && ForemanOpenscap::ScapContent.unconfigured?
|
18
18
|
redirect_to scap_contents_path
|
19
19
|
end
|
@@ -70,6 +70,11 @@ class PoliciesController < ApplicationController
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
def tailoring_file_selected
|
74
|
+
@policy ||= ::ForemanOpenscap::Policy.new
|
75
|
+
render :partial => 'tailoring_file_selected', :locals => { :policy => @policy, :tailoring_file => @tailoring_file }
|
76
|
+
end
|
77
|
+
|
73
78
|
def select_multiple_hosts; end
|
74
79
|
|
75
80
|
def update_multiple_hosts
|
@@ -99,21 +104,15 @@ class PoliciesController < ApplicationController
|
|
99
104
|
end
|
100
105
|
end
|
101
106
|
|
102
|
-
def welcome
|
103
|
-
@searchbar = true
|
104
|
-
if (model_of_controller.first.nil? rescue false)
|
105
|
-
@searchbar = false
|
106
|
-
render :welcome rescue nil and return
|
107
|
-
end
|
108
|
-
rescue
|
109
|
-
not_found
|
110
|
-
end
|
111
|
-
|
112
107
|
private
|
113
108
|
def find_by_id
|
114
109
|
@policy = resource_base.find(params[:id])
|
115
110
|
end
|
116
111
|
|
112
|
+
def find_tailoring_file
|
113
|
+
@tailoring_file = ForemanOpenscap::TailoringFile.find(params[:tailoring_file_id]) if params[:tailoring_file_id].present?
|
114
|
+
end
|
115
|
+
|
117
116
|
def find_multiple
|
118
117
|
# Lets search by name or id and make sure one of them exists first
|
119
118
|
if params[:host_ids].present?
|
@@ -136,7 +135,7 @@ class PoliciesController < ApplicationController
|
|
136
135
|
|
137
136
|
def action_permission
|
138
137
|
case params[:action]
|
139
|
-
when 'parse'
|
138
|
+
when 'parse', 'tailoring_file_selected'
|
140
139
|
:view
|
141
140
|
else
|
142
141
|
super
|
@@ -48,16 +48,6 @@ class ScapContentsController < ApplicationController
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def welcome
|
52
|
-
@searchbar = true
|
53
|
-
if (model_of_controller.first.nil? rescue false)
|
54
|
-
@searchbar = false
|
55
|
-
render :welcome rescue nil and return
|
56
|
-
end
|
57
|
-
rescue
|
58
|
-
not_found
|
59
|
-
end
|
60
|
-
|
61
51
|
private
|
62
52
|
def find_by_id
|
63
53
|
@scap_content = resource_base.find(params[:id])
|
@@ -0,0 +1,75 @@
|
|
1
|
+
class TailoringFilesController < ApplicationController
|
2
|
+
include Foreman::Controller::AutoCompleteSearch
|
3
|
+
include Foreman::Controller::Parameters::TailoringFile
|
4
|
+
|
5
|
+
before_filter :find_tailoring_file, :only => [:destroy, :update, :edit, :xml]
|
6
|
+
before_filter :handle_file_upload, :only => [:create, :update]
|
7
|
+
|
8
|
+
def model_of_controller
|
9
|
+
::ForemanOpenscap::TailoringFile
|
10
|
+
end
|
11
|
+
|
12
|
+
def index
|
13
|
+
@tailoring_files = resource_base.search_for(params[:search], :order => params[:order]).
|
14
|
+
paginate(:page => params[:page], :per_page => params[:per_page])
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
@tailoring_file = ::ForemanOpenscap::TailoringFile.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
@tailoring_file = ForemanOpenscap::TailoringFile.new(tailoring_file_params)
|
23
|
+
if @tailoring_file.save
|
24
|
+
process_success
|
25
|
+
else
|
26
|
+
process_error
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
if @tailoring_file.update_attributes(tailoring_file_params)
|
35
|
+
process_success
|
36
|
+
else
|
37
|
+
process_error
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
if @tailoring_file.destroy
|
43
|
+
process_success
|
44
|
+
else
|
45
|
+
process_error :object => @tailoring_file
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def xml
|
50
|
+
send_data @tailoring_file.scap_file,
|
51
|
+
:type => 'application/xml',
|
52
|
+
:filename => @tailoring_file.original_filename || "#{@tailoring_file.name}.xml"
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def find_tailoring_file
|
58
|
+
@tailoring_file = resource_base.find(params[:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
def handle_file_upload
|
62
|
+
return unless params[:tailoring_file] && raw_file = params[:tailoring_file][:scap_file]
|
63
|
+
params[:tailoring_file][:original_filename] = raw_file.original_filename
|
64
|
+
params[:tailoring_file][:scap_file] = raw_file.tempfile.read if raw_file.respond_to?(:tempfile) && raw_file.tempfile.respond_to?(:read)
|
65
|
+
end
|
66
|
+
|
67
|
+
def action_permission
|
68
|
+
case params[:action]
|
69
|
+
when 'xml'
|
70
|
+
:view
|
71
|
+
else
|
72
|
+
super
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|