Git diff does not work with path_regex
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
Description
When using git diff with path_regex it fails to match any paths. This appears to be because git diff will create a temp file (for textconv?). Sops will then try to decrypt that file using the .sops.yaml configuration. The temp file does not match the path_regex so it fails.
I've hacked the sops source to get some debugging to see what's going on and this shows the events
[CMD] time="2020-04-27T13:21:53+01:00" level=info msg="CLI args are: [/var/folders/2k/6q86kgm12sq9rxxvqp7d0c5c0000gn/T//PeMph9_etcd-browser-aws.yaml]"
[CMD] time="2020-04-27T13:21:53+01:00" level=info msg="Loading file /var/folders/2k/6q86kgm12sq9rxxvqp7d0c5c0000gn/T/PeMph9_etcd-browser-aws.yaml"
[CMD] time="2020-04-27T13:21:53+01:00" level=info msg="Loading config .sops.yaml"
[CONFIG] time="2020-04-27T13:21:53+01:00" level=info msg="Loaded config file"
[CONFIG] time="2020-04-27T13:21:53+01:00" level=info msg="Parsing rules!!!"
[CONFIG] time="2020-04-27T13:21:53+01:00" level=info msg="Parsing rule - secrets/dev/.*"
[CONFIG] time="2020-04-27T13:21:53+01:00" level=info msg="Does secrets/dev/.* match /var/folders/2k/6q86kgm12sq9rxxvqp7d0c5c0000gn/T/PeMph9_etcd-browser-aws.yaml"
[CONFIG] time="2020-04-27T13:21:53+01:00" level=info msg="Parsing rule - secrets/test/.*"
[CONFIG] time="2020-04-27T13:21:53+01:00" level=info msg="Does secrets/test/.* match /var/folders/2k/6q86kgm12sq9rxxvqp7d0c5c0000gn/T/PeMph9_etcd-browser-aws.yaml"
[CONFIG] time="2020-04-27T13:21:53+01:00" level=info msg="Parsing rule - secrets/prod/.*"
[CONFIG] time="2020-04-27T13:21:53+01:00" level=info msg="Does secrets/prod/.* match /var/folders/2k/6q86kgm12sq9rxxvqp7d0c5c0000gn/T/PeMph9_etcd-browser-aws.yaml"
[CMD] time="2020-04-27T13:21:53+01:00" level=info msg="parsed config"
[CMD] time="2020-04-27T13:21:53+01:00" level=info msg="Got error parsing config"
error loading config: no matching creation rules found
fatal: unable to read files to diff
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing git diff with a path_regex rule and trace how the temporary file is passed to Sops and matched against .sops.yaml. The fix is complete when paths selected by path_regex can be diffed successfully despite Git's temporary file, with the configuration error no longer occurring.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, go
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100