-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Un-revert "Siem query rule - reduce field_caps usage" #186317
Un-revert "Siem query rule - reduce field_caps usage" #186317
Conversation
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes lgtm, the additional unit tests are a nice touch. I'm relying on @elastic/security-detection-engine to verify the functionality of their tests.
We should also add a functional test for a lucene query in discover but that's best done as a follow up.
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Page load bundle
To update your PR or re-run it, just comment with: cc @lukasolson |
let fields = dataView.timeFieldName ? [dataView.timeFieldName] : []; | ||
if (sort) { | ||
const sortArr = Array.isArray(sort) ? sort : [sort]; | ||
fields.push(...sortArr.flatMap((s) => Object.keys(s))); | ||
} | ||
for (const query of request.query) { | ||
if (query.query && query.language === 'kuery') { | ||
const nodes = fromKueryExpression(query.query); | ||
const queryFields = getKqlFieldNames(nodes); | ||
fields = fields.concat(queryFields); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if the let
usage is only due to the concat
call at the end, maybe that can be replaced with push(...queryFields)
and make this a const
let fields = dataView.timeFieldName ? [dataView.timeFieldName] : []; | |
if (sort) { | |
const sortArr = Array.isArray(sort) ? sort : [sort]; | |
fields.push(...sortArr.flatMap((s) => Object.keys(s))); | |
} | |
for (const query of request.query) { | |
if (query.query && query.language === 'kuery') { | |
const nodes = fromKueryExpression(query.query); | |
const queryFields = getKqlFieldNames(nodes); | |
fields = fields.concat(queryFields); | |
} | |
} | |
const fields = dataView.timeFieldName ? [dataView.timeFieldName] : []; | |
if (sort) { | |
const sortArr = Array.isArray(sort) ? sort : [sort]; | |
fields.push(...sortArr.flatMap((s) => Object.keys(s))); | |
} | |
for (const query of request.query) { | |
if (query.query && query.language === 'kuery') { | |
const nodes = fromKueryExpression(query.query); | |
const queryFields = getKqlFieldNames(nodes); | |
fields.push(...queryFields); | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this nit makes sense, I prefer to leave this PR as close to its original counterpart (#184890) as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a minor code review, not a blocker for the PR.
Approve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally with one of the original offending pre-built rules Cobalt Strike Command and Control Beacon
and that generated an alert. This LGTM! Glad the fix was a simple one-liner.
Summary
#184890 was reverted in #186196 because it contained a bug with alerts created using Lucene queries. The bug was fixed in #186217. This PR un-reverts the original changes and preserves the fix. It also adds unit tests to cover the failed cases.
Checklist