Skip to content

feat: add extra-vars flag and overlay drop detection for lab config - #34

Merged
l50 merged 2 commits into
mainfrom
fix/overlay-drops-and-reconcile-dry-run
Jul 31, 2026
Merged

feat: add extra-vars flag and overlay drop detection for lab config#34
l50 merged 2 commits into
mainfrom
fix/overlay-drops-and-reconcile-dry-run

Conversation

@l50

@l50 l50 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Key Changes:

  • Introduced a repeatable -E/--extra-vars flag on provision and lab reset so operators can pass Ansible variables from the CLI, most importantly ad_reconcile_check_only=true to rehearse a reset as a drift report instead of a destructive write
  • Added CheckOverlayDrops to catch a class of silent misconfiguration where an overlay redeclares a per-host array (like vulns) and drops entries the base config grants, which RFC 7386 array replacement makes invisible to referential checks
  • Fixed the shipped defect where adcs_esc10_case1 was added to dc03 in each lab's config.json but missing from the dev, staging, and test overlays, leaving ESC6/ESC9 unexploitable in those environments

Added:

  • CLI extra-vars support - Added the -E/--extra-vars flag (shared extraVarsUsage const), parseExtraVars to read repeatable key=value pairs, and applyExtraVars/sortedPairs to layer user vars over SOCKS tunnel vars with user precedence and echo what was applied - cli/cmd/provision.go, cli/cmd/lab_reset.go
  • Overlay drop detection - Added CheckOverlayDrops, hostsOf, and the overlayDropKeys table covering vulns, scripts, and vulns_adcs_templates; deleted hosts (explicit null) are intentionally not reported since the removal is already legible - cli/internal/labconfig/integrity.go
  • Test coverage - Added provision_test.go covering extra-vars parsing edge cases (multiple equals signs, empty values, malformed input, precedence, non-mutation of caller maps) and overlay-drop tests pinning the shipped defect and the deleted-host exemption - cli/cmd/provision_test.go, cli/internal/labconfig/integrity_test.go
  • adcs_esc10_case1 vuln - Added the missing vuln to the dc03 host in the dev, staging, and test overlays for both GOAD and GOAD-variant-1 labs
  • Documentation - Documented array-replacement semantics and the requirement to update every overlay after adding a vuln, referencing CheckOverlayDrops and known_findings.txt - docs/mkdocs/docs/developers/add_lab.md

Changed:

  • Provisioning signature - Extended provisionPlaybooks to accept extraVars and thread them into the Ansible runner's ExtraVars, replacing the SOCKS-only var map - cli/cmd/provision.go
  • Host struct - Extended the host type with Scripts and VulnsADCSTemplates fields so the drop check can inspect all provisioned arrays - cli/internal/labconfig/integrity.go
  • Known findings baseline - Recorded the two GOAD dev srv02 shares drops as correct-by-design entries (the share is rehomed to dc02, not lost) with a reason and removal condition, replacing the "intentionally empty" note - cli/internal/labconfig/testdata/known_findings.txt
  • Reset command help - Documented the ad_reconcile_check_only=true rehearsal workflow in the lab reset long help and examples - cli/cmd/lab_reset.go

**Added:**

- `--extra-vars`/`-E` flag to `provision`, `ad-users`, and `lab reset` commands, enabling role defaults like `ad_reconcile_check_only=true` to be set from the command line for dry-run drift reporting instead of destructive writes - cli/cmd/provision.go, cli/cmd/lab_reset.go
- `parseExtraVars` and `sortedPairs` helpers to parse repeatable key=value flags (rejecting malformed input) and render var maps for display, with user-supplied vars layered on top of tunnel vars so explicit `-E` always wins - cli/cmd/provision.go
- `CheckOverlayDrops` integrity check that catches capability the base config grants a host but the merged overlay silently discards, a class CheckIntegrity cannot detect since RFC 7386 arrays replace wholesale - cli/internal/labconfig/integrity.go
- `Scripts` and `VulnsADCSTemplates` fields to the host struct so their per-host arrays are covered by drop detection - cli/internal/labconfig/integrity.go
- `adcs_esc10_case1` vuln to dc03 across dev, staging, and test overlays for GOAD and GOAD-variant-1, restoring the ESC6/ESC9 capability the base grant left unexploitable in those environments
- Tests covering extra-vars parsing, malformed rejection, stable pair sorting, silent overlay-drop detection, and deleted-host handling - cli/cmd/provision_test.go, cli/internal/labconfig/integrity_test.go
- Documentation explaining array-replace overlay semantics and the requirement to propagate new vulns to every re-declaring overlay - docs/mkdocs/docs/developers/add_lab.md

**Changed:**

- `provisionPlaybooks` signature to accept an `extraVars` map, merged into run vars before execution - cli/cmd/provision.go
- `known_findings.txt` to record two deliberate, correct srv02 share relocations flagged by the new drop check, replacing the "intentionally empty" note - cli/internal/labconfig/testdata/known_findings.txt
**Added:**

- `applyExtraVars` helper that layers user-supplied vars over the SOCKS tunnel's connection vars, preserving -e precedence and echoing applied vars - `cli/cmd/provision.go`
- Tests for `applyExtraVars` covering var precedence, non-mutation of the caller's map, and passthrough when no user vars are given - `cli/cmd/provision_test.go`

**Changed:**

- Replaced inline var-merging logic in `provisionPlaybooks` with a call to the new `applyExtraVars` helper - `cli/cmd/provision.go`
- Aligned struct field indentation for `MSSQL` in the host type - `cli/internal/labconfig/integrity.go`
- Normalized "re-declare"/"re-declared" to "redeclare"/"redeclared" across comments, tests, and docs - `integrity.go`, `integrity_test.go`, `add_lab.md`
@l50 l50 changed the title feat: add overlay drop detection and extra-vars flag for reset rehearsals feat: add extra-vars flag and overlay drop detection for lab config Jul 30, 2026
@l50
l50 merged commit 53349b2 into main Jul 31, 2026
9 checks passed
@l50
l50 deleted the fix/overlay-drops-and-reconcile-dry-run branch July 31, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant