hammer_cli_foreman_openscap 0.1.6 → 0.1.11
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 +5 -5
- data/lib/hammer_cli_foreman_openscap.rb +10 -0
- data/lib/hammer_cli_foreman_openscap/commands.rb +5 -4
- data/lib/hammer_cli_foreman_openscap/host.rb +32 -0
- data/lib/hammer_cli_foreman_openscap/policy.rb +17 -0
- data/lib/hammer_cli_foreman_openscap/scap_content_profile.rb +29 -0
- data/lib/hammer_cli_foreman_openscap/version.rb +1 -1
- data/test/compliance_resource_mock.rb +9 -2
- data/test/functional/scap_content_test.rb +2 -2
- data/test/functional/tailoring_file_test.rb +3 -5
- data/test/test_helper.rb +1 -1
- metadata +25 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 26f5ac7c0c6d03de357a8d903cc1f642f17748821d6f6c06011ecde5330a2bba
|
4
|
+
data.tar.gz: deb6a45e5359cff52e0b9dc2670a084c4ddde5cb884ae2cdf6052740d75b4457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a83f3ebe046effbab0fd17bb02e322c50bec587b2347420b19aa84376d446d95649804b359ee77fd9b10d1e32f599b36ff9a87c733d77e0e603e81c65e34311b
|
7
|
+
data.tar.gz: 8e9ecd49d0ccc090dd3a24c4b8d13edb1d50c67242f89ccf0fef54e82fb8c82c7d410f891396c518eb33fb5b40b1b30a9ce5a7cdefa9fe8661b012ab9fac5572
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'hammer_cli_foreman'
|
2
|
+
require 'hammer_cli_foreman/host'
|
2
3
|
require 'hammer_cli_foreman_openscap/options/normalizers'
|
3
4
|
require 'hammer_cli_foreman_openscap/id_resolver'
|
4
5
|
require 'hammer_cli_foreman_openscap/commands'
|
@@ -6,6 +7,7 @@ require 'hammer_cli_foreman_openscap/error'
|
|
6
7
|
require 'hammer_cli_foreman_openscap/exception_handler'
|
7
8
|
require 'hammer_cli_foreman_openscap/hostgroup'
|
8
9
|
require 'hammer_cli_foreman_openscap/host'
|
10
|
+
require 'hammer_cli_foreman_openscap/scap_content_profile'
|
9
11
|
|
10
12
|
module HammerCLIForemanOpenscap
|
11
13
|
require 'hammer_cli_foreman_openscap/version'
|
@@ -29,4 +31,12 @@ module HammerCLIForemanOpenscap
|
|
29
31
|
HammerCLI::MainCommand.lazy_subcommand("tailoring-file", _("Manipulate Tailoring files"),
|
30
32
|
"HammerCLIForemanOpenscap::TailoringFile",
|
31
33
|
"hammer_cli_foreman_openscap/tailoring_file")
|
34
|
+
|
35
|
+
HammerCLI::MainCommand.lazy_subcommand("scap-content-profile", _("Manipulate Scap Content Profiles"),
|
36
|
+
"HammerCLIForemanOpenscap::ScapContentProfile",
|
37
|
+
"hammer_cli_foreman_openscap/scap_content_profile")
|
38
|
+
|
39
|
+
HammerCLIForeman::Host.lazy_subcommand(Host::PoliciesEnc.command_name, _('View policies ENC for host'),
|
40
|
+
"HammerCLIForemanOpenscap::Host::PoliciesEnc",
|
41
|
+
"hammer_cli_foreman_openscap/host")
|
32
42
|
end
|
@@ -50,10 +50,11 @@ module HammerCLIForemanOpenscap
|
|
50
50
|
option("--scap-file", "SCAP_FILE", description, opts, &block)
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
54
|
-
|
53
|
+
def method_options(params)
|
54
|
+
opts = super params
|
55
|
+
opts[resource.singular_name]['original_filename'] ||= self.class.declared_options.find { |opt| opt.attribute_name == "option_scap_file" }
|
55
56
|
.value_formatter.original_filename
|
56
|
-
|
57
|
+
opts
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -87,7 +88,7 @@ module HammerCLIForemanOpenscap
|
|
87
88
|
return
|
88
89
|
end
|
89
90
|
# get file name from header, remove leading and trailing quotes
|
90
|
-
filename = response.headers[:content_disposition].match(/filename=(.*)
|
91
|
+
filename = response.headers[:content_disposition].match(/filename=(.*);/)[1].chop.reverse.chop.reverse
|
91
92
|
path = option_path.dup
|
92
93
|
path << '/' unless path.end_with? '/'
|
93
94
|
raise HammerCLIForemanOpenscap::DownloadError.new "Cannot save file: #{path} does not exist" unless File.directory?(path)
|
@@ -1,2 +1,34 @@
|
|
1
1
|
require 'hammer_cli_foreman/host'
|
2
2
|
require 'hammer_cli_foreman_openscap/host_extensions'
|
3
|
+
|
4
|
+
module HammerCLIForemanOpenscap
|
5
|
+
class Host < HammerCLIForeman::Command
|
6
|
+
resource :hosts
|
7
|
+
|
8
|
+
class PoliciesEnc < HammerCLIForeman::ListCommand
|
9
|
+
command_name "policies-enc"
|
10
|
+
action :policies_enc
|
11
|
+
|
12
|
+
output do
|
13
|
+
field :id, _('Id')
|
14
|
+
field :profile_id, _('Profile Id')
|
15
|
+
field :content_path, _('Content path')
|
16
|
+
field :download_path, _('Content download path')
|
17
|
+
field :tailoring_path, _('Tailoring path')
|
18
|
+
field :tailoring_download_path, _('Tailoring download path')
|
19
|
+
field :monthday, _('Day of month')
|
20
|
+
field :hour, _('Hour')
|
21
|
+
field :minute, ('Minute')
|
22
|
+
field :month, _('Month')
|
23
|
+
field :week, _('Week')
|
24
|
+
end
|
25
|
+
|
26
|
+
def adapter
|
27
|
+
@context[:adapter] || :base
|
28
|
+
end
|
29
|
+
|
30
|
+
build_options
|
31
|
+
end
|
32
|
+
autoload_subcommands
|
33
|
+
end
|
34
|
+
end
|
@@ -22,6 +22,7 @@ module HammerCLIForemanOpenscap
|
|
22
22
|
field :scap_content_profile_id, _("SCAP Content profile Id")
|
23
23
|
field :tailoring_file_id, _("Tailoring file Id")
|
24
24
|
field :tailoring_file_profile_id, _("Tailoring file profile Id")
|
25
|
+
field :deploy_by, _("Deployment option")
|
25
26
|
HammerCLIForeman::References.taxonomies(self)
|
26
27
|
HammerCLIForeman::References.hostgroups(self)
|
27
28
|
end
|
@@ -51,6 +52,22 @@ module HammerCLIForemanOpenscap
|
|
51
52
|
build_options
|
52
53
|
end
|
53
54
|
|
55
|
+
class HostsCommand < HammerCLIForeman::AssociatedListSearchCommand
|
56
|
+
command_name 'hosts'
|
57
|
+
search_resource :hosts
|
58
|
+
|
59
|
+
def self.search_options_mapping
|
60
|
+
{
|
61
|
+
'id' => 'compliance_policy_id',
|
62
|
+
'name' => 'compliance_policy'
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
output HammerCLIForeman::Host::ListCommand.output_definition
|
67
|
+
|
68
|
+
build_options
|
69
|
+
end
|
70
|
+
|
54
71
|
autoload_subcommands
|
55
72
|
end
|
56
73
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module HammerCLIForemanOpenscap
|
2
|
+
class ScapContentProfile < HammerCLIForeman::Command
|
3
|
+
resource :scap_content_profiles
|
4
|
+
|
5
|
+
class ListCommand < HammerCLIForeman::ListCommand
|
6
|
+
output do
|
7
|
+
field :id, _("Id")
|
8
|
+
field :title, _("Title")
|
9
|
+
field :profile_id, _("Profile Id")
|
10
|
+
from :scap_content do
|
11
|
+
field :id, _("Scap Content Id")
|
12
|
+
field :title, _("Scap Content Title")
|
13
|
+
end
|
14
|
+
from :tailoring_file do
|
15
|
+
field :id, _("Tailoring File Id")
|
16
|
+
field :name, _("Tailoring File Name")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def adapter
|
21
|
+
@context[:adapter] || :base
|
22
|
+
end
|
23
|
+
|
24
|
+
build_options
|
25
|
+
end
|
26
|
+
|
27
|
+
autoload_subcommands
|
28
|
+
end
|
29
|
+
end
|
@@ -4,12 +4,19 @@
|
|
4
4
|
def self.arf
|
5
5
|
{
|
6
6
|
:id => 1,
|
7
|
-
:host =>
|
7
|
+
:host => {
|
8
|
+
:name => "somewhere.example.com"
|
9
|
+
},
|
8
10
|
:reported_at => "1916-06-08",
|
9
11
|
:passed => 24,
|
10
12
|
:failed => 25,
|
11
13
|
:othered => 26,
|
12
|
-
:
|
14
|
+
:openscap_proxy_name => {
|
15
|
+
:name => "scap_proxy.example.com"
|
16
|
+
},
|
17
|
+
:policy => {
|
18
|
+
:name => "strict policy"
|
19
|
+
}
|
13
20
|
}
|
14
21
|
end
|
15
22
|
|
@@ -12,9 +12,9 @@ describe 'scap content' do
|
|
12
12
|
expected_result = CommandExpectation.new
|
13
13
|
expected_result.expected_err =
|
14
14
|
['Could not download the SCAP content file:',
|
15
|
-
' Error: Option --path is required',
|
15
|
+
' Error: Option --path is required.',
|
16
16
|
' ',
|
17
|
-
" See: 'hammer scap-content download --help'",
|
17
|
+
" See: 'hammer scap-content download --help'.",
|
18
18
|
''].join("\n")
|
19
19
|
|
20
20
|
expected_result.expected_exit_code = HammerCLI::EX_USAGE
|
@@ -11,9 +11,7 @@ describe 'tailoring file' do
|
|
11
11
|
|
12
12
|
expected_result = CommandExpectation.new
|
13
13
|
expected_result.expected_err =
|
14
|
-
|
15
|
-
" Missing arguments for 'tailoring_file[scap_file]'",
|
16
|
-
''].join("\n")
|
14
|
+
"Failed to create Tailoring file:\n Missing arguments for '--scap-file'.\n"
|
17
15
|
expected_result.expected_exit_code = HammerCLI::EX_USAGE
|
18
16
|
|
19
17
|
api_expects_no_call
|
@@ -45,9 +43,9 @@ describe 'tailoring file' do
|
|
45
43
|
expected_result = CommandExpectation.new
|
46
44
|
expected_result.expected_err =
|
47
45
|
['Could not download the Tailoring file:',
|
48
|
-
' Error: Option --path is required',
|
46
|
+
' Error: Option --path is required.',
|
49
47
|
' ',
|
50
|
-
" See: 'hammer tailoring-file download --help'",
|
48
|
+
" See: 'hammer tailoring-file download --help'.",
|
51
49
|
''].join("\n")
|
52
50
|
|
53
51
|
expected_result.expected_exit_code = HammerCLI::EX_USAGE
|
data/test/test_helper.rb
CHANGED
@@ -4,7 +4,7 @@ FOREMAN_OPENSCAP_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'])
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require 'minitest/spec'
|
6
6
|
require "minitest-spec-context"
|
7
|
-
require "mocha/
|
7
|
+
require "mocha/minitest"
|
8
8
|
require 'hammer_cli'
|
9
9
|
|
10
10
|
if HammerCLI.context[:api_connection]
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
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.11
|
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:
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hammer_cli_foreman
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.19'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.19'
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
32
|
+
version: '3.0'
|
27
33
|
description:
|
28
34
|
email:
|
29
35
|
executables: []
|
@@ -47,6 +53,7 @@ files:
|
|
47
53
|
- lib/hammer_cli_foreman_openscap/options/normalizers.rb
|
48
54
|
- lib/hammer_cli_foreman_openscap/policy.rb
|
49
55
|
- lib/hammer_cli_foreman_openscap/scap_content.rb
|
56
|
+
- lib/hammer_cli_foreman_openscap/scap_content_profile.rb
|
50
57
|
- lib/hammer_cli_foreman_openscap/tailoring_file.rb
|
51
58
|
- lib/hammer_cli_foreman_openscap/version.rb
|
52
59
|
- locale/Makefile
|
@@ -95,23 +102,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
102
|
- !ruby/object:Gem::Version
|
96
103
|
version: '0'
|
97
104
|
requirements: []
|
98
|
-
|
99
|
-
rubygems_version: 2.6.8
|
105
|
+
rubygems_version: 3.1.2
|
100
106
|
signing_key:
|
101
107
|
specification_version: 4
|
102
108
|
summary: Foreman OpenSCAP commands for Hammer
|
103
109
|
test_files:
|
104
|
-
- test/
|
105
|
-
- test/unit/tailoring_file_test.rb
|
106
|
-
- test/unit/test_helper.rb
|
107
|
-
- test/unit/policy_test.rb
|
108
|
-
- test/unit/arf_report_test.rb
|
109
|
-
- test/test_helper.rb
|
110
|
-
- test/functional/scap_content_test.rb
|
111
|
-
- test/functional/tailoring_file_test.rb
|
112
|
-
- test/functional/test_helper.rb
|
113
|
-
- test/data/1.14/foreman_api.json
|
110
|
+
- test/compliance_resource_mock.rb
|
114
111
|
- test/data/1.11/foreman_api.json
|
112
|
+
- test/data/1.14/foreman_api.json
|
115
113
|
- test/data/1.15/foreman_api.json
|
116
114
|
- test/data/tailoring.xml
|
117
|
-
- test/
|
115
|
+
- test/functional/scap_content_test.rb
|
116
|
+
- test/functional/tailoring_file_test.rb
|
117
|
+
- test/functional/test_helper.rb
|
118
|
+
- test/test_helper.rb
|
119
|
+
- test/unit/arf_report_test.rb
|
120
|
+
- test/unit/policy_test.rb
|
121
|
+
- test/unit/scap_content_test.rb
|
122
|
+
- test/unit/tailoring_file_test.rb
|
123
|
+
- test/unit/test_helper.rb
|