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

Feature: Disable Secret Deletion Sync Option #3246

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

scott-ray-wilson
Copy link
Contributor

@scott-ray-wilson scott-ray-wilson commented Mar 14, 2025

Description 📣

This PR adds the ability to disable secret deletion for secret syncs on sync. This option prevents manually managed secrets outside of Infisical from being removed. Doc additions and fixes included.

CleanShot 2025-03-14 at 15 25 29@2x

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

Summary by CodeRabbit

  • New Features

    • Introduced a "Disable Secret Deletion" option across secret synchronization integrations. When enabled, this setting preserves secrets at the sync destination, giving you more control over manual secret management.
  • Documentation

    • Updated configuration guides and integration instructions to highlight the new option and explain its impact on secret management.

Copy link

coderabbitai bot commented Mar 14, 2025

Walkthrough

The changes introduce a new configuration property, disableSecretDeletion, which is now available within the secret synchronization options. This property is added to centralized schema definitions, API documentation, and source code across several back-end and front-end components. In the back-end, conditional checks are implemented for AWS Parameter Store, AWS Secrets Manager, Azure App Configuration, Azure Key Vault, Databricks, GCP, GitHub, and Humanitec integrations to bypass secret deletion logic when the flag is enabled. Front-end changes include updates to forms, review components, and type definitions, ensuring that the new option is represented in the user interface and handled correctly within validations and feedback components. Documentation for all affected integrations has been updated to include the new option and explain its usage.

Possibly related PRs

Suggested reviewers

  • akhilmhdh
  • sheensantoscapadngan

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/backend".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "backend/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

backend/src/services/secret-sync/aws-secrets-manager/aws-secrets-manager-sync-fns.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/backend".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "backend/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

backend/src/services/secret-sync/azure-app-configuration/azure-app-configuration-sync-fns.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/backend".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "backend/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 7 others

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
frontend/src/hooks/api/secretSyncs/types/root-sync.ts (1)

6-6: LGTM - Type declaration looks good

The disableSecretDeletion property is properly defined as an optional boolean, maintaining backward compatibility with existing code.

Consider adding JSDoc comments to provide more context about this property:

+ /**
+  * When enabled, prevents Infisical from removing secrets from the sync destination
+  * that do not exist in Infisical. Useful when managing some secrets manually outside of Infisical.
+  */
  disableSecretDeletion?: boolean;
backend/src/services/secret-sync/humanitec/humanitec-sync-fns.ts (1)

199-200:

❓ Verification inconclusive

LGTM - Implementation looks correct

The early return prevents secret deletion when the disableSecretDeletion option is enabled, which aligns with the feature's purpose.

Consider adding a comment to clarify the purpose of this check for future maintainers:

+ // Skip deletion of secrets not present in Infisical when disableSecretDeletion is enabled
  if (secretSync.syncOptions.disableSecretDeletion) return;

Also, verify that the feature is properly tested to ensure it works as expected in various scenarios.


🏁 Script executed:

#!/bin/bash
# Check if there are tests covering the new disableSecretDeletion functionality
rg -A 3 -B 3 "disableSecretDeletion.*true" --type ts

Length of output: 54


Action: Add clarifying comment and verify test coverage manually

The early return implementation is correct. To improve maintainability, please add a comment above the return to clarify that secret deletion is skipped when disableSecretDeletion is enabled. For example:

+ // Skip deletion of secrets not present in Infisical when disableSecretDeletion is enabled
  if (secretSync.syncOptions.disableSecretDeletion) return;

Additionally, our automated search did not reveal any tests covering this functionality. Can you please verify manually that tests exist to validate that secrets are not deleted when disableSecretDeletion is active?

backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts (1)

385-385: Effective implementation of deletion prevention.

The early return approach efficiently prevents secret deletion when the option is enabled. This implementation correctly bypasses the entire deletion process, including the collecting of parameters to delete and the subsequent batch deletion operation.

However, note that this implementation differs slightly from the GCP implementation (return vs. continue). While both achieve the same goal, ensuring consistency in implementation patterns across similar functions can aid maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d6da1e and cc7d0d7.

