PrincsFilter to ClientFilter reimplementation#186
Conversation
4144e3a to
7220434
Compare
|
Hi! Thanks, again, for this cool PR! Let's start this (huge) answer with a some history! At first, OpenWEC only supported Kerberos authentication. The Kerberos principal filter was implemented to mimic the subscription ACL of MS WEC, even if explicitly listing principals is quite tedious. I had some plans to parse the Kerberos PAC at some point to enable filtering on AD groups or claims, but I never found the time (and the motivation) to do it. I later added the custom "uri" system to manage which subscriptions are available to which machines, depending on the configuration of the machines. When TLS authentication was implemented, we extended the "Kerberos principal filter" to support TLS subjects, but we did not change the name out of laziness (sorry). In practice, my organization used custom "uri" to tag events based on the location of the machines, but we stopped doing that at some point. We never used the prinicpal/subject filtering feature. I assume you have a specific use case in mind. Could you share it?
|
|
Thank you for the detailed and thorough explanation. :) I also had a feeling that something bigger needs to be done around the current filtering implementation, so I really like your idea. The case-insensitivity option is also something that I find very useful, I would even consider changing the default (but only with the new config naming, I don't want to break anything when one uses the old option names, of course). In our use-cases, machine filtering is essential, as events are coming from very different domains, locations, etc. towards the same collector, and even with wildcards, it is sometimes non-trivial to achieve the the desired categorization when using TLS. The URI trick sounds good, but managing "what we collect and from where" would be better being stored on the server side, we would like to keep everything unified and stupid on the client side. So all things considered, I would gladly continue this implementation in the direction you suggested as "filter rework". (Sorry for the typo, I usually wrap up conversations terribly, so I asked for a little help :)) |
|
About the MachineID part: I don't have a specific use case that would not work with principals or cert subjects, I just had a fairly old memory when I was investigating the Microsoft implementation of WEC that in case of the source-initiated push method with TLS, their wildcard filters might have been applied on the Machine field of the request and not on the cert DN or common name. |
Ok. I'm fine with adding such a filter as long as the documentation clearly states that the value can be manipulated by an evil machine.
That's nice! I will be happy to help you if you need it 😄 Do you plan to implement the "single filter" approach or the last one with multiple filters? |
|
I would go with the single filter list and try to implement it in a way that wouldn't cause too many problems if one wanted to extend the functionality to the ACL-like idea you mentioned. The single filter list with flags (case-sensitivity, pattern) and a type field covers all my use cases. |
|
Sorry for the delay, I'll update the PR soon. |
7220434 to
3bbb970
Compare
183c7b5 to
b7c61b4
Compare
|
@vruello I updated the PR description. I'm still learning Rust, and it seems I have made a few relatively bad decisions, so the implementation does not look as clean as I wanted it to be. |
b7c61b4 to
1f5850f
Compare
|
Hi! Thanks for all your work on this feature! Do you think it is ready for review? |
|
My pleasure. :)
Yes, I think it is ready. |
|
Cool! I will check it out as soon as possible 😄 |
vruello
left a comment
There was a problem hiding this comment.
Thanks for the update! (and sorry for being a bit slow to review it)
I think it is much better than before. I wrote some comments. Most of the remaining work seems to be adding a new export version and adding some tests for filters.
I have some doubts about whether the "type/kind" (TLS subject, Kerberos principal, Machine ID) and the "flags" (case sensitive, "exact" or "glob") of targets should be global or target-specific. In fact, it feels more natural (and powerful) to specify them "per target", but I am not sure of how to format them in configuration files.
Do you have an opinion on this? (we need to decide this before (re-)working on the implementation)
I think it would be unnecessary (at least in our use cases) to allow per-target types and flags. My reasoning is something like this: |
|
Your reasoning is quite convincing. We are probably in one of those cases where perfect is the enemy of good, and supporting limited filtering capabilities is probably the best choice for now. We'll always be able to add a more complete (and complex) filtering syntax later, if the need arises. |
854fa8a to
edddee0
Compare
|
@vruello Sorry for the huge delay. I think I've resolved all review notes. |
7e8f709 to
308990b
Compare
308990b to
99fbca4
Compare
|
@vruello If you have some free time, could you take a look, please? :) |
|
We'll integrate this PR into our fork the upcoming week and start using/testing it. |
99fbca4 to
617ed95
Compare
|
@vruello Do you think there's a chance this could be merged upstream? |
617ed95 to
cd9c201
Compare
|
Hi! I squashed your commits, rebased on upstream and made some changes. The most significant change is replacing the filtering types I need some time to review it one last time but it should be ready for merging soon. |
|
Hi @vruello, Could you take a last look at this, please, in the hope it can be merged? |
config: add "cert_subjects" alias for "princs" filters subscription: rename PrincsFilter to ClientFilter subscription: rename principal to client/target subscription: make ClientFilter optional instead of Operation database: rename princs_filter to client_filter subscription: deprecate field setters in ClientFilter server: publish Header::machine_id cargo: update dependencies subscription: implement ClientFilterType and ClientFilterFlags subscription: replace ClientFilterOperation's str impls with strum config: define own ClientFilterType and ClientFilterFlags export: implement V3 due to ClientFilter config: add client filter test database: rename client-filter-related fields subscription: add ClientFilter tests database: set default client_filter_kind during migration database: store client_filter_flags as integer
cd9c201 to
6cbcdcc
Compare
6cbcdcc to
cfec315
Compare
|
Hi @vruello, Do you think this PR can be merged? Is there anything I can help with including testing, validating, improving the code? |
|
Hi @MrAnno! I am very sorry for the huge delay on this one. It has been quite a challenge to find the time to properly review and test it during these past few months, but it's finally been merged! Thank you so much for this great contribution and for your patience (more than a year, wow). |
|
Thanks for the persistent review and test rounds! :) |
Client filter
Filtering modes:
Only: the subscription will only be shown to the listed clientsExcept: the subscription will be shown to everyone except the listed clientsFiltering types:
KerberosPrinc: the filter will be evaluated on the Kerberos principalTLSCertSubject: the filter will be evaluated on the TLS certificate's subject fieldMachineID: the filtering is done based on the name of the computerThe default is either
KerberosPrincorTLSCertSubject, depending on how server authentication is configured.Warning:
MachineIDis not cryptographically authenticated information, it can be spoofed.Filtering flags:
GlobPattern: Glob patterns like*and?can be used intargetsCaseInsensitive: Filter matching will be case-insensitiveFlags are composable using the
|operator.The comparison is case-sensitive by default.
Backward compatibility:
V3Import/Export API?