Skip to content

Commit

Permalink
[8.15] [Automatic Import] resolve a bug in ECS missing fields detecti…
Browse files Browse the repository at this point in the history
…on (#191502) (#191526)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Automatic Import] resolve a bug in ECS missing fields detection
(#191502)](#191502)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marius
Iversen","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-08-27T15:52:00Z","message":"[Automatic
Import] resolve a bug in ECS missing fields detection (#191502)\n\n##
Summary\n\nResolves a bug when comparing LLM ECS mapping output with
combined\nsamples, and the mapping is right under the data_stream
object,\nproviding false positive
results.","sha":"fb84360e2e8dd7ef6d8b72687abcead44329c839","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","backport:prev-minor","v8.16.0","Team:Security-Scalability","v8.15.1"],"number":191502,"url":"https://github.com/elastic/kibana/pull/191502","mergeCommit":{"message":"[Automatic
Import] resolve a bug in ECS missing fields detection (#191502)\n\n##
Summary\n\nResolves a bug when comparing LLM ECS mapping output with
combined\nsamples, and the mapping is right under the data_stream
object,\nproviding false positive
results.","sha":"fb84360e2e8dd7ef6d8b72687abcead44329c839"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191502","number":191502,"mergeCommit":{"message":"[Automatic
Import] resolve a bug in ECS missing fields detection (#191502)\n\n##
Summary\n\nResolves a bug when comparing LLM ECS mapping output with
combined\nsamples, and the mapping is right under the data_stream
object,\nproviding false positive
results.","sha":"fb84360e2e8dd7ef6d8b72687abcead44329c839"}},{"branch":"8.15","label":"v8.15.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
  • Loading branch information
P1llus authored Aug 27, 2024
1 parent 8c908bc commit 2dd29b8
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ function extractKeys(data: AnyObject, prefix: string = ''): Set<string> {
// Directly add the key for arrays without iterating over elements
keys.add(fullKey);
} else if (typeof value === 'object' && value !== null) {
const valueKeys = new Set(Object.keys(value));

if ([...valueFieldKeys].every((k) => valueKeys.has(k))) {
keys.add(fullKey);
} else {
// Recursively extract keys if the current value is a nested object
for (const nestedKey of extractKeys(value, fullKey)) {
keys.add(nestedKey);
}
keys.add(fullKey);
// Recursively extract keys if the current value is a nested object
for (const nestedKey of extractKeys(value, fullKey)) {
keys.add(nestedKey);
}
} else {
// Add the key if the value is not an object or is null
Expand Down

0 comments on commit 2dd29b8

Please sign in to comment.