diff --git a/plugins/servicenow/.CHECKSUM b/plugins/servicenow/.CHECKSUM index 5db110ee47..86a3b426ba 100644 --- a/plugins/servicenow/.CHECKSUM +++ b/plugins/servicenow/.CHECKSUM @@ -1,7 +1,7 @@ { - "spec": "94a012dce3dbe3d18e71a3e6f59bfcce", - "manifest": "a5b5f251a2c5b6cbc83db3db2022d8b5", - "setup": "c876bdc35376c6287e582200ea7e2761", + "spec": "e23584dc8ec1d9ffd6f301de6609b76a", + "manifest": "85a12a5377d2a993c6666fee3b2acd66", + "setup": "d62b866092d8128bde1fb2e858612947", "schemas": [ { "identifier": "create_ci/schema.py", @@ -21,7 +21,7 @@ }, { "identifier": "get_attachments_for_an_incident/schema.py", - "hash": "b7931b68a7bf9c09e61c2904b8add4e1" + "hash": "2b92dc73a70dcecb1cc718b9d53f68de" }, { "identifier": "get_ci/schema.py", diff --git a/plugins/servicenow/bin/icon_servicenow b/plugins/servicenow/bin/icon_servicenow index 670555ec38..92db79b671 100644 --- a/plugins/servicenow/bin/icon_servicenow +++ b/plugins/servicenow/bin/icon_servicenow @@ -6,7 +6,7 @@ from sys import argv Name = "ServiceNow" Vendor = "rapid7" -Version = "5.2.0" +Version = "6.0.0" Description = "ServiceNow is a tool for managing incidents and configuration management. Using the ServiceNow plugin for Rapid7 InsightConnect, users can manage all aspects of incidents including creation, search, updates, as well as monitor them for changes" diff --git a/plugins/servicenow/help.md b/plugins/servicenow/help.md index 01998529c2..cefe13d627 100644 --- a/plugins/servicenow/help.md +++ b/plugins/servicenow/help.md @@ -70,15 +70,18 @@ Example input: |Name|Type|Required|Description| |----|----|--------|-----------| -|incident_attachments|[]bytes|False|Attachments for a given incident ID| +|incident_attachments|[]attachment_file|False|List of attachments for a given incident ID| Example output: ``` { "incident_attachments": [ - "UmFwaWQ3IEluc2lnaHRDb25uZWN0Cg==", - "cmFwaWQ3" + { + "content": "9de5069c5afe602b2ea0a04b66beb2c0", + "content_type": "text/plain", + "file_name": "example.txt" + } ] } ``` @@ -856,6 +859,7 @@ _This plugin does not contain any troubleshooting information._ # Version History +* 6.0.0 - Add additional file information in output for Get Attachments for an Incident * 5.2.0 - Add new action Get Attachments for an Incident | Add unit test for action Get Attachments for an Incident and Get Incident Attachment * 5.1.1 - Fix output parsing bug in Get Incident Attachment action * 5.1.0 - Add new Incident URL output for Create Incident action diff --git a/plugins/servicenow/icon_servicenow/actions/get_attachments_for_an_incident/action.py b/plugins/servicenow/icon_servicenow/actions/get_attachments_for_an_incident/action.py index a1edc0efbc..dc13acb0da 100755 --- a/plugins/servicenow/icon_servicenow/actions/get_attachments_for_an_incident/action.py +++ b/plugins/servicenow/icon_servicenow/actions/get_attachments_for_an_incident/action.py @@ -21,6 +21,12 @@ def run(self, params={}): attachment = response.get("resource").get("result") attachments = [] for item in attachment: - attachments.append(RequestHelper.get_attachment(self.connection, item.get("sys_id"))) + attachments.append( + { + "file_name": item.get("file_name"), + "content": RequestHelper.get_attachment(self.connection, item.get("sys_id")), + "content_type": item.get("content_type"), + } + ) return {Output.INCIDENT_ATTACHMENTS: attachments} diff --git a/plugins/servicenow/icon_servicenow/actions/get_attachments_for_an_incident/schema.py b/plugins/servicenow/icon_servicenow/actions/get_attachments_for_an_incident/schema.py index d5be58069c..ff5bc612cf 100755 --- a/plugins/servicenow/icon_servicenow/actions/get_attachments_for_an_incident/schema.py +++ b/plugins/servicenow/icon_servicenow/actions/get_attachments_for_an_incident/schema.py @@ -44,14 +44,38 @@ class GetAttachmentsForAnIncidentOutput(insightconnect_plugin_runtime.Output): "incident_attachments": { "type": "array", "title": "Incident Attachments", - "description": "Attachments for a given incident ID", + "description": "List of attachments for a given incident ID", "items": { - "type": "string", - "displayType": "bytes", - "format": "bytes" + "$ref": "#/definitions/attachment_file" }, "order": 1 } + }, + "definitions": { + "attachment_file": { + "type": "object", + "title": "attachment_file", + "properties": { + "content": { + "type": "string", + "title": "Content", + "description": "File content encoded with base64", + "order": 2 + }, + "content_type": { + "type": "string", + "title": "Content Type", + "description": "Content type", + "order": 3 + }, + "file_name": { + "type": "string", + "title": "File Name", + "description": "File name", + "order": 1 + } + } + } } } """) diff --git a/plugins/servicenow/plugin.spec.yaml b/plugins/servicenow/plugin.spec.yaml index 7e48581e94..2bb1e88ccf 100644 --- a/plugins/servicenow/plugin.spec.yaml +++ b/plugins/servicenow/plugin.spec.yaml @@ -4,7 +4,7 @@ products: ["insightconnect"] name: servicenow title: ServiceNow description: ServiceNow is a tool for managing incidents and configuration management. Using the ServiceNow plugin for Rapid7 InsightConnect, users can manage all aspects of incidents including creation, search, updates, as well as monitor them for changes -version: 5.2.0 +version: 6.0.0 supported_versions: ["2020-03-11 Orlando"] vendor: rapid7 support: rapid7 @@ -64,6 +64,22 @@ types: description: Either 'comments' or 'work_notes' type: string required: true + attachment_file: + file_name: + title: File Name + description: File name + type: string + required: false + content: + title: Content + description: File content encoded with base64 + type: string + required: false + content_type: + title: Content Type + description: Content type + type: string + required: false connection: url: title: ServiceNow URL @@ -592,8 +608,8 @@ actions: output: incident_attachments: title: Incident Attachments - description: Attachments for a given incident ID - type: "[]bytes" + description: List of attachments for a given incident ID + type: "[]attachment_file" required: false triggers: incident_changed: diff --git a/plugins/servicenow/setup.py b/plugins/servicenow/setup.py index 6c425dd8db..e79017aa06 100644 --- a/plugins/servicenow/setup.py +++ b/plugins/servicenow/setup.py @@ -3,7 +3,7 @@ setup(name="servicenow-rapid7-plugin", - version="5.2.0", + version="6.0.0", description="ServiceNow is a tool for managing incidents and configuration management. Using the ServiceNow plugin for Rapid7 InsightConnect, users can manage all aspects of incidents including creation, search, updates, as well as monitor them for changes", author="rapid7", author_email="", diff --git a/plugins/servicenow/unit_test/test_get_attachments_for_an_incident.py b/plugins/servicenow/unit_test/test_get_attachments_for_an_incident.py index 9f3a87e298..d882615627 100644 --- a/plugins/servicenow/unit_test/test_get_attachments_for_an_incident.py +++ b/plugins/servicenow/unit_test/test_get_attachments_for_an_incident.py @@ -19,7 +19,15 @@ def setUpClass(cls) -> None: def test_get_attachments_for_an_incident(self, mock_post): actual = self.action.run({Input.INCIDENT_ID: "3072d01d07a552f6d0ea83ef29c936be"}) - expected = {"incident_attachments": ["ImNtRndhV1EzWVhSMFlXTm9iV1Z1ZEhSbGN6ZzNOalF6TWpKMCI="]} + expected = { + "incident_attachments": [ + { + "file_name": "testtattatxt", + "content": "ImNtRndhV1EzWVhSMFlXTm9iV1Z1ZEhSbGN6ZzNOalF6TWpKMCI=", + "content_type": "text/plain (.txt)", + } + ] + } self.assertEqual(actual, expected) @patch("requests.sessions.Session.get", side_effect=Util.mocked_requests) @@ -28,8 +36,16 @@ def test_get_attachments_for_an_incident_many(self, mock_post): expected = { "incident_attachments": [ - "ImNtRndhV1EzWVhSMFlXTm9iV1Z1ZEhSbGN6ZzNOalF6TWpKMCI=", - "ImNtRndhV1EzWVhSMFlXTm9iV1Z1ZEhSbGN6ZzNOalF6TWpKMCI=", + { + "file_name": "testtattatxt", + "content": "ImNtRndhV1EzWVhSMFlXTm9iV1Z1ZEhSbGN6ZzNOalF6TWpKMCI=", + "content_type": "text/plain (.txt)", + }, + { + "file_name": "testtattatxt", + "content": "ImNtRndhV1EzWVhSMFlXTm9iV1Z1ZEhSbGN6ZzNOalF6TWpKMCI=", + "content_type": "text/plain (.txt)", + }, ] } self.assertEqual(actual, expected)