Commit c4510ea
authored
[Security Solution] Update rule's last run on early exit due to error (elastic#264286)
## Summary
Follow-up fix for elastic#257203 where an early-exit path was missed when migrating security rule execution logging.
- Closes the rule execution logger when the rule exits early because `getInputIndex` fails (data view not found or unexpected error), so the rule's last run object gets updated for that execution.
## Details
In [`create_security_rule_type_wrapper.ts`](x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_types/create_security_rule_type_wrapper.ts) the executor returns early when resolving the input index (data view / index pattern) throws. Before this change, `ruleExecutionLogger.close()` was not called on that branch, which meant `setRuleLastRun` was never invoked and the rule's last run object was left stale for the execution.
## Test plan
- [ ] Unit tests in `create_query_alert_type.test.ts` cover both early-exit branches (data view not found, generic error resolving the input index) and assert that `ruleExecutionLogger.close()` is invoked.
- [ ] Manual: configure a rule with a `dataViewId` that does not exist, run the rule, and verify its last run shows the error instead of remaining stale.
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent cad8fb1 commit c4510ea
2 files changed
Lines changed: 46 additions & 0 deletions
File tree
- x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_types
- query
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
272 | 275 | | |
273 | 276 | | |
274 | 277 | | |
| |||
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
298 | 341 | | |
0 commit comments