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

feat(api): list secrets filter by metadata #3060

Merged
merged 12 commits into from
Feb 7, 2025

Conversation

DanielHougaard
Copy link
Contributor

Description 📣

This PR adds support for filtering secrets by their metadata. If multiple metadata fields are passed in, the operation will work as an AND operator, which means the secrets returned will match all the metadata fields.

The format for the secretMetadata query parameter is key1:value1,key2:value2.

The metadata filter is limited to max 10 metadata key-value pairs. This is to avoid overloading the backend, and to avoid bad actors passing into a list with millions of key-value pairs, which could result in a DoS attack.

if (metadata.length > 10) {
                ctx.addIssue({
                  code: z.ZodIssueCode.custom,
                  message: "You can only filter by up to 10 metadata fields"
                });
              }

Type ✨

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

@DanielHougaard DanielHougaard self-assigned this Jan 28, 2025
akhilmhdh
akhilmhdh previously approved these changes Jan 29, 2025
akhilmhdh
akhilmhdh previously approved these changes Feb 4, 2025
Copy link
Member

@akhilmhdh akhilmhdh left a comment

Choose a reason for hiding this comment

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

All good.

One small thought process was I felt OR would be more appropriate than AND when multiple combo of key=key1,value=value1:key=key2,value=value2

I felt in above [ key1 and value1 ] or [ key2 and value2 ] than [ key1 and value1 ] and [ key2 and value2 ]. But it may be subjective.

CC: @DanielHougaard @maidul98

@DanielHougaard DanielHougaard merged commit 9d66659 into main Feb 7, 2025
6 checks passed
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.

3 participants