insightconnect-plugin-runtime 5.5.0__py3-none-any.whl → 5.5.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- insightconnect_plugin_runtime/helper.py +14 -14
- {insightconnect_plugin_runtime-5.5.0.dist-info → insightconnect_plugin_runtime-5.5.2.dist-info}/METADATA +3 -1
- {insightconnect_plugin_runtime-5.5.0.dist-info → insightconnect_plugin_runtime-5.5.2.dist-info}/RECORD +5 -5
- {insightconnect_plugin_runtime-5.5.0.dist-info → insightconnect_plugin_runtime-5.5.2.dist-info}/WHEEL +0 -0
- {insightconnect_plugin_runtime-5.5.0.dist-info → insightconnect_plugin_runtime-5.5.2.dist-info}/top_level.txt +0 -0
|
@@ -10,7 +10,7 @@ import subprocess
|
|
|
10
10
|
import time
|
|
11
11
|
from datetime import datetime, timedelta
|
|
12
12
|
from io import IOBase
|
|
13
|
-
from typing import Any, Callable, Dict, List, Union
|
|
13
|
+
from typing import Any, Callable, Dict, List, Union, Tuple
|
|
14
14
|
from urllib import request
|
|
15
15
|
from hashlib import sha1
|
|
16
16
|
from json import JSONDecodeError
|
|
@@ -31,11 +31,11 @@ ENCODE_TYPE = "utf-8"
|
|
|
31
31
|
DEFAULTS_HOURS_AGO = 24
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
def hash_sha1(log:
|
|
34
|
+
def hash_sha1(log: Dict) -> str:
|
|
35
35
|
"""
|
|
36
36
|
Iterate through a dictionary and hash each value.
|
|
37
37
|
:param log: Dictionary to be hashed.
|
|
38
|
-
:type
|
|
38
|
+
:type Dict:
|
|
39
39
|
:return: Hex digest of hash.
|
|
40
40
|
:rtype: str
|
|
41
41
|
"""
|
|
@@ -47,7 +47,7 @@ def hash_sha1(log: dict) -> str:
|
|
|
47
47
|
|
|
48
48
|
def compare_and_dedupe_hashes(
|
|
49
49
|
previous_logs_hashes: list, new_logs: list
|
|
50
|
-
) ->
|
|
50
|
+
) -> Tuple[list, list]:
|
|
51
51
|
"""
|
|
52
52
|
Iterate through two lists of values, hashing each. Compare hash value to a list of existing hash values.
|
|
53
53
|
If the hash exists, return both it and the value in separate lists once iterated.
|
|
@@ -56,7 +56,7 @@ def compare_and_dedupe_hashes(
|
|
|
56
56
|
:param new_logs: New values to hash and compare to existing list of hashes.
|
|
57
57
|
:type list:
|
|
58
58
|
:return: Hex digest of hash.
|
|
59
|
-
:rtype:
|
|
59
|
+
:rtype: Tuple[list, list]
|
|
60
60
|
"""
|
|
61
61
|
new_logs_hashes = []
|
|
62
62
|
logs_to_return = []
|
|
@@ -75,13 +75,13 @@ def make_request(
|
|
|
75
75
|
_request: requests.Request,
|
|
76
76
|
timeout: int = 60,
|
|
77
77
|
verify: bool = True,
|
|
78
|
-
cert: Union[str,
|
|
78
|
+
cert: Union[str, Tuple]=None,
|
|
79
79
|
stream: bool = False,
|
|
80
80
|
allow_redirects: bool = True,
|
|
81
81
|
exception_custom_configs: Dict[int, Exception]={},
|
|
82
82
|
exception_data_location: str = None,
|
|
83
|
-
allowed_status_codes:
|
|
84
|
-
) ->
|
|
83
|
+
allowed_status_codes: List[str] = [],
|
|
84
|
+
) -> Tuple[requests.Response, Dict]:
|
|
85
85
|
"""
|
|
86
86
|
Makes a HTTP request while checking for RequestErrors and JSONDecodeErrors
|
|
87
87
|
Returns the request response and the response JSON if required.
|
|
@@ -92,7 +92,7 @@ def make_request(
|
|
|
92
92
|
:param verify: Whether to verify the server's TLS certificate
|
|
93
93
|
:type bool:
|
|
94
94
|
:param cert: Certificate to include with request, str location or key/value pair
|
|
95
|
-
:type Union[str,
|
|
95
|
+
:type Union[str, Dict]:
|
|
96
96
|
:param stream: Whether to immediately download the response content
|
|
97
97
|
:type bool:
|
|
98
98
|
:param allow_redirects: Set to true by default
|
|
@@ -102,10 +102,10 @@ def make_request(
|
|
|
102
102
|
:param exception_data_location: Where the returned data should be retrieved. Can provide ResponseExceptionData values.
|
|
103
103
|
:type str:
|
|
104
104
|
:param allowed_status_codes: Status codes that will not raise an exception.
|
|
105
|
-
:type
|
|
105
|
+
:type List[str]:
|
|
106
106
|
|
|
107
107
|
:return: The request response and the response JSON.
|
|
108
|
-
:rtype:
|
|
108
|
+
:rtype: Tuple[Response, Dict]
|
|
109
109
|
"""
|
|
110
110
|
try:
|
|
111
111
|
with requests.Session() as session:
|
|
@@ -139,7 +139,7 @@ def make_request(
|
|
|
139
139
|
return response
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
def extract_json(response: requests.Response) ->
|
|
142
|
+
def extract_json(response: requests.Response) -> Dict:
|
|
143
143
|
"""Extract JSON from a request object while error handling a JSONDecodeError.
|
|
144
144
|
:param response: Response object ot utilize in extract
|
|
145
145
|
:type Response:
|
|
@@ -197,7 +197,7 @@ def response_handler(
|
|
|
197
197
|
response: requests.Response,
|
|
198
198
|
custom_configs: Dict[int, Exception]={},
|
|
199
199
|
data_location: str = None,
|
|
200
|
-
allowed_status_codes:
|
|
200
|
+
allowed_status_codes: List[str] = [],
|
|
201
201
|
) -> None:
|
|
202
202
|
"""
|
|
203
203
|
Check response status codes and return a generic PluginException preset if a HTTPError is raised.
|
|
@@ -210,7 +210,7 @@ def response_handler(
|
|
|
210
210
|
:param data_location: Where the returned data should be retrieved. Can provide ResponseExceptionData values.
|
|
211
211
|
:type str:
|
|
212
212
|
:param allowed_status_codes: Status codes that will not raise an exception.
|
|
213
|
-
:type
|
|
213
|
+
:type List[str]:
|
|
214
214
|
|
|
215
215
|
:return: None.
|
|
216
216
|
:rtype: None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: insightconnect-plugin-runtime
|
|
3
|
-
Version: 5.5.
|
|
3
|
+
Version: 5.5.2
|
|
4
4
|
Summary: InsightConnect Plugin Runtime
|
|
5
5
|
Home-page: https://github.com/rapid7/komand-plugin-sdk-python
|
|
6
6
|
Author: Rapid7 Integrations Alliance
|
|
@@ -211,6 +211,8 @@ contributed. Black is installed as a test dependency and the hook can be initial
|
|
|
211
211
|
after cloning this repository.
|
|
212
212
|
|
|
213
213
|
## Changelog
|
|
214
|
+
* 5.5.2 - Address bug with typing for type `List` in Python 3.8
|
|
215
|
+
* 5.5.1 - Address bug with typing for type `Tuple` in Python 3.8
|
|
214
216
|
* 5.5.0 - Updated helper class to add `make_request`, `response_handler`, `extract_json`, and `request_error_handling` for HTTP requests, and `hash_sha1` and `compare_and_dedupe_hashes` to provide support for hash comparisons | Add `METHOD_NOT_ALLOWED`, `CONFLICT`, `REDIRECT_ERROR`, and `CONNECTION_ERROR` to PluginException presets
|
|
215
217
|
* 5.4.9 - Updated aws_client to clean assume role json object to remove any none or empty string values.
|
|
216
218
|
* 5.4.8 - Address vulnerabilities within `gunicorn` and `idna` python packages.
|
|
@@ -4,7 +4,7 @@ insightconnect_plugin_runtime/cli.py,sha256=Pb-Janu-XfRlSXxPHh30OIquljWptrhhS51C
|
|
|
4
4
|
insightconnect_plugin_runtime/connection.py,sha256=4bHHV2B0UFGsAtvLu1fiYQRwx7fissUakHPUyjLQO0E,2340
|
|
5
5
|
insightconnect_plugin_runtime/dispatcher.py,sha256=ru7njnyyWE1-oD-VbZJ-Z8tELwvDf69rM7Iezs4rbnw,1774
|
|
6
6
|
insightconnect_plugin_runtime/exceptions.py,sha256=7aYNoGgmV6SugHAQqeQYm1zo2LZm0vgXEGqHmYD7NCo,8260
|
|
7
|
-
insightconnect_plugin_runtime/helper.py,sha256=
|
|
7
|
+
insightconnect_plugin_runtime/helper.py,sha256=XlMGpW2LQYo5KjhJeJtaYRCEDDWjrA9ZW1jP9FDpKpE,31155
|
|
8
8
|
insightconnect_plugin_runtime/metrics.py,sha256=hf_Aoufip_s4k4o8Gtzz90ymZthkaT2e5sXh5B4LcF0,3186
|
|
9
9
|
insightconnect_plugin_runtime/plugin.py,sha256=9k01QqEh78OTs0pMRfnwZcRr-vFe7iyAtLz_QBa23e4,24127
|
|
10
10
|
insightconnect_plugin_runtime/schema.py,sha256=jTNc6KAMqFpaDVWrAYhkVC6e8I63P3X7uVlJkAr1hiY,583
|
|
@@ -78,7 +78,7 @@ tests/unit/test_server_spec.py,sha256=je97BaktgK0Fiz3AwFPkcmHzYtOJJNqJV_Fw5hrvqX
|
|
|
78
78
|
tests/unit/test_trigger.py,sha256=E53mAUoVyponWu_4IQZ0IC1gQ9lakBnTn_9vKN2IZfg,1692
|
|
79
79
|
tests/unit/test_variables.py,sha256=OUEOqGYZA3Nd5oKk5GVY3hcrWKHpZpxysBJcO_v5gzs,291
|
|
80
80
|
tests/unit/utils.py,sha256=VooVmfpIgxmglNdtmT32AkEDFxHxyRHLK8RsCWjjYRY,2153
|
|
81
|
-
insightconnect_plugin_runtime-5.5.
|
|
82
|
-
insightconnect_plugin_runtime-5.5.
|
|
83
|
-
insightconnect_plugin_runtime-5.5.
|
|
84
|
-
insightconnect_plugin_runtime-5.5.
|
|
81
|
+
insightconnect_plugin_runtime-5.5.2.dist-info/METADATA,sha256=OHfxHfvU8vRAiFkDevFvTnw39pzjpWuYNkKQWQD9mlE,13636
|
|
82
|
+
insightconnect_plugin_runtime-5.5.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
83
|
+
insightconnect_plugin_runtime-5.5.2.dist-info/top_level.txt,sha256=AJtyJOpiFzHxsbHUICTcUKXyrGQ3tZxhrEHsPjJBvEA,36
|
|
84
|
+
insightconnect_plugin_runtime-5.5.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|