A command-line utility to simplify the code review process for SOPS-encrypted secrets by automatically decrypting and displaying differences between files.
SOPS-Diff addresses a common challenge in secure code review: reviewing changes to encrypted files. By automating the decryption and comparison of SOPS-encrypted files, this tool makes it easier to identify and verify changes to sensitive configuration without exposing those secrets to unnecessary risk.
- Automated Comparison: Decrypt two SOPS-encrypted files and show only their differences
- Multiple Format Support: Parse and compare YAML, JSON, and ENV file formats
- Output Modes:
- Full mode: Show both keys and values that have changed
- Summary mode: Display only the changed keys without sensitive values
- Git Integration:
- Compare between Git revisions (e.g.,
sops-diff --git HEAD:secrets.enc.yaml secrets.enc.yaml) - Git attribute support for automatic invocation during
git diff - Resolve merge conflicts in encrypted files with
git-conflictscommand - Set up custom Git merge tool for encrypted files with
setup-git-merge-toolcommand
- Compare between Git revisions (e.g.,
- Output Options:
- Color-coded output for better readability in terminal
- Save results to file with
--outputflag
- Security-Focused:
- No decrypted content written to disk by default
- Minimized exposure of secrets
- Automatic detection and warning for decrypted files
For detailed installation instructions for different platforms, please refer to INSTALLATION.md.
# Linux (amd64)
curl -L https://github.com/saltydogtechnology/sops-diff/releases/download/v0.2.0/sops-diff-v0.2.0-linux-amd64.tar.gz | tar xz
sudo mv sops-diff-linux-amd64 /usr/local/bin/sops-diff
# macOS (amd64)
curl -L https://github.com/saltydogtechnology/sops-diff/releases/download/v0.2.0/sops-diff-v0.2.0-darwin-amd64.tar.gz | tar xz
sudo mv sops-diff-darwin-amd64 /usr/local/bin/sops-diff
# macOS (Apple Silicon)
curl -L https://github.com/saltydogtechnology/sops-diff/releases/download/v0.2.0/sops-diff-v0.2.0-darwin-arm64.tar.gz | tar xz
sudo mv sops-diff-darwin-arm64 /usr/local/bin/sops-diff
# Compare two encrypted files
sops-diff secret1.enc.yaml secret2.enc.yaml
# Show only keys that have changed (without values)
sops-diff --summary secret1.enc.yaml secret2.enc.yaml
# Compare different formats
sops-diff --format=json config1.enc.json config2.enc.json
# Save output to file
sops-diff secret1.enc.yaml secret2.enc.yaml --output diff.txt# Compare between different Git revisions
sops-diff --git HEAD:secrets.enc.yaml secrets.enc.yaml
# Compare between branches
sops-diff --git main:secrets.enc.yaml feature/new-secret:secrets.enc.yaml# Display decrypted conflict with syntax highlighting
sops-diff git-conflicts conflicts.enc.yaml
# View conflicts in Git diff format rather than with conflict markers
sops-diff git-conflicts conflicts.enc.yaml --view-as-diff
# Save to a file for editing
sops-diff git-conflicts conflicts.enc.yaml --output resolved.yaml# Use your preferred diff tool
sops-diff --diff-tool=vimdiff secret1.enc.yaml secret2.enc.yaml
# Use with a graphical diff tool
sops-diff --diff-tool=meld secret1.enc.yaml secret2.enc.yaml- YAML (
.yaml,.yml) - JSON (
.json) - Environment files (
.env)
# Set up Git integration
sops-diff setup-git-merge-toolAdd the following to your repository's .gitattributes file:
*.enc.json diff=sopsdiffer merge=sops
*.enc.yaml diff=sopsdiffer merge=sops
*.enc.yml diff=sopsdiffer merge=sops
*.enc.env diff=sopsdiffer merge=sops
# Option: Full diff (shows all values)
git config diff.sopsdiffer.command "sops-diff --git"# Alternative: Summary mode (only keys changed without values)
git config diff.sopsdiffer.command "sops-diff --git --summary"After this setup, git diff will automatically use SOPS-Diff for files matching the patterns, and merge conflicts will be handled with the git mergetool --tool=sops command.
- SOPS-Diff does not write decrypted content to disk by default
- In CI/CD environments, use
--summarymode to avoid exposing sensitive values - The tool works with your existing SOPS encryption/decryption configuration (AWS KMS, GCP KMS, age, PGP)
- Ensure proper access controls for CI/CD environments that need to decrypt files
- SOPS v3.7.x or higher
- For Git integration: Git 2.20.0 or higher
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.