Skip to content

fix(clustertool): correct SOPS staging, validation and format handling - #642

Merged
alfi0812 merged 7 commits into
mainfrom
fix/encrypt-without-staging
Oct 31, 2026
Merged

alfi0812 merged 7 commits into
mainfrom
fix/encrypt-without-staging

Conversation

@Boemeltrein

@Boemeltrein Boemeltrein commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Description

⚒️ Partially addresses #639.

Correct SOPS staging behavior, staged-file selection, configuration validation and file-format handling.

Following the numbering in #639:

  1. Standalone encryption: clustertool encrypt encrypts working-tree files without staging them. The Git index remains unchanged, including any plaintext already staged. The user or hook must stage the encrypted result.

  2. Staged file selection: Read NUL-separated Git paths without filename quoting, supporting spaces and non-ASCII characters. Missing working copies of matching staged files now cause an error. Staged deletions are excluded, and empty selections no longer cause an error.

  3. Encryption detection — unchanged: Existing metadata-based encryption detection remains in place.

  4. Regex validation: Validate both path_regex and encrypted_regex when loading .sops.yaml. Invalid syntax stops processing before encryption or staging.

  5. Hook staging — error handling fixed: Abort the commit if staging an encrypted result fails. Existing behavior of staging the complete saved working copy of selected files is intentionally retained.

  6. Multiple recipients — unchanged: Existing recipient selection, key groups and the fixed Shamir threshold remain unchanged.

  7. Overlapping rules — unchanged: File deduplication is deferred. Overlapping creation rules can still cause the same file to be processed multiple times.

  8. Hook installation — unchanged: Support for core.hooksPath and linked worktrees remains deferred.

  9. File formats: Use the corresponding SOPS parsers for YAML/YML, JSON, dotenv and INI. Binary and unknown formats return an explicit unsupported-format error without replacing the affected source file.

⚙️ Type of change

  • 🆕 New feature (e.g., bootstrap, cluster config, or automation)
  • 🐛 Bugfix (e.g., node setup, config generation)
  • 🔃 Chart Updates/Changes included with clustertool
  • 🔃 Refactor (internal changes, no functional impact)
  • ⚠️ Breaking change (changes Talos cluster behavior)

🧪 How Has This Been Tested?

  • Run clustertool commands locally
  • Verified cluster bootstrap on Talos nodes
  • Checked generated configs are valid
  • Validated cluster state after changes

Automated verification:

  • go test ./... passed on Linux and Windows in the test-build workflow.
  • Regression tests cover staged paths, missing working copies, staged deletions, regex validation, supported-format round trips, repeated encryption and unsupported-format rejection.
  • A separate injected failure confirmed that unsuccessful staging after encryption returns exit code 1.

Manual verification with Linux build test-a444fed69446:

  • Standalone encryption leaves unstaged files unstaged and preserves existing index contents.
  • Hook commits correctly process filenames containing spaces and non-ASCII characters.
  • Missing working copies block processing; staged deletions and empty selections succeed.
  • Invalid regex syntax is rejected by encrypt, decrypt and precommit.
  • YAML/YML, JSON, dotenv and INI successfully encrypt and decrypt.
  • Repeated encryption leaves already encrypted files unchanged.
  • Unsupported formats produce an error without replacing the affected file.

📃 Notes:

  • This PR intentionally leaves several findings from Fix plaintext commit risks and SOPS handling in encrypt, decrypt and the Git hook #639 unresolved.
  • The existing extra shamCheck() on cluster-settings.sops.yaml is unchanged. After hook encryption, that file must still exist and contain shamir_threshold, even when it is not staged.
  • Hook cache locations and behavior when switching between host and container environments are unchanged.
  • No new runtime dependencies are introduced.

✔️ Checklist:

  • ⚖️ Followed project style and contribution guidelines
  • 👀 Self-reviewed my changes
  • 🧪 Documented testing steps
  • 🏷️ PR title follows convention:
    • feat(clustertool):
    • fix(clustertool):
    • chore(clustertool):

@trueforge-bot

trueforge-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🚀 HelmRelease CI Report

Overall Status

Stage Result
🔍 Detect HelmReleases success
🧪 Helm Tests skipped

🧪 HelmReleases Tested


⏭️ HelmReleases Skipped


Result

ℹ️ No HelmReleases required testing

@Boemeltrein Boemeltrein changed the title in work fix(clustertool): correct SOPS staging, validation and format handling Oct 30, 2026
@Boemeltrein
Boemeltrein marked this pull request as ready for review October 31, 2026 14:56
@alfi0812
alfi0812 merged commit 00ae0a0 into main Oct 31, 2026
11 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.

1 participant