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

Only read referenced secret on template rendering #497

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

DDoSolitary
Copy link
Contributor

While we can't use non-utf8 data in template, it's not a good idea to use config.sops.secrets.<name>.format to determine if a secret is actually utf8 text, as yaml secrets can have embedded binary data (#496) and "binary" secrets can actually contain utf8 text (#439).

With this patch, we only read secret file when the corresponding placeholder actually occurs in template content. This way, we no longer need to try to exclude binary files from the replacement list, but rely on users to only reference text secret in templates.

Adds an extra check to determine if the placeholder ocurrs in template
content before actually reading the corresponding secret file.
In terms of performance, this adds an extra string search, but removes
possibly unneceassary file reading if the secret is not used in the
template, though both of them should be negligible in most cases.
Fixes Mic92#496.
This reverts commit 7711514.

With db82bca, we no longer need to
ensure that the pair list only contains utf-8 text, as long as users
don't reference non-utf-8 data in template content.
Fixes Mic92#439.
@DDoSolitary DDoSolitary changed the title Patch/template lazy read Only read referenced secret on template rendering Feb 19, 2024
@Mic92
Copy link
Owner

Mic92 commented Feb 20, 2024

@mergify queue

@Mic92
Copy link
Owner

Mic92 commented Feb 20, 2024

Thanks!

Copy link
Contributor

mergify bot commented Feb 20, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at f88661c

@mergify mergify bot merged commit f88661c into Mic92:master Feb 20, 2024
59 checks passed
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

Successfully merging this pull request may close these issues.

2 participants