-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add environment selector to move secrets modal #5064
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?
Add environment selector to move secrets modal #5064
Conversation
This change enables users to move secrets across different environments from the overview page, in addition to moving them between folders. Changes: - Added environment dropdown selector to move secrets modal - Updated destination environment logic to support cross-environment moves - Modified folder search to only query the selected destination environment - Enhanced validation to enable move button when either path or environment changes Closes Infisical#2937
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Greptile SummaryThis PR adds an environment selector dropdown to the move secrets modal on the overview page, enabling cross-environment secret moves. The implementation successfully adds the UI component and connects it to the existing move API. Key Changes:
Critical Issues Found:
Confidence Score: 2/5
Important Files Changed
|
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.
Additional Comments (4)
-
frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx, line 118-121 (link)logic: logic bug: condition always evaluates to true when changing environments
environments.some((env) => env.slug !== destinationEnvironmentSlug)will always be true in multi-environment projects (all envs except the selected one will fail the check)actually, track whether the selected environment differs from the original first environment:
-
frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx, line 98-116 (link)logic: logic bug: permission check uses source environment but should check destination environment permissions
The
moveSecretsEligibilitychecks DELETE permissions on the source environment (line 107), which is correct for removing secrets. However, for cross-environment moves, the code doesn't verify CREATE permissions on thedestinationEnvironmentSlug.When moving to a different environment, users need permission to create secrets in the destination. This security gap allows users to move secrets to environments where they lack write access. Should destination environment permissions be validated separately, or does the backend API handle this check?
-
frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx, line 96 (link)logic: logic bug:
folderEnvironmentscalculated beforedestinationEnvironmentSlugis used in queryThe
folderEnvironmentsdepends on thefoldersdata fromuseGetProjectSecretsQuickSearch(line 86-92), which now queries only thedestinationEnvironmentSlug. However,folderEnvironmentsis used to check if paths exist in the SOURCE environments (line 112), not the destination.This causes incorrect "Secret path does not exist" warnings for source environments when the path exists in source but not in destination.
-
frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx, line 74-76 (link)style: initial state could be undefined
If
environmentsarray is empty,destinationEnvironmentSlugwill be an empty string. Consider handling this edge case or validating that environments exist before rendering the modal.
1 file reviewed, 4 comments
Description
This PR adds the ability to move secrets across different environments from the overview page's move secrets modal, completing the feature request in #2937.
Previously, the move secrets modal on the overview page only allowed moving secrets between folders within the same environment. This enhancement adds an environment selector dropdown, enabling users to move secrets to different environments as well.
Changes Made
How It Works
Technical Implementation
destinationEnvironmentSlugstate to track selected environmentuseGetProjectSecretsQuickSearchto fetch folders only for the selected destination environmentdestinationSelectedvalidation to consider environment changesmoveSecrets.mutateAsynccall to use the selected destination environmentTesting
Manual testing performed:
Closes #2937
PR Type
Checklist