How mitre/emasser works
Project Type and Purpose
• eMASSer is a standalone Ruby Command-Line Interface (CLI) tool.
• Its sole purpose is to automate interactions with the eMASS REST API by leveraging the emass_client Ruby gem.
File-Structure Analysis
• exe/: entry point (exe/emasser) that bootstraps the CLI.
• lib/emasser/: core Ruby code, including:
• cli.rb – orchestrates commands and subcommands
• options_parser.rb – parses user flags and arguments
• configuration.rb / configure.rb – reads .env and certificate files
• input_converters.rb / output_converters.rb – transforms data in/out
• get.rb, post.rb, put.rb, delete.rb – business-logic modules that map CLI calls to API calls
• help/…_mapper.md – help text and sample payloads for each endpoint
• Gemfile, .env-example, Dockerfile – packaging and deployment
• .github/ workflows / Rakefile – CI/CD pipelines and test orchestration
README Insights
• eMASSer delegates all REST interactions to the emass_client gem (OpenAPI‐generated).
• Business logic centers on:
a. Parsing CLI input
b. Validating and transforming data
c. Dispatching calls to emass_client
d. Formatting and printing responses
a. Main Components
• User Terminal / CLI Executable (exe/emasser)
• CLI Core:
– Options Parser
– Command Dispatcher
– Input Converters & Validators
– Business-Logic Modules (get/post/put/delete)
– Output Converters & Formatter
• API Client Layer (emass_client gem)
• External eMASS REST API Server
• Environment / Configuration Store (Environment Variables, .env file, TLS certificates)
• (Optional) Packaging & CI/CD (Docker, GitHub Actions)
b. Relationships & Data Flows
1. User types emasser <command> --flags in terminal.
2. CLI executable loads configuration from .env + certs.
3. Options Parser splits command and flags, hands off to Command Dispatcher.
4. Dispatcher routes to the appropriate business-logic module (get, post, etc.).
5. Module uses Input Converters to build API request objects.
6. Calls the emass_client gem methods (OpenAPI-generated stubs).
7. emass_client makes HTTPS requests to eMASS REST endpoints.
8. eMASS responds with JSON; the gem returns native Ruby objects.
9. Output Converters format the results, which the CLI prints to STDOUT.
c. Architectural Patterns & Principles
• Single Responsibility: separate modules for parsing, conversion, business logic, and API transport.
• Dependency Injection: emass_client gem is an external dependency injected into business logic.
• OpenAPI-Driven Client: decouples CLI logic from protocol details.
• Extensibility: help mapper files and modular command files support easy addition of new endpoints.
d. Key Technologies & Libraries
• Ruby 3.x
• emass_client (OpenAPI V3 generated client)
• RubyGems package (emasser.gemspec)
• Docker (optional container image)
• GitHub Actions (CI/CD, linting, testing)