diff --git a/plugins/komand/.CHECKSUM b/plugins/komand/.CHECKSUM index 696d08cfd6..535726f2a7 100644 --- a/plugins/komand/.CHECKSUM +++ b/plugins/komand/.CHECKSUM @@ -1,23 +1,23 @@ { - "spec": "4e786fde1aa6a3442454a650271b5bd0", - "manifest": "4401ae6250c18c56e062c818b1bd86af", - "setup": "61c77e271214ef4b8f913aff446e921e", + "spec": "10457cf131fb240cb5eb30d6d4144c11", + "manifest": "2777097d2933eac28bc56741671f0d99", + "setup": "b25869f305f408eea4c085d1f1d8ae76", "schemas": [ { "identifier": "run_asynchronously/schema.py", - "hash": "53aa3ee3fa5f04ee29b31830f945f0f9" + "hash": "3434ef52dbb8a715d4b24dcd5acb53c3" }, { "identifier": "run_synchronously/schema.py", - "hash": "956dae3d5681164b0c9a3c7f2a76381a" + "hash": "763c1701fdc0520c1434173e6e286c25" }, { "identifier": "connection/schema.py", - "hash": "aa49bcaf442f5e8a84cce13175607d52" + "hash": "820a19f7b96b39d81d0ca8cfa82c66ae" }, { "identifier": "job/schema.py", - "hash": "5c06b56479720ad202fe815b3471de71" + "hash": "443c2fd80fe621788a385924efcad058" } ] } \ No newline at end of file diff --git a/plugins/komand/Dockerfile b/plugins/komand/Dockerfile index 4ba75fb7fb..884f39d63c 100755 --- a/plugins/komand/Dockerfile +++ b/plugins/komand/Dockerfile @@ -1,10 +1,11 @@ -FROM komand/python-3-plugin:2 -# The three supported python parent images are: -# - komand/python-2-plugin -# - komand/python-3-plugin -# - komand/python-pypy3-plugin -# -# Update the tag to a full semver version +FROM rapid7/insightconnect-python-3-38-plugin:5 +LABEL organization=komand +LABEL sdk=python +LABEL type=plugin + +ENV SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt +ENV SSL_CERT_DIR /etc/ssl/certs +ENV REQUESTS_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt # Add any custom package dependencies here # NOTE: Add pip packages to requirements.txt @@ -12,14 +13,17 @@ FROM komand/python-3-plugin:2 # End package dependencies # Add source code -WORKDIR /python/src ADD ./plugin.spec.yaml /plugin.spec.yaml ADD . /python/src +WORKDIR /python/src + # Install pip dependencies RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi # Install plugin RUN python setup.py build && python setup.py install +USER nobody + ENTRYPOINT ["/usr/local/bin/komand_komand"] \ No newline at end of file diff --git a/plugins/komand/bin/komand_komand b/plugins/komand/bin/komand_komand index 87bed6b053..5b1b70a583 100755 --- a/plugins/komand/bin/komand_komand +++ b/plugins/komand/bin/komand_komand @@ -1,34 +1,48 @@ #!/usr/bin/env python # GENERATED BY KOMAND SDK - DO NOT EDIT -import komand -from komand_komand import connection, actions, triggers +import os +import json +from sys import argv +Name = "Komand" +Vendor = "rapid7" +Version = "1.0.4" +Description = "Komand Meta-Actions" -Name = 'Komand' -Vendor = 'rapid7' -Version = '1.0.3' -Description = 'Komand Meta-Actions' - -class ICONKomand(komand.Plugin): - def __init__(self): - super(self.__class__, self).__init__( +def main(): + if 'http' in argv: + if os.environ.get("GUNICORN_CONFIG_FILE"): + with open(os.environ.get("GUNICORN_CONFIG_FILE")) as gf: + gunicorn_cfg = json.load(gf) + if gunicorn_cfg.get("worker_class", "sync") == "gevent": + from gevent import monkey + monkey.patch_all() + elif 'gevent' in argv: + from gevent import monkey + monkey.patch_all() + + import insightconnect_plugin_runtime + from komand_komand import connection, actions, triggers + + class ICONKomand(insightconnect_plugin_runtime.Plugin): + def __init__(self): + super(self.__class__, self).__init__( name=Name, vendor=Vendor, version=Version, description=Description, connection=connection.Connection() - ) - self.add_trigger(triggers.Job()) + ) + self.add_trigger(triggers.Job()) - self.add_action(actions.RunAsynchronously()) + self.add_action(actions.RunAsynchronously()) - self.add_action(actions.RunSynchronously()) + self.add_action(actions.RunSynchronously()) -def main(): """Run plugin""" - cli = komand.CLI(ICONKomand()) + cli = insightconnect_plugin_runtime.CLI(ICONKomand()) cli.run() diff --git a/plugins/komand/help.md b/plugins/komand/help.md index 8a84f18c75..477d8b51f4 100644 --- a/plugins/komand/help.md +++ b/plugins/komand/help.md @@ -12,16 +12,32 @@ The [Komand](komand.com) plugin provides backwards compatibility to run workflow * Username and Password * Komand Server +# Supported Product Versions + +* 2023-05-15 + # Documentation ## Setup The connection configuration accepts the following parameters: -|Name|Type|Default|Required|Description|Enum| -|----|----|-------|--------|-----------|----| -|url|string|None|True|URL to Komand server, e.g. https://komand.company.com|None| -|credentials|credential_username_password|None|True|Username and password for user|None| +|Name|Type|Default|Required|Description|Enum|Example| +|----|----|-------|--------|-----------|----|-------| +|url|string|None|True|URL to Komand server|None|https://komand.company.com| +|credentials|credential_username_password|None|True|Username and password for user|None|{ 'username': 'user1', 'password': 'mypassword' }| + +Example input: + +``` +{ + "credentials": { + "username": "user1", + "password": "mypassword" + }, + "url": "https://komand.company.com" +} +``` ## Technical Details @@ -33,18 +49,37 @@ This action is used to run a workflow without waiting for results. ##### Input -|Name|Type|Default|Required|Description|Enum| -|----|----|-------|--------|-----------|----| -|workflow_uid|string|None|False|Workflow UID to run. Either this or name should be provided.|None| -|input|object|None|False|Input object to supply to the workflow job|None| -|workflow_name|string|None|False|Workflow name to run. Either this or UID should be provided.|None| +|Name|Type|Default|Required|Description|Enum|Example| +|----|----|-------|--------|-----------|----|-------| +|input|object|None|False|Input object to supply to the workflow job|None|{}| +|workflow_name|string|None|False|Workflow name to run. Either this or UID should be provided|None|example-name| +|workflow_uid|string|None|False|Workflow UID to run. Either this or name should be provided|None|b595ccea-f324-11ed-a05b-0242ac120003| + +Example input: + +``` +{ + "input": "{}", + "workflow_name": "example-name", + "workflow_uid": "b595ccea-f324-11ed-a05b-0242ac120003" +} +``` ##### Output -|Name|Type|Required|Description| -|----|----|--------|-----------| -|url|string|False|Job URL| -|job_id|string|False|Job ID| +|Name|Type|Required|Description|Example| +|----|----|--------|-----------|-------| +|url|string|False|Job URL|www.example.com| +|job_id|string|False|Job ID|b595ccea-f324-11ed-a05b-0242ac120003| + +Example output: + +``` +{ + "url": "www.example.com", + "job_id": "b595ccea-f324-11ed-a05b-0242ac120003" +} +``` #### Run Synchronously @@ -52,28 +87,57 @@ This action is used to run a workflow and wait for results. ##### Input -|Name|Type|Default|Required|Description|Enum| -|----|----|-------|--------|-----------|----| -|workflow_uid|string|None|False|Workflow UID to run. Either this or name should be provided|None| -|input|object|None|False|Input object to supply to the workflow job|None| -|workflow_name|string|None|False|Workflow name to run. Either this or UID should be provided|None| -|timeout|number|150|True|Timeout for executed workflow to finish, in seconds. Use 0 for no timeout|None| -|completion_checks|number|10|False|How many times the executed workflow should be checked for completion during the timeout period. Higher numbers should result in quicker job turnover. Leave blank if timeout is set to 0|None| +|Name|Type|Default|Required|Description|Enum|Example| +|----|----|-------|--------|-----------|----|-------| +|completion_checks|number|10|False|How many times the executed workflow should be checked for completion during the timeout period. Higher numbers should result in quicker job turnover. Leave blank if timeout is set to 0|None|10| +|input|object|None|False|Input object to supply to the workflow job|None|{}| +|timeout|number|150|True|Timeout for executed workflow to finish, in seconds. Use 0 for no timeout|None|150| +|workflow_name|string|None|False|Workflow name to run. Either this or UID should be provided|None|example-name| +|workflow_uid|string|None|False|Workflow UID to run. Either this or name should be provided|None|b595ccea-f324-11ed-a05b-0242ac120003| + +Example input: + +``` +{ + "completion_checks": 10, + "input": "{}", + "timeout": 150, + "workflow_name": "example-name", + "workflow_uid": "b595ccea-f324-11ed-a05b-0242ac120003" +} +``` ##### Output -|Name|Type|Required|Description| -|----|----|--------|-----------| -|status|string|False|Job Status| -|ended_at|string|False|None| -|job_id|string|False|Job ID| -|workflow_uid|string|False|Workflow UID| -|created_at|string|False|None| -|updated_at|string|False|None| -|url|string|False|Job URL| -|steps|[]object|False|Step outputs| -|group_id|string|False|Job Group ID| -|name|string|False|None| +|Name|Type|Required|Description|Example| +|----|----|--------|-----------|-------| +|status|string|False|Job Status|failed| +|ended_at|string|False|None|Jan 01, 2000 0:00 AM| +|job_id|string|False|Job ID|b595ccea-f324-11ed-a05b-0242ac120003| +|workflow_uid|string|False|Workflow UID|b595ccea-f324-11ed-a05b-0242ac120003| +|created_at|string|False|Created at|Jan 01, 2000 0:00 AM| +|updated_at|string|False|Updated at|Jan 01, 2000 0:00 AM|', '|ended_at|string|False|Ended at|Jan 01, 2000 0:00 AM| +|url|string|False|Job URL|www.example.com| +|steps|[]object|False|Step outputs|[{}]| +|group_id|string|False|Job Group ID|b595ccea-f324-11ed-a05b-0242ac120003| +|name|string|False|Name|example-name| + +Example output: + +``` +{ + "status": "failed", + "ended_at": "Jan 01, 2000 0:00 AM", + "job_id": "b595ccea-f324-11ed-a05b-0242ac120003", + "workflow_uid": "b595ccea-f324-11ed-a05b-0242ac120003", + "created_at": "Jan 01, 2000 0:00 AM", + "updated_at": "Jan 01, 2000 0:00 AM", + "url": "www.example.com", + "steps": [{}], + "group_id": "b595ccea-f324-11ed-a05b-0242ac120003", + "name": "example-name" +} +``` ### Triggers @@ -83,23 +147,47 @@ This trigger is used to monitor for new jobs. ##### Input -|Name|Type|Default|Required|Description|Enum| -|----|----|-------|--------|-----------|----| -|status|string|None|True|Status to trigger on|['failed', 'queued', 'succeeded', 'retried']| +|Name|Type|Default|Required|Description|Enum|Example| +|----|----|-------|--------|-----------|----|-------| +|status|string|None|True|Status to trigger on|['failed', 'queued', 'succeeded', 'retried']|failed| + +Example input: + +``` +{ + "status": "failed" +} +``` ##### Output -|Name|Type|Required|Description| -|----|----|--------|-----------| -|status|string|False|Job Status| -|ended_at|string|False|None| -|job_id|string|False|Job ID| -|workflow_uid|string|False|Workflow UID| -|created_at|string|False|None| -|updated_at|string|False|None| -|url|string|False|Job URL| -|group_id|string|False|Job Group ID| -|name|string|False|None| +|Name|Type|Required|Description|Example| +|----|----|--------|-----------|-------| +|status|string|False|Job status|succeeded| +|ended_at|string|False|Ended at|Jan 01, 2000 0:00 AM| +|job_id|string|False|Job ID|b595ccea-f324-11ed-a05b-0242ac120003| +|workflow_uid|string|False|Workflow UID|b595ccea-f324-11ed-a05b-0242ac120003| +|created_at|string|False|Created at|Jan 01, 2000 0:00 AM| +|updated_at|string|False|Updated at|Jan 01, 2000 0:00 AM| +|url|string|False|Job URL|www.example.com| +|group_id|string|False|Job group ID|b595ccea-f324-11ed-a05b-0242ac120003| +|name|string|False|Name|example-name| + +Example output: + +``` +{ + "status": "failed", + "ended_at": "Jan 01, 2000 0:00 AM", + "job_id": "b595ccea-f324-11ed-a05b-0242ac120003", + "workflow_uid": "b595ccea-f324-11ed-a05b-0242ac120003", + "created_at": "Jan 01, 2000 0:00 AM", + "updated_at": "Jan 01, 2000 0:00 AM", + "url": "www.example.com", + "group_id": "b595ccea-f324-11ed-a05b-0242ac120003", + "name": "example-name" +} +``` ### Custom Output Types @@ -111,6 +199,7 @@ _This plugin does not contain any troubleshooting information._ # Version History +* 1.0.4 - Deprecate Komand plugin as it is no longer supported * 1.0.3 - New spec and help.md format for the Extension Library * 1.0.2 - Add `utilities` plugin tag for Marketplace searchability * 1.0.1 - Fix issue where Lookup Workflow Name can crash due to excessive data @@ -124,7 +213,6 @@ _This plugin does not contain any troubleshooting information._ # Links -## References - * [Komand](https://www.komand.com/) +## References diff --git a/plugins/komand/komand_komand/actions/run_asynchronously/action.py b/plugins/komand/komand_komand/actions/run_asynchronously/action.py index 550a3d24ef..0073cd0b72 100755 --- a/plugins/komand/komand_komand/actions/run_asynchronously/action.py +++ b/plugins/komand/komand_komand/actions/run_asynchronously/action.py @@ -1,11 +1,12 @@ -import komand +import insightconnect_plugin_runtime from .schema import RunAsynchronouslyInput, RunAsynchronouslyOutput +from insightconnect_plugin_runtime.exceptions import PluginException # Custom imports below import requests -class RunAsynchronously(komand.Action): +class RunAsynchronously(insightconnect_plugin_runtime.Action): def __init__(self): super(self.__class__, self).__init__( name="run_asynchronously", @@ -21,15 +22,19 @@ def run(self, params={}): if not uid: uid = self.connection.lookup_workflow_name(params["workflow_name"]) if not uid: - raise Exception("invalid workflow name provided") + raise PluginException( + cause="Invalid workflow name provided", assistance="Please provide a valid workflow name" + ) url = self.connection.credentials.base_url + "/v2/workflows/" + uid + "/events" - r = self.connection.session().post(url, json=params["input"]) + response = self.connection.session().post(url, json=params["input"]) - if r.status_code != requests.codes.ok: - raise Exception("Failure to create job, bad request code: " + str(r.status_code) + str("text")) + if response.status_code != requests.codes.ok: + raise PluginException( + cause="Failure to create job", assistane=f"Response: {str(response.status_code) + str(response.text)}" + ) - job = r.json() + job = response.json() return {"job_id": job["job_id"], "url": job["job_url"]} def test(self): diff --git a/plugins/komand/komand_komand/actions/run_asynchronously/schema.py b/plugins/komand/komand_komand/actions/run_asynchronously/schema.py index c0bf8faa01..f077800e53 100755 --- a/plugins/komand/komand_komand/actions/run_asynchronously/schema.py +++ b/plugins/komand/komand_komand/actions/run_asynchronously/schema.py @@ -1,5 +1,5 @@ # GENERATED BY KOMAND SDK - DO NOT EDIT -import komand +import insightconnect_plugin_runtime import json @@ -18,7 +18,7 @@ class Output: URL = "url" -class RunAsynchronouslyInput(komand.Input): +class RunAsynchronouslyInput(insightconnect_plugin_runtime.Input): schema = json.loads(""" { "type": "object", @@ -50,7 +50,7 @@ def __init__(self): super(self.__class__, self).__init__(self.schema) -class RunAsynchronouslyOutput(komand.Output): +class RunAsynchronouslyOutput(insightconnect_plugin_runtime.Output): schema = json.loads(""" { "type": "object", diff --git a/plugins/komand/komand_komand/actions/run_synchronously/action.py b/plugins/komand/komand_komand/actions/run_synchronously/action.py index 4d99ab6ae8..6ca42baf7d 100755 --- a/plugins/komand/komand_komand/actions/run_synchronously/action.py +++ b/plugins/komand/komand_komand/actions/run_synchronously/action.py @@ -1,12 +1,13 @@ -import komand +import insightconnect_plugin_runtime from .schema import RunSynchronouslyInput, RunSynchronouslyOutput +from insightconnect_plugin_runtime.exceptions import PluginException # Custom imports below import requests import time -class RunSynchronously(komand.Action): +class RunSynchronously(insightconnect_plugin_runtime.Action): def __init__(self): super(self.__class__, self).__init__( name="run_synchronously", @@ -27,24 +28,27 @@ def run(self, params={}): if not uid: uid = self.connection.lookup_workflow_name(params["workflow_name"]) if not uid: - raise Exception("invalid workflow name provided") + raise PluginException( + cause="Invalid workflow name provided", assistance="Please provide a valid workflow name" + ) # Execute workflow url = self.connection.credentials.base_url + "/v2/workflows/" + uid + "/events" - r = self.connection.session().post(url, json=params["input"]) + response = self.connection.session().post(url, json=params["input"]) # Check status code of executed workflow - if r.status_code != requests.codes.ok: - raise Exception("Failure to create job, bad request code: " + str(r.status_code) + str(r.text)) - - job = r.json() + if response.status_code != requests.codes.ok: + raise PluginException( + cause="Failure to create job", assistane=f"Response: {str(response.status_code) + str(response.text)}" + ) + job = response.json() # Try/except here in case of API changes try: uid = job["job_id"] job_url = job["job_url"] except KeyError: - raise Exception("Failed to get job ID and/or URL from asynchronous job") + raise PluginException(cause="Failed to get job ID and/or URL from asynchronous job") else: job = self.connection.get_job(uid) @@ -63,17 +67,17 @@ def run(self, params={}): count = 0 while job["status"] not in done_statuses: - self.logger.info("Current job status: %s" % job["status"]) + self.logger.info(f"Current job status: {job.get('status')}") count += 1 - if (count > completion_checks) and (timeout is not 0): - raise Exception("Timeout waiting for job: %s" + job["job_id"]) + if (count > completion_checks) and (timeout != 0): + raise PluginException(cause="Timeout waiting for job", assistance=f"Job ID: {job.get('job_id')}") time.sleep(check_interval) job = self.connection.get_job(uid) if not job: - raise Exception("No job found: " + uid) + raise PluginException(cause="No job found", assistance=f"ID: {uid}") job["url"] = job_url return job @@ -81,7 +85,7 @@ def run(self, params={}): @staticmethod def get_check_interval(timeout, completion_checks): """Determines amount of seconds to sleep given total timeout period and amount of checks to make""" - if timeout is 0: + if timeout == 0: return 5 else: return timeout / completion_checks diff --git a/plugins/komand/komand_komand/actions/run_synchronously/schema.py b/plugins/komand/komand_komand/actions/run_synchronously/schema.py index 34ecc70005..a21227115b 100755 --- a/plugins/komand/komand_komand/actions/run_synchronously/schema.py +++ b/plugins/komand/komand_komand/actions/run_synchronously/schema.py @@ -1,5 +1,5 @@ # GENERATED BY KOMAND SDK - DO NOT EDIT -import komand +import insightconnect_plugin_runtime import json @@ -28,7 +28,7 @@ class Output: WORKFLOW_UID = "workflow_uid" -class RunSynchronouslyInput(komand.Input): +class RunSynchronouslyInput(insightconnect_plugin_runtime.Input): schema = json.loads(""" { "type": "object", @@ -77,7 +77,7 @@ def __init__(self): super(self.__class__, self).__init__(self.schema) -class RunSynchronouslyOutput(komand.Output): +class RunSynchronouslyOutput(insightconnect_plugin_runtime.Output): schema = json.loads(""" { "type": "object", diff --git a/plugins/komand/komand_komand/connection/connection.py b/plugins/komand/komand_komand/connection/connection.py index d698f24802..db2abd93c9 100755 --- a/plugins/komand/komand_komand/connection/connection.py +++ b/plugins/komand/komand_komand/connection/connection.py @@ -1,5 +1,6 @@ -import komand +import insightconnect_plugin_runtime from .schema import ConnectionSchema +from insightconnect_plugin_runtime.exceptions import PluginException # Custom import below import requests @@ -12,7 +13,7 @@ def __init__(self, base_url, username, password): self.password = password -class Connection(komand.Connection): +class Connection(insightconnect_plugin_runtime.Connection): def __init__(self): super(self.__class__, self).__init__(input=ConnectionSchema()) self.credentials = None @@ -20,34 +21,35 @@ def __init__(self): def get_job(self, uid): self.logger.debug("fetching job: %s", uid) url = self.credentials.base_url + "/v2/jobs/" + uid - r = self.session().get(url) - if r.status_code != requests.codes.ok: - self.logger.error("Failure to get job bad status code : " + str(r.status_code) + str(r.text)) + response = self.session().get(url) + if response.status_code != requests.codes.ok: + self.logger.error("Failure to get job bad status code : " + str(response.status_code) + str(response.text)) return None - job = r.json() + job = response.json() return job def lookup_workflow_name(self, name): url = self.credentials.base_url + "/v2/workflows?status=active&minimum=true" - r = self.session().get(url) + response = self.session().get(url) - if r.status_code != requests.codes.ok: - raise Exception("Bad request code: " + str(r.status_code) + str(r.text)) + if response.status_code != requests.codes.ok: + raise PluginException( + cause="Unexpected Error", assistane=f"Response: {str(response.status_code) + str(response.text)}" + ) + workflows = response.json()["workflows"] - workflows = r.json()["workflows"] - - for w in workflows: - if w["name"] == name: - return w["workflow_uid"] + for workflow in workflows: + if workflow["name"] == name: + return workflow["workflow_uid"] return None def _get_session_token(self): """Obtains a session token via /sessions endpoint using user credentials""" - self.logger.info("Getting session token for user %s" % self.credentials.username) + self.logger.info("Getting session token for user...") url = self.credentials.base_url + "/v2/sessions" auth_payload = { @@ -55,13 +57,13 @@ def _get_session_token(self): "user_secret": self.credentials.password, } - auth_response = requests.post(url=url, json=auth_payload) + auth_response = requests.post(url=url, json=auth_payload) # nosec bandit: B113 auth_response.raise_for_status() try: token = auth_response.json()["token"] - except KeyError as e: - self.logger.error("Error obtaining session token: %s" % e) + except KeyError as error: + self.logger.error(f"Error obtaining session token: {error}") else: self.logger.info("Got token!") return token diff --git a/plugins/komand/komand_komand/connection/schema.py b/plugins/komand/komand_komand/connection/schema.py index f085fdeb7e..39e4140ae8 100755 --- a/plugins/komand/komand_komand/connection/schema.py +++ b/plugins/komand/komand_komand/connection/schema.py @@ -1,5 +1,5 @@ # GENERATED BY KOMAND SDK - DO NOT EDIT -import komand +import insightconnect_plugin_runtime import json @@ -8,7 +8,7 @@ class Input: URL = "url" -class ConnectionSchema(komand.Input): +class ConnectionSchema(insightconnect_plugin_runtime.Input): schema = json.loads(""" { "type": "object", @@ -23,7 +23,7 @@ class ConnectionSchema(komand.Input): "url": { "type": "string", "title": "URL", - "description": "URL to Komand server, e.g. https://komand.company.com", + "description": "URL to Komand server", "order": 1 } }, @@ -43,12 +43,14 @@ class ConnectionSchema(komand.Input): "title": "Password", "displayType": "password", "description": "The password", - "format": "password" + "format": "password", + "order": 2 }, "username": { "type": "string", "title": "Username", - "description": "The username to log in with" + "description": "The username to log in with", + "order": 1 } }, "required": [ diff --git a/plugins/komand/komand_komand/triggers/job/schema.py b/plugins/komand/komand_komand/triggers/job/schema.py index 138597a945..ef50cbed2c 100755 --- a/plugins/komand/komand_komand/triggers/job/schema.py +++ b/plugins/komand/komand_komand/triggers/job/schema.py @@ -1,5 +1,5 @@ # GENERATED BY KOMAND SDK - DO NOT EDIT -import komand +import insightconnect_plugin_runtime import json @@ -25,7 +25,7 @@ class Output: WORKFLOW_UID = "workflow_uid" -class JobInput(komand.Input): +class JobInput(insightconnect_plugin_runtime.Input): schema = json.loads(""" { "type": "object", @@ -54,7 +54,7 @@ def __init__(self): super(self.__class__, self).__init__(self.schema) -class JobOutput(komand.Output): +class JobOutput(insightconnect_plugin_runtime.Output): schema = json.loads(""" { "type": "object", diff --git a/plugins/komand/komand_komand/triggers/job/trigger.py b/plugins/komand/komand_komand/triggers/job/trigger.py index bdcc4c835c..972fc905dc 100755 --- a/plugins/komand/komand_komand/triggers/job/trigger.py +++ b/plugins/komand/komand_komand/triggers/job/trigger.py @@ -1,9 +1,9 @@ -import komand +import insightconnect_plugin_runtime from .schema import JobInput, JobOutput import time -class Job(komand.Trigger): +class Job(insightconnect_plugin_runtime.Trigger): def __init__(self): super(self.__class__, self).__init__( name="job", description="Trigger on new jobs", input=JobInput(), output=JobOutput() @@ -32,7 +32,7 @@ def poll(self, init=False): last_job_id = "" - self.logger.info("Looking for messages from id=%s with status=%s", self.last_job_id, self.status) + self.logger.info(f"Looking for messages from id={self.last_job_id} with status={self.status}") for job in jobs: diff --git a/plugins/komand/plugin.spec.yaml b/plugins/komand/plugin.spec.yaml index 976cda47ac..61a7d33927 100644 --- a/plugins/komand/plugin.spec.yaml +++ b/plugins/komand/plugin.spec.yaml @@ -4,10 +4,11 @@ products: [insightconnect] name: komand title: Komand description: Komand Meta-Actions -version: 1.0.3 +version: 1.0.4 +supported_versions: ["2023-05-15"] vendor: rapid7 support: community -status: [] +status: [obsolete] resources: source_url: https://github.com/rapid7/insightconnect-plugins/tree/master/plugins/komand license_url: https://github.com/rapid7/insightconnect-plugins/blob/master/LICENSE @@ -24,13 +25,15 @@ connection: url: title: URL type: string - description: URL to Komand server, e.g. https://komand.company.com + description: URL to Komand server required: true + example: https://komand.company.com credentials: title: Username and Password type: credential_username_password description: Username and password for user required: true + example: "{ 'username': 'user1', 'password': 'mypassword' }" triggers: job: title: Job @@ -46,52 +49,62 @@ triggers: - succeeded - retried required: true + example: failed output: status: title: Status type: string description: Job status required: false + example: succeeded job_id: title: Job ID type: string description: Job ID required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 group_id: title: Group ID type: string description: Job group ID required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 workflow_uid: title: Workflow UID type: string description: Workflow UID required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 name: title: Name type: string description: Name required: false + example: example-name created_at: title: Created At type: string description: Created at required: false + example: Jan 01, 2000 0:00 AM updated_at: title: Updated At type: string description: Updated at required: false + example: Jan 01, 2000 0:00 AM ended_at: title: Ended At type: string description: Ended at required: false + example: Jan 01, 2000 0:00 AM url: title: URL type: string description: Job URL required: false + example: www.example.com actions: run_asynchronously: title: Run Asynchronously @@ -102,27 +115,32 @@ actions: type: string description: Workflow name to run. Either this or UID should be provided required: false + example: example-name workflow_uid: title: Workflow UID type: string description: Workflow UID to run. Either this or name should be provided required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 input: title: Input type: object description: Input object to supply to the workflow job required: false + example: "{}" output: job_id: title: Job ID type: string description: Job ID required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 url: title: URL type: string description: Job URL required: false + example: www.example.com run_synchronously: title: Run Synchronously description: Run a workflow and wait for results @@ -132,11 +150,13 @@ actions: type: string description: Workflow name to run. Either this or UID should be provided required: false + example: example-name workflow_uid: title: Workflow UID type: string description: Workflow UID to run. Either this or name should be provided required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 timeout: title: Timeout type: number @@ -144,6 +164,7 @@ actions: no timeout required: true default: 150 + example: 150 completion_checks: title: Completion Checks description: How many times the executed workflow should be checked for completion @@ -152,59 +173,71 @@ actions: type: number default: 10 required: false + example: 10 input: title: Input type: object description: Input object to supply to the workflow job required: false + example: "{}" output: status: title: Status type: string description: Job Status required: false + example: failed job_id: title: Job ID type: string description: Job ID required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 group_id: title: Group ID type: string description: Job Group ID required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 workflow_uid: title: Workflow UID type: string description: Workflow UID required: false + example: b595ccea-f324-11ed-a05b-0242ac120003 name: title: Name type: string description: Name required: false + example: example-name steps: title: Steps description: Step outputs type: '[]object' required: false + example: "[{}]" created_at: title: Created At type: string description: Created at required: false + example: Jan 01, 2000 0:00 AM updated_at: title: Updated At type: string description: Updated at required: false + example: Jan 01, 2000 0:00 AM ended_at: title: Ended At type: string description: Ended at required: false + example: Jan 01, 2000 0:00 AM url: title: URL type: string description: Job URL required: false + example: www.example.com diff --git a/plugins/komand/requirements.txt b/plugins/komand/requirements.txt index 6434bfb394..73334e1fb6 100755 --- a/plugins/komand/requirements.txt +++ b/plugins/komand/requirements.txt @@ -1,4 +1,4 @@ # List third-party dependencies here, separated by newlines. # All dependencies must be version-pinned, eg. requests==1.2.0 # See: https://pip.pypa.io/en/stable/user_guide/#requirements-files -requests==2.19.1 +requests==2.20.0 diff --git a/plugins/komand/setup.py b/plugins/komand/setup.py index 5e8bcacb9a..90176d8c46 100755 --- a/plugins/komand/setup.py +++ b/plugins/komand/setup.py @@ -2,13 +2,13 @@ from setuptools import setup, find_packages -setup(name='komand-rapid7-plugin', - version='1.0.3', - description='Komand Meta-Actions', - author='rapid7', - author_email='', - url='', +setup(name="komand-rapid7-plugin", + version="1.0.4", + description="Komand Meta-Actions", + author="rapid7", + author_email="", + url="", packages=find_packages(), - install_requires=['komand'], # Add third-party dependencies to requirements.txt, not here! + install_requires=['insightconnect-plugin-runtime'], # Add third-party dependencies to requirements.txt, not here! scripts=['bin/komand_komand'] )