Commit 9aa9756
Security Solution] Fix string spread bug when syncing watchlists to Entity Store (#260941)
### Summary:
Fix string spread bug when syncing watchlists to entity store
Fixes a bug where single-string `entity.attributes.watchlists` values
in the Entity Store were being incorrectly parsed and spread into an
array of individual characters during sync.
If the Entity Store contained a single string value instead of an array
(e.g., `"privileged-user-monitoring-watchlist-id"`), the sync logic
would destructure it via `[...watchlists, watchlistId]`, resulting in
an array of characters `["p", "r", "i", "v", ...]`.
This commit adds defensive checks in both `WatchlistEntitiesService`
(when reading from Elasticsearch) and `entity_store_sync` (before
mutating)
to ensure `currentWatchlists` is always safely coerced into an array of
strings before any spread operations occur.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>1 parent d0020e7 commit 9aa9756
File tree
2 files changed
+16
-5
lines changed- x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/watchlists
- entities
- entity_sources/sync
2 files changed
+16
-5
lines changedLines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
105 | 111 | | |
106 | | - | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| |||
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
75 | | - | |
76 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| |||
0 commit comments