📒 Files selected for processing (23)
  • backend/src/lib/api-docs/constants.ts (1 hunks)
  • backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts (1 hunks)
  • backend/src/services/secret-sync/aws-secrets-manager/aws-secrets-manager-sync-fns.ts (1 hunks)
  • backend/src/services/secret-sync/azure-app-configuration/azure-app-configuration-sync-fns.ts (1 hunks)
  • backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts (1 hunks)
  • backend/src/services/secret-sync/databricks/databricks-sync-fns.ts (1 hunks)
  • backend/src/services/secret-sync/gcp/gcp-sync-fns.ts (1 hunks)
  • backend/src/services/secret-sync/github/github-sync-fns.ts (1 hunks)
  • backend/src/services/secret-sync/humanitec/humanitec-sync-fns.ts (1 hunks)
  • backend/src/services/secret-sync/secret-sync-schemas.ts (1 hunks)
  • docs/integrations/secret-syncs/aws-parameter-store.mdx (1 hunks)
  • docs/integrations/secret-syncs/aws-secrets-manager.mdx (1 hunks)
  • docs/integrations/secret-syncs/azure-app-configuration.mdx (2 hunks)
  • docs/integrations/secret-syncs/azure-key-vault.mdx (2 hunks)
  • docs/integrations/secret-syncs/databricks.mdx (1 hunks)
  • docs/integrations/secret-syncs/gcp-secret-manager.mdx (1 hunks)
  • docs/integrations/secret-syncs/github.mdx (1 hunks)
  • docs/integrations/secret-syncs/humanitec.mdx (1 hunks)
  • frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsx (2 hunks)
  • frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx (2 hunks)
  • frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts (1 hunks)
  • frontend/src/hooks/api/secretSyncs/types/root-sync.ts (1 hunks)
  • frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SecretSyncOptionsSection.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Check Frontend Type and Lint check
  • GitHub Check: Check TS and Lint
  • GitHub Check: Run integration test
🔇 Additional comments (30)
docs/integrations/secret-syncs/gcp-secret-manager.mdx (1)

46-46: LGTM - Good addition to sync options

The new "Disable Secret Deletion" option is clearly documented with a good explanation of its purpose and when to use it.

docs/integrations/secret-syncs/humanitec.mdx (1)

59-59: LGTM - Documentation is consistent

The "Disable Secret Deletion" option is consistently documented across integrations with clear explanations.

backend/src/services/secret-sync/databricks/databricks-sync-fns.ts (1)

115-116: Good implementation of the disable-deletion feature.

The added conditional check will prevent secret deletion when the disableSecretDeletion option is set, allowing users to maintain manually managed secrets outside of Infisical while still syncing secrets from Infisical.

docs/integrations/secret-syncs/github.mdx (1)

66-67: Documentation is clear and accurately describes the new feature.

The added description for the "Disable Secret Deletion" option clearly explains its purpose and when users should enable it. This is helpful for users who need to maintain some secrets manually outside of Infisical.

backend/src/services/secret-sync/aws-secrets-manager/aws-secrets-manager-sync-fns.ts (1)

399-400: The disable-deletion feature is correctly implemented.

The added conditional check prevents secrets from being deleted when the disableSecretDeletion flag is set to true. The implementation is consistent with other sync services and properly placed before the deletion loop.

backend/src/lib/api-docs/constants.ts (1)

1729-1730: API documentation correctly includes the new sync option.

The disableSecretDeletion option has been properly documented with a clear description of its purpose. This ensures API users will have accurate information about this feature.

backend/src/services/secret-sync/azure-app-configuration/azure-app-configuration-sync-fns.ts (1)

139-140: Correctly implemented skip condition for secret deletion

The addition of this conditional check properly implements the feature to disable secret deletion during synchronization. When disableSecretDeletion is enabled in sync options, the function will return early, preventing execution of the code that would delete secrets from Azure App Configuration.

backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts (1)

192-193: Correctly implemented skip condition for secret deletion

This conditional check properly implements the feature to disable secret deletion during synchronization with Azure Key Vault. The early return prevents execution of the deletion logic when the disableSecretDeletion option is enabled. The implementation is consistent with other integration services.

frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/SecretSyncReviewFields.tsx (2)

39-39: Correctly added new option to watched properties

The disableSecretDeletion property is properly added to the destructured properties from the form context, making it available for use in the component.


115-119: Well implemented UI feedback for the new option

The conditional rendering of the "Disable Secret Deletion" label with a success badge provides clear visual feedback to users when they've enabled this feature. The implementation follows the established pattern used for other options in this component.

frontend/src/components/secret-syncs/forms/schemas/base-secret-sync-schema.ts (1)

10-11: Properly defined schema for the new option

The disableSecretDeletion property is correctly defined in the schema as an optional boolean that defaults to false. This ensures the feature is opt-in, which is appropriate for functionality that modifies default behavior.

docs/integrations/secret-syncs/aws-secrets-manager.mdx (2)

49-49: Helpful tag precedence clarification.

