-
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
[Cloud security] Fix runtime fields scripts - checking field exist #156458
Merged
kfirpeled
merged 6 commits into
elastic:main
from
kfirpeled:cloud_security/fix_runtime_fields
May 4, 2023
Merged
[Cloud security] Fix runtime fields scripts - checking field exist #156458
kfirpeled
merged 6 commits into
elastic:main
from
kfirpeled:cloud_security/fix_runtime_fields
May 4, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kfirpeled
changed the title
[Cloud security] fix runtime fields scripts - checking field exist
[Cloud security] Fix runtime fields scripts - checking field exist
May 2, 2023
This was
linked to
issues
May 2, 2023
4 tasks
kfirpeled
added
release_note:skip
Skip the PR/issue when compiling release notes
v8.8.0
v8.9.0
labels
May 3, 2023
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
CohenIdo
approved these changes
May 4, 2023
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
May 4, 2023
…lastic#156458) (cherry picked from commit 17528b2)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
kibanamachine
added a commit
that referenced
this pull request
May 4, 2023
…ist (#156458) (#156701) # Backport This will backport the following commits from `main` to `8.8`: - [[Cloud security] Fix runtime fields scripts - checking field exist (#156458)](#156458) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Kfir Peled","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-04T14:41:27Z","message":"[Cloud security] Fix runtime fields scripts - checking field exist (#156458)","sha":"17528b291af9fc7601a9c408cb235f0de083acce","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.8.0","v8.9.0"],"number":156458,"url":"https://github.com/elastic/kibana/pull/156458","mergeCommit":{"message":"[Cloud security] Fix runtime fields scripts - checking field exist (#156458)","sha":"17528b291af9fc7601a9c408cb235f0de083acce"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156458","number":156458,"mergeCommit":{"message":"[Cloud security] Fix runtime fields scripts - checking field exist (#156458)","sha":"17528b291af9fc7601a9c408cb235f0de083acce"}}]}] BACKPORT--> Co-authored-by: Kfir Peled <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR address to an issue we have with backward and forward compatibility
For a robust check of the existence of a field, and that it has a value we first need to use
doc.containsKey
and afterwards to check it is not empty usingempty
property:doc["field.path"].empty
Checklist
How to test this
I would recommend using first the Dev Tools to check the runtime fields is correct
For example, I run a query with aggs to see when things break and when not
List of edge cases I've checked:
Here is the query