Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Automatic Import] Remove fields with @ from the script process…
…or (#201548) (#201589) # Backport This will backport the following commits from `main` to `8.x`: - [[Automatic Import] Remove fields with @ from the script processor (#201548)](#201548) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Bharat Pasupula","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-25T13:00:14Z","message":"[Automatic Import] Remove fields with @ from the script processor (#201548)\n\n## Summary\r\n\r\nThis PR filters the fields containing `@` in date type from `script`\r\nprocessor.\r\n\r\n## Before this PR\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a733d81f-aaaf-4787-b974-1e5d35ff4b8f)\r\n\r\n```json\r\n {\r\n \"script\": {\r\n \"tag\": \"script_convert_array_to_string\",\r\n \"description\": \"Ensures the date processor does not receive an array value.\",\r\n \"lang\": \"painless\",\r\n \"source\": \"if (ctx.varonis?.varonis_alerts?.@timestamp != null &&\\n ctx.varonis.varonis_alerts.@timestamp instanceof ArrayList){\\n ctx.varonis.varonis_alerts.@timestamp = ctx.varonis.varonis_alerts.@timestamp[0];\\n}\\n\"\r\n }\r\n },\r\n {\r\n \"date\": {\r\n \"if\": \"ctx.varonis?.varonis_alerts?.@timestamp != null\",\r\n \"tag\": \"date_processor_varonis.varonis_alerts.@timestamp\",\r\n \"field\": \"varonis.varonis_alerts.@timestamp\",\r\n \"target_field\": \"event.start\",\r\n \"formats\": [\r\n \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\",\r\n \"ISO8601\"\r\n ]\r\n }\r\n },\r\n```\r\n\r\n## After this PR\r\n\r\n```json\r\n \"date\": {\r\n \"if\": \"ctx.varonis?.varonis_alerts?.@timestamp != null\",\r\n \"tag\": \"date_processor_varonis.varonis_alerts.@timestamp\",\r\n \"field\": \"varonis.varonis_alerts.@timestamp\",\r\n \"target_field\": \"event.start\",\r\n \"formats\": [\r\n \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\",\r\n \"ISO8601\"\r\n ]\r\n }\r\n },\r\n```\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"8964dc92c774d9ac5c82a411022ece3fb91e3cfd","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","backport:prev-major","Team:Security-Scalability"],"title":"[Automatic Import] Remove fields with @ from the script processor","number":201548,"url":"https://github.com/elastic/kibana/pull/201548","mergeCommit":{"message":"[Automatic Import] Remove fields with @ from the script processor (#201548)\n\n## Summary\r\n\r\nThis PR filters the fields containing `@` in date type from `script`\r\nprocessor.\r\n\r\n## Before this PR\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a733d81f-aaaf-4787-b974-1e5d35ff4b8f)\r\n\r\n```json\r\n {\r\n \"script\": {\r\n \"tag\": \"script_convert_array_to_string\",\r\n \"description\": \"Ensures the date processor does not receive an array value.\",\r\n \"lang\": \"painless\",\r\n \"source\": \"if (ctx.varonis?.varonis_alerts?.@timestamp != null &&\\n ctx.varonis.varonis_alerts.@timestamp instanceof ArrayList){\\n ctx.varonis.varonis_alerts.@timestamp = ctx.varonis.varonis_alerts.@timestamp[0];\\n}\\n\"\r\n }\r\n },\r\n {\r\n \"date\": {\r\n \"if\": \"ctx.varonis?.varonis_alerts?.@timestamp != null\",\r\n \"tag\": \"date_processor_varonis.varonis_alerts.@timestamp\",\r\n \"field\": \"varonis.varonis_alerts.@timestamp\",\r\n \"target_field\": \"event.start\",\r\n \"formats\": [\r\n \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\",\r\n \"ISO8601\"\r\n ]\r\n }\r\n },\r\n```\r\n\r\n## After this PR\r\n\r\n```json\r\n \"date\": {\r\n \"if\": \"ctx.varonis?.varonis_alerts?.@timestamp != null\",\r\n \"tag\": \"date_processor_varonis.varonis_alerts.@timestamp\",\r\n \"field\": \"varonis.varonis_alerts.@timestamp\",\r\n \"target_field\": \"event.start\",\r\n \"formats\": [\r\n \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\",\r\n \"ISO8601\"\r\n ]\r\n }\r\n },\r\n```\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"8964dc92c774d9ac5c82a411022ece3fb91e3cfd"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201548","number":201548,"mergeCommit":{"message":"[Automatic Import] Remove fields with @ from the script processor (#201548)\n\n## Summary\r\n\r\nThis PR filters the fields containing `@` in date type from `script`\r\nprocessor.\r\n\r\n## Before this PR\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/a733d81f-aaaf-4787-b974-1e5d35ff4b8f)\r\n\r\n```json\r\n {\r\n \"script\": {\r\n \"tag\": \"script_convert_array_to_string\",\r\n \"description\": \"Ensures the date processor does not receive an array value.\",\r\n \"lang\": \"painless\",\r\n \"source\": \"if (ctx.varonis?.varonis_alerts?.@timestamp != null &&\\n ctx.varonis.varonis_alerts.@timestamp instanceof ArrayList){\\n ctx.varonis.varonis_alerts.@timestamp = ctx.varonis.varonis_alerts.@timestamp[0];\\n}\\n\"\r\n }\r\n },\r\n {\r\n \"date\": {\r\n \"if\": \"ctx.varonis?.varonis_alerts?.@timestamp != null\",\r\n \"tag\": \"date_processor_varonis.varonis_alerts.@timestamp\",\r\n \"field\": \"varonis.varonis_alerts.@timestamp\",\r\n \"target_field\": \"event.start\",\r\n \"formats\": [\r\n \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\",\r\n \"ISO8601\"\r\n ]\r\n }\r\n },\r\n```\r\n\r\n## After this PR\r\n\r\n```json\r\n \"date\": {\r\n \"if\": \"ctx.varonis?.varonis_alerts?.@timestamp != null\",\r\n \"tag\": \"date_processor_varonis.varonis_alerts.@timestamp\",\r\n \"field\": \"varonis.varonis_alerts.@timestamp\",\r\n \"target_field\": \"event.start\",\r\n \"formats\": [\r\n \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\",\r\n \"ISO8601\"\r\n ]\r\n }\r\n },\r\n```\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"8964dc92c774d9ac5c82a411022ece3fb91e3cfd"}}]}] BACKPORT--> Co-authored-by: Bharat Pasupula <[email protected]>
- Loading branch information