refactor: split scoped secrets and narrow SOPS recipients #122
No reviewers
Labels
No labels
host:electra
host:fleet
host:lyra
host:vega
host:vega
phase:cutover
phase:deploy
phase:mcp
phase:module
phase:packaging
phase:prep
phase:validation
project:attic-postgres-lyra-rollout
project:auto-update-reliability
project:declarative-purity-cleanup
project:external-review
project:host-facts-refactor
project:lyra-nixos-deploy
project:lyra-service-stack-migration
project:nebula-mesh-network
project:security-hardening
project:service-stack-migration
project:vega-sillytavern-cutover
service:auto-update
service:mem0
service:sillytavern
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
nimmo/nixos-config!122
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/split-scoped-secrets"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #80
Refs #39
Summary
Validation
Live deployment evidence is intentionally still outstanding, so this PR does not close the issues automatically.
Automated code review
Reviewed commit:
9c02457316a4a1291b7ac536fc7ae28b1b9d5367Verdict: Ready to merge
No blocking or important findings were retained, and deterministic checks passed. Suggestions remain advisory.
Overall assessment
Refactors monolithic SOPS secrets into scoped files with narrowed recipient rules, updates Nix modules and Just recipes accordingly, and introduces validation for Nebula secret injection. The change improves secret isolation but leaves a broad catch-all rule in .sops.yaml and removes default arguments from secret editing recipes without input guards.
Blocking findings
None.
Important findings
None.
Suggestions
Catch-all SOPS creation rule remains overly broad (.sops.yaml; high confidence)
key_groups:
Impact: Any new secret file not explicitly covered by the preceding rules will inherit broad access to all hosts, undermining the scoping policy.
Suggested fix: Restrict the catch-all rule to only include admin, YubiKey, and provision-key recipients. This forces explicit creation rules for future files and enforces the principle of least privilege.
edit-secrets recipe lacks input validation (justfiles/secrets.just:321; high confidence)
edit-secrets NAME:
#!/usr/bin/env bash
set -euo pipefail
AGE_KEY=$(sudo ssh-to-age -private-key -i /etc/ssh/ssh_host_ed25519_key)
sops secrets/{{ NAME }}.yaml
Impact: Running
just edit-secretswithout an argument will executesops secrets/.yaml, which may fail or create an unintended empty file.Suggested fix: Add a guard at the start of the recipe:
[[ -z "${NAME:-}" ]] && { echo "Error: NAME argument required"; exit 1; }.Secret rotation relies on staged Git files only (justfiles/secrets.just:100; medium confidence)
done < <(git ls-files 'secrets/.yaml' 'secrets/**/.yaml' | sort)
Impact: Newly created secret files that have not been staged will be skipped during key rotation, leaving them undecryptable by newly registered hosts.
Suggested fix: Update documentation to explicitly require staging before running rotation recipes. Alternatively, consider using
find secrets/ -name '*.yaml'if processing untracked files is desired, though tracked-only aligns with the stated PR goal.Tests and validation
Questions
Review limitations
Diff coverage
.sops.yaml: reviewed — included in a context-limited batchREADME.md: reviewed — included in a context-limited batchhosts/lyra/default.nix: reviewed — included in a context-limited batchhosts/vega/default.nix: reviewed — included in a context-limited batchjustfiles/nebula.just: reviewed — included in a context-limited batchjustfiles/secrets.just: reviewed — included in a context-limited batchmodules/common/default-config.nix: reviewed — included in a context-limited batchmodules/networking/nebula.nix: reviewed — included in a context-limited batchmodules/networking/wifi-networks.nix: reviewed — included in a context-limited batchmodules/networking/wireguard-vpn.nix: reviewed — included in a context-limited batchmodules/profiles/ai-agents.nix: reviewed — included in a context-limited batchmodules/profiles/ai-runtime.nix: reviewed — included in a context-limited batchmodules/services/backrest.nix: reviewed — included in a context-limited batchmodules/services/beszel-agent.nix: reviewed — included in a context-limited batchmodules/services/docker-report.nix: reviewed — included in a context-limited batchmodules/services/hermes.nix: reviewed — included in a context-limited batchmodules/services/nixos-auto-update.nix: reviewed — included in a context-limited batchmodules/services/service-failure-monitor.nix: reviewed — included in a context-limited batchsecrets/README.md: reviewed — included in a context-limited batchsecrets/ai-agents.yaml: reviewed — included in a context-limited batchsecrets/ai-runtime.yaml: reviewed — included in a context-limited batchsecrets/attic.yaml: reviewed — included in a context-limited batchsecrets/backrest.yaml: reviewed — included in a context-limited batchsecrets/beszel/cosmos.yaml: reviewed — included in a context-limited batchsecrets/beszel/electra.yaml: reviewed — included in a context-limited batchsecrets/beszel/lena.yaml: reviewed — included in a context-limited batchsecrets/beszel/lyra.yaml: reviewed — included in a context-limited batchsecrets/beszel/vega.yaml: reviewed — included in a context-limited batchsecrets/docker-report.yaml: reviewed — included in a context-limited batchsecrets/hermes.yaml: reviewed — included in a context-limited batchReview metadata