hammer_cli_foreman_openscap 0.1.0
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 +7 -0
- data/lib/hammer_cli_foreman_openscap.rb +23 -0
- data/lib/hammer_cli_foreman_openscap/arf_report.rb +38 -0
- data/lib/hammer_cli_foreman_openscap/commands.rb +31 -0
- data/lib/hammer_cli_foreman_openscap/exception_handler.rb +29 -0
- data/lib/hammer_cli_foreman_openscap/id_resolver.rb +15 -0
- data/lib/hammer_cli_foreman_openscap/policy.rb +52 -0
- data/lib/hammer_cli_foreman_openscap/scap_content.rb +58 -0
- data/lib/hammer_cli_foreman_openscap/version.rb +5 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1fc5d0eb8a93164a6b322c5fe13fe465f55fa04c
|
4
|
+
data.tar.gz: 654ad7376c529f32ebed0933e00f90946f9d2b2c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f44785802b5cbc2214336b3d94e9d85078074206cbac4f9211cb49ca4bf3ee5ed2c35b0d49451185cb12a83cf96df98c64f18de39a6dcb32857100a3dc47967
|
7
|
+
data.tar.gz: d95061ebba27c1bdebc52ff00cd862b6bada2df11062ae9d5dda8da1862eb72e993be37e8ac555473bc46e7c6a1993349d662a2eb797e817a5f5c476ff916f81
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'hammer_cli_foreman'
|
2
|
+
require 'hammer_cli_foreman_openscap/id_resolver'
|
3
|
+
require 'hammer_cli_foreman_openscap/commands'
|
4
|
+
require 'hammer_cli_foreman_openscap/exception_handler'
|
5
|
+
|
6
|
+
module HammerCLIForemanOpenscap
|
7
|
+
def self.exception_handler_class
|
8
|
+
HammerCLIForemanOpenscap::ExceptionHandler
|
9
|
+
end
|
10
|
+
|
11
|
+
HammerCLI::MainCommand.lazy_subcommand("arf-report", _("Manipulate compliance reports."),
|
12
|
+
"HammerCLIForemanOpenscap::ArfReport",
|
13
|
+
"hammer_cli_foreman_openscap/arf_report")
|
14
|
+
|
15
|
+
HammerCLI::MainCommand.lazy_subcommand("policy", _("Manipulate policies."),
|
16
|
+
"HammerCLIForemanOpenscap::Policy",
|
17
|
+
"hammer_cli_foreman_openscap/policy")
|
18
|
+
|
19
|
+
HammerCLI::MainCommand.lazy_subcommand("scap-content", _("Manipulate Scap contents."),
|
20
|
+
"HammerCLIForemanOpenscap::ScapContent",
|
21
|
+
"hammer_cli_foreman_openscap/scap_content")
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module HammerCLIForemanOpenscap
|
2
|
+
class ArfReport < HammerCLIForeman::Command
|
3
|
+
|
4
|
+
resource :arf_reports
|
5
|
+
|
6
|
+
class ListCommand < HammerCLIForeman::ListCommand
|
7
|
+
output do
|
8
|
+
field :id, _("Id")
|
9
|
+
field :host, _("Host")
|
10
|
+
field :reported_at, _("Reported at")
|
11
|
+
field :passed, _("Passed")
|
12
|
+
field :failed, _("Failed")
|
13
|
+
field :othered, _("Othered")
|
14
|
+
end
|
15
|
+
build_options
|
16
|
+
end
|
17
|
+
|
18
|
+
class InfoCommand < HammerCLIForemanOpenscap::InfoCommand
|
19
|
+
output ListCommand.output_definition do
|
20
|
+
field :host_id, _("Host Id")
|
21
|
+
field :openscap_proxy_id, _("Openscap proxy Id")
|
22
|
+
field :openscap_proxy_name, _("Openscap proxy name")
|
23
|
+
HammerCLIForeman::References.taxonomies(self)
|
24
|
+
end
|
25
|
+
|
26
|
+
build_options
|
27
|
+
end
|
28
|
+
|
29
|
+
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
30
|
+
success_message _("Arf report deleted")
|
31
|
+
failure_message _("Could not delete the Arf report")
|
32
|
+
|
33
|
+
build_options
|
34
|
+
end
|
35
|
+
|
36
|
+
autoload_subcommands
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module HammerCLIForemanOpenscap
|
2
|
+
module ResolverCommons
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def resolver
|
9
|
+
api = HammerCLI::Connection.get("foreman").api
|
10
|
+
HammerCLIForeman::IdResolver.new(api, HammerCLIForemanOpenscap::Searchables.new)
|
11
|
+
end
|
12
|
+
|
13
|
+
def searchables
|
14
|
+
@searchables ||= HammerCLIForemanOpenscap::Searchables.new
|
15
|
+
@searchables
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
21
|
+
include HammerCLIForemanOpenscap::ResolverCommons
|
22
|
+
end
|
23
|
+
|
24
|
+
class InfoCommand < HammerCLIForeman::InfoCommand
|
25
|
+
include HammerCLIForemanOpenscap::ResolverCommons
|
26
|
+
end
|
27
|
+
|
28
|
+
class CreateCommand < HammerCLIForeman::CreateCommand
|
29
|
+
include HammerCLIForemanOpenscap::ResolverCommons
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module HammerCLIForemanOpenscap
|
2
|
+
class ExceptionHandler < HammerCLIForeman::ExceptionHandler
|
3
|
+
def mappings
|
4
|
+
[
|
5
|
+
[RestClient::InternalServerError, :handle_internal_error],
|
6
|
+
[RestClient::UnprocessableEntity, :handle_unprocessable_entity]
|
7
|
+
] + super
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def handle_internal_error(e)
|
13
|
+
handle_scap_error(e)
|
14
|
+
HammerCLI::EX_SOFTWARE
|
15
|
+
end
|
16
|
+
|
17
|
+
def handle_unprocessable_entity(e)
|
18
|
+
handle_scap_error(e)
|
19
|
+
HammerCLI::EX_DATAERR
|
20
|
+
end
|
21
|
+
|
22
|
+
def handle_scap_error(e)
|
23
|
+
response = JSON.parse(e.response)
|
24
|
+
response = HammerCLIForeman.record_to_common_format(response)
|
25
|
+
print_error(response["message"] || response["full_messages"])
|
26
|
+
log_full_error e
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module HammerCLIForemanOpenscap
|
2
|
+
class Searchables < HammerCLIForeman::Searchables
|
3
|
+
SEARCHABLES = {
|
4
|
+
:scap_content => [s("title", _("Scap content title"))],
|
5
|
+
:arf_report => [],
|
6
|
+
:policy => [s_name(_("Policy name"))]
|
7
|
+
}
|
8
|
+
|
9
|
+
DEFAULT_SEARCHABLES = [s_name(_("Name to search by"))]
|
10
|
+
|
11
|
+
def for(resource)
|
12
|
+
SEARCHABLES[resource.singular_name.to_sym] || DEFAULT_SEARCHABLES
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module HammerCLIForemanOpenscap
|
2
|
+
class Policy < HammerCLIForeman::Command
|
3
|
+
|
4
|
+
resource :policies
|
5
|
+
|
6
|
+
class ListCommand < HammerCLIForeman::ListCommand
|
7
|
+
output do
|
8
|
+
field :id, _("Id")
|
9
|
+
field :name, _("Name")
|
10
|
+
field :created_at, _("Created at")
|
11
|
+
end
|
12
|
+
build_options
|
13
|
+
end
|
14
|
+
|
15
|
+
class InfoCommand < HammerCLIForeman::InfoCommand
|
16
|
+
output ListCommand.output_definition do
|
17
|
+
field :period, _("Period")
|
18
|
+
field :weekday, _("Weekday")
|
19
|
+
field :cron_line, _("Cron line")
|
20
|
+
field :scap_content_id, _("Scap content Id")
|
21
|
+
field :scap_content_profile_id, _("Scap Content profile Id")
|
22
|
+
HammerCLIForeman::References.taxonomies(self)
|
23
|
+
end
|
24
|
+
build_options
|
25
|
+
end
|
26
|
+
|
27
|
+
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
28
|
+
success_message _("Policy has been deleted")
|
29
|
+
failure_message _("Could not delete the policy")
|
30
|
+
|
31
|
+
build_options
|
32
|
+
end
|
33
|
+
|
34
|
+
class CreateCommand < HammerCLIForemanOpenscap::CreateCommand
|
35
|
+
|
36
|
+
success_message _("Policy created")
|
37
|
+
failure_message _("Could not create the policy")
|
38
|
+
|
39
|
+
build_options
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
class UpdateCommand < HammerCLIForemanOpenscap::UpdateCommand
|
44
|
+
success_message _("Policy updated")
|
45
|
+
failure_message _("Could not update the policy")
|
46
|
+
|
47
|
+
build_options
|
48
|
+
end
|
49
|
+
|
50
|
+
autoload_subcommands
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module HammerCLIForemanOpenscap
|
2
|
+
class ScapContent < HammerCLIForeman::Command
|
3
|
+
|
4
|
+
resource :scap_contents
|
5
|
+
|
6
|
+
class ListCommand < HammerCLIForeman::ListCommand
|
7
|
+
output do
|
8
|
+
field :id, _("Id")
|
9
|
+
field :title, _("Title")
|
10
|
+
end
|
11
|
+
build_options
|
12
|
+
end
|
13
|
+
|
14
|
+
class CreateCommand < HammerCLIForeman::CreateCommand
|
15
|
+
success_message _("Scap content successfully created")
|
16
|
+
failure_message _("Failed to create Scap content")
|
17
|
+
|
18
|
+
option "--scap-file", "SCAP_FILE", _("Scap content file"),
|
19
|
+
:attribute_name => :option_scap_file,
|
20
|
+
:format => HammerCLI::Options::Normalizers::File.new
|
21
|
+
build_options
|
22
|
+
end
|
23
|
+
|
24
|
+
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
25
|
+
success_message _("Scap content deleted")
|
26
|
+
failure_message _("Could not delete Scap content")
|
27
|
+
|
28
|
+
build_options
|
29
|
+
end
|
30
|
+
|
31
|
+
class InfoCommand < HammerCLIForemanOpenscap::InfoCommand
|
32
|
+
output ListCommand.output_definition do
|
33
|
+
field :created_at, _("Created at")
|
34
|
+
field :original_filename, _("Original filename")
|
35
|
+
|
36
|
+
collection :scap_content_profiles, _("Scap content profiles") do
|
37
|
+
field :id, _("Id")
|
38
|
+
field :profile_id, _("Profile id")
|
39
|
+
field :title, _("Title")
|
40
|
+
end
|
41
|
+
HammerCLIForeman::References.taxonomies(self)
|
42
|
+
end
|
43
|
+
build_options
|
44
|
+
end
|
45
|
+
|
46
|
+
class UpdateCommand < HammerCLIForemanOpenscap::UpdateCommand
|
47
|
+
success_message _("Scap content updated")
|
48
|
+
failure_message _("Could not update Scap content")
|
49
|
+
|
50
|
+
option "--scap-file", "SCAP_FILE", _("Scap content file"),
|
51
|
+
:attribute_name => :option_scap_file,
|
52
|
+
:format => HammerCLI::Options::Normalizers::File.new
|
53
|
+
build_options
|
54
|
+
end
|
55
|
+
|
56
|
+
autoload_subcommands
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hammer_cli_foreman_openscap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- The Foreman team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: hammer_cli_foreman
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.6'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/hammer_cli_foreman_openscap.rb
|
34
|
+
- lib/hammer_cli_foreman_openscap/arf_report.rb
|
35
|
+
- lib/hammer_cli_foreman_openscap/commands.rb
|
36
|
+
- lib/hammer_cli_foreman_openscap/exception_handler.rb
|
37
|
+
- lib/hammer_cli_foreman_openscap/id_resolver.rb
|
38
|
+
- lib/hammer_cli_foreman_openscap/policy.rb
|
39
|
+
- lib/hammer_cli_foreman_openscap/scap_content.rb
|
40
|
+
- lib/hammer_cli_foreman_openscap/version.rb
|
41
|
+
homepage:
|
42
|
+
licenses:
|
43
|
+
- GPL-3
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.4.6
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: ForemanOpenscap commands for Hammer
|
65
|
+
test_files: []
|