getsops / getsops/sops

Git diff doesn't work if .sops.yaml exists in root with directory path matchers

Open
#959 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
23.1k
Forks
1.1k
Avg merge
1d 11h
Merged PRs (30d)
9

Description

What is the problem

I've created a .sops.yaml file in the root of my git repo and added creation rules for two directories:

creation_rules:
  - path_regex: sops/dev/.*
    kms: 'arn:aws:kms:eu-west-1:1231231230:key/mrk-k1'
  - path_regex: sops/production/.*
    kms: 'arn:aws:kms:eu-west-1:1231231230:key/mrk-k2'

I've set up everything for git diff to work following the documentation.

When I run e.g. git diff sops/production/secrets.yaml, I get:

error loading config: no matching creation rules found
fatal: unable to read files to diff

This happens as sopsdiffer will be called with the following two paths:

  • /var/folders/1p/kj4p1zcn7qg32x53jfztnfb00000gq/T//MPTcrc_secrets.yaml
  • sops/production/secrets.yaml

And there is no matching rule for the first one.

Possible workaround

I can pass an empty config file to sops in sopsdiffer and git diff will work.

[diff "sopsdiffer"]
	textconv = sops --config empty-file.yaml -d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the sopsdiffer invocation and how its temporary and repository paths are passed to SOPS; the issue identifies the root .sops.yaml creation rules and the git diff configuration as the relevant entry points. Verify the fix with directory path matchers so git diff no longer reports that no matching creation rules were found.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, git, go
Domain
devops, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.