-
Notifications
You must be signed in to change notification settings - Fork 65
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
Support for $and operand #69
Comments
Make sense. I've heard some murmurs on needing this elsewhere as well. Similar to
Some relevant files based on
|
@baldawar - I suspect the above example doesn't need the $and operator in that the fields all have different names (existing engine already handles that)... The only gap I can find that needs addressing is to allow multiple rules on the SAME field, specifically in the suffix/prefix/anything-but-[prefix|suffix]. Do you disagree? @baldawar @timbray ... Curious of your thoughts... From what I can gather, the OR operator implementation essentially just built "n" separate rules with the same name, with each permutation of "or"s children. In your view, what is the right way to build the $and operator to allow multiple conditions on the same key... Things I can think of:
|
I suppose if route 2 was taken, it could similarly support a |
In general, over the history of Ruler, we basically haven't added any feature unless we had some group yelling "we really need this". Who really needs this? What's the scenario? |
@timbray An "$and" use case... in a detection system, false positive reductions often revolve around defining lists of exclusions... For example, in a signature were you're trying to detect an individual user doing something naughty (abusing a capability intended for system processes), you might have a list of exclusions to exclude the known accounts who are entitled to use said functionality. This could take the form of accounts running administrative tools (exact matches) plus accounts with particular suffixes (like AD designators, identifiers for system users, etc...) I suppose the fundamental issue here is that the anything-but operators only allow either a list of explicit matches OR a single prefix or suffix, rather than mix of explicit matches and multiple prefix/suffix's. The same issue is at the root of the "$not" idea. |
Not bad. But I meant actual groups with actual concrete problems they need solutions for right now. In my career, I've had really bad luck guessing what people need. |
I agree. This is a real use case for me. I can fairly easily create a layer on top of event-ruler to perform these functions in my context, but it seemed high-likelihood that someone else would benefit from the functionality as well. Either way I appreciate the engagement. |
Just came across this by chance when researching how to combine "prefix" and "suffix" on a field. Eg I think |
Depends what you mean by "solve". I think this syntax is nice and expressive and we can probably figure out how to build a state machine to implement it: "key": [{ "prefix": "landing/", "suffix": ".xml" }] It's a bit of departure from current Rule syntax and raises questions about what you could combine with what, but it's a direction that's worth investigating; and probably less kludgy then |
Thinking about how this would get interpreted for keys with sub-key elements, the syntax isn't that bad (looks simpler compared to using
It's definitely a big departure from current query syntax but inline with rest of the ruler's existing AND behaviour today. no new matcher for users to learn, a big plus for me. We'd need to make changes to how we compile rules, starting from this line
In any case, definitely don't see any reason to supporting |
@baldawar - One potential point of confusion with the syntax above is that something like the below evaluates to true if
|
There is actually a defect tied into here... if you do this:
|
That's a great catch. Ruler can't push breaking change. Looking back at Nick's comment, I may have interpreted the wrong way. It might just have been an answer to "Who really needs this?" question and had no objections to implementing it like this {
"message": {
"$and": [
{ "prefix": "landing/" },
{ "suffix": ".xml" },
]
}
} @NickMoores can you confirm? |
Sorry for the confusion. Can confirm: my intent was to show support for an $and operator. My example was an alternative syntax I tried for my use case before arriving here. I think it’s expressive, but I’m not read up enough on Ruler to understand whether it aligns with other design choices, so happy to bow to others with experience. I think $and makes sense given the existence of $or. |
From requirements standpoint I have two patterns worth testing here Simple AND Matching
Complex AND & OR MatchingThis is purely to stress the functioality and test if we hit any limitations. {
"$or": [
{
"$and": [
{ "prefix": "landing/" },
{ "anything-but": { "suffix": ".xml" } }
]
},
{
"$and": [
{ "anything-but": { "prefix": "landing/" } },
{ "suffix": ".xml" }
]
}
]
} |
Adding an interesting ask around Rule:
Event 1 (MATCHES):
Event 2 (SHOULD NOT MATCH):
|
@baldawar any update on $and operator? Also can you please tell me whether $or works for the same field name. |
No progress has been made yet though we have plans to look at this in late 2024. We don't have a firm date for this to be picked up. That being said, if anyone needs it sooner, we're happy to help guide them through the change.
It does, though in future would recommend creating a different issue for unrelated questions to avoid multiple topics getting mixed up in the same thread. |
Adding a +1 for a use case, in this case we are looking to use event ruler in an algebra that supports {
"elements_used": [
"shapes",
"text",
"images"
]
} Moreover array support along the concept of |
Use-case wise supporting $AND fits well with ruler. In case anyone is curious on progress, there's a branch on this repo where I've backed up work so far. So far, Ruler can parse rulers with $AND matchers, but the actual matching part is not fully-functional yet. |
What is your idea?
It would be great to allow an
$and
operand, (overcoming JSON "last-one-in-wins" semantics for fields) to enable tagging multiple conditions to a given field. I think this may be possible given how I interpret the implementation of the$or
operand. For example, this would exclude any value that (starts with "abc" AND ends with "123" AND also excludes "notmyvalue" and "alsonotmyvalue").Would you be willing to make the change?
Maybe
Additional context
Add any other context (such as images, docs, posts) about the idea here.
The text was updated successfully, but these errors were encountered: