fix: support wildcard filtering in EC2 filters#837
Merged
Conversation
Add wildcard pattern matching support to EC2 filter values to match AWS behavior. Changes: - Added wildcardToRegex() method to convert AWS wildcard patterns (* and ?) to Java regex - Added matchesValue() method for pattern-based value matching - Updated all filter matching logic to use wildcard patterns instead of exact string matching - Supports wildcard filtering for all filter types: tag filters, tag-key, tag-value, and resource-specific filters - Applies to all EC2 resources: VPCs, Subnets, Security Groups, Instances, Internet Gateways, Route Tables, Volumes Added comprehensive integration tests: - describeVpcsWithWildcardTagFilter: Tests asterisk wildcard patterns - describeVpcsWithWildcardQuestionMark: Tests question mark wildcard patterns All 69 EC2 integration tests pass. Backward compatible with exact string matching. Fixes floci-io#830
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds AWS-style wildcard matching for EC2 filter values, addressing wildcard tag filtering behavior for DescribeVpcs and applying the shared filter matching path across EC2 resources.
Changes:
- Adds wildcard-to-regex matching for EC2 filter values.
- Replaces exact
containschecks with pattern-based matching across supported EC2 filters. - Adds integration coverage for VPC tag filters using
*and?wildcards.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java |
Implements wildcard-aware EC2 filter matching. |
src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java |
Adds integration tests for wildcard VPC tag filtering. |
Comments suppressed due to low confidence (1)
src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java:1226
- EC2 filter wildcards can be escaped with a backslash to match literal
*and?, but this conversion treats\as a literal regex backslash and still expands the following wildcard. That makes filters such asValue=foo\*barmatchfoo\anythingbarinstead of a tag value offoo*bar, which diverges from AWS wildcard filtering. Consume the escaped character and quote it as a literal before applying wildcard expansion.
}
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Prakhar Kapoor <59886854+kapoorp99@users.noreply.github.com>
hectorvent
approved these changes
May 14, 2026
Collaborator
hectorvent
left a comment
There was a problem hiding this comment.
Thanks @kapoorp99,
This is a great addition to Floci.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add wildcard pattern matching support to EC2 filter values to match AWS behavior.
Changes:
Added comprehensive integration tests:
All 69 EC2 integration tests pass. Backward compatible with exact string matching.
Fixes #830