-
Notifications
You must be signed in to change notification settings - Fork 95
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
Filter: drop packets not Valid (with basic rules). #404
Comments
I can see us having a Filter that drops packets based on a min and max size value. Maybe a config like:
Other name ideas:
Thoughts? |
Thanks for your help |
I tried with your example but return the following error: please guide me how can it work |
Hi @tuongnd7 so the mentioned |
Dropping packets that don't meet some criteria definitely sounds reasonable, re what we should call it, I think it can be something more generic like a |
I understood thank you |
Let's keep this open! It's a good suggestion! |
Updated the title, let me know if it doesn't work. |
I like this idea a lot! We could even just start with min/max length, and expand the set of rules over time. 👍🏻 |
Coming back around, given the above conversation, a configuration like the following I think would work: version: v1alpha1
static:
filters:
- name: quilkin.extensions.filters.debug.v1alpha1.Validate
config:
bytes:
min: 0 # (defaults to 0)
max: 500 # (defaults to max UDP packet size)
endpoints:
- address: 127.0.0.1:7001 Then we can also add extra potential requirements as needed, as their own top level item under Other options for What do we think? |
config wise we likely don't need to group options since all such fields would be some sort of validation on the packet, something like config:
min_size: 0
max_size: 1 @tuongnd7 re blocking traffic we're looking into adding support for that here #158 (comment) |
On review, I think I like To give an example, if we had (switched from version: v1alpha1
static:
filters:
- name: quilkin.extensions.filters.debug.v1alpha1.Validate
config:
size:
min: 0 # (defaults to 0)
max: 500 # (defaults to max UDP packet size)
endpoints:
- address: 127.0.0.1:7001 And we wanted to add a version: v1alpha1
static:
filters:
- name: quilkin.extensions.filters.debug.v1alpha1.Validate
config:
size:
min: 0 # (defaults to 0)
max: 500 # (defaults to max UDP packet size)
prefix:
size: 2
value: AA==
suffix:
size: 1
value: AA==
endpoints:
- address: 127.0.0.1:7001 I find this much better to view and use. Otherwise, this will become: version: v1alpha1
static:
filters:
- name: quilkin.extensions.filters.debug.v1alpha1.Validate
config:
min_length: 0:
max_length: 500
size_prefix: 2
value_prefix: AA==
size_suffix: 1
value_suffix: AA==
endpoints:
- address: 127.0.0.1:7001 (a) I find this inconsistent and (b) I think it's harder to read (c) and I don't find it as aesthetically nice (for whatever that is worth 😄 ) |
That sounds reasonable yeah! |
I'm not sure what static:
filters:
- name: quilkin.extensions.filters.debug.v1alpha1.Validate
config:
# Inclusive Ranges
length: 0..=500
# Exclusive Ranges
length: 0..501
# Single Value
length: 42
# Up To 42 bytes
length: ..42
# At least 42 bytes
length: 42.. |
It was more of a potential example of how the config could expand, rather than a functionality design. |
🤔 Going back and digging through old issues - this seemed like a fun one to tackle. One thought I had here was - rather than have the So in theory, if I wanted to validate a packet is between 10 and 30 bytes in length, it could be something like: version: v1alpha1
endpoints:
- address: 127.0.0.1:26000
- address: 127.0.0.1:26001
filters:
- name: quilkin.extensions.filters.debug.v1alpha1.Validate
config:
metadataKey: myapp.com/valid
regex: ^.{10,30}$
- name: quilkin.filters.match.v1alpha1.Match
config:
on_read:
metadataKey: myapp.com/valid
branches:
- value: true
filter: quilkin.filters.pass.v1alpha1.Pass
fallthrough: quilkin.filters.drop.v1alpha1.Drop I could then do more complex packet structure checking, etc if I needed to, I expect with Unicode based regular expressions. We could still add a Thoughts? |
My only thought is, could this use case be covered by adding a |
I was also wondering if this could be combined somehow into Capture -- my eventual thought there was that while they are similar, they aren't quite the same, and I'd rather err on the side of "have a Filter do one thing, and one thing well" - basically Unix philosophy. Let's say you in a scenario wherein you want to (a) check if a packet is between 5 and 10 bytes in length, and if so, grab the first 3 bytes, and do something with it. I could do that with: version: v1alpha1
endpoints:
- address: 127.0.0.1:26000
filters:
- name: quilkin.extensions.filters.debug.v1alpha1.Validate
config:
metadataKey: myapp.com/valid
regex: ^.{5,10}$
- name: quilkin.filters.match.v1alpha1.Match
config:
on_read:
metadataKey: myapp.com/valid
branches:
- value: true
filter: quilkin.filters.pass.v1alpha1.Capture
metadataKey: myapp.com/capture
config:
prefix:
size: 3
remove: false
fallthrough: quilkin.filters.drop.v1alpha1.Drop
# ...now do something with the capture And I think that's verbose, but easy to read. Also, long term we can expand the functionality of Validate, without worrying about running into anything in Capture. It would definitely be more succinct if we had something like the following: version: v1alpha1
endpoints:
- address: 127.0.0.1:26000
filters:
- name: quilkin.extensions.filters.debug.v1alpha1.Parse
config:
metadataKey: myapp.com/capture
regex: ^(.{3}).{2,7}$
drop: true
- name: quilkin.filters.match.v1alpha1.Match
config:
on_read:
# ...now do something with the capture
fallthrough: quilkin.filters.drop.v1alpha1.Drop Then we have to manage having two captured elements -the outermost and the innermost, and that's a little scary, as it could allow data through that it wasn't meant to, if either the whole element or its part matches the Thoughts? |
Chatting in community meeting - happy to have separate filters, but the internal functionality will likely be able to be shared, so try and avoid duplication between |
Hi everyone,
I see UDP attack packets about 1400 in length.
while game UDP packets are about 3 to 20 in length.
I only found examples of drop UDP packets with a length less than the "size" configuration.
Can you help me how to configure to drop packets with length greater than size or maybe a range in size.
Thank you.
The text was updated successfully, but these errors were encountered: