Decryption fails if line ending is not set to LF on Windows systems
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
Version: sops 3.7.1
To replicate the problem, use a Windows system or VM with Windows
Instructions:
- Create a new folder - sopstest
- git init
- create file .sops.yaml. (edit to put in your AWS account # and KMS guid id)
creation_rules:
- path-regex: .*
kms: 'arn:aws:kms:us-east-2:[AWSACCOUNT]:key/[KEY-GUID]'
- Create a keyvalue file test.txt with content
A=B
C=D
- Encrypt the file using sops
AWS_PROFILE=default sops -e test.txt > text.txt.enc
- Verify text.txt.enc has LF line endings
- Verify that your c:\users\[USER]\.gitconfig has
[core]
autocrlf = true # recommended for Windows systems
- git add . --all
- git commit -m "First commit"
Now, clone the repo by doing this:
- cd .. (move to the parent folder of sopstest)
- git clone ./sopstest sopstest2
- Load test.txt.enc in sopstest2 folder in an editor. The line endings will be CRLF
- decrypt the file using sops by
AWS_PROFILE=default sops -d test.txt.enc > test.txt
(an error message is shown that it can't parse the date, and the file is not decrypted.)
Verify that line endings in test.txt.enc are CRLF.
Workaround:
Create a .gitattributes file at the root of your repo, and add this line
*.enc -cr
This will prevent the auto cr → crlf conversion for files with extension .enc
It would be good for sops to handle CRLF terminated encrypted files correctly -- and that's why I am submitting this issue.
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 the Windows checkout and CRLF decryption failure described in the issue, using the sample .sops.yaml and test.txt.enc workflow. Trace the decryption path that reports the date-parsing error; done means sops decrypts CRLF-terminated encrypted files without requiring the .gitattributes workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, git, go
- Domain
- cli, devops, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100