-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
nixos/postgresql: add ensureUsers.*.passwordFile option #326306
Open
Atemu
wants to merge
3
commits into
NixOS:master
Choose a base branch
from
Atemu:nixos/postgresql-user-password
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think that
types.path
for secrets is a huge footgun. As soon as somebody does${foo}
rather thantoString foo
in a subsequent change somewhere, the file will be written into the store without a warning.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Would
apply = toString
remedy this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this a little and it does at least cover trivial cases. #78640 would likely be a more complete solution but this works in the meantime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I don't think it's a good idea to use a syntax construct with the intention of copying sources into the store to specify secrets. At least that's my impression given its behavior.
Does your change solve the core problem I have in mind? I think so, yes.
However, I have the impression that it takes a while until people are aware of the semantics of the path type and until then they easily run into errors like this. It may be implemented correctly here, but there are still enough other wrongly implemented options out there where this is a footgun. And that's understandable given that we work against the semantics of the path-type here IMHO.
The only benefit I see by using the path-type is that we get some kind of validation for free[1] from the Nix parser when using the literal path syntax (the variant of the path-type that I have an issue with to be clear). Personally, I think it's much better to force a string there and then do a
check = x: builtins.substring 0 1 (toString x) == "/"
as it's the case for the string-case intypes.path
.Is there any other benefit you have in mind?
[1] and normalization of relative paths to absolute ones, but I'd argue that this isn't used that much for cases like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate on what you mean by this?
There is no intention to copy the secret to the Nix store here whatsoever; exactly the opposite is the case. The
apply
prevents having the specified path being brought into the Nix store even if you declare it as a path literal which would otherwise be a shot in the foot.There is likely a way you could still break this but it at least covers the trivial case.
I'd love a more generic solution but it simply doesn't exist yet and there doesn't appear to have been any progress on that in the past few years.
Nope, merely that the value passed should look like a path.
types.path
is little more than that check anyways and having it be atypes.str
would cause a type error if a path was passed which would be an even better behaviour.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason there is no
types.secret
that's just an alias totypes.str
with that substring check (and maybe some way to force allow a store path for tests)? It'd be clearer for users and also avoid this problem.A bit besides the point though, is there an issue this could be spun out into instead of blocking the PR on it? Not that this isn't valuable discussion, but given it's a widespread problem 1) it should be solved generally and 2) the audience here is far smaller than it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path literal - that's allowed by types.path - is something being used to copy stuff into the store. At least that's what its semantics are for.
This syntax is allowed by types.path and I think it's wrong to accept this in any case.
OK, we're aligned on this I think (given the last change you pushed).
Fair.
Would you be motivated to do so? I may be able to get to it in the upcoming days otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give it a shot! Should be the kind of change to start with a PR.