-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SIEM migrations] Implement ES|QL lookups and other fixes #204960
Conversation
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
} else if (state.validation_errors?.esql_errors) { | ||
translationResult = RuleTranslationResult.PARTIAL; | ||
} else if (query.match(/\[(macro|lookup):.*?\]/)) { | ||
translationResult = RuleTranslationResult.PARTIAL; |
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.
I think we should not be able to get to this point because it will be caught in the previous check state.validation_errors?.esql_errors
since [(macro|lookup):.*?\]
like string will be a syntax error. Does not hurt to have this check though.
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.
I changed the validation node to execute the syntax check without the placeholders, this way we only try to fix the query when there is a real syntax issue. Placeholders were causing the graph to run all iterations trying to fix a query that could not be fixed.
That's why now we check for placeholders explicitly at the end.
@@ -25,13 +25,14 @@ export const getValidationNode = ({ logger }: GetValidationNodeParams): GraphNod | |||
// We want to prevent infinite loops, so we increment the iterations counter for each validation run. | |||
const currentIteration = ++state.validation_errors.iterations; | |||
let esqlErrors: string = ''; | |||
if (!isEmpty(query)) { | |||
const { errors, isEsqlQueryAggregating, hasMetadataOperator } = parseEsqlQuery(query); | |||
const sanitizedQuery = query ? removePlaceHolders(query) : ''; |
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.
won't queries like
|
[macro:something]
[lookup:something]
and similar variations, lead to an empty sanitizedQuery
after removePlaceHolders(query)
call? And this will suggest those queries pass ES|QL validation?
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.
Yes, that's fine, the graph tries to fix queries that do not validate here. I don't think we should try to fix queries like these. They will be labeled as partial translation at the last translationResult
node.
...rity_solution/server/lib/siem_migrations/rules/task/agent/sub_graphs/translate_rule/state.ts
Outdated
Show resolved
Hide resolved
...urity_solution/server/lib/siem_migrations/rules/task/retrievers/rule_migrations_retriever.ts
Outdated
Show resolved
Hide resolved
Some minor stuff:
Screen.Recording.2024-12-30.at.15.47.57.mov
Screen.Recording.2024-12-30.at.16.06.10.mov |
Hey @angorayc
Yes, the lookups list is generated from the content uploaded previously (rules and macros). If the user provides lookups that are not in the list (they are not needed), we just ignore them, they are not even uploaded to the server. We only care about lookups that we need to perform the translations.
Good catch. Noted. We'll fix that in a separate PR since it's not part of this task Thanks for the review! |
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 looking great! I think from my perspective its nice to get it merged and anything that might need an update later it would be easier to modify it at that point, as the PR gives plenty of great improvements!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled in files
Total ESLint disabled count
History
cc @semd |
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
Summary
Adds support for ES|QL native LOOKUP JOIN operators for Splunk lookups.
Lookups import changes:
lookup_<lookup_name>
pattern (queries fail if the name contains-
)_lookup
suffix in the names coming from Splunk: queries use the_lookup
suffix, but files in the. lookup editor don't have it)Lookups translation changes:
inline_query
node updated to support lookups, replacing the splunk lookup name with the new Elastic lookup index name. Placeholders for missing macros/lookups are now added in this node instead of thetranslate_query
node.Other improvements on the agent graph:
Other fixes
FULL
when we missed the integration and index pattern (logs-*). Changed toPARTIAL
Screenshots
New summary comments:
Prebuilt rule matching:
matching
not matching
Query inlining summary:
Integration matching:
matching:
not matching
ES|QL translation
Needs manual translation reason:
Lookups UI:
Lookup index example:
Translation
Test data
rules.json
all_macros.json
lookups.zip (uncompress before uploading)