Skip to content

Commit 768ef2e

Browse files
committed
Mimecast v2 - 19380 - Modified status code returned by task when receiving 'Unauthorized Request' and 'token_verification_failed' fail codes | Updated SDK to the latest version (6.3.3)
1 parent aac087c commit 768ef2e

File tree

13 files changed

+61
-35
lines changed

13 files changed

+61
-35
lines changed

plugins/mimecast_v2/.CHECKSUM

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"spec": "6ad9b422f8b11c9ac980823a3bd7178d",
3-
"manifest": "bab588e5111280f4869a5c26f6219e18",
4-
"setup": "8ee045ac750aaf41d76efff6e7a71c3e",
2+
"spec": "57b07496f05cbb9742aadc8103112ecd",
3+
"manifest": "4f1c067e5fecba324ac5fab389574e83",
4+
"setup": "0799e3efcff6bbc45933d0de2038d03c",
55
"schemas": [
66
{
77
"identifier": "connection/schema.py",
8-
"hash": "3253f4b76caee91ee0f0cdc596b64a98"
8+
"hash": "2cf8e41c56e1270adc8e930562bbefff"
99
},
1010
{
1111
"identifier": "monitor_siem_logs/schema.py",
12-
"hash": "0a566c7d94e6689de4d0528d24470b94"
12+
"hash": "88ad3235753c61b1afc346aea3e7caef"
1313
}
1414
]
1515
}

plugins/mimecast_v2/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.2.6 AS builder
1+
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.3.3 AS builder
22

33
WORKDIR /python/src
44

@@ -11,14 +11,15 @@ ADD . /python/src
1111
RUN pip install .
1212
RUN pip uninstall -y setuptools
1313

14-
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.2.6
14+
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.3.3
1515

1616
LABEL organization=rapid7
1717
LABEL sdk=python
1818

1919
WORKDIR /python/src
2020

2121
COPY --from=builder /python/src /python/src
22+
COPY --from=builder /plugin.spec.yaml /plugin.spec.yaml
2223

2324

2425
RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
@@ -30,4 +31,4 @@ RUN rm -rf /root/.cache;
3031
# User to run plugin code. The two supported users are: root, nobody
3132
USER nobody
3233

33-
ENTRYPOINT ["python", "/python/src/bin/icon_mimecast_v2"]
34+
ENTRYPOINT ["python", "/python/src/bin/icon_mimecast_v2"]

plugins/mimecast_v2/bin/icon_mimecast_v2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from sys import argv
66

77
Name = "Mimecast V2"
88
Vendor = "rapid7"
9-
Version = "1.0.4"
9+
Version = "1.0.5"
1010
Description = "[Mimecast](https://www.mimecast.com) is a set of cloud services designed to provide next generation protection against advanced email-borne threats such as malicious URLs, malware, impersonation attacks, as well as internally generated threats, with a focus on email security. This plugin utilizes the [Mimecast API](https://www.mimecast.com/developer/documentation)"
1111

1212

plugins/mimecast_v2/help.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ This task is used to monitor and retrieve the latest logs
6060
|Name|Type|Required|Description|Example|
6161
| :--- | :--- | :--- | :--- | :--- |
6262
|data|[]object|True|List of logs|[{"processingId": "processingId", "aggregateId": "aggregateId", "spamProcessingDetail": "Spam Processing Detail", "numberAttachments": "1", "subject": "siem_recipient - email subject line", "tlsVersion": "TLSv1.2", "senderEnvelope": "[email protected]", "messageId": "messageId", "senderHeader": "[email protected]", "rejectionType": "rejectionType", "eventType": "receipt", "accountId": "C0A0", "recipients": "[email protected]", "tlsCipher": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "action": "Allow", "subType": "Allow", "spamInfo": None, "senderIp": "123.123.123.123", "timestamp": 1689685338597, "direction": "Inbound", "spamScore": "0", "spamDetectionLevel": "0"}]|
63-
63+
6464
Example output:
6565

