Skip to content

feat: add DreadGOAD CLI core command set and AWS/Ansible integration#58

Merged
l50 merged 6 commits into
mainfrom
feat/go-cli
Apr 1, 2026
Merged

feat: add DreadGOAD CLI core command set and AWS/Ansible integration#58
l50 merged 6 commits into
mainfrom
feat/go-cli

Conversation

@l50
Copy link
Copy Markdown
Contributor

@l50 l50 commented Apr 1, 2026

Key Changes:

  • Introduced initial DreadGOAD CLI with core commands for provisioning, validation,
    SSM, inventory, configuration, and lab management
  • Implemented robust AWS (EC2/SSM) and Ansible integration with retry logic and
    error classification
  • Added pre-flight system checks, configuration management, and validation
    routines for lab vulnerabilities
  • Established CI test workflow, pre-commit hooks, and Go module structure

Added:

  • DreadGOAD CLI commands:
    • Provisioning (provision, ad-users) with Ansible playbook orchestration,
      retry logic, and log file management
    • Lab lifecycle management (lab status, lab start, lab stop) using AWS EC2
    • Inventory operations (inventory sync, show, mapping) with AWS integration
    • SSM session operations (ssm status, cleanup, connect, run)
    • Configuration management (config show, init, set)
    • Pre-flight system checks (doctor)
    • Vulnerability validation (validate) with PowerShell checks via SSM
  • Internal packages:
    • internal/aws: abstraction for AWS EC2/SSM operations, instance discovery,
      SSM session management, and command execution
    • internal/ansible: playbook runner, error type classification, retry
      strategies, and output parsing
    • internal/inventory: inventory file parser and utilities
    • internal/config: configuration loader, default settings, and project root
      resolution
    • internal/doctor: system/environment check routines
    • internal/logging: structured logger initialization and management
    • internal/validate: GOAD vulnerability validation logic and reporting
  • Go module files (go.mod, go.sum) for dependency management
  • Pre-commit hooks for Go formatting, linting, testing, and module hygiene
  • CI workflow for running Go tests and uploading coverage reports
  • .gitignore update to exclude built binary and artifacts

Changed:

  • Enhanced pre-commit and CI:
    • Updated .pre-commit-config.yaml to include Go-specific hooks for formatting,
      linting, module verification, vetting, and running relevant unit tests
    • Modified GitHub Actions workflow to install and configure all required Go
      tooling for lint/test jobs
  • Project hygiene:
    • Ensured Go binary (dreadgoad) and build artifacts are ignored in source

Removed:

  • Static/manual steps for Go module replacement and test/lint execution, now
    automated via pre-commit and CI scripts
  • Outdated or redundant entries from .gitignore replaced by more explicit
    patterns for new build outputs and artifacts

l50 added 3 commits March 31, 2026 17:51
…ation

**Added:**

- Introduced CLI command structure using Cobra, including root, config, doctor,
  inventory, lab, provision, ssm, and validate commands for orchestrating
  Active Directory lab environments
- Implemented AWS integration for EC2 and SSM operations, including discovery,
  status, instance start/stop, PowerShell execution, and SSM session
  management
- Added Ansible playbook runner with retry logic and error classification to
  improve provisioning robustness, including idle timeout and error-specific
  handling
- Provided configuration management via Viper, supporting environment
  variables, config files, and CLI flags, with sensible defaults and project
  root detection
- Developed inventory parser for INI-style Ansible inventories to facilitate
  host/group resolution and mapping to AWS resources
- Implemented 'doctor' pre-flight checks for local dependencies, Ansible
  version, AWS credentials, and collection requirements
- Added validation framework to verify GOAD vulnerability configurations via
  automated PowerShell checks and produce a JSON report
- Included logging utility for structured output to console and file with
  debug support
- Provided Go module dependencies (`go.mod`, `go.sum`) for reproducible builds

**Changed:**

- No changes to existing code (initial implementation)

**Removed:**

- No removals (all content is new)
…ory packages

**Added:**

- Introduced unit tests for error detection logic in `ansible/errors_test.go`, covering
  error type classification, pattern matching, and context extraction
- Added tests for Ansible log parsing and failure extraction in
  `ansible/logparser_test.go`, including success/failure scenarios and host
  failure detection from recap output
