insightconnect-plugin-runtime 6.3.9__tar.gz → 6.4.0__tar.gz
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-6.3.9/insightconnect_plugin_runtime.egg-info → insightconnect_plugin_runtime-6.4.0}/PKG-INFO +6 -4
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/README.md +5 -3
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/connection.py +15 -16
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/telemetry.py +5 -1
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0/insightconnect_plugin_runtime.egg-info}/PKG-INFO +6 -4
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime.egg-info/SOURCES.txt +1 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/setup.py +1 -1
- insightconnect_plugin_runtime-6.4.0/tests/unit/test_connection.py +113 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/MANIFEST.in +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect-plugin-swagger.json +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/action.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/api/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/api/endpoints.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/api/schemas.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/cli.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/clients/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/clients/aws_client.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/clients/oauth.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/data/input_message_schema.json +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/data/output_message_schema.json +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/dispatcher.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/exceptions.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/helper.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/metrics.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/plugin.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/server.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/step.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/task.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/trigger.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/util.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime/variables.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime.egg-info/dependency_links.txt +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime.egg-info/requires.txt +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/insightconnect_plugin_runtime.egg-info/top_level.txt +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/setup.cfg +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/hello/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/hello/action.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/hello/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/return_bad_json/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/return_bad_json/action.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/return_bad_json/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/throw_exception/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/throw_exception/action.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/actions/throw_exception/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/connection/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/connection/connection.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/connection/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/tasks/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/tasks/monitor_events/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/tasks/monitor_events/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/tasks/monitor_events/task.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/hello_trigger/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/hello_trigger/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/hello_trigger/trigger.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/return_bad_json_trigger/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/return_bad_json_trigger/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/return_bad_json_trigger/trigger.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/throw_exception_trigger/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/throw_exception_trigger/schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/triggers/throw_exception_trigger/trigger.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/komand_hello_world/util/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/hello_world/setup.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/tests/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/tests/conftest.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/tests/test_cli.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/tests/test_hello_world.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/hello_world/tests/test_server.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/__init__.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_action.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_api.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_aws_action.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_custom_encoder.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_endpoints.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_exceptions.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_helpers.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_metrics.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_oauth.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_plugin.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_schema.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_server_cloud_plugins.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_server_spec.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_trigger.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_variables.py +0 -0
- {insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: insightconnect-plugin-runtime
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.4.0
|
|
4
4
|
Summary: InsightConnect Plugin Runtime
|
|
5
5
|
Home-page: https://github.com/rapid7/komand-plugin-sdk-python
|
|
6
6
|
Author: Rapid7 Integrations Alliance
|
|
@@ -199,11 +199,11 @@ Running a specific test file:
|
|
|
199
199
|
|
|
200
200
|
| | Plugin | Slim Plugin |
|
|
201
201
|
|:------------------|:-------:|:-----------:|
|
|
202
|
-
| Python Version | 3.
|
|
203
|
-
| OS | Alpine |
|
|
202
|
+
| Python Version | 3.13.9 | 3.13.9 |
|
|
203
|
+
| OS | Alpine | Trixie |
|
|
204
204
|
| Package installer | apk | apt |
|
|
205
205
|
| Shell | /bin/sh | /bin/bash |
|
|
206
|
-
| Image Size | ~
|
|
206
|
+
| Image Size | ~500MB | ~300MB |
|
|
207
207
|
|
|
208
208
|
Note that for the plugin image, we run `apk update` and `apk add ..` which leads to a longer build time.
|
|
209
209
|
|
|
@@ -226,6 +226,8 @@ contributed. Black is installed as a test dependency and the hook can be initial
|
|
|
226
226
|
after cloning this repository.
|
|
227
227
|
|
|
228
228
|
## Changelog
|
|
229
|
+
* 6.4.0 - When running in cloud mode, always create a new connection object | Bump Python version to 3.13.9 | Docker build tidyup to reduce image size
|
|
230
|
+
* 6.3.10 - Fixed tracing name to better allign otel standards
|
|
229
231
|
* 6.3.9 - Fixed `monitor_task_delay` decorator handling of millisecond epoch timestamps | Allow `test_task` connection method to accept task name parameter | Updated base images to Python 3.11.13
|
|
230
232
|
* 6.3.8 - Update exception string representation methods to remove newline characters
|
|
231
233
|
* 6.3.7 - Addressed vulnerability in 'urllib3' (removed from `requirements.txt` as it's a dependency of `botocore`)
|
|
@@ -155,11 +155,11 @@ Running a specific test file:
|
|
|
155
155
|
|
|
156
156
|
| | Plugin | Slim Plugin |
|
|
157
157
|
|:------------------|:-------:|:-----------:|
|
|
158
|
-
| Python Version | 3.
|
|
159
|
-
| OS | Alpine |
|
|
158
|
+
| Python Version | 3.13.9 | 3.13.9 |
|
|
159
|
+
| OS | Alpine | Trixie |
|
|
160
160
|
| Package installer | apk | apt |
|
|
161
161
|
| Shell | /bin/sh | /bin/bash |
|
|
162
|
-
| Image Size | ~
|
|
162
|
+
| Image Size | ~500MB | ~300MB |
|
|
163
163
|
|
|
164
164
|
Note that for the plugin image, we run `apk update` and `apk add ..` which leads to a longer build time.
|
|
165
165
|
|
|
@@ -182,6 +182,8 @@ contributed. Black is installed as a test dependency and the hook can be initial
|
|
|
182
182
|
after cloning this repository.
|
|
183
183
|
|
|
184
184
|
## Changelog
|
|
185
|
+
* 6.4.0 - When running in cloud mode, always create a new connection object | Bump Python version to 3.13.9 | Docker build tidyup to reduce image size
|
|
186
|
+
* 6.3.10 - Fixed tracing name to better allign otel standards
|
|
185
187
|
* 6.3.9 - Fixed `monitor_task_delay` decorator handling of millisecond epoch timestamps | Allow `test_task` connection method to accept task name parameter | Updated base images to Python 3.11.13
|
|
186
188
|
* 6.3.8 - Update exception string representation methods to remove newline characters
|
|
187
189
|
* 6.3.7 - Addressed vulnerability in 'urllib3' (removed from `requirements.txt` as it's a dependency of `botocore`)
|
|
@@ -5,7 +5,7 @@ import json
|
|
|
5
5
|
|
|
6
6
|
from jsonschema import validate
|
|
7
7
|
|
|
8
|
-
from .util import sample as utilsample
|
|
8
|
+
from .util import sample as utilsample, is_running_in_cloud
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def key(parameters):
|
|
@@ -26,28 +26,27 @@ def key(parameters):
|
|
|
26
26
|
class ConnectionCache(object):
|
|
27
27
|
def __init__(self, prototype):
|
|
28
28
|
self.connections = {}
|
|
29
|
-
self.prototype = prototype
|
|
29
|
+
self.prototype = prototype # connection JSON which does not contain a logger or validation on the values
|
|
30
30
|
|
|
31
31
|
def get(self, parameters, logger):
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
# when we're running in cloud mode we don't want to create and store connections to reduce the number
|
|
33
|
+
# of connection objects lying around in memory as this isn't safe and can cause OOM errors.
|
|
34
|
+
if is_running_in_cloud():
|
|
35
|
+
conn = self.create_and_validate_connection(parameters, logger)
|
|
36
|
+
else:
|
|
37
|
+
# first check if we have an existing connection obj we can return as it's been validated already
|
|
38
|
+
conn_key = key(parameters)
|
|
39
|
+
if not (conn := self.connections.get(conn_key)): # otherwise create a new conn obj and save in cache
|
|
40
|
+
conn = self.create_and_validate_connection(parameters, logger)
|
|
41
|
+
self.connections[conn_key] = conn
|
|
42
|
+
return conn
|
|
43
43
|
|
|
44
|
+
def create_and_validate_connection(self, parameters, logger):
|
|
44
45
|
conn = copy.copy(self.prototype)
|
|
45
46
|
conn.logger = logger
|
|
46
47
|
conn.set_(parameters)
|
|
47
|
-
# i don't know why this is needed twice..
|
|
48
|
-
# i think for backwards compat reasons
|
|
49
48
|
conn.connect(parameters)
|
|
50
|
-
|
|
49
|
+
|
|
51
50
|
return conn
|
|
52
51
|
|
|
53
52
|
|
|
@@ -36,7 +36,11 @@ def init_tracing(app: Flask, plugin: Plugin, endpoint: str) -> None:
|
|
|
36
36
|
if not is_running_in_cloud():
|
|
37
37
|
return
|
|
38
38
|
|
|
39
|
-
resource = Resource(
|
|
39
|
+
resource = Resource(
|
|
40
|
+
attributes={
|
|
41
|
+
"service.name": f'pif.{plugin.name.lower().replace(" ", "_")}',
|
|
42
|
+
"service.version": plugin.version,
|
|
43
|
+
})
|
|
40
44
|
|
|
41
45
|
trace_provider = TracerProvider(resource=resource)
|
|
42
46
|
exporter = OTLPSpanExporter(endpoint=endpoint)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: insightconnect-plugin-runtime
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.4.0
|
|
4
4
|
Summary: InsightConnect Plugin Runtime
|
|
5
5
|
Home-page: https://github.com/rapid7/komand-plugin-sdk-python
|
|
6
6
|
Author: Rapid7 Integrations Alliance
|
|
@@ -199,11 +199,11 @@ Running a specific test file:
|
|
|
199
199
|
|
|
200
200
|
| | Plugin | Slim Plugin |
|
|
201
201
|
|:------------------|:-------:|:-----------:|
|
|
202
|
-
| Python Version | 3.
|
|
203
|
-
| OS | Alpine |
|
|
202
|
+
| Python Version | 3.13.9 | 3.13.9 |
|
|
203
|
+
| OS | Alpine | Trixie |
|
|
204
204
|
| Package installer | apk | apt |
|
|
205
205
|
| Shell | /bin/sh | /bin/bash |
|
|
206
|
-
| Image Size | ~
|
|
206
|
+
| Image Size | ~500MB | ~300MB |
|
|
207
207
|
|
|
208
208
|
Note that for the plugin image, we run `apk update` and `apk add ..` which leads to a longer build time.
|
|
209
209
|
|
|
@@ -226,6 +226,8 @@ contributed. Black is installed as a test dependency and the hook can be initial
|
|
|
226
226
|
after cloning this repository.
|
|
227
227
|
|
|
228
228
|
## Changelog
|
|
229
|
+
* 6.4.0 - When running in cloud mode, always create a new connection object | Bump Python version to 3.13.9 | Docker build tidyup to reduce image size
|
|
230
|
+
* 6.3.10 - Fixed tracing name to better allign otel standards
|
|
229
231
|
* 6.3.9 - Fixed `monitor_task_delay` decorator handling of millisecond epoch timestamps | Allow `test_task` connection method to accept task name parameter | Updated base images to Python 3.11.13
|
|
230
232
|
* 6.3.8 - Update exception string representation methods to remove newline characters
|
|
231
233
|
* 6.3.7 - Addressed vulnerability in 'urllib3' (removed from `requirements.txt` as it's a dependency of `botocore`)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
from os import environ
|
|
2
|
+
from unittest import TestCase
|
|
3
|
+
from unittest.mock import patch, MagicMock
|
|
4
|
+
|
|
5
|
+
from insightconnect_plugin_runtime.connection import Connection, ConnectionCache, key
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Any time an action / task / trigger API is called and we route through `plugin.py` -> `start_step`
|
|
9
|
+
the request body, containing the connection JSON is parsed and we make use of the `ConnectionCache` to retrieve
|
|
10
|
+
a connection that has already been validated or we create the new `Connection` object and call the `connect` method
|
|
11
|
+
which should be implemented within the paryicular plugin.
|
|
12
|
+
|
|
13
|
+
These unit test file is testing that the validation, and caching logic works as expected both when running
|
|
14
|
+
on an orchestrator or when running on the cloud. Cloud enabled plugins we do not want to re-use a previously
|
|
15
|
+
validated connection as more customers use the plugin, more and more connection objects can be left on the pod
|
|
16
|
+
which increases the memory usage and instead these should always be freshly created.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class TestCloudConnections(TestCase):
|
|
21
|
+
def setUp(self):
|
|
22
|
+
# Create a sample connection schema that will be validated
|
|
23
|
+
self.connection_schema = {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"username": {"type": "string"},
|
|
27
|
+
},
|
|
28
|
+
"required": ["username"],
|
|
29
|
+
}
|
|
30
|
+
# these initialisations happen during plugin start up
|
|
31
|
+
self.connection = Connection(self.connection_schema)
|
|
32
|
+
self.connection_cache = ConnectionCache(self.connection)
|
|
33
|
+
|
|
34
|
+
self.connection = {
|
|
35
|
+
"username": "test_user@rapid7.com"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
self.logger = MagicMock()
|
|
39
|
+
|
|
40
|
+
def stub_con(self, params):
|
|
41
|
+
# very basic example of what our connections do in plugins
|
|
42
|
+
self.logger.info("Connect: Connecting...")
|
|
43
|
+
self.username = params.get("username")
|
|
44
|
+
|
|
45
|
+
@patch.dict(environ, {"PLUGIN_RUNTIME_ENVIRONMENT": "cloud"})
|
|
46
|
+
@patch.object(Connection, "connect", new=stub_con)
|
|
47
|
+
def test_running_cloud_has_no_cache(self):
|
|
48
|
+
conn = self.connection_cache.get(self.connection, self.logger)
|
|
49
|
+
self.assertEqual(conn.parameters, self.connection)
|
|
50
|
+
self.assertDictEqual(self.connection_cache.connections, {})
|
|
51
|
+
|
|
52
|
+
@patch.dict(environ, {"PLUGIN_RUNTIME_ENVIRONMENT": "cloud"})
|
|
53
|
+
@patch.object(Connection, "connect", new=stub_con)
|
|
54
|
+
def test_running_cloud_has_no_cache_on_subsequent_run(self):
|
|
55
|
+
# call twice and we should still have no connection cache values
|
|
56
|
+
with patch("insightconnect_plugin_runtime.connection.key", MagicMock(side_effect=key)) as stub_key:
|
|
57
|
+
conn = self.connection_cache.get(self.connection, self.logger)
|
|
58
|
+
_ = self.connection_cache.get(self.connection, self.logger)
|
|
59
|
+
self.assertEqual(conn.parameters, self.connection)
|
|
60
|
+
self.assertDictEqual(self.connection_cache.connections, {})
|
|
61
|
+
self.assertEqual(stub_key.call_count, 0) # shouldn't call this at all
|
|
62
|
+
|
|
63
|
+
@patch.object(Connection, "connect", new=stub_con)
|
|
64
|
+
def test_running_onprem_has_cached_connection(self):
|
|
65
|
+
conn = self.connection_cache.get(self.connection, self.logger)
|
|
66
|
+
self.assertEqual(conn.parameters, self.connection)
|
|
67
|
+
self.assertNotEquals(self.connection_cache.connections, {})
|
|
68
|
+
|
|
69
|
+
# the connection cache key should exist
|
|
70
|
+
hashed_key = key(conn.parameters)
|
|
71
|
+
self.assertIn(hashed_key, self.connection_cache.connections)
|
|
72
|
+
self.assertTrue(type(self.connection_cache.connections[hashed_key] == Connection))
|
|
73
|
+
|
|
74
|
+
@patch.object(ConnectionCache, "create_and_validate_connection")
|
|
75
|
+
def test_running_onprem_uses_cache_on_subsequent_calls(self, stub_create):
|
|
76
|
+
with patch("insightconnect_plugin_runtime.connection.key", MagicMock(side_effect=key)) as stub_key:
|
|
77
|
+
# Mock the return value of create_and_validate_connection
|
|
78
|
+
pretend_obj = 'for this unit test pretend this is a conn object'
|
|
79
|
+
stub_create.return_value = pretend_obj
|
|
80
|
+
|
|
81
|
+
# first call the connection cache for the first time adding a new entry
|
|
82
|
+
conn = self.connection_cache.get(self.connection, self.logger)
|
|
83
|
+
self.assertEqual(len(self.connection_cache.connections), 1)
|
|
84
|
+
self.assertEquals(list(self.connection_cache.connections.values())[0], pretend_obj)
|
|
85
|
+
self.assertEquals(conn, pretend_obj)
|
|
86
|
+
self.assertEqual(stub_key.call_count, 1)
|
|
87
|
+
|
|
88
|
+
# on a second call we get the same value but the create_and_validate shouldn't be called again
|
|
89
|
+
conn2 = self.connection_cache.get(self.connection, self.logger)
|
|
90
|
+
self.assertEquals(conn, conn2)
|
|
91
|
+
stub_create.assert_called_once_with(self.connection, self.logger)
|
|
92
|
+
|
|
93
|
+
# on a third call we add a new entry to the cached connections
|
|
94
|
+
new_conn = self.connection.copy()
|
|
95
|
+
new_conn["username"] = "test_user_2@rapid7.com"
|
|
96
|
+
_ = self.connection_cache.get(new_conn, self.logger)
|
|
97
|
+
self.assertEqual(len(self.connection_cache.connections), 2) # new entry added
|
|
98
|
+
|
|
99
|
+
self.assertEqual(stub_key.call_count, 3) # should have been called each time
|
|
100
|
+
|
|
101
|
+
def test_connection_not_implemented_raised(self):
|
|
102
|
+
with self.assertRaises(NotImplementedError): # we haven't stubbed this so the error is expected
|
|
103
|
+
_conn = self.connection_cache.get(self.connection, self.logger)
|
|
104
|
+
|
|
105
|
+
# this means the connection object is not saved in cache
|
|
106
|
+
self.assertEquals(self.connection_cache.connections, {})
|
|
107
|
+
|
|
108
|
+
def test_connection_validation_raised(self):
|
|
109
|
+
with self.assertRaises(Exception): # not the expected input to match the connection schema
|
|
110
|
+
_conn = self.connection_cache.get({"not_expected_key": "value"}, self.logger)
|
|
111
|
+
|
|
112
|
+
# this means the connection object is not saved in cache
|
|
113
|
+
self.assertEquals(self.connection_cache.connections, {})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/__init__.py
RENAMED
|
File without changes
|
{insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/plugin/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_api.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/test_oauth.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{insightconnect_plugin_runtime-6.3.9 → insightconnect_plugin_runtime-6.4.0}/tests/unit/utils.py
RENAMED
|
File without changes
|