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

fix(platform): Validate secret name before adding #764

Closed
wants to merge 0 commits into from

Conversation

Agastya221
Copy link
Contributor

@Agastya221 Agastya221 commented Feb 17, 2025

Description

fix: validate secret name before adding

Fixes #701

Screenshots of relevant screens

ssforopensource

Developer's checklist

  • My PR follows the style guidelines of this project
  • I have performed a self-check on my work

If changes are made in the code:

  • I have followed the coding guidelines
  • My changes in code generate no new warnings
  • My changes are breaking another fix/feature of the project
  • I have added test cases to show that my feature works
  • I have added relevant screenshots in my PR
  • There are no UI/UX issues

Documentation Update

  • This PR requires an update to the documentation at docs.keyshade.xyz
  • I have made the necessary updates to the documentation, or no documentation changes are required.

Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Input Validation

The validation only checks if the secret name is empty or whitespace. Consider adding additional validation rules for secret name format, length limits, and special character restrictions.

if (!newSecretData.secretName.trim()) {

Copy link
Contributor

codiumai-pr-agent-free bot commented Feb 17, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Security
Validate secret name format

Add validation for special characters and spaces in secret name to prevent
potential security issues and ensure compatibility with backend systems.

apps/platform/src/components/dashboard/secret/addSecretDialogue/index.tsx [46-55]

-if (!newSecretData.secretName.trim()) {
-  toast.error('Secret name is required', {
+const secretNameRegex = /^[a-zA-Z0-9_-]+$/;
+if (!newSecretData.secretName.trim() || !secretNameRegex.test(newSecretData.secretName)) {
+  toast.error('Invalid secret name', {
     description: (
       <p className="text-xs text-red-300">
-        Please provide a name for the secret.
+        Secret name must contain only letters, numbers, underscores and hyphens.
       </p>
     )
   })
   return
 }
  • Apply this suggestion
Suggestion importance[1-10]: 9

__

Why: Adding validation for special characters in secret names is crucial for security and system compatibility. This prevents potential injection attacks and ensures the secret names conform to standard naming conventions that work across different systems.

High
  • Update

@rajdip-b rajdip-b changed the title fix(secret-dialog): validate secret name before adding fix(platform): validate secret name before adding Feb 18, 2025
@rajdip-b rajdip-b changed the title fix(platform): validate secret name before adding fix(platform): Validate secret name before adding Feb 18, 2025
@rajdip-b
Copy link
Member

Hey man, i completely missed to merge your PR. could you please update the code to resolve the merge conflict?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Secrets get created even with empty names
2 participants