DOTENV multi-line vars with double quotes are converted
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
In some cases when using DOTENV where a private key is required as an environment variable the only way to make it work is to provide the var in a very specific format (this is commonly found when working with firebase in node/react):
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nzzzzzzzz\n-----END PRIVATE KEY-----\n"
If you encrypt a file containing a value like the above SOPS converts it to:
FIREBASE_PRIVATE_KEY='
-----BEGIN PRIVATE KEY-----
zzzzzzzz
-----END PRIVATE KEY-----
'
This breaks the format and services using that var will refuse to start because of invalid PEM format.
If the var is entered the same but with single quotes:
FIREBASE_PRIVATE_KEY='-----BEGIN PRIVATE KEY-----\nzzzzzzzz\n-----END PRIVATE KEY-----\n'
SOPS does not convert it to a multi-line variable but it also retains the single quotes, and the var won't work unless it is double quoted.
The values are retained exactly if binary format is used instead of DOTENV, however when doing so the plain text keys are lost so it is no longer possible to view the keys when viewing the encrypted file (lose all the benefits).
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 issue with the DOTENV examples in the report, including double-quoted escaped newlines and single-quoted values. Trace the DOTENV serialization path and compare its output with the expected escaped form; done means private-key values retain valid PEM formatting and existing DOTENV behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100