Skip to content

fix: preserve lab config keys dropped during variant generation - #404

Merged
mwendigg merged 1 commit into
dreadnode:mainfrom
l50:upstream/variant-roundtrip-key-preservation
Aug 3, 2026
Merged

fix: preserve lab config keys dropped during variant generation#404
mwendigg merged 1 commit into
dreadnode:mainfrom
l50:upstream/variant-roundtrip-key-preservation

Conversation

@l50

@l50 l50 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Key Changes:

  • Added missing struct fields (OS, VulnsADCSTemplates, CAWebEnrollment, SCCM) so variant generate no longer silently drops these keys during the JSON round-trip
  • Introduced a round-trip test across all lab configs to guard against future key-dropping regressions
  • Fixed a real defect where GOAD-variant-1 lost its vulns_adcs_templates scoreboard annotation and SCCM variants lost their entire sccm block

Added:

  • Host-level config fields in HostConfig (cli/internal/variant/generator.go) - OS to mark non-Windows hosts (e.g., DRACARYS "linux" for lx01) and VulnsADCSTemplates to carry certificate templates consumed by cli/internal/ansible/prepare.go
  • Domain-level config fields in DomainConfig (cli/internal/variant/generator.go) - CAWebEnrollment as a *bool so an explicit false survives the round-trip (otherwise absent is treated as true by adcs.yml, silently re-enabling CA web enrollment), and SCCM as a raw map to preserve the MECM/SCCM site configuration without reshaping
  • Round-trip key-preservation test - New cli/internal/variant/roundtrip_test.go with TestConfigRoundTripPreservesKeys, which decodes each ad/*/data/config.json, marshals it through LabConfig, and asserts no non-empty keys are lost; a collectKeys helper walks the decoded JSON while skipping empty values (which omitempty legitimately drops)

**Added:**

- New struct fields to model previously unmodeled config keys - `OS` and `VulnsADCSTemplates` on `HostConfig`, plus `CAWebEnrollment` (pointer so an explicit `false` survives) and raw `SCCM` map on `DomainConfig` in `generator.go`; without these, `variant generate` silently drops the `vulns_adcs_templates` scoreboard annotation and the entire `sccm` block
- Round-trip regression test that decodes every `ad/*/data/config.json`, re-encodes it through `LabConfig`, and fails if any non-empty key is lost - `roundtrip_test.go`; guards against future keys being added to configs without a matching struct field
@mwendigg
mwendigg added this pull request to the merge queue Aug 3, 2026
Merged via the queue into dreadnode:main with commit b62d9d9 Aug 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants