From c9946e555e7d3b33ba9866c2e21831c229b30b76 Mon Sep 17 00:00:00 2001 From: George Dias Date: Thu, 6 Jan 2022 22:01:09 -0600 Subject: [PATCH 01/22] updates to the README and features docs --- README.md | 30 ++++++++++++++++++++++-------- docs/features.md | 2 +- emasser.gemspec | 6 +++--- spec/test_emass_client_spec.rb | 9 +++++++++ spec/test_emasser_cli_spec.rb | 21 +++++++++++++++++---- spec/test_get_cli_spec.rb | 2 ++ spec/test_post_cli_spec.rb | 2 ++ spec/test_put_cli_spec.rb | 2 ++ 8 files changed, 58 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3e7e810..207e6f8 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ This project is actively looking for user stories, features to build, and intera ## Roadmap -Emasser is currently in MVP development and we are targeting all the features listed in Current and In Development for version 1.0. The Road Map are things that the team and community have talked about as possible great additions but feedback on which should come first, second, and third are what we would love feedback on from you. +Emasser is currently in MVP development and we are targeting all the features listed in Current and In Development for version 1.0.X. The Road Map are things that the team and community have talked about as possible great additions but feedback on which should come first, second, and third are what we would love feedback on from you. * Update a system's record with met/not met NIST 800-53 Security and Privacy controls and/or common control indicators (CCI) based on scan results expressed in [Heimdall Data Format (HDF)](https://saf.mitre.org/#/normalize). * Resolve a particular plan of action and milestone (POA&M) based on scan results or git-ops workflow. @@ -49,27 +49,41 @@ Runtime Dependencies: * Ruby version 2.7 or greater. * `rubyzip (latest version)` * `emass_client (latest version)` - * On Windows the `cURL` binary is required (libcurl.dll). Options to install cURL for the emasser CLI to work are: - - Download the curl for windows zip file from [curl x.x.x for Windows](https://curl.se/windows/) - - Go into the archive and browse to /bin - - Locate libcurl_x64.dll (it may be just libcurl.dll) + * On Windows the `cURL` binary is required (libcurl.dll). To install cURL: + - Download cURL for windows from [curl x.x.x for Windows](https://curl.se/windows/) + - Go into the archive and browse to the /bin directory + - Locate libcurl_x64.dll (it may be named just libcurl.dll) - Extract the file into the Ruby installation /bin directory - Rename the file to `libcurl.dll` if it has the `_x64` suffix - Install [cURL for windows](https://community.chocolatey.org/packages/curl) and add the installation directory to the PATH. -To install: +To install (via github): ```bash git clone emasser cd emasser +``` +Build the emasser gem +``` gem build *.gemspec gem install *.gem ``` +Build the emass_client gem +``` +cd emass_client/ruby_client +gem build *.gemspec +gem install *.gem +``` + +To install (via published RubyGems): +``` +gem install emasser +``` ## Use **Requirement 1 & 2: Authentication and Authorization:** -`emasser` requires authentication to eMASS as well as authorization to use the eMASS API. This authentication and authorization is **not** a function of `emasser` and needs to be handled directly with discussions with eMASS. `emasser` will accept credentials that are created based on those discussions. +`emasser` requires authentication to eMASS as well as authorization to use the eMASS API. This authentication and authorization is **not** a function of `emasser` and needs to be handled directly with discussions with [eMASS](https://www.dcsa.mil/is/emass/). `emasser` will accept credentials that are created based on those discussions. **Approve API Client for Actionable Requests** Users are required to log-in to eMASS and grant permissions for a client to update data within eMASS on their behalf. This is only required for actionable requests (PUT, POST, DELETE). The Registration Endpoint and all GET requests can be accessed without completing this process with the correct permissions. @@ -83,7 +97,7 @@ To establish an account with eMASS and/or acquire an api-key/user-uid, contact o ## Design **Interactions with eMASS API:** -`emasser` leverages a MITRE dependency, `emass_client`, which provides a REST API client based on a MITRE-created [OpenAPI](https://www.openapis.org/) version 3 specification based on the official eMASS version 2.3 API documentation. This design enables REST API clients to be generated in [any supported programming language](https://swagger.io/tools/swagger-codegen/). This design decision enables `emass_client` to generate a Ruby client for `emasser` and a TypeScript client that is included with [Heimdall Enterprise Server](https://github.com/mitre/heimdall2). +`emasser` leverages a MITRE dependency, `emass_client`, which provides a REST API client based on a MITRE-created [OpenAPI](https://www.openapis.org/) version 3 specification for the official eMASS version 3.2 API documentation. This design enables REST API clients to be generated in [any supported programming language](https://swagger.io/tools/swagger-codegen/). This design decision enables `emass_client` to generate a Ruby client for `emasser` and a TypeScript client that is included with [Heimdall Enterprise Server](https://github.com/mitre/heimdall2). **Business Logic:** Because interactions with the API are handled by a dependency, the bulk of `emasser` is business logic for accepting user input/output, reading data from eMASS or from input, transforming data, and routing data to the appropriate eMASS API endpoint. This business logic is organized into Ruby Classes and Modules based on the command or subcommand requested by the user. diff --git a/docs/features.md b/docs/features.md index fff62cd..e8dc2ff 100644 --- a/docs/features.md +++ b/docs/features.md @@ -19,7 +19,7 @@ emasser environment variables required: - To invoke any boolean parameters use --parameterName for TRUE and --no-parameterName for FALSE - The eMASS API provides the capability of updating multiple entries within several endpoints, however this CLI only supports updating one entry at the time. -## Invoking emmaser CLI Commands +## Invoking emasser CLI Commands The CLI invoke commands listed in this document shows them when executing from the source code (after a pull from GitHub). If an executable (.gem) is created the command to invoke the endpoint is different. For example: - Invoking the GET systems endpoint from the source code is: diff --git a/emasser.gemspec b/emasser.gemspec index b57d447..2c9a782 100644 --- a/emasser.gemspec +++ b/emasser.gemspec @@ -26,14 +26,14 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'colorize', '~> 0.8.1' spec.add_runtime_dependency 'dotenv', '~> 2.7.6' spec.add_runtime_dependency 'rubyzip', '~> 2.3.2' - spec.add_runtime_dependency 'thor', '~> 1.1.0' + spec.add_runtime_dependency 'thor', '~> 1.1.0' spec.add_runtime_dependency 'emass_client', '~> 1.0' spec.add_development_dependency 'bundler', '~> 2.1' spec.add_development_dependency 'bundler-audit', '~> 0.7' spec.add_development_dependency 'byebug', '~> 11.1.3' - spec.add_development_dependency 'rspec', '~>3.10.0' - spec.add_development_dependency 'yaml', '~>0.2.0' + spec.add_development_dependency 'rspec', '~> 3.10.0' + spec.add_development_dependency 'yaml', '~> 0.2.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.7' spec.add_development_dependency 'rubocop-minitest', '~> 0.10' diff --git a/spec/test_emass_client_spec.rb b/spec/test_emass_client_spec.rb index 4c68fb9..0ced092 100644 --- a/spec/test_emass_client_spec.rb +++ b/spec/test_emass_client_spec.rb @@ -30,3 +30,12 @@ require 'test_results_api_spec' require 'workflow_definitions_api_spec' require 'workflow_instances_api_spec' + +# Test that versions match +require 'emasser/version' + +describe 'emass_client version number' do + it 'is equal to the emasser version number' do + expect(Emasser::VERSION).to eq(EmassClient::VERSION) + end +end diff --git a/spec/test_emasser_cli_spec.rb b/spec/test_emasser_cli_spec.rb index e6be899..af2ca70 100644 --- a/spec/test_emasser_cli_spec.rb +++ b/spec/test_emasser_cli_spec.rb @@ -15,18 +15,31 @@ # The top describe block can also be any string that describes the testing. describe 'emasser cli' do # rubocop:disable Style/StringConcatenation, Style/CommandLiteral, Style/PercentLiteralDelimiters - let(:file) { File.expand_path('../emass_client', __dir__)+'/eMASSRestOpenApi.yaml' } + let(:yamlFile) { File.expand_path('../emass_client', __dir__)+'/eMASSRestOpenApi.yaml' } + let(:devDoc) { File.expand_path('../docs', __dir__)+'/developers.md' } + let(:featuresDoc) { File.expand_path('../docs', __dir__)+'/features.md' } + + it 'has a version number' do + expect(Emasser::VERSION).not_to be nil + end it 'should have the eMASS API yaml definition file' do - yaml_object = JSON.generate(YAML.load_file(file)) - # puts "definition is: #{yaml_object.length}" + yaml_object = JSON.generate(YAML.load_file(yamlFile)) expect(yaml_object.length).to be > 0 end it 'should have a valid API yaml definition file' do - yaml_object = %x[ruby -r yaml -e 'YAML.load_file ARGV[0];puts "ok"' #{file}] + yaml_object = %x[ruby -r yaml -e 'YAML.load_file ARGV[0];puts "ok"' #{yamlFile}] expect(yaml_object).to eq("ok\n") end + + it 'should have a developers markdown file' do + expect(File).to exist(devDoc) + end + + it 'should have a features markdown file' do + expect(File).to exist(featuresDoc) + end # rubocop:enable Style/StringConcatenation, Style/CommandLiteral, Style/PercentLiteralDelimiters end diff --git a/spec/test_get_cli_spec.rb b/spec/test_get_cli_spec.rb index ea63783..a7d21f4 100644 --- a/spec/test_get_cli_spec.rb +++ b/spec/test_get_cli_spec.rb @@ -7,6 +7,8 @@ require 'emasser/help' require 'emasser/get' +# ---------------------------------------------------- +# Test that all required CLI GET classes are available describe Emasser::Test do before do # run before each test diff --git a/spec/test_post_cli_spec.rb b/spec/test_post_cli_spec.rb index 91f2f28..a224083 100644 --- a/spec/test_post_cli_spec.rb +++ b/spec/test_post_cli_spec.rb @@ -6,6 +6,8 @@ require 'emasser/help' require 'emasser/post' +# ----------------------------------------------------- +# Test that all required CLI POST classes are available describe Emasser::TestResults do before do # run before each test diff --git a/spec/test_put_cli_spec.rb b/spec/test_put_cli_spec.rb index 48b5ce0..d56869a 100644 --- a/spec/test_put_cli_spec.rb +++ b/spec/test_put_cli_spec.rb @@ -5,6 +5,8 @@ require 'emasser/help' require 'emasser/put' +# ----------------------------------------------------- +# Test that all required CLI PUT classes are available describe Emasser::Controls do before do # run before each test From b2fc0560461e782494fd93074904a97be61681db Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Thu, 6 Jan 2022 22:12:10 -0600 Subject: [PATCH 02/22] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 207e6f8..8226a12 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # emasser +[![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) ![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) ![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) From 85db2f28190d7d0495444035140a8f06458ec06e Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:14:52 -0600 Subject: [PATCH 03/22] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8226a12..11db16f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # emasser [![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) +[![Gem Version](https://badge.fury.io/rb/emasse_client.svg)](https://badge.fury.io/rb/emasse_client) ![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) ![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) From 144097de0603f6f95aeac6d73fcb478632d98226 Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:18:09 -0600 Subject: [PATCH 04/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11db16f..e7bc4ca 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # emasser [![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) -[![Gem Version](https://badge.fury.io/rb/emasse_client.svg)](https://badge.fury.io/rb/emasse_client) +[![emass_client Gem Version](https://badge.fury.io/rb/emass_client.svg)](https://badge.fury.io/rb/emass_client) ![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) ![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) From 9e19791804962aca6c1ebdd0df5acbfc43aed48f Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:33:57 -0600 Subject: [PATCH 05/22] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e7bc4ca..8b27d1c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # emasser [![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) -[![emass_client Gem Version](https://badge.fury.io/rb/emass_client.svg)](https://badge.fury.io/rb/emass_client) +![GitHub Release Date](https://img.shields.io/github/release-date/mitre/emasser) +![GitHub Release Version](https://github.com/v/release/mitre/emasser) ![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) ![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) From b28cb4fae6e83dcf9987e759d16242979659fda2 Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:38:14 -0600 Subject: [PATCH 06/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b27d1c..78d0799 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # emasser [![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) ![GitHub Release Date](https://img.shields.io/github/release-date/mitre/emasser) -![GitHub Release Version](https://github.com/v/release/mitre/emasser) +![GitHub release (latest by date)](https://img.shields.io/github/v/release/mitre/emasser) ![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) ![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) From 1cfc114d8f3762b8c1b629514dce2c0a64ffb0eb Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:40:33 -0600 Subject: [PATCH 07/22] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 78d0799..59b8e73 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # emasser [![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) -![GitHub Release Date](https://img.shields.io/github/release-date/mitre/emasser) -![GitHub release (latest by date)](https://img.shields.io/github/v/release/mitre/emasser) +![GitHub Release Date](https://img.shields.io/github/release-date/mitre/emasser?label=Release%20Date) +![GitHub release (latest by date)](https://img.shields.io/github/v/release/mitre/emasser?label=Release%20Version) ![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) ![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) From 6bded6fb016b79b4321fe503d68c413309dbb94f Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:41:27 -0600 Subject: [PATCH 08/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59b8e73..ed98ece 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/mitre/emasser?label=Release%20Version) ![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) -![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) +![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg?label=Docs%20Generation) ![Code Linter](https://github.com/mitre/emasser/actions/workflows/rubocop.yml/badge.svg) ## About From 3bcdab0cae57fac8a1e04881dd9bbde1f7a30524 Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:42:47 -0600 Subject: [PATCH 09/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed98ece..59b8e73 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/mitre/emasser?label=Release%20Version) ![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) -![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg?label=Docs%20Generation) +![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) ![Code Linter](https://github.com/mitre/emasser/actions/workflows/rubocop.yml/badge.svg) ## About From 672b934d6dd64fbdbefd16fdb1a12069049ee325 Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:43:37 -0600 Subject: [PATCH 10/22] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 59b8e73..4512a6c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) ![GitHub Release Date](https://img.shields.io/github/release-date/mitre/emasser?label=Release%20Date) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/mitre/emasser?label=Release%20Version) +
![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) ![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) From 6d24423ac82ed1c2a056fb3bfde0f1a2417e36b8 Mon Sep 17 00:00:00 2001 From: "George M. Dias" Date: Fri, 7 Jan 2022 19:44:33 -0600 Subject: [PATCH 11/22] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4512a6c..f71a1b3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # emasser -[![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) ![GitHub Release Date](https://img.shields.io/github/release-date/mitre/emasser?label=Release%20Date) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/mitre/emasser?label=Release%20Version) +[![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser)
![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) From dfbfce6c69882270c987ebedc61429b40be3b48e Mon Sep 17 00:00:00 2001 From: George Dias Date: Fri, 7 Jan 2022 21:28:04 -0600 Subject: [PATCH 12/22] updates to the readme and configurations files --- README.md | 28 ++++++++++++++++++---------- lib/emasser/cli.rb | 6 +++++- lib/emasser/configuration.rb | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 207e6f8..4bd001d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # emasser +![GitHub Release Date](https://img.shields.io/github/release-date/mitre/emasser?label=Release%20Date) +![GitHub release (latest by date)](https://img.shields.io/github/v/release/mitre/emasser?label=Release%20Version) +[![Gem Version](https://badge.fury.io/rb/emasser.svg)](https://badge.fury.io/rb/emasser) +
![emasser Testing](https://github.com/mitre/emasser/actions/workflows/test-cli.yml/badge.svg) ![CodeQL Vulnerabilities and Errors](https://github.com/mitre/emasser/actions/workflows/codeql-analysis.yml/badge.svg) ![Docs Generation](https://github.com/mitre/emasser/actions/workflows/generate_docs.yml/badge.svg) @@ -63,23 +67,27 @@ To install (via github): git clone emasser cd emasser ``` -Build the emasser gem -``` -gem build *.gemspec -gem install *.gem -``` -Build the emass_client gem +- Build the emasser gem +```bash + gem build *.gemspec + gem install *.gem ``` -cd emass_client/ruby_client -gem build *.gemspec -gem install *.gem +- Build the emass_client gem +```bash + cd emass_client/ruby_client + gem build *.gemspec + gem install *.gem ``` To install (via published RubyGems): -``` +```bash gem install emasser ``` +**Note:** To run in development mode there isn't a need to build the gem, simply clone from the emasser repository and use: +``` +bundle exec exe/emasser [command] +``` ## Use **Requirement 1 & 2: Authentication and Authorization:** diff --git a/lib/emasser/cli.rb b/lib/emasser/cli.rb index 474106e..f91c9c7 100644 --- a/lib/emasser/cli.rb +++ b/lib/emasser/cli.rb @@ -17,7 +17,11 @@ class CLI < Thor require 'emasser/delete' register(Emasser::Delete, 'delete', 'delete [RESOURCE]', 'Deletes resources') elsif (ARGV[0].to_s.include? '-v') || (ARGV[0].to_s.include? '-V') - puts Emasser::VERSION.green + puts "emasser version: #{Emasser::VERSION}".green + exit + elsif ARGV[0].to_s.include? 'hello' + # 5.times { print "Hello world!\t".cyan } + print "Hello #{ENV['USERNAME']} - enjoy using emasser!".cyan exit end diff --git a/lib/emasser/configuration.rb b/lib/emasser/configuration.rb index cf010cb..fc49cab 100644 --- a/lib/emasser/configuration.rb +++ b/lib/emasser/configuration.rb @@ -9,7 +9,7 @@ def self.raise_unless_present(env) ENV.fetch(env) { raise Emasser::ConfigurationMissingError.new(env) } rescue Emasser::ConfigurationMissingError => e if (ARGV[0].to_s.include? '-v') || (ARGV[0].to_s.include? '-V') - puts Emasser::VERSION.green + puts "emasser version: #{Emasser::VERSION}".green else puts "\n", e.message.red puts 'Create a .env file with the necessary variables, place it in the root directory where the emasser command'.yellow From 0697c51ae111e842d745689c9358476fa65bb8c5 Mon Sep 17 00:00:00 2001 From: George Dias Date: Mon, 10 Jan 2022 16:07:26 -0600 Subject: [PATCH 13/22] Added default CLI help and list of required env variables --- docs/features.md | 4 +++- lib/emasser/configuration.rb | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/features.md b/docs/features.md index e8dc2ff..2b851fc 100644 --- a/docs/features.md +++ b/docs/features.md @@ -3,13 +3,15 @@ ## Required Environment Variables To facilitate setting the required environment variables the emasser CLI utilized the zero-dependency module to load these variables from a .env file. An .env-example file is provided with the required fields (listed below). -emasser environment variables required: +emasser environment variables (required): * EMASSER_API_KEY_API_KEY=`` * EMASSER_API_KEY_USER_UID=`` * EMASSER_KEY_FILE_PATH=`` * EMASSER_CERT_FILE_PATH=`` * EMASSER_KEY_PASSWORD=`` + +emasser environment variables (optional): * EMASSER_CLIENT_SIDE_VALIDATION=`` * EMASSER_VERIFY_SSL=`` * EMASSER_VERIFY_SSL_HOST=`` diff --git a/lib/emasser/configuration.rb b/lib/emasser/configuration.rb index fc49cab..df0c237 100644 --- a/lib/emasser/configuration.rb +++ b/lib/emasser/configuration.rb @@ -12,8 +12,15 @@ def self.raise_unless_present(env) puts "emasser version: #{Emasser::VERSION}".green else puts "\n", e.message.red - puts 'Create a .env file with the necessary variables, place it in the root directory where the emasser command'.yellow - puts 'is executed. See emasser environment variables requirements in emasser CLI Features for more information'.yellow, "\n" + puts 'Create a .env file containing required variables, place it in the root directory where the emasser command is executed'.yellow + puts 'Required environment variables are:'.yellow + puts ' export EMASSER_API_KEY_API_KEY='.green + puts ' export EMASSER_API_KEY_USER_UID='.green + puts ' export EMASSER_HOST='.green + puts ' export EMASSER_KEY_FILE_PATH='.green + puts ' export EMASSER_CERT_FILE_PATH='.green + puts ' export EMASSER_KEY_PASSWORD='.green, "\n" + puts 'See emasser environment variables requirements in emasser CLI Features for more information (https://mitre.github.io/emasser/docs/features.html).', "\n" end exit end @@ -21,6 +28,7 @@ def self.raise_unless_present(env) # rubocop: disable Style/TernaryParentheses, Style/IfWithBooleanLiteralBranches EmassClient.configure do |config| + # Required env variables config.api_key['api-key'] = raise_unless_present('EMASSER_API_KEY_API_KEY') config.api_key['user-uid'] = raise_unless_present('EMASSER_API_KEY_USER_UID') config.scheme = 'https' @@ -29,10 +37,11 @@ def self.raise_unless_present(env) config.key_file = raise_unless_present('EMASSER_KEY_FILE_PATH') config.cert_file = raise_unless_present('EMASSER_CERT_FILE_PATH') config.key_password = raise_unless_present('EMASSER_KEY_PASSWORD') - config.client_side_validation = (ENV.fetch('EMASSER_CLIENT_SIDE_VALIDATION', false) == 'false') ? false : true - config.verify_ssl = (ENV.fetch('EMASSER_VERIFY_SSL', false) == 'false') ? false : true - config.verify_ssl_host = (ENV.fetch('EMASSER_VERIFY_SSL_HOST', false) == 'false') ? false : true - config.debugging = (ENV.fetch('EMASSER_DEBUGGING', false) == 'true') ? true : false + # Optional env variables + config.client_side_validation = (ENV.fetch('EMASSER_CLIENT_SIDE_VALIDATION', 'true').eql? 'true') ? true : false + config.verify_ssl = (ENV.fetch('EMASSER_VERIFY_SSL', 'true').eql? 'true') ? true : false + config.verify_ssl_host = (ENV.fetch('EMASSER_VERIFY_SSL_HOST', 'true').eql? 'true') ? true : false + config.debugging = (ENV.fetch('EMASSER_DEBUGGING', 'false') == 'false') ? false : true end # rubocop: enable Style/TernaryParentheses, Style/IfWithBooleanLiteralBranches end From 70b641453845ee0bb7f5c08354f01f5192207ae1 Mon Sep 17 00:00:00 2001 From: George Dias Date: Mon, 10 Jan 2022 20:00:26 -0600 Subject: [PATCH 14/22] Added default CLI help and list of required env variables --- lib/emasser/cli.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/emasser/cli.rb b/lib/emasser/cli.rb index f91c9c7..4803e01 100644 --- a/lib/emasser/cli.rb +++ b/lib/emasser/cli.rb @@ -20,14 +20,13 @@ class CLI < Thor puts "emasser version: #{Emasser::VERSION}".green exit elsif ARGV[0].to_s.include? 'hello' - # 5.times { print "Hello world!\t".cyan } print "Hello #{ENV['USERNAME']} - enjoy using emasser!".cyan exit end def help - puts 'Emasser commands:' - puts ' emasser [get, put, post, delete, -v, or -V]' + puts 'Emasser commands:'.yellow + puts ' emasser [get, put, post, delete, -v, or -V]'.yellow end def self.exit_on_failure? From 28bfdd280bc4b821e7055c2fc66173c2ae51dbe0 Mon Sep 17 00:00:00 2001 From: George Dias Date: Wed, 12 Jan 2022 22:45:02 -0600 Subject: [PATCH 15/22] Updates to the Dockerfile --- .env-example | 2 +- .github/workflows/push-to-docker-mail.yml | 28 ++++++++++++++++++ .github/workflows/push-to-docker.yml | 35 +++++++++++++++++++++++ Dockerfile | 17 ++++++++++- 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/push-to-docker-mail.yml create mode 100644 .github/workflows/push-to-docker.yml diff --git a/.env-example b/.env-example index b903d54..87fb54e 100644 --- a/.env-example +++ b/.env-example @@ -2,7 +2,7 @@ export EMASSER_API_KEY_API_KEY= export EMASSER_API_KEY_USER_UID= export EMASSER_HOST= export EMASSER_KEY_FILE_PATH= -export EMASSER_CERT_FILE_PATH= +export EMASSER_CERT_FILE_PATH= export EMASSER_KEY_PASSWORD= export EMASSER_CLIENT_SIDE_VALIDATION= export EMASSER_VERIFY_SSL= diff --git a/.github/workflows/push-to-docker-mail.yml b/.github/workflows/push-to-docker-mail.yml new file mode 100644 index 0000000..2cdb473 --- /dev/null +++ b/.github/workflows/push-to-docker-mail.yml @@ -0,0 +1,28 @@ +name: Push emasser CLI to Docker Hub on every merge to master and tag as latest + +on: + push: + branches: [ main ] + + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Checkout the emasser Repository + uses: actions/checkout@v2 + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + push: true + tags: mitre/emasser:lateste \ No newline at end of file diff --git a/.github/workflows/push-to-docker.yml b/.github/workflows/push-to-docker.yml new file mode 100644 index 0000000..73638b8 --- /dev/null +++ b/.github/workflows/push-to-docker.yml @@ -0,0 +1,35 @@ +name: Push emasser to Docker Hub on every release + +on: + release: + types: [published] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Run string replace + uses: frabert/replace-string-action@master + id: format-tag + with: + pattern: 'v' + string: "${{ github.event.release.tag_name }}" + replace-with: '' + flags: 'g' + - name: Checkout the emasser Repository + uses: actions/checkout@v2 + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + push: true + tags: mitre/emasser:release-latest,mitre/emasser:${{ steps.format-tag.outputs.replaced }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9cff68a..26d7014 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,24 @@ -FROM ruby:2.5 +# Buld from ruby 2.7.5 image +FROM ruby:2.7 +LABEL name="emasser" \ + vendor="MTIRE" \ + version="${EMASSER_VERSION}" \ + release="1" \ + url="https://github.com/mitre/emasser" \ + description="Emasser is a command-line interface (CLI) that aims to automate routine business use-cases and provide utility surrounding the Enterprise Mission Assurance Support Service (eMASS) by leveraging its representational state transfer (REST) application programming interface (API)." \ + docs="https://mitre.github.io/emasser/" \ + run="docker run -d --name ${NAME} ${IMAGE} " + +# Set the base directory that will be used from now on WORKDIR /emasser +# Copy - source (.) destination (.) COPY . . +# Don't install development or test dependencies +RUN bundle config set without 'development test' +# Install dependency RUN bundle install ENTRYPOINT ["bundle", "exec", "exe/emasser"] From 3eda9e1dfb6c0bcddbb498f5770cc7854ac4dba5 Mon Sep 17 00:00:00 2001 From: George Dias Date: Wed, 12 Jan 2022 23:06:41 -0600 Subject: [PATCH 16/22] Updates to the Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 26d7014..4a6412a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,4 +22,4 @@ RUN bundle config set without 'development test' RUN bundle install ENTRYPOINT ["bundle", "exec", "exe/emasser"] -CMD ["-h"] +CMD ["-h"] \ No newline at end of file From 0e6ffb7db32b8675f4a6cc13a3ff2f382e7ef3ff Mon Sep 17 00:00:00 2001 From: George Dias Date: Wed, 12 Jan 2022 23:34:55 -0600 Subject: [PATCH 17/22] Updated the Bundler version to 2.3.4 --- Dockerfile | 20 ++++++++++---------- Gemfile.lock | 7 +++---- emasser.gemspec | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a6412a..0e9fd0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ # Buld from ruby 2.7.5 image FROM ruby:2.7 -LABEL name="emasser" \ - vendor="MTIRE" \ - version="${EMASSER_VERSION}" \ - release="1" \ - url="https://github.com/mitre/emasser" \ - description="Emasser is a command-line interface (CLI) that aims to automate routine business use-cases and provide utility surrounding the Enterprise Mission Assurance Support Service (eMASS) by leveraging its representational state transfer (REST) application programming interface (API)." \ - docs="https://mitre.github.io/emasser/" \ - run="docker run -d --name ${NAME} ${IMAGE} " +# LABEL name="emasser" \ +# vendor="MTIRE" \ +# version="${EMASSER_VERSION}" \ +# release="1" \ +# url="https://github.com/mitre/emasser" \ +# description="Emasser is a command-line interface (CLI) that aims to automate routine business use-cases and provide utility surrounding the Enterprise Mission Assurance Support Service (eMASS) by leveraging its representational state transfer (REST) application programming interface (API)." \ +# docs="https://mitre.github.io/emasser/" \ +# run="docker run -d --name ${NAME} ${IMAGE} " # Set the base directory that will be used from now on WORKDIR /emasser @@ -17,9 +17,9 @@ WORKDIR /emasser COPY . . # Don't install development or test dependencies -RUN bundle config set without 'development test' +# RUN bundle config set without 'development test' # Install dependency RUN bundle install ENTRYPOINT ["bundle", "exec", "exe/emasser"] -CMD ["-h"] \ No newline at end of file +CMD ["-hello"] \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index d14aca3..bb3de5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,7 +36,7 @@ GEM dotenv (2.7.6) ethon (0.15.0) ffi (>= 1.15.0) - ffi (1.15.4-x64-mingw32) + ffi (1.15.5-x64-mingw32) i18n (1.8.11) concurrent-ruby (~> 1.0) json (2.6.1) @@ -44,7 +44,7 @@ GEM parallel (1.21.0) parser (3.1.0.0) ast (~> 2.4.1) - rainbow (3.0.0) + rainbow (3.1.1) rake (13.0.6) regexp_parser (2.2.0) rexml (3.2.5) @@ -92,10 +92,9 @@ GEM PLATFORMS x64-mingw32 - x86_64-darwin-20 DEPENDENCIES - bundler (~> 2.1) + bundler (~> 2.3.4) bundler-audit (~> 0.7) byebug (~> 11.1.3) emass_client! diff --git a/emasser.gemspec b/emasser.gemspec index 2c9a782..a12ad00 100644 --- a/emasser.gemspec +++ b/emasser.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'thor', '~> 1.1.0' spec.add_runtime_dependency 'emass_client', '~> 1.0' - spec.add_development_dependency 'bundler', '~> 2.1' + spec.add_development_dependency 'bundler', '~> 2.3.4' spec.add_development_dependency 'bundler-audit', '~> 0.7' spec.add_development_dependency 'byebug', '~> 11.1.3' spec.add_development_dependency 'rspec', '~> 3.10.0' From f7efc00f7cd967773a12be7b194f6fe7444d057e Mon Sep 17 00:00:00 2001 From: George Dias Date: Thu, 13 Jan 2022 20:59:17 -0600 Subject: [PATCH 18/22] Add instructions on how to run emasser in Docker --- .dockerignore | 16 +++++++++++++--- .gitignore | 3 ++- Dockerfile | 25 ++++++++++++++----------- Gemfile.lock | 4 ++-- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ emasser.gemspec | 2 +- lib/emasser/cli.rb | 3 ++- lib/emasser/delete.rb | 4 ++-- 8 files changed, 79 insertions(+), 21 deletions(-) diff --git a/.dockerignore b/.dockerignore index 0fca2e5..d297491 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,11 +1,21 @@ # git -.git .gitignore +Gemfile.lock CHANGELOG.md +# VS Code +.vscode/ + +# doc +doc/ + # ci -.gitlab-ci.yml +.github +_config.yml # code spec -.env + +#rubocop +.rubocop.yml +.rubocop_todo.yml \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3446266..cda9acb 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,9 @@ **/*.un~ -emassing/test/test_example.zip .DS_Store .byebug_history .env +key.pem +client.pem *.gem diff --git a/Dockerfile b/Dockerfile index 0e9fd0e..f39e17a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,28 @@ # Buld from ruby 2.7.5 image -FROM ruby:2.7 +FROM ruby:2.7.5 -# LABEL name="emasser" \ -# vendor="MTIRE" \ -# version="${EMASSER_VERSION}" \ -# release="1" \ -# url="https://github.com/mitre/emasser" \ -# description="Emasser is a command-line interface (CLI) that aims to automate routine business use-cases and provide utility surrounding the Enterprise Mission Assurance Support Service (eMASS) by leveraging its representational state transfer (REST) application programming interface (API)." \ -# docs="https://mitre.github.io/emasser/" \ -# run="docker run -d --name ${NAME} ${IMAGE} " +LABEL name="emasser" \ + vendor="MITRE" \ + version="${EMASSER_VERSION}" \ + release="1" \ + url="https://github.com/mitre/emasser" \ + description="Emasser is a command-line interface (CLI) that aims to automate routine business use-cases and provide utility surrounding the Enterprise Mission Assurance Support Service (eMASS) by leveraging its representational state transfer (REST) application programming interface (API)." \ + docs="https://mitre.github.io/emasser/" \ + run="docker run -d --name ${NAME} ${IMAGE} " # Set the base directory that will be used from now on WORKDIR /emasser +VOLUME ["/emasser"] # Copy - source (.) destination (.) COPY . . # Don't install development or test dependencies -# RUN bundle config set without 'development test' +RUN bundle config set without 'development test' # Install dependency +RUN gem install bundler -v '2.3.5' RUN bundle install ENTRYPOINT ["bundle", "exec", "exe/emasser"] -CMD ["-hello"] \ No newline at end of file + +CMD ["-h"] diff --git a/Gemfile.lock b/Gemfile.lock index bb3de5f..4736f84 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,7 +94,7 @@ PLATFORMS x64-mingw32 DEPENDENCIES - bundler (~> 2.3.4) + bundler (~> 2.3) bundler-audit (~> 0.7) byebug (~> 11.1.3) emass_client! @@ -108,4 +108,4 @@ DEPENDENCIES yaml (~> 0.2.0) BUNDLED WITH - 2.3.4 + 2.3.5 diff --git a/README.md b/README.md index 4bd001d..75d4b94 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,49 @@ gem install emasser ``` bundle exec exe/emasser [command] ``` + +## Using Docker +**Note:** Before building the container: + - Add a .env file containing the emasser required variables in the emasser source directory + - Place the certificates (key.pem and client.pem) used to access the eMASS URL in the emasser source directory as well + +### Build the Docker Container +- Install and start Docker +- Download emasser by running git clone https://github.com/mitre/emasser.git. +- Navigate to the base folder where Dockerfile is located +- Build the emasser container from a terminal window in the emasser source directory: + ``` + docker build -t emasser . + ``` +- To see the build output use: + ``` + docker build --no-cache --progress=plain -t emasser . + ``` + +### Run the emasser Docker Container (--rm remove the container when exit) +- To run the emasser container use: + ``` + docker run --rm emasser + ``` +- To list all GET, POST, PUT, or DELETE commands use: + ``` + docker run --rm emasser get help + ``` + ``` + docker run --rm emasser post help + ``` + ``` + docker run --rm emasser put help + ``` + ``` + docker run --rm emasser delete help + ``` + +### Delete (remove) the Docker Container +``` + docker rmi -f emasser +``` + ## Use **Requirement 1 & 2: Authentication and Authorization:** diff --git a/emasser.gemspec b/emasser.gemspec index a12ad00..c3a4941 100644 --- a/emasser.gemspec +++ b/emasser.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'thor', '~> 1.1.0' spec.add_runtime_dependency 'emass_client', '~> 1.0' - spec.add_development_dependency 'bundler', '~> 2.3.4' + spec.add_development_dependency 'bundler', '~> 2.3' spec.add_development_dependency 'bundler-audit', '~> 0.7' spec.add_development_dependency 'byebug', '~> 11.1.3' spec.add_development_dependency 'rspec', '~> 3.10.0' diff --git a/lib/emasser/cli.rb b/lib/emasser/cli.rb index 4803e01..fcf03e9 100644 --- a/lib/emasser/cli.rb +++ b/lib/emasser/cli.rb @@ -20,7 +20,8 @@ class CLI < Thor puts "emasser version: #{Emasser::VERSION}".green exit elsif ARGV[0].to_s.include? 'hello' - print "Hello #{ENV['USERNAME']} - enjoy using emasser!".cyan + user_name = ENV['USERNAME'] || 'rookie' + print "Hello #{user_name} - enjoy using emasser!".cyan exit end diff --git a/lib/emasser/delete.rb b/lib/emasser/delete.rb index a5f9544..809a78d 100644 --- a/lib/emasser/delete.rb +++ b/lib/emasser/delete.rb @@ -47,7 +47,7 @@ def self.exit_on_failure? end # Delete a POAM ----------------------------------------------------------- - desc 'remove', 'Add one or many POA&M items in a system' + desc 'remove', 'Delete one or many POA&M items in a system' long_desc Help.text(:poam_del_mapper) # Required parameters/fields @@ -110,7 +110,7 @@ def self.exit_on_failure? true end - desc 'remove', 'Remove one or many artifacts in a system' + desc 'remove', 'Delete one or many artifacts in a system' long_desc Help.text(:artifact_del_mapper) # Required parameters/fields From f5af6cfb8c9be36eb3f05fe01b23a0b3f892bfc3 Mon Sep 17 00:00:00 2001 From: George Dias Date: Thu, 13 Jan 2022 21:04:40 -0600 Subject: [PATCH 19/22] Added instructions on how to run emasser in Docker --- .github/workflows/push-to-docker-mail.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-to-docker-mail.yml b/.github/workflows/push-to-docker-mail.yml index 2cdb473..df2168c 100644 --- a/.github/workflows/push-to-docker-mail.yml +++ b/.github/workflows/push-to-docker-mail.yml @@ -25,4 +25,4 @@ jobs: context: . file: Dockerfile push: true - tags: mitre/emasser:lateste \ No newline at end of file + tags: mitre/emasser:latest \ No newline at end of file From ae1ec21d9ffb37ba724ffc5e1f33b7d47d24047a Mon Sep 17 00:00:00 2001 From: Robert Clark Date: Fri, 14 Jan 2022 14:01:15 -0500 Subject: [PATCH 20/22] Setup docker with multi-stage builds --- .dockerignore | 15 +----------- .github/workflows/push-to-docker-mail.yml | 8 +++---- .github/workflows/push-to-docker.yml | 8 +++---- Dockerfile | 28 +++++++++++++++++----- README.md | 29 +++++------------------ 5 files changed, 37 insertions(+), 51 deletions(-) diff --git a/.dockerignore b/.dockerignore index d297491..fd29103 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,21 +1,8 @@ -# git -.gitignore -Gemfile.lock -CHANGELOG.md - # VS Code .vscode/ # doc doc/ -# ci -.github -_config.yml - # code -spec - -#rubocop -.rubocop.yml -.rubocop_todo.yml \ No newline at end of file +spec/ diff --git a/.github/workflows/push-to-docker-mail.yml b/.github/workflows/push-to-docker-mail.yml index df2168c..3a802a7 100644 --- a/.github/workflows/push-to-docker-mail.yml +++ b/.github/workflows/push-to-docker-mail.yml @@ -14,10 +14,10 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v1 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Checkout the emasser Repository - uses: actions/checkout@v2 + uses: actions/checkout@v2 - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -25,4 +25,4 @@ jobs: context: . file: Dockerfile push: true - tags: mitre/emasser:latest \ No newline at end of file + tags: mitre/emasser:latest diff --git a/.github/workflows/push-to-docker.yml b/.github/workflows/push-to-docker.yml index 73638b8..76b6a84 100644 --- a/.github/workflows/push-to-docker.yml +++ b/.github/workflows/push-to-docker.yml @@ -13,8 +13,8 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v1 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Run string replace uses: frabert/replace-string-action@master id: format-tag @@ -24,7 +24,7 @@ jobs: replace-with: '' flags: 'g' - name: Checkout the emasser Repository - uses: actions/checkout@v2 + uses: actions/checkout@v2 - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -32,4 +32,4 @@ jobs: context: . file: Dockerfile push: true - tags: mitre/emasser:release-latest,mitre/emasser:${{ steps.format-tag.outputs.replaced }} \ No newline at end of file + tags: mitre/emasser:release-latest,mitre/emasser:${{ steps.format-tag.outputs.replaced }} diff --git a/Dockerfile b/Dockerfile index f39e17a..54a279f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Buld from ruby 2.7.5 image -FROM ruby:2.7.5 +FROM ruby:2.7.5 as build LABEL name="emasser" \ vendor="MITRE" \ @@ -12,17 +12,33 @@ LABEL name="emasser" \ # Set the base directory that will be used from now on WORKDIR /emasser -VOLUME ["/emasser"] # Copy - source (.) destination (.) -COPY . . -# Don't install development or test dependencies -RUN bundle config set without 'development test' # Install dependency RUN gem install bundler -v '2.3.5' +RUN apt update && apt install -y build-essential +COPY . . RUN bundle install +WORKDIR /emasser/emass_client/ruby_client +RUN gem build emass_client.gemspec +WORKDIR /emasser +RUN gem build emasser.gemspec +RUN mkdir gems +RUN mv emass_client/ruby_client/emass_client*.gem gems/emass_client.gem +RUN mv emasser*.gem gems/emasser.gem + +FROM ruby:2-alpine + +COPY --from=build /emasser/gems /emass-gems + +RUN sed -i 's/https/http/g' /etc/apk/repositories + +RUN apk add build-base libcurl && gem install /emass-gems/emass_client.gem && gem install /emass-gems/emasser.gem + +VOLUME [ "/data" ] +WORKDIR /data -ENTRYPOINT ["bundle", "exec", "exe/emasser"] +ENTRYPOINT ["emasser"] CMD ["-h"] diff --git a/README.md b/README.md index 75d4b94..0dfa27b 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Runtime Dependencies: * Ruby version 2.7 or greater. * `rubyzip (latest version)` * `emass_client (latest version)` - * On Windows the `cURL` binary is required (libcurl.dll). To install cURL: + * On Windows the `cURL` binary is required (libcurl.dll). To install cURL: - Download cURL for windows from [curl x.x.x for Windows](https://curl.se/windows/) - Go into the archive and browse to the /bin directory - Locate libcurl_x64.dll (it may be named just libcurl.dll) @@ -90,40 +90,23 @@ bundle exec exe/emasser [command] ``` ## Using Docker -**Note:** Before building the container: - - Add a .env file containing the emasser required variables in the emasser source directory - - Place the certificates (key.pem and client.pem) used to access the eMASS URL in the emasser source directory as well - -### Build the Docker Container -- Install and start Docker -- Download emasser by running git clone https://github.com/mitre/emasser.git. -- Navigate to the base folder where Dockerfile is located -- Build the emasser container from a terminal window in the emasser source directory: - ``` - docker build -t emasser . - ``` -- To see the build output use: - ``` - docker build --no-cache --progress=plain -t emasser . - ``` - ### Run the emasser Docker Container (--rm remove the container when exit) - To run the emasser container use: ``` - docker run --rm emasser + docker run --rm -v $PWD/path-to-secrets:/data mitre/emasser:latest ``` - To list all GET, POST, PUT, or DELETE commands use: ``` - docker run --rm emasser get help + docker run --rm -v $PWD/path-to-secrets:/data mitre/emasser:latest get help ``` ``` - docker run --rm emasser post help + docker run --rm -v $PWD/path-to-secrets:/data mitre/emasser:latest post help ``` ``` - docker run --rm emasser put help + docker run --rm -v $PWD/path-to-secrets:/data mitre/emasser:latest put help ``` ``` - docker run --rm emasser delete help + docker run --rm -v $PWD/path-to-secrets:/data mitre/emasser:latest delete help ``` ### Delete (remove) the Docker Container From 4fb5f09bc126ab0dc83851cff47ba474b29d484e Mon Sep 17 00:00:00 2001 From: Robert Clark Date: Fri, 14 Jan 2022 14:02:52 -0500 Subject: [PATCH 21/22] Remove SSL workaround --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 54a279f..a42d8cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,8 +32,6 @@ FROM ruby:2-alpine COPY --from=build /emasser/gems /emass-gems -RUN sed -i 's/https/http/g' /etc/apk/repositories - RUN apk add build-base libcurl && gem install /emass-gems/emass_client.gem && gem install /emass-gems/emasser.gem VOLUME [ "/data" ] From 361908b40fcf4c8d601b687f565b082b602237a9 Mon Sep 17 00:00:00 2001 From: George Dias Date: Fri, 14 Jan 2022 13:08:44 -0600 Subject: [PATCH 22/22] Updated the readme --- Dockerfile | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a42d8cb..c7b471c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN mv emass_client/ruby_client/emass_client*.gem gems/emass_client.gem RUN mv emasser*.gem gems/emasser.gem FROM ruby:2-alpine - +# RUN sed -i 's/https/http/g' /etc/apk/repositories COPY --from=build /emasser/gems /emass-gems RUN apk add build-base libcurl && gem install /emass-gems/emass_client.gem && gem install /emass-gems/emasser.gem diff --git a/README.md b/README.md index 0dfa27b..8e8f832 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ bundle exec exe/emasser [command] ### Delete (remove) the Docker Container ``` - docker rmi -f emasser + docker rmi -f mitre/emasser ``` ## Use