- Implemented unit tests for configuration path construction, environment
  variable generation, playbook lists, and project root detection in
  `config/config_test.go`
- Created tests for inventory parsing, including host/group/var extraction,
  region detection, host lookup by name/instance ID, and file edge cases in
  `inventory/parser_test.go`
- Included shell scripts `.hooks/go-no-replacement.sh`, `.hooks/go-vet.sh`, and
  `.hooks/run-go-tests.sh` to support Go testing and linting in pre-commit and CI
- Added a new GitHub Actions workflow `tests.yaml` for running Go tests and
  publishing code coverage artifacts

**Changed:**

- Updated `.pre-commit-config.yaml` to integrate Go test, vet, lint, and
  formatting checks via `pre-commit-golang` and custom scripts
- Enhanced `.github/workflows/pre-commit.yaml` to explicitly install and
  configure Go tools (shfmt, goimports, gocyclo, golangci-lint, go-critic) in
  CI, ensuring toolchain availability for linting and code checks

**Added:**

- Automated Go code quality and testing coverage enforcement in both developer
  workflow (via pre-commit hooks) and CI pipeline
feat: add ansible-core version check as pre-flight gate before provisioning


**Added:**

- Implemented `CheckAnsibleCoreVersion` to verify ansible-core is installed and
  within a compatible version range (<2.19), returning an error if not
- Integrated ansible-core version check as a pre-flight step in the provision
  workflow to prevent incompatibility issues

**Changed:**

- Updated `.gitignore` to exclude the `dreadgoad` build artifact
@dreadnode-renovate-bot dreadnode-renovate-bot Bot added area/github Changes made to github actions area/pre-commit Changes made to pre-commit hooks labels Apr 1, 2026
l50 added 3 commits March 31, 2026 20:43
**Changed:**

- Updated the `actions/upload-artifact` action to a newer commit SHA in the
  test workflow to incorporate latest upstream fixes and improvements for
  artifact uploading
…d go code

**Changed:**

- Shell scripts in `.hooks/` updated for consistent spacing around redirections
  and improved readability by adding spaces before `>` and `/dev/null`
- Improved indentation and alignment in Go source files for better code clarity,
  including struct field alignment and composite literal formatting
- Replaced if/else chains with `switch` statements for clearer multi-branch logic
  in Go validation checks
- Updated Go test cases to align field formatting and improve consistency
- Reformatted YAML in `.pre-commit-config.yaml` to remove deprecated
  `pre-commit-golang` repo and add equivalent Go hooks using custom shell
  commands for more control and maintainability
- Fixed inconsistent indentation and alignment in map initializations and
  assignment statements in Go code
**Changed:**

- Consistently check and ignore errors for functions like `os.MkdirAll`, `os.Chdir`,
  `viper.BindPFlag`, and similar cases to reduce linter noise and avoid unhandled errors
- Refactored inventory sync logic for better readability and error handling:
  - Split logic into `backupInventory`, `updateEnvField`, `loadInstances`,
    and `applyInstanceUpdates` helper functions
  - Improved error reporting and eliminated redundant code
- Extracted host filtering logic in SSM command to a new `filterInstances` function
- Improved error handling for JSON marshaling and file writing in inventory mapping command
- Refactored Ansible runner idle timeout logic:
  - Moved idle timeout monitoring into a separate `monitorIdleTimeout` function
  - Ensure deferred file closing ignores errors
  - Ignore errors in process killing for cleanup robustness
- Refactored inventory parser to extract line handling into `parseLine`, `parseHostDef`, and
  `parseGroupMembership` methods for clarity and maintainability
- Updated inventory parser tests to use individual test functions for clarity and improved
  error reporting
- Minor cleanup: removed unused regex variables and improved comment clarity in several files

**Removed:**

- Eliminated unused `fatalLineRe` and `instanceRe` regex variables from ansible logparser
  and inventory parser for clarity
@l50 l50 merged commit cb0fe80 into main Apr 1, 2026
6 checks passed
@l50 l50 deleted the feat/go-cli branch April 1, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/github Changes made to github actions area/pre-commit Changes made to pre-commit hooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant