Binary files are not encrypted when encrypted_suffix is specified
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
Hello,
I'm using 3.7.1 on Ubuntu 20.04.3 LTS. I noticed that binary files are not encrypted by sops, when encrypted_suffix is provided in .sops.yaml. See below files for an example.
# secret.txt
this is a secret value
# .sops.yaml
---
creation_rules:
- path_regex: 'secret\.txt'
encrypted_suffix: _encrypted
key_groups:
- pgp:
- ... # valid fingerprint
Next enter the following command: sops -e secret.txt > secret.txt.sopsenc.json. As a result of this command I get the following file:
{
"data": "this is a secret value",
"sops": {
"...": null,
"mac": "ENC[...]",
"pgp": [
{
"created_at": "2022-01-10T14:25:14Z",
"enc": "...",
"fp": "..."
}
],
"encrypted_suffix": "_encrypted",
"version": "3.7.1"
}
}
But I expect such a file:
{
"data_encrypted": "ENC[...]",
"sops": {
"...": null,
"mac": "ENC[...]",
"pgp": [
{
"created_at": "2022-01-10T14:25:14Z",
"enc": "...",
"fp": "..."
}
],
"encrypted_suffix": "_encrypted",
"version": "3.7.1"
}
}
I see two solutions for this case:
- automatic append value of
encrypted_suffixkey todatakey name, but in this caseencrypted_regexstill will not work, - add new configuration key, like
data_key_name, that will have valuedata_encryptedin my case, so will work regardless ofencrypted_*setting.
Thank you in advance for considering my request
Regards
Piotr Minkina
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
Reproduce the report with the shown .sops.yaml and sops -e secret.txt command, comparing the produced JSON with the expected data_encrypted output. Trace how encrypted_suffix is handled for the binary/JSON output path, then add coverage for the reported case and verify that the resulting data key is encrypted without regressing other encrypted_* settings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100