6666
```
@@ -103,6 +103,7 @@ Example output:
103103

104104
# Version History
105105

106+
* 1.0.5 - `Monitor SIEM Logs` Modified status code returned by task when receiving 'Unauthorized Request' and 'token_verification_failed' fail codes | Updated SDK to the latest version (6.3.3)
106107
* 1.0.4 - `Monitor SIEM Logs` Fix issue where duplicate batches in a page are processed | SDK update to 6.2.6
107108
* 1.0.3 - `Monitor SIEM Logs` Fix issue retrieving logs from larger log files
108109
* 1.0.2 - `Monitor SIEM Logs` Limit the amount of logs used to deduplicate logs in subsequent runs
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
2-

plugins/mimecast_v2/icon_mimecast_v2/connection/schema.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class Input:
99

1010

1111
class ConnectionSchema(insightconnect_plugin_runtime.Input):
12-
schema = json.loads(r"""
12+
schema = json.loads(
13+
r"""
1314
{
1415
"type": "object",
1516
"title": "Variables",
@@ -56,7 +57,8 @@ class ConnectionSchema(insightconnect_plugin_runtime.Input):
5657
}
5758
}
5859
}
59-
""")
60+
"""
61+
)
6062

6163
def __init__(self):
6264
super(self.__class__, self).__init__(self.schema)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
22

33
from .monitor_siem_logs.task import MonitorSiemLogs
4-

plugins/mimecast_v2/icon_mimecast_v2/tasks/monitor_siem_logs/schema.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,30 @@ class Output:
2020

2121

2222
class MonitorSiemLogsInput(insightconnect_plugin_runtime.Input):
23-
schema = json.loads(r"""
23+
schema = json.loads(
24+
r"""
2425
{}
25-
""")
26+
"""
27+
)
2628

2729
def __init__(self):
2830
super(self.__class__, self).__init__(self.schema)
2931

3032

3133
class MonitorSiemLogsState(insightconnect_plugin_runtime.State):
32-
schema = json.loads(r"""
34+
schema = json.loads(
35+
r"""
3336
{}
34-
""")
37+
"""
38+
)
3539

3640
def __init__(self):
3741
super(self.__class__, self).__init__(self.schema)
3842

3943

4044
class MonitorSiemLogsOutput(insightconnect_plugin_runtime.Output):
41-
schema = json.loads(r"""
45+
schema = json.loads(
46+
r"""
4247
{
4348
"type": "array",
4449
"title": "Data",
@@ -49,7 +54,8 @@ class MonitorSiemLogsOutput(insightconnect_plugin_runtime.Output):
4954
],
5055
"definitions": {}
5156
}
52-
""")
57+
"""
58+
)
5359

5460
def __init__(self):
5561
super(self.__class__, self).__init__(self.schema)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
2-

plugins/mimecast_v2/icon_mimecast_v2/util/api.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,35 @@ def make_api_request(
253253
status_code=exception.data.status_code,
254254
)
255255
raise exception
256-
if response.status_code == HTTPStatusCodes.UNAUTHORIZED:
256+
257+
status_code = response.status_code
258+
if status_code != 200:
259+
request_id = response.headers.get("x-request-id")
260+
self.logger.info(
261+
f"API: The status code was different than 200 (status_code = {status_code}). Mimecast API request ID: {request_id}"
262+
)
263+
264+
if status_code == HTTPStatusCodes.UNAUTHORIZED:
257265
json_data = extract_json(response)
258-
if json_data.get("fail", [{}])[0].get("code") == "token_expired":
259-
self.authenticate()
266+
failure_code = json_data.get("fail", [{}])[0].get("code")
267+
268+
# Check if we are dealing with `token_expired` code in error message
269+
if failure_code == "token_expired":
260270
self.logger.info("API: Token has expired, attempting re-authentication...")
271+
self.authenticate()
261272
return self.make_api_request(url, method, headers, json, data, params, return_json, auth)
262-
if response.status_code == HTTPStatusCodes.UNAUTHORIZED:
273+
274+
# Check if we're dealing with `Unauthorized Request` or `token_verification_failed` code in error message
275+
elif failure_code in ("Unauthorized Request", "token_verification_failed"):
276+
self.logger.info(
277+
f"API: Received 'Unauthorized Request' or 'token_verification_failed', setting status code to 500..."
278+
)
279+
status_code = HTTPStatusCodes.INTERNAL_SERVER_ERROR
280+
263281
raise APIException(
264282
preset=PluginException.Preset.API_KEY,
265283
data=response.text,
266-
status_code=response.status_code,
284+
status_code=status_code,
267285
)
268286
if return_json:
269287
json_data = extract_json(response)

plugins/mimecast_v2/plugin.spec.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ links:
1515
- "[Mimecast](http://mimecast.com)"
1616
references:
1717
- "[Mimecast API](https://www.mimecast.com/developer/documentation)"
18-
version: 1.0.4
18+
version: 1.0.5
1919
connection_version: 1
2020
supported_versions: ["Mimecast 2.0 API 2025-01-23"]
2121
vendor: rapid7
2222
support: rapid7
2323
cloud_ready: true
2424
sdk:
2525
type: slim
26-
version: 6.2.6
26+
version: 6.3.3
2727
user: nobody
2828
status: []
2929
resources:
@@ -38,11 +38,12 @@ hub_tags:
3838
keywords: [mimecast, email, cloud_enabled]
3939
features: []
4040
version_history:
41-
- "1.0.4 - `Monitor SIEM Logs` Fix issue where duplicate batches in a page are processed | SDK update to 6.2.6"
42-
- "1.0.3 - `Monitor SIEM Logs` Fix issue retrieving logs from larger log files"
43-
- "1.0.2 - `Monitor SIEM Logs` Limit the amount of logs used to deduplicate logs in subsequent runs"
44-
- "1.0.1 - Update SDK | Improve output for a successful connection test"
45-
- "1.0.0 - Initial plugin"
41+
- "1.0.5 - `Monitor SIEM Logs` Modified status code returned by task when receiving 'Unauthorized Request' and 'token_verification_failed' fail codes | Updated SDK to the latest version (6.3.3)"
42+
- "1.0.4 - `Monitor SIEM Logs` Fix issue where duplicate batches in a page are processed | SDK update to 6.2.6"
43+
- "1.0.3 - `Monitor SIEM Logs` Fix issue retrieving logs from larger log files"
44+
- "1.0.2 - `Monitor SIEM Logs` Limit the amount of logs used to deduplicate logs in subsequent runs"
45+
- "1.0.1 - Update SDK | Improve output for a successful connection test"
46+
- "1.0.0 - Initial plugin"
4647
connection:
4748
client_id:
4849
title: Client ID

plugins/mimecast_v2/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name="mimecast_v2-rapid7-plugin",
7-
version="1.0.4",
7+
version="1.0.5",
88
description="[Mimecast](https://www.mimecast.com) is a set of cloud services designed to provide next generation protection against advanced email-borne threats such as malicious URLs, malware, impersonation attacks, as well as internally generated threats, with a focus on email security. This plugin utilizes the [Mimecast API](https://www.mimecast.com/developer/documentation)",
99
author="rapid7",
1010
author_email="",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
22
import sys
33

4-
sys.path.append("../")
4+
sys.path.append("../")

0 commit comments

Comments
 (0)