This note adds valuable clarification about how tag conflicts are resolved, making it clear to users that manually configured tags take precedence over automatically generated tags from metadata.


51-51: Good addition of the Secret Deletion control feature.

This new option enhances user control by allowing them to maintain manually managed secrets alongside those synchronized by Infisical. This addition directly addresses the PR objective of preventing removal of manually managed secrets outside the platform.

backend/src/services/secret-sync/gcp/gcp-sync-fns.ts (1)

150-152: Well-implemented secret deletion prevention.

The conditional check properly implements the "Disable Secret Deletion" feature for GCP secrets. By using a continue statement, it correctly skips over the deletion logic without interfering with other operations.

docs/integrations/secret-syncs/databricks.mdx (1)

50-50: Consistent documentation of new feature.

The addition of the "Disable Secret Deletion" option maintains consistency with other integration documentation, providing the same capability across different platforms.

backend/src/services/secret-sync/github/github-sync-fns.ts (1)

221-228: Well-implemented feature for optional secret deletion bypassing

The added conditional check for disableSecretDeletion creates a clear guard clause that properly implements the feature described in the PR objectives. When enabled, this prevents Infisical from removing secrets that might be managed manually outside the platform, which is an excellent addition for environments with mixed secret management workflows.

The code structure is clean and follows the existing pattern with a straightforward early return when deletion should be skipped.

docs/integrations/secret-syncs/azure-key-vault.mdx (2)

9-9: Improved connection path reference

The link now properly directs to the specific Azure Key Vault connection documentation rather than the general Azure connection page. The grammar correction from "a Azure" to "an Azure" is also appropriate.


55-55: Clear documentation for the new feature

The added description for the "Disable Secret Deletion" option clearly explains both the functionality and the use case for this feature, matching the implementation in the code.

backend/src/services/secret-sync/secret-sync-schemas.ts (1)

26-27: Schema properly extended to support the new option

The schema definition for disableSecretDeletion is correctly implemented as an optional boolean field with appropriate description reference. This ensures proper validation in API requests and consistent documentation.

docs/integrations/secret-syncs/aws-parameter-store.mdx (2)

46-46: Improved formatting for note element

The note about tag precedence has been reformatted for better consistency with the document structure.


48-48: Consistent documentation of the new feature

The description for the "Disable Secret Deletion" option matches the one in other integration pages, ensuring consistent documentation of this feature across the platform.

frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncOptionsSection/SecretSyncOptionsSection.tsx (4)

7-7: Proper import update for Badge component.

The Badge component has been correctly imported to support displaying the "Enabled" status for the new disableSecretDeletion option.


27-28: New configuration property added correctly.

The disableSecretDeletion property has been properly added to the destructured syncOptions object, aligning with the PR objective of adding a feature to disable the deletion of secrets during synchronization.


62-77: Component structure improvement.

The ProjectPermissionCan component rendering has been refactored to simplify the control flow, making it more consistent by always rendering the edit button based on user permissions rather than conditionally checking for AdditionalSyncOptionsComponent.


87-91: Well-implemented UI for the new feature.

The conditional rendering of the disableSecretDeletion status with a success badge is clean and consistent with the UI design patterns in the application.

docs/integrations/secret-syncs/azure-app-configuration.mdx (2)

9-9: Clarified connection type for better user guidance.

The prerequisite has been updated to specify "Azure App Configuration Connection" instead of the more general "Azure Connection," making it clearer which specific connection type is required for setup.


53-53: Clear documentation for the new feature.

The documentation for the "Disable Secret Deletion" feature clearly explains its purpose and when to use it. The explanation that "Infisical will not remove secrets from the sync destination" and that this is useful "if you intend to manage some secrets manually outside of Infisical" provides users with the necessary context to make informed decisions.

frontend/src/components/secret-syncs/forms/SecretSyncOptionsFields/SecretSyncOptionsFields.tsx (3)

3-3: Updated imports to support new UI elements.

The faQuestionCircle icon has been properly imported to provide helpful tooltips for the new feature.


6-6: Added necessary UI components for the feature.

Switch and Tooltip components have been correctly imported to implement the UI for enabling/disabling secret deletion.


119-156: Well-implemented form control for the new feature.

The implementation of the disableSecretDeletion option is thorough and user-friendly:

  1. The Switch component is styled consistently with other form elements
  2. The tooltip provides clear explanation of the feature's purpose
  3. Error handling is properly implemented
  4. The copy explains both what the feature does and when it should be used

This implementation aligns perfectly with the PR's objective of allowing users to disable the deletion of secrets during synchronization.

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.

1 participant