emasser 3.4.1 → 3.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +8 -8
- data/.env-example +12 -12
- data/.github/release-drafter.yml +15 -15
- data/.github/workflows/codeql-analysis.yml +70 -70
- data/.github/workflows/draft-release.yml +15 -15
- data/.github/workflows/gh-pages.yml +32 -32
- data/.github/workflows/push-to-docker-mail.yml +28 -28
- data/.github/workflows/push-to-docker.yml +35 -35
- data/.github/workflows/release.yml +42 -42
- data/.github/workflows/rubocop.yml +23 -23
- data/.github/workflows/test-cli.yml +39 -72
- data/.gitignore +19 -19
- data/.mergify.yml +25 -25
- data/.rubocop.yml +83 -80
- data/.rubocop_todo.yml +27 -27
- data/CHANGELOG.md +66 -16
- data/Dockerfile +44 -44
- data/Gemfile +8 -8
- data/Gemfile.lock +108 -104
- data/LICENSE.md +15 -15
- data/README.md +179 -178
- data/Rakefile +18 -18
- data/_config.yml +1 -1
- data/docs/features.md +1677 -1437
- data/docs/redoc/index.html +1230 -1230
- data/emasser.gemspec +44 -44
- data/exe/emasser +5 -5
- data/lib/emasser/cli.rb +37 -37
- data/lib/emasser/configuration.rb +49 -49
- data/lib/emasser/constants.rb +22 -26
- data/lib/emasser/delete.rb +210 -148
- data/lib/emasser/errors.rb +14 -14
- data/lib/emasser/get.rb +1401 -949
- data/lib/emasser/help/approvalCac_post_mapper.md +20 -20
- data/lib/emasser/help/approvalPac_post_mapper.md +20 -20
- data/lib/emasser/help/artifacts_del_mapper.md +9 -9
- data/lib/emasser/help/artifacts_post_mapper.md +59 -59
- data/lib/emasser/help/artifacts_put_mapper.md +34 -34
- data/lib/emasser/help/cloudresource_post_mapper.md +62 -62
- data/lib/emasser/help/cmmc_get_mapper.md +4 -4
- data/lib/emasser/help/container_post_mapper.md +44 -44
- data/lib/emasser/help/controls_put_mapper.md +74 -74
- data/lib/emasser/help/milestone_del_mapper.md +11 -11
- data/lib/emasser/help/milestone_post_mapper.md +14 -14
- data/lib/emasser/help/milestone_put_mapper.md +23 -23
- data/lib/emasser/help/poam_del_mapper.md +5 -5
- data/lib/emasser/help/poam_post_mapper.md +93 -93
- data/lib/emasser/help/poam_put_mapper.md +107 -107
- data/lib/emasser/help/staticcode_clear_mapper.md +16 -16
- data/lib/emasser/help/staticcode_post_mapper.md +21 -21
- data/lib/emasser/help/testresults_post_mapper.md +21 -21
- data/lib/emasser/help.rb +11 -11
- data/lib/emasser/input_converters.rb +21 -21
- data/lib/emasser/options_parser.rb +20 -20
- data/lib/emasser/output_converters.rb +125 -111
- data/lib/emasser/post.rb +830 -830
- data/lib/emasser/put.rb +588 -588
- data/lib/emasser/version.rb +5 -5
- data/lib/emasser.rb +19 -19
- metadata +16 -10
data/emasser.gemspec
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'lib/emasser/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'emasser'
|
7
|
-
spec.version = Emasser::VERSION
|
8
|
-
spec.authors = ['Amndeep Singh Mann', 'George Dias', 'Kyle Fagan', 'Robert Clark', 'Aaron Lippold']
|
9
|
-
spec.email = ['saf@groups.mitre.org']
|
10
|
-
spec.licenses = ['Apache-2.0']
|
11
|
-
|
12
|
-
spec.summary = 'Provide an automated capability for invoving eMASS API endpoints'
|
13
|
-
spec.description = 'The emasser can be used as a gem or used from the command line (CL) to access eMASS endpoints via their API.'
|
14
|
-
spec.homepage = 'https://saf.mitre.org'
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
|
16
|
-
|
17
|
-
# Specify which files should be added to the gem when it is released.
|
18
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(emass_client|test|spec|features)/}) }
|
21
|
-
end
|
22
|
-
spec.bindir = 'exe'
|
23
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
-
# References: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry
|
25
|
-
spec.metadata = { "github_repo" => "ssh://github.com/mitre/emasser" }
|
26
|
-
|
27
|
-
spec.add_runtime_dependency 'activesupport', '
|
28
|
-
spec.add_runtime_dependency 'colorize', '~> 0.8.1'
|
29
|
-
spec.add_runtime_dependency 'dotenv', '~> 2.7.6'
|
30
|
-
spec.add_runtime_dependency 'rubyzip', '~> 2.3.2'
|
31
|
-
spec.add_runtime_dependency 'thor', '~> 1.1.0'
|
32
|
-
spec.add_runtime_dependency 'emass_client', '~> 3.
|
33
|
-
|
34
|
-
spec.add_development_dependency 'bundler', '~> 2.3'
|
35
|
-
spec.add_development_dependency 'bundler-audit', '~> 0.7'
|
36
|
-
spec.add_development_dependency 'byebug', '~> 11.1.3'
|
37
|
-
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
38
|
-
spec.add_development_dependency 'yaml', '~> 0.2.0'
|
39
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
40
|
-
spec.add_development_dependency 'rubocop', '~> 1.7'
|
41
|
-
spec.add_development_dependency 'rubocop-minitest', '~> 0.10'
|
42
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.11'
|
43
|
-
spec.add_development_dependency 'rubocop-rake', '~> 0.5'
|
44
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/emasser/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'emasser'
|
7
|
+
spec.version = Emasser::VERSION
|
8
|
+
spec.authors = ['Amndeep Singh Mann', 'George Dias', 'Kyle Fagan', 'Robert Clark', 'Aaron Lippold']
|
9
|
+
spec.email = ['saf@groups.mitre.org']
|
10
|
+
spec.licenses = ['Apache-2.0']
|
11
|
+
|
12
|
+
spec.summary = 'Provide an automated capability for invoving eMASS API endpoints'
|
13
|
+
spec.description = 'The emasser can be used as a gem or used from the command line (CL) to access eMASS endpoints via their API.'
|
14
|
+
spec.homepage = 'https://saf.mitre.org'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(emass_client|test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
# References: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry
|
25
|
+
spec.metadata = { "github_repo" => "ssh://github.com/mitre/emasser" }
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'activesupport', '>= 6.1.4', '< 7.1.0'
|
28
|
+
spec.add_runtime_dependency 'colorize', '~> 0.8.1'
|
29
|
+
spec.add_runtime_dependency 'dotenv', '~> 2.7.6'
|
30
|
+
spec.add_runtime_dependency 'rubyzip', '~> 2.3.2'
|
31
|
+
spec.add_runtime_dependency 'thor', '~> 1.1.0'
|
32
|
+
spec.add_runtime_dependency 'emass_client', '~> 3.12'
|
33
|
+
|
34
|
+
spec.add_development_dependency 'bundler', '~> 2.3'
|
35
|
+
spec.add_development_dependency 'bundler-audit', '~> 0.7'
|
36
|
+
spec.add_development_dependency 'byebug', '~> 11.1.3'
|
37
|
+
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
38
|
+
spec.add_development_dependency 'yaml', '~> 0.2.0'
|
39
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
40
|
+
spec.add_development_dependency 'rubocop', '~> 1.7'
|
41
|
+
spec.add_development_dependency 'rubocop-minitest', '~> 0.10'
|
42
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.11'
|
43
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.5'
|
44
|
+
end
|
data/exe/emasser
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'dotenv/load'
|
5
|
-
require 'emasser'
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'dotenv/load'
|
5
|
+
require 'emasser'
|
data/lib/emasser/cli.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Emasser
|
4
|
-
class CLI < Thor
|
5
|
-
package_name 'Emasser'
|
6
|
-
|
7
|
-
if ARGV[0].to_s.include? 'get'
|
8
|
-
require 'emasser/get'
|
9
|
-
register(Emasser::Get, 'get', 'get [RESOURCE]', 'Gets a resource')
|
10
|
-
elsif ARGV[0].to_s.include? 'post'
|
11
|
-
require 'emasser/post'
|
12
|
-
register(Emasser::Post, 'post', 'post [RESOURCE]', 'Posts resources')
|
13
|
-
elsif ARGV[0].to_s.include? 'put'
|
14
|
-
require 'emasser/put'
|
15
|
-
register(Emasser::Put, 'put', 'put [RESOURCE]', 'Puts resources')
|
16
|
-
elsif ARGV[0].to_s.include? 'del'
|
17
|
-
require 'emasser/delete'
|
18
|
-
register(Emasser::Delete, 'delete', 'delete [RESOURCE]', 'Deletes resources')
|
19
|
-
elsif (ARGV[0].to_s.include? '-v') || (ARGV[0].to_s.include? '-V')
|
20
|
-
puts "emasser version: #{Emasser::VERSION}".green
|
21
|
-
exit
|
22
|
-
elsif ARGV[0].to_s.include? 'hello'
|
23
|
-
user_name = ENV.fetch('USERNAME', 'rookie')
|
24
|
-
puts "Hello #{user_name} - enjoy using emasser version #{Emasser::VERSION}!".cyan
|
25
|
-
exit
|
26
|
-
end
|
27
|
-
|
28
|
-
def help
|
29
|
-
puts 'Emasser commands:'.yellow
|
30
|
-
puts ' emasser [get, put, post, delete, -v, or -V]'.yellow
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.exit_on_failure?
|
34
|
-
true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Emasser
|
4
|
+
class CLI < Thor
|
5
|
+
package_name 'Emasser'
|
6
|
+
|
7
|
+
if ARGV[0].to_s.include? 'get'
|
8
|
+
require 'emasser/get'
|
9
|
+
register(Emasser::Get, 'get', 'get [RESOURCE]', 'Gets a resource')
|
10
|
+
elsif ARGV[0].to_s.include? 'post'
|
11
|
+
require 'emasser/post'
|
12
|
+
register(Emasser::Post, 'post', 'post [RESOURCE]', 'Posts resources')
|
13
|
+
elsif ARGV[0].to_s.include? 'put'
|
14
|
+
require 'emasser/put'
|
15
|
+
register(Emasser::Put, 'put', 'put [RESOURCE]', 'Puts resources')
|
16
|
+
elsif ARGV[0].to_s.include? 'del'
|
17
|
+
require 'emasser/delete'
|
18
|
+
register(Emasser::Delete, 'delete', 'delete [RESOURCE]', 'Deletes resources')
|
19
|
+
elsif (ARGV[0].to_s.include? '-v') || (ARGV[0].to_s.include? '-V')
|
20
|
+
puts "emasser version: #{Emasser::VERSION}".green
|
21
|
+
exit
|
22
|
+
elsif ARGV[0].to_s.include? 'hello'
|
23
|
+
user_name = ENV.fetch('USERNAME', 'rookie')
|
24
|
+
puts "Hello #{user_name} - enjoy using emasser version #{Emasser::VERSION}!".cyan
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
def help
|
29
|
+
puts 'Emasser commands:'.yellow
|
30
|
+
puts ' emasser [get, put, post, delete, -v, or -V]'.yellow
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.exit_on_failure?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Emasser
|
4
|
-
require 'emasser/errors'
|
5
|
-
|
6
|
-
class Configuration
|
7
|
-
# rubocop: disable Style/RaiseArgs
|
8
|
-
def self.raise_unless_present(env)
|
9
|
-
ENV.fetch(env) { raise Emasser::ConfigurationMissingError.new(env) }
|
10
|
-
rescue Emasser::ConfigurationMissingError => e
|
11
|
-
if (ARGV[0].to_s.include? '-v') || (ARGV[0].to_s.include? '-V')
|
12
|
-
puts "
|
13
|
-
else
|
14
|
-
puts "\n", e.message.red
|
15
|
-
puts 'Create a .env file containing required variables, place it in the root directory where the emasser command is executed'.yellow
|
16
|
-
puts 'Required environment variables are:'.yellow
|
17
|
-
puts ' export
|
18
|
-
puts ' export
|
19
|
-
puts ' export
|
20
|
-
puts ' export EMASSER_KEY_FILE_PATH=<path to your
|
21
|
-
puts ' export EMASSER_CERT_FILE_PATH=<path to your
|
22
|
-
puts ' export
|
23
|
-
puts 'See
|
24
|
-
end
|
25
|
-
exit
|
26
|
-
end
|
27
|
-
# rubocop: enable Style/RaiseArgs
|
28
|
-
|
29
|
-
# rubocop: disable Style/TernaryParentheses, Style/IfWithBooleanLiteralBranches
|
30
|
-
EmassClient.configure do |config|
|
31
|
-
# Required env variables
|
32
|
-
config.api_key['api-key'] = raise_unless_present('
|
33
|
-
config.api_key['user-uid'] = raise_unless_present('
|
34
|
-
config.scheme = 'https'
|
35
|
-
config.base_path = '/'
|
36
|
-
config.server_index = nil
|
37
|
-
config.host = raise_unless_present('
|
38
|
-
config.key_file = raise_unless_present('EMASSER_KEY_FILE_PATH')
|
39
|
-
config.cert_file = raise_unless_present('EMASSER_CERT_FILE_PATH')
|
40
|
-
config.key_password = raise_unless_present('
|
41
|
-
# Optional env variables
|
42
|
-
config.client_side_validation = (ENV.fetch('EMASSER_CLIENT_SIDE_VALIDATION', 'true').eql? 'true') ? true : false
|
43
|
-
config.verify_ssl = (ENV.fetch('EMASSER_VERIFY_SSL', 'true').eql? 'true') ? true : false
|
44
|
-
config.verify_ssl_host = (ENV.fetch('EMASSER_VERIFY_SSL_HOST', 'true').eql? 'true') ? true : false
|
45
|
-
config.debugging = (ENV.fetch('EMASSER_DEBUGGING', 'false') == 'false') ? false : true
|
46
|
-
end
|
47
|
-
# rubocop: enable Style/TernaryParentheses, Style/IfWithBooleanLiteralBranches
|
48
|
-
end
|
49
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Emasser
|
4
|
+
require 'emasser/errors'
|
5
|
+
|
6
|
+
class Configuration
|
7
|
+
# rubocop: disable Style/RaiseArgs
|
8
|
+
def self.raise_unless_present(env)
|
9
|
+
ENV.fetch(env) { raise Emasser::ConfigurationMissingError.new(env) }
|
10
|
+
rescue Emasser::ConfigurationMissingError => e
|
11
|
+
if (ARGV[0].to_s.include? '-v') || (ARGV[0].to_s.include? '-V')
|
12
|
+
puts "eMASSer version: #{Emasser::VERSION}".green
|
13
|
+
else
|
14
|
+
puts "\n", e.message.red
|
15
|
+
puts 'Create a .env file containing required variables, place it in the root directory where the emasser command is executed'.yellow
|
16
|
+
puts 'Required environment variables are:'.yellow
|
17
|
+
puts ' export EMASSER_API_KEY=<API key>'.green
|
18
|
+
puts ' export EMASSER_USER_UID=<unique identifier of the eMASS user EMASSER_API_KEY belongs to>'.green
|
19
|
+
puts ' export EMASSER_HOST_URL=<FQDN of the eMASS server>'.green
|
20
|
+
puts ' export EMASSER_KEY_FILE_PATH=<path to your eMASS key in PEM format>'.green
|
21
|
+
puts ' export EMASSER_CERT_FILE_PATH=<path to your eMASS certficate in PEM format>'.green
|
22
|
+
puts ' export EMASSER_KEY_FILE_PASSWORD=<password for the key given in EMASSER_KEY_FILE_PATH>'.green, "\n"
|
23
|
+
puts 'See eMASSer environment variables requirements in eMASSer CLI Features for more information (https://mitre.github.io/emasser/docs/features.html).', "\n"
|
24
|
+
end
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
# rubocop: enable Style/RaiseArgs
|
28
|
+
|
29
|
+
# rubocop: disable Style/TernaryParentheses, Style/IfWithBooleanLiteralBranches
|
30
|
+
EmassClient.configure do |config|
|
31
|
+
# Required env variables
|
32
|
+
config.api_key['api-key'] = raise_unless_present('EMASSER_API_KEY')
|
33
|
+
config.api_key['user-uid'] = raise_unless_present('EMASSER_USER_UID')
|
34
|
+
config.scheme = 'https'
|
35
|
+
config.base_path = '/'
|
36
|
+
config.server_index = nil
|
37
|
+
config.host = raise_unless_present('EMASSER_HOST_URL')
|
38
|
+
config.key_file = raise_unless_present('EMASSER_KEY_FILE_PATH')
|
39
|
+
config.cert_file = raise_unless_present('EMASSER_CERT_FILE_PATH')
|
40
|
+
config.key_password = raise_unless_present('EMASSER_KEY_FILE_PASSWORD')
|
41
|
+
# Optional env variables
|
42
|
+
config.client_side_validation = (ENV.fetch('EMASSER_CLIENT_SIDE_VALIDATION', 'true').eql? 'true') ? true : false
|
43
|
+
config.verify_ssl = (ENV.fetch('EMASSER_VERIFY_SSL', 'true').eql? 'true') ? true : false
|
44
|
+
config.verify_ssl_host = (ENV.fetch('EMASSER_VERIFY_SSL_HOST', 'true').eql? 'true') ? true : false
|
45
|
+
config.debugging = (ENV.fetch('EMASSER_DEBUGGING', 'false') == 'false') ? false : true
|
46
|
+
end
|
47
|
+
# rubocop: enable Style/TernaryParentheses, Style/IfWithBooleanLiteralBranches
|
48
|
+
end
|
49
|
+
end
|
data/lib/emasser/constants.rb
CHANGED
@@ -1,26 +1,22 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Emasser
|
4
|
-
GET_SYSTEM_ID_QUERY_PARAMS = {
|
5
|
-
include_package: false,
|
6
|
-
include_ditpr_metrics: false,
|
7
|
-
include_decommissioned: false,
|
8
|
-
debug_return_type: 'SystemResponse' # This is used by swagger client only to format output
|
9
|
-
}.freeze
|
10
|
-
|
11
|
-
GET_SYSTEM_RETURN_TYPE = {
|
12
|
-
debug_return_type: 'SystemResponse'
|
13
|
-
}.freeze
|
14
|
-
|
15
|
-
GET_ARTIFACTS_RETURN_TYPE = {
|
16
|
-
debug_return_type: 'String'
|
17
|
-
}.freeze
|
18
|
-
|
19
|
-
GET_WORKFLOWINSTANCES_RETURN_TYPE = {
|
20
|
-
debug_return_type: 'Object'
|
21
|
-
}.freeze
|
22
|
-
|
23
|
-
DEL_MILESTONES_RETURN_TYPE = {
|
24
|
-
debug_return_type: 'Object'
|
25
|
-
}.freeze
|
26
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Emasser
|
4
|
+
GET_SYSTEM_ID_QUERY_PARAMS = {
|
5
|
+
include_package: false,
|
6
|
+
include_ditpr_metrics: false,
|
7
|
+
include_decommissioned: false,
|
8
|
+
debug_return_type: 'SystemResponse' # This is used by swagger client only to format output
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
GET_SYSTEM_RETURN_TYPE = {
|
12
|
+
debug_return_type: 'SystemResponse'
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
GET_ARTIFACTS_RETURN_TYPE = {
|
16
|
+
debug_return_type: 'String'
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
GET_WORKFLOWINSTANCES_RETURN_TYPE = {
|
20
|
+
debug_return_type: 'Object'
|
21
|
+
}.freeze
|
22
|
+
end
|