hammer_cli_foreman_openscap 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hammer_cli_foreman_openscap.rb +1 -0
- data/lib/hammer_cli_foreman_openscap/arf_report.rb +9 -0
- data/lib/hammer_cli_foreman_openscap/commands.rb +22 -0
- data/lib/hammer_cli_foreman_openscap/error.rb +4 -0
- data/lib/hammer_cli_foreman_openscap/exception_handler.rb +7 -1
- data/lib/hammer_cli_foreman_openscap/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f615d3216c436b10ee3ce5648adafb7a4a99cdb
|
4
|
+
data.tar.gz: 62ba1ea938ff2b8a028a6df9a24edcd4d5e9c90a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5003bedf626c98610254a8f7a1af2a2c50067777b9521f49a0539eefd7e4e85b56f3ddde30e4c58c25b71b6c92b4e4c6efe91599813d823dd0e913aacab06bb
|
7
|
+
data.tar.gz: fabf00f0f67644cc20ff42af54a0cb431ac83bd1bb559534e544710ee7b84918d7ba6289f4dac5c9dba9e82cad84421c011ca47b8a7de9a671747bafc57d4edb
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'hammer_cli_foreman'
|
2
2
|
require 'hammer_cli_foreman_openscap/id_resolver'
|
3
3
|
require 'hammer_cli_foreman_openscap/commands'
|
4
|
+
require 'hammer_cli_foreman_openscap/error'
|
4
5
|
require 'hammer_cli_foreman_openscap/exception_handler'
|
5
6
|
|
6
7
|
module HammerCLIForemanOpenscap
|
@@ -33,6 +33,15 @@ module HammerCLIForemanOpenscap
|
|
33
33
|
build_options
|
34
34
|
end
|
35
35
|
|
36
|
+
class DownloadCommand < HammerCLIForemanOpenscap::DownloadCommand
|
37
|
+
success_message _("Arf report downloaded")
|
38
|
+
failure_message _("Could not download the Arf report")
|
39
|
+
|
40
|
+
option "--path", "PATH", _("Path where to save downloaded file"),
|
41
|
+
:attribute_name => :option_path
|
42
|
+
build_options
|
43
|
+
end
|
44
|
+
|
36
45
|
autoload_subcommands
|
37
46
|
end
|
38
47
|
end
|
@@ -28,4 +28,26 @@ module HammerCLIForemanOpenscap
|
|
28
28
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
29
29
|
include HammerCLIForemanOpenscap::ResolverCommons
|
30
30
|
end
|
31
|
+
|
32
|
+
class DownloadCommand < HammerCLIForeman::Command
|
33
|
+
include HammerCLIForemanOpenscap::ResolverCommons
|
34
|
+
action :download
|
35
|
+
|
36
|
+
def self.command_name(name = nil)
|
37
|
+
super(name) || "download"
|
38
|
+
end
|
39
|
+
|
40
|
+
def request_options
|
41
|
+
{ :response => :raw }
|
42
|
+
end
|
43
|
+
|
44
|
+
def print_data(response)
|
45
|
+
# get file name from header, remove leading and trailing quotes
|
46
|
+
filename = response.headers[:content_disposition].match(/filename=(.*)/)[1].chop.reverse.chop.reverse
|
47
|
+
path = option_path.dup || '.'
|
48
|
+
path << '/' unless path.end_with? '/'
|
49
|
+
raise HammerCLIForemanOpenscap::DownloadError.new "Cannot save file: #{path} does not exist" unless File.directory?(path)
|
50
|
+
File.write(path + filename, response.body)
|
51
|
+
end
|
52
|
+
end
|
31
53
|
end
|
@@ -3,12 +3,18 @@ module HammerCLIForemanOpenscap
|
|
3
3
|
def mappings
|
4
4
|
[
|
5
5
|
[RestClient::InternalServerError, :handle_internal_error],
|
6
|
-
[RestClient::UnprocessableEntity, :handle_unprocessable_entity]
|
6
|
+
[RestClient::UnprocessableEntity, :handle_unprocessable_entity],
|
7
|
+
[HammerCLIForemanOpenscap::DownloadError, :handle_download_error]
|
7
8
|
] + super
|
8
9
|
end
|
9
10
|
|
10
11
|
protected
|
11
12
|
|
13
|
+
def handle_download_error(e)
|
14
|
+
print_error e.message
|
15
|
+
log_full_error e
|
16
|
+
end
|
17
|
+
|
12
18
|
def handle_internal_error(e)
|
13
19
|
handle_scap_error(e)
|
14
20
|
HammerCLI::EX_SOFTWARE
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_foreman_openscap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Foreman team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hammer_cli_foreman
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- lib/hammer_cli_foreman_openscap.rb
|
37
37
|
- lib/hammer_cli_foreman_openscap/arf_report.rb
|
38
38
|
- lib/hammer_cli_foreman_openscap/commands.rb
|
39
|
+
- lib/hammer_cli_foreman_openscap/error.rb
|
39
40
|
- lib/hammer_cli_foreman_openscap/exception_handler.rb
|
40
41
|
- lib/hammer_cli_foreman_openscap/id_resolver.rb
|
41
42
|
- lib/hammer_cli_foreman_openscap/policy.rb
|
@@ -70,7 +71,7 @@ rubyforge_project:
|
|
70
71
|
rubygems_version: 2.4.6
|
71
72
|
signing_key:
|
72
73
|
specification_version: 4
|
73
|
-
summary:
|
74
|
+
summary: Foreman OpenSCAP commands for Hammer
|
74
75
|
test_files:
|
75
76
|
- test/compliance_resource_mock.rb
|
76
77
|
- test/test_helper.rb
|