Commit 718dcce
[Entity Analytics] Parameterise refresh on resolution bulk writes (elastic#268467)
## Summary
Fixes the 403 returned by `POST
/api/security/entity_store/resolution/link` and `/unlink` on serverless
with `platform_engineer` role (caught in e2e tests). Root cause:
`bulkUpdateEntityDocs` called `esClient.bulk({ refresh: true })`, which
requires the `indices:admin/refresh/unpromotable` action — not granted
to `platform_engineer` on `.entities.v2.latest.*`.
This PR replaces the hardcoded `refresh: true` with a configurable
`refresh` option on `bulkUpdateEntityDocs`, defaulting to `'wait_for'`.
Both `'wait_for'` and `false` only require `write` privilege.
Caller settings:
| Caller | Setting | Why |
| --- | --- | --- |
| UI flyout routes (`/resolution/link`, `/resolution/unlink`) |
`'wait_for'` (default) | UI immediately refetches the resolution group;
without read-your-writes guarantee the refetch might get stale state |
| CSV upload (`processRow`) | `false` | `'wait_for'` adds ~1s per row in
sequential CSV processing; 200-row uploads were exceeding the HTTP
socket timeout. With `false`, 200 rows complete in ~2s. Trade-off:
within a single upload, two rows resolving the same alias to different
targets silently take the last writer (though this matches existing
"latest wins" semantics) |
| Automated resolution maintainer | `false` | Buckets are pre-collected
in memory; nothing within the same task run reads back the write, so the
refresh wait is dead time |
Fixes elastic#266752
Related: elastic#266589 (Cypress e2e that surfaced the bug)
### Checklist
- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.
### Identify risks
- **Stale read for ~1s after CSV upload / maintainer write.** Severity:
low. Mitigation: the CSV per-row response is built from in-process
state, not a re-read; the maintainer doesn't read back its own writes
within a run. Subsequent reads from a different request will see the new
state after the next natural index refresh (<1s).
- **"Last write wins" within a single CSV upload.** Severity: low.
Mitigation: matches the broader "latest wins" approach already accepted.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>1 parent dafdc05 commit 718dcce
11 files changed
Lines changed: 96 additions & 22 deletions
File tree
- oas_docs/output
- x-pack/solutions/security/plugins
- entity_store/server
- domain/resolution
- infra/elasticsearch
- maintainers/automated_resolution
- __tests__
- routes/apis/resolution
- security_solution/server/lib/entity_analytics/entity_resolution
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76103 | 76103 | | |
76104 | 76104 | | |
76105 | 76105 | | |
76106 | | - | |
| 76106 | + | |
76107 | 76107 | | |
76108 | 76108 | | |
76109 | 76109 | | |
| |||
76217 | 76217 | | |
76218 | 76218 | | |
76219 | 76219 | | |
76220 | | - | |
| 76220 | + | |
76221 | 76221 | | |
76222 | 76222 | | |
76223 | 76223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81312 | 81312 | | |
81313 | 81313 | | |
81314 | 81314 | | |
81315 | | - | |
| 81315 | + | |
81316 | 81316 | | |
81317 | 81317 | | |
81318 | 81318 | | |
| |||
81426 | 81426 | | |
81427 | 81427 | | |
81428 | 81428 | | |
81429 | | - | |
| 81429 | + | |
81430 | 81430 | | |
81431 | 81431 | | |
81432 | 81432 | | |
| |||
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
114 | 129 | | |
115 | 130 | | |
116 | 131 | | |
| |||
348 | 363 | | |
349 | 364 | | |
350 | 365 | | |
351 | | - | |
| 366 | + | |
352 | 367 | | |
353 | 368 | | |
354 | 369 | | |
| |||
366 | 381 | | |
367 | 382 | | |
368 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
369 | 395 | | |
370 | 396 | | |
371 | 397 | | |
| |||
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
75 | 81 | | |
76 | 82 | | |
77 | 83 | | |
78 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
| |||
133 | 144 | | |
134 | 145 | | |
135 | 146 | | |
136 | | - | |
| 147 | + | |
137 | 148 | | |
138 | 149 | | |
139 | 150 | | |
| |||
144 | 155 | | |
145 | 156 | | |
146 | 157 | | |
147 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
148 | 163 | | |
149 | 164 | | |
150 | 165 | | |
| |||
176 | 191 | | |
177 | 192 | | |
178 | 193 | | |
179 | | - | |
| 194 | + | |
180 | 195 | | |
181 | 196 | | |
182 | 197 | | |
| |||
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
94 | 112 | | |
95 | 113 | | |
96 | 114 | | |
| |||
100 | 118 | | |
101 | 119 | | |
102 | 120 | | |
| 121 | + | |
103 | 122 | | |
104 | 123 | | |
105 | | - | |
| 124 | + | |
| 125 | + | |
106 | 126 | | |
107 | 127 | | |
108 | | - | |
| 128 | + | |
109 | 129 | | |
110 | 130 | | |
111 | 131 | | |
112 | 132 | | |
113 | 133 | | |
114 | 134 | | |
115 | 135 | | |
116 | | - | |
| 136 | + | |
117 | 137 | | |
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
| |||
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
239 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
240 | 244 | | |
241 | 245 | | |
242 | 246 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
| 305 | + | |
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
315 | 317 | | |
316 | 318 | | |
317 | 319 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
343 | | - | |
| 343 | + | |
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
353 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
354 | 356 | | |
355 | 357 | | |
356 | 358 | | |
| |||
0 commit comments