Skip to content

Commit 37a971a

Browse files
authored
abnormal_security: allow configuration of a grace period for ai_security_mailbox_not_analyzed (#14235)
The "Not Analyzed" data source may have a delayed availability for messages, with advice from Abnormal Security being that 95% of messages are ready by 60s, but that a 5-10 minute delay would likely be sufficient to account for most messages transitioning from "Not Analyzed" to successfully scanned. Given this range of expectations, provide a mechanism for the user to tune the agent's response. The default behaviour is to retain no grace period, the current behaviour.
1 parent c17a47c commit 37a971a

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

packages/abnormal_security/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "1.8.1"
3+
changes:
4+
- description: Prevent loss of recent unprocessed messages by the `ai_security_mailbox_not_analyzed` data stream.
5+
type: bugfix
6+
link: https://github.com/elastic/integrations/pull/14235
27
- version: "1.8.0"
38
changes:
49
- description: Enrich threat events with attachment and link details.

packages/abnormal_security/data_stream/ai_security_mailbox_not_analyzed/agent/stream/cel.yml.hbs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,30 @@ state:
1818
initial_interval: {{initial_interval}}
1919
access_token: {{access_token}}
2020
want_more: false
21+
{{#if wait_interval}}
22+
wait: {{wait_interval}}
23+
{{/if}}
2124
redact:
2225
fields:
2326
- access_token
2427
program: |
25-
(
26-
state.with({
27-
"start_time": state.?cursor.last_timestamp.orValue((now - duration(state.initial_interval)).format(time_layout.RFC3339)),
28-
"end_time": now.format(time_layout.RFC3339),
29-
})
30-
).as(state, state.with(
28+
{
29+
"start_time": state.?cursor.last_timestamp.optMap(t,
30+
t.parse_time(time_layout.RFC3339)
31+
).orValue(
32+
now - duration(state.initial_interval)
33+
),
34+
"end_time": now - duration(state.?wait.orValue("0s")),
35+
}.as(query_range, state.with(
3136
request(
3237
"GET",
3338
state.url.trim_right("/") + "/v1/abuse_mailbox/not_analyzed?" + {
34-
"start": [state.start_time],
35-
"end": [state.end_time],
39+
// Condition the start of the request interval so that start is never
40+
// after end. Sacrifice a null interval request in the case that the
41+
// last start is still within the wait interval.
42+
// TODO: replace list min with diadic min when stack version is at least v8.18.
43+
"start": [min([query_range.start_time, query_range.end_time]).format(time_layout.RFC3339)],
44+
"end": [query_range.end_time.format(time_layout.RFC3339)],
3645
}.format_query()
3746
).with({
3847
"Header":{
@@ -47,10 +56,14 @@ program: |
4756
}
4857
),
4958
"cursor": {
50-
?"last_timestamp": has(body.results) && body.results.size() > 0 ?
51-
optional.of(body.results.map(r, timestamp(r.reported_datetime)).max().format(time_layout.RFC3339))
59+
"last_timestamp": has(body.results) && body.results.size() > 0 ?
60+
body.results.map(r, timestamp(r.reported_datetime)).max().format(time_layout.RFC3339)
61+
: has(state.?cursor.last_timestamp) ?
62+
state.cursor.last_timestamp
5263
:
53-
state.?cursor.last_timestamp
64+
// If we did not get any messages, keep the start as
65+
// the next cursor.
66+
query_range.start_time
5467
},
5568
}
5669
:

packages/abnormal_security/data_stream/ai_security_mailbox_not_analyzed/manifest.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ streams:
1414
show_user: true
1515
default: 2160h
1616
description: How far back to pull the AI Security Mailbox Not Analyzed messages from Abnormal Security API. Defaults to 90 days (2160h) before end. Supported units for this parameter are h/m/s.
17+
- name: wait_interval
18+
type: text
19+
title: Recent Message Grace Interval
20+
multi: false
21+
required: true
22+
show_user: true
23+
description: How long to wait before attempting to collect recent messages. This option allows the Abnormal Security API to complete analysis of messages before the agent attempts to collect them. This should not be greater than the initial interval. Supported units for this parameter are h/m/s.
1724
- name: interval
1825
type: text
1926
title: Interval

packages/abnormal_security/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format_version: 3.2.1
22
name: abnormal_security
33
title: Abnormal Security
4-
version: "1.8.0"
4+
version: "1.8.1"
55
description: Collect logs from Abnormal Security with Elastic Agent.
66
type: integration
77
categories:

0 commit comments

Comments
 (0)