-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: support '/' in secret keys and updated docker to install bash #5604
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,20 @@ import { | |||||||||||||||||||||||||||||||||||
| TUpdateSecretsV3DTO | ||||||||||||||||||||||||||||||||||||
| } from "./types"; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const splitKeyAndPath = (secretKey: string, secretPath: string = "/") => { | ||||||||||||||||||||||||||||||||||||
| if (!secretKey.includes("/")) { | ||||||||||||||||||||||||||||||||||||
| return { actualSecretKey: secretKey, actualSecretPath: secretPath }; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| const parts = secretKey.split("/"); | ||||||||||||||||||||||||||||||||||||
| const actualSecretKey = parts.pop() as string; | ||||||||||||||||||||||||||||||||||||
| const folderPart = parts.join("/"); | ||||||||||||||||||||||||||||||||||||
| const actualSecretPath = | ||||||||||||||||||||||||||||||||||||
| secretPath === "/" | ||||||||||||||||||||||||||||||||||||
| ? `/${folderPart}` | ||||||||||||||||||||||||||||||||||||
| : `${secretPath}/${folderPart}`; | ||||||||||||||||||||||||||||||||||||
| return { actualSecretKey, actualSecretPath }; | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double slash when key starts with leading forward slash If the input key begins with For example, with key =
When path = These malformed paths will likely cause 404 errors or routing issues. Consider normalizing slashes:
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| export const useCreateSecretV3 = ({ | ||||||||||||||||||||||||||||||||||||
| options | ||||||||||||||||||||||||||||||||||||
| }: { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -40,6 +54,9 @@ export const useCreateSecretV3 = ({ | |||||||||||||||||||||||||||||||||||
| skipMultilineEncoding, | ||||||||||||||||||||||||||||||||||||
| tagIds | ||||||||||||||||||||||||||||||||||||
| }) => { | ||||||||||||||||||||||||||||||||||||
| const { actualSecretKey, actualSecretPath } = splitKeyAndPath(secretKey, secretPath); | ||||||||||||||||||||||||||||||||||||
| secretKey = actualSecretKey; | ||||||||||||||||||||||||||||||||||||
| secretPath = actualSecretPath; | ||||||||||||||||||||||||||||||||||||
| const { data } = await apiRequest.post(`/api/v4/secrets/${secretKey}`, { | ||||||||||||||||||||||||||||||||||||
| secretPath, | ||||||||||||||||||||||||||||||||||||
| type, | ||||||||||||||||||||||||||||||||||||
|
|
@@ -106,6 +123,9 @@ export const useUpdateSecretV3 = ({ | |||||||||||||||||||||||||||||||||||
| skipMultilineEncoding, | ||||||||||||||||||||||||||||||||||||
| secretMetadata | ||||||||||||||||||||||||||||||||||||
| }) => { | ||||||||||||||||||||||||||||||||||||
| const { actualSecretKey, actualSecretPath } = splitKeyAndPath(secretKey, secretPath); | ||||||||||||||||||||||||||||||||||||
| secretKey = actualSecretKey; | ||||||||||||||||||||||||||||||||||||
| secretPath = actualSecretPath; | ||||||||||||||||||||||||||||||||||||
| const { data } = await apiRequest.patch(`/api/v4/secrets/${secretKey}`, { | ||||||||||||||||||||||||||||||||||||
| projectId, | ||||||||||||||||||||||||||||||||||||
| environment, | ||||||||||||||||||||||||||||||||||||
|
|
@@ -163,6 +183,9 @@ export const useDeleteSecretV3 = ({ | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| return useMutation<object, object, TDeleteSecretsV3DTO>({ | ||||||||||||||||||||||||||||||||||||
| mutationFn: async ({ secretPath = "/", type, environment, projectId, secretKey, secretId }) => { | ||||||||||||||||||||||||||||||||||||
| const { actualSecretKey, actualSecretPath } = splitKeyAndPath(secretKey, secretPath); | ||||||||||||||||||||||||||||||||||||
| secretKey = actualSecretKey; | ||||||||||||||||||||||||||||||||||||
| secretPath = actualSecretPath; | ||||||||||||||||||||||||||||||||||||
| const { data } = await apiRequest.delete(`/api/v4/secrets/${secretKey}`, { | ||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||
| projectId, | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
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.
Empty secret key when input ends with
/If a user enters a key with a trailing slash (e.g.,
"test/"or"/"),parts.pop()will return an empty string, makingactualSecretKey = "". The resulting request URL becomes/api/v4/secrets/(empty key segment), which hits an unintended endpoint or returns a confusing error.Consider adding validation to guard against this case — either fall back to the original value so the server can return a proper validation error, or surface a clear client-side message before making the request.