Skip to content

Commit 0a84ae1

Browse files
authored
mimecast: Handle empty events in a time window inside threat events. (#12937)
Mimecast threat events return fail message containing `err_threat_intel_feed_no_result_found` when no events within the query time window. Handle this by saving empty events array and not report error.
1 parent 236d1d1 commit 0a84ae1

File tree

5 files changed

+116
-5
lines changed

5 files changed

+116
-5
lines changed

packages/mimecast/_dev/deploy/docker/files/config.yml

+78
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ rules:
745745
headers:
746746
Content-Type:
747747
- "application/json"
748+
X-Mc-Threat-Feed-Next-Token:
749+
- nextnexttoken
748750
body: |
749751
{{ minify_json `
750752
{
@@ -815,6 +817,43 @@ rules:
815817
]
816818
}
817819
`}}
820+
- path: /api/ttp/threat-intel/get-feed
821+
methods: ["POST"]
822+
request_body: /"feedType":"malware_customer","fileType":"stix","token":"nextnexttoken"/
823+
request_headers:
824+
authorization: ["Bearer topsecretaccesstokenthatshouldnotbeleakedforabit"]
825+
responses:
826+
- status_code: 200
827+
headers:
828+
Content-Type:
829+
- "application/json"
830+
body: |
831+
{{ minify_json `
832+
{
833+
"meta": {
834+
"status": 200
835+
},
836+
"data": [],
837+
"fail": [
838+
{
839+
"key": {
840+
"start": "2025-02-01T01:00:00+0000",
841+
"end": "2025-02-01T01:00:01+0000",
842+
"fileType": "stix",
843+
"feedType": "malware_customer",
844+
"compress": false
845+
},
846+
"errors": [
847+
{
848+
"code": "err_threat_intel_feed_no_result_found",
849+
"message": "No results found for threat intel feed.",
850+
"retryable": false
851+
}
852+
]
853+
}
854+
]
855+
}
856+
`}}
818857
819858
- path: /api/ttp/threat-intel/get-feed
820859
methods: ["POST"]
@@ -899,6 +938,8 @@ rules:
899938
headers:
900939
Content-Type:
901940
- "application/json"
941+
X-Mc-Threat-Feed-Next-Token:
942+
- nextnexttoken
902943
body: |
903944
{{ minify_json `
904945
{
@@ -969,6 +1010,43 @@ rules:
9691010
]
9701011
}
9711012
`}}
1013+
- path: /api/ttp/threat-intel/get-feed
1014+
methods: ["POST"]
1015+
request_body: /"feedType":"malware_grid","fileType":"stix","token":"nextnexttoken"/
1016+
request_headers:
1017+
authorization: ["Bearer topsecretaccesstokenthatshouldnotbeleakedforabit"]
1018+
responses:
1019+
- status_code: 200
1020+
headers:
1021+
Content-Type:
1022+
- "application/json"
1023+
body: |
1024+
{{ minify_json `
1025+
{
1026+
"meta": {
1027+
"status": 200
1028+
},
1029+
"data": [],
1030+
"fail": [
1031+
{
1032+
"key": {
1033+
"start": "2025-02-01T01:00:00+0000",
1034+
"end": "2025-02-01T01:00:01+0000",
1035+
"fileType": "stix",
1036+
"feedType": "malware_customer",
1037+
"compress": false
1038+
},
1039+
"errors": [
1040+
{
1041+
"code": "err_threat_intel_feed_no_result_found",
1042+
"message": "No results found for threat intel feed.",
1043+
"retryable": false
1044+
}
1045+
]
1046+
}
1047+
]
1048+
}
1049+
`}}
9721050
9731051
- path: /api/ttp/attachment/get-logs
9741052
methods: ["POST"]

packages/mimecast/changelog.yml

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "2.6.2"
3+
changes:
4+
- description: Handle empty events within a time window inside threat events.
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/12937
27
- version: "2.6.1"
38
changes:
49
- description: Prevent pageToken from incorrectly reappearing in interval requests in multiple data streams.

packages/mimecast/data_stream/threat_intel_malware_customer/agent/stream/cel.yml.hbs

+16-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,23 @@ program: |
107107
},
108108
"want_more": resp.?Header["X-Mc-Threat-Feed-Next-Token"].hasValue(),
109109
}
110+
: (body.?fail[0].errors[0].code.orValue("") == "err_threat_intel_feed_no_result_found") ?
111+
// Mimecast threat events return fail message
112+
// containing 'err_threat_intel_feed_no_result_found'
113+
// when no events within the query time window.
114+
// Handle this by saving empty events array but
115+
// do not report an error.
116+
{
117+
"events": [],
118+
// Override cursor to remove cursor.token if present.
119+
"cursor": {
120+
"last": state.?cursor.last,
121+
},
122+
"want_more": false,
123+
}
110124
:
111-
// Mimecast can return failure states with a 200. This
112-
// is detected by a non-empty fail array at the root
125+
// Mimecast can also return other failure states with a 200.
126+
// This is detected by a non-empty fail array at the root
113127
// of the response body. Don't attempt to parse this
114128
// out, just dump the whole body into the error message.
115129
{

packages/mimecast/data_stream/threat_intel_malware_grid/agent/stream/cel.yml.hbs

+16-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,23 @@ program: |
107107
},
108108
"want_more": resp.?Header["X-Mc-Threat-Feed-Next-Token"].hasValue(),
109109
}
110+
: (body.?fail[0].errors[0].code.orValue("") == "err_threat_intel_feed_no_result_found") ?
111+
// Mimecast threat events return fail message
112+
// containing 'err_threat_intel_feed_no_result_found'
113+
// when no events within the query time window.
114+
// Handle this by saving empty events array but
115+
// do not report an error.
116+
{
117+
"events": [],
118+
// Override cursor to remove cursor.token if present.
119+
"cursor": {
120+
"last": state.?cursor.last,
121+
},
122+
"want_more": false,
123+
}
110124
:
111-
// Mimecast can return failure states with a 200. This
112-
// is detected by a non-empty fail array at the root
125+
// Mimecast can also return other failure states with a 200.
126+
// This is detected by a non-empty fail array at the root
113127
// of the response body. Don't attempt to parse this
114128
// out, just dump the whole body into the error message.
115129
{

packages/mimecast/manifest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format_version: "3.0.2"
22
name: mimecast
33
title: "Mimecast"
4-
version: "2.6.1"
4+
version: "2.6.2"
55
description: Collect logs from Mimecast with Elastic Agent.
66
type: integration
77
categories: ["security", "email_security"]

0 commit comments

Comments
 (0)