SOPS-Cop is a CLI tool to enforce SOPS encryption rules without requiring the SOPS binary or encryption keys; designed for commit hooks and CI jobs.
- Discovers your existing SOPS configuration and verifies encryption rules are followed.
- Supports YAML, JSON, ENV, and INI files when matched by
.sops.yamlcreation rules. - Reports each unencrypted key path to
stderrwith file path and location details (line:column for YAML; path-only fallback for other formats).
0: all checked values are encrypted2: invalid arguments (for example, unresolvable target path)3: file read error (for example, file missing or permission denied)4: invalid input for the matched file format (YAML/JSON/ENV/INI)5: one or more unencrypted values were found6:.sops.yamlconfig error (for example, invalid regex)
- Go 1.26+
If you install from release binaries, Go is not required.
go install github.com/binbashing/sops-cop@latestDownload the correct binary from the GitHub Releases page for your OS/arch and place sops-cop on your PATH.
go build -o sops-cop ../sops-copOr start from any path inside the project:
./sops-cop -target path/to/any/subdirPrint version:
./sops-cop -versionHelp:
./sops-cop -hEncrypted YAML (ok.yaml):
apiVersion: ENC[AES256_GCM,data:abc]
kind: ENC[AES256_GCM,data:def]
spec:
db:
password: ENC[AES256_GCM,data:ghi]
sops:
version: 3.9.0Run from anywhere in that repo:
./sops-cop -target ./secrets
# exit code: 0Unencrypted YAML (bad.yaml):
spec:
db:
password: plaintextRun:
./sops-cop -target .
# stderr:
# /path/to/repo/secrets/bad.yaml:3:15: unencrypted value found at 'spec.db.password'
# exit code: 5go test ./...
go vet ./...GitHub Actions runs tests on push and pull request via:
.github/workflows/ci.yml
Dependabot is configured via .github/dependabot.yml to open weekly PRs for:
- Go modules (
gomod) - Docker base images (
Dockerfile) - GitHub Actions workflow dependencies
main.go: CLI entrypoint and YAML validation logicconfig.go:.sops.yamlloading and rule matchingmain_test.go: table-driven unit tests.sops.yaml: example SOPS config for the included fixturesecrets.example.yaml: example encrypted Kubernetes Secretgo.mod/go.sum: module and dependency locks
- Uses the SOPS library (
github.com/getsops/sops/v3) for config parsing, rule matching, and encryption path selection — ensuring exact behavioral parity with SOPS. - Uses
gopkg.in/yaml.v3node traversal for line:column error reporting. - Keeps implementation in a single executable package for simplicity and portability.
- Follows fail-fast CLI behavior with deterministic exit codes for CI/pipeline integration.