-
Notifications
You must be signed in to change notification settings - Fork 3
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
Update secrets env
to omit single trailing \n
from files which automatically include it
#296
Comments
We need to modify the command to allow for just specifiying the vaultname if we want to specify the root path. So currently you can do |
The |
|
@tegefaulkes says in the short term use Well I think it's actually a big problem for UX. The point is that we are crossing contexts between "file editing" which has a convention of having The problem is that if the "file" is supposed to represent an implementation of key-value structure, then the invisible and implicit How should we solve this problem? |
Suppose you rely on a schema MatrixAI/Polykey#222. This would mean a schema adds a trim constraint, that basically is applied on ingress. You trim any whitespace before it saves the file. Alternatively on context-aware usage, we might then do a trim on the egress when using the One might add an option specifically not to apply automatic trim for the |
I think we need a do a few things here:
|
Relying on short term write is not a good idea cause interactively you have to do So I think we need to do the above 4 things to make this work well. Right now my vim even refuses to save the file without a newline. |
I suggest things like Or something to help not add trim the trailing newline. Also I want to emphasize this should be automatic trim of 1 SINGLE trailing newline. If should not remove all whitespace characters only the final Leading whitespace and trailing whitespace might still be significant. Also I would argue that if we detect non-text values, we might want to not do that trim of the trailing newline. It would have to be a sort of smart heuristic. |
This isn't really a proper development issue template, @tegefaulkes @aryanjassal please incorporate the ideas from #296 (comment) into the OP spec. |
This issue is meant to be a discussion and doesn't follow the template or provide a specification. I will make a separate issue with the specs as discussed here. Once the discussion is finished and we have a good idea where to take |
secrets env
command designsecrets env
to omit single trailing \n
from files which automatically include it
As requested, I have updated this issue itself instead of making a new issue and treating this one as a discussion issue. |
While working on zeta house, I hit the problem of thinking about how the vault schema works. After going through several iterations... I think we would want to create a new standard in the community called Then: {
"type": "object",
"properties": {
"ZETA_HOUSE_ENV": {
"type": "string",
"enum": ["development", "production"],
"default": "development"
},
"ZETA_HOUSE_GOOGLE_MAPS_API_KEY": {
"type": "string"
}
},
"required": [
"ZETA_HOUSE_GOOGLE_MAPS_API_KEY"
]
} This is an example of a JSON schema that matches what a So what do you do with this? This becomes standardised "type" specification as well as documentation about the "free variables" within an application. By doing this they become explicit. Well they are only explicit if the programming tools perform automatic checks during development/compilation/production. No automatic checks would mean they are no different from just README.md. However in this case, that would mean we can then integrate this... I'm going to call this a "environment schema" (a subschema of "egress schema") into the You can then do:
Now what does this do? Well this would be an error because right now there's no vaults. It's an egress schema that Polykey can interpret and apply a check to the final output. This allows one to compose a variety of vault paths together to produce the required egress environment.
Note that this is a egress schema, NOT a vault schema. It's applied to the entire thing. It's also an open-world schema, meaning any key values produced that is not part of the schema is allowed. We can also make use of the We have a json schema validator built into Polykey core library already, so it wouldn't be too difficult to make use of this. This reveals another thing to understand. The vault and secret paths here are name/aliases. The vault path itself or just vaultX or vaultX:/dirpath is actually a reference that can be swapped based on context. These are not "content addressed paths" like they are in other scenarios like Nix and stuff. Because they are not a globally unique thing. They are more like an alias, and the value that they point to changes depending on who's asking. Who's asking is the identity by which authority is delegated to. Thus they cannot be "hard paths" like content addresses, but they are aliases to be fulfilled by a dynamic fine-grained access control context. In practice this means, the CI's |
Specification
Currently, most Unix files, and by extension, all files inside Polykey's vault will have a trailing
\n
. This is the standard way to end a file in Unix (see this question). This poses an issue, as all secrets will also have this newline when it might not be intentional, breaking applications (see additional context below).A long-term solution would require a vault schema to dictate the formatting of the secrets (see Polykey#222). However, that is still some time away, and this issue needs to be solved before that can be merged. To do this, we can implement a flag which would explicitly tell the command to preserve the single trailing
\n
at the end of the file, otherwise the default behaviour would be to exclude it.Keep in mind that only a single, trailing newline must be removed. Trailing white space must be preserved, and any trailing white space but the last one should also be preserved, unless the user explicitly specifies that the newline can be kept.
While we technically can use
polykey secrets write
to write without entering the newline, it is not ideal, as a vault is a file system, and in most cases, users will paste their secrets using an editor, which would add the newline at the end. This is why we need this to work right now.Additional context
vim
adding newlines by default at the end of files in this Stackoverflow question.Tasks
The text was updated successfully, but these errors were encountered: