Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"error loading config: no matching creation rules found" when using .gitattributes and .sops.yaml #1201

Open
steled opened this issue Apr 20, 2023 · 1 comment

Comments

@steled
Copy link

steled commented Apr 20, 2023

I'm using SOPS with a .gitattributes and .sops.yaml file.

See content of files below:

# .gitattributes

secret.json filter=sops-json
secret.yaml filter=sops-yaml diff=sops-yaml
secret.yml filter=sops-yaml diff=sops-yaml
# .sops.yaml

creation_rules:
  - age: >-
      age1<REDACTED>,
      age1<REDACTED>
    encrypted_regex: ^(password|metadata|privateKey)$
    path_regex: '(secret.json|test.yaml)'

And the config part from .git/config file:

[filter "sops-json"]
        clean = sops --input-type json --output-type json -e /dev/stdin
        smudge = SOPS_AGE_KEY_FILE=$(pwd)/secrets/age-key.txt sops --input-type json --output-type json -d /dev/stdin
        required = true

I can run the commands for encrypt/decrypt as expected:

sops -e -i secret.json
SOPS_AGE_KEY_FILE=$(pwd)/secrets/age-key.txt sops -d -i secret.json

But when I'm using git to try to commit the files I always get the following error message:

> git status -z -uall
error loading config: no matching creation rules found
error: external filter 'sops --input-type json --output-type json -e /dev/stdin' failed 1
error: external filter 'sops --input-type json --output-type json -e /dev/stdin' failed
fatal: secret.json: clean filter 'sops-json' failed

Maybe someone has an idea what's happening here.

EDIT: When I remove path_regex: '(secret.json|test.yaml)' from the .sops.yaml file it also works with git.

@dimaj
Copy link

dimaj commented Jul 26, 2023

It's an old question, but I just solved it by changing /dev/stdin in the filter.<name>.clean and filter.<name>.smudge to use %f

[filter "sops-json"]
        clean = sops --input-type json --output-type json -e %f
        smudge = SOPS_AGE_KEY_FILE=$(pwd)/secrets/age-key.txt sops --input-type json --output-type json -d %f
        required = true

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

No branches or pull requests

2 participants