From 024fa2b7a5da64f311c9024998f9b72a28ca64ab Mon Sep 17 00:00:00 2001 From: ewilson-r7 Date: Mon, 19 Aug 2024 10:10:23 -0500 Subject: [PATCH] Initial Commit --- plugins/servicenow/.CHECKSUM | 8 ++++---- plugins/servicenow/bin/icon_servicenow | 2 +- plugins/servicenow/help.md | 3 +++ .../icon_servicenow/triggers/incident_changed/schema.py | 9 ++++++++- .../icon_servicenow/triggers/incident_changed/trigger.py | 5 +++-- plugins/servicenow/plugin.spec.yaml | 8 +++++++- plugins/servicenow/setup.py | 2 +- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/plugins/servicenow/.CHECKSUM b/plugins/servicenow/.CHECKSUM index 3bc65bc03c..3b3b26f0e6 100644 --- a/plugins/servicenow/.CHECKSUM +++ b/plugins/servicenow/.CHECKSUM @@ -1,7 +1,7 @@ { - "spec": "66383258e1872c8d7b97cb41c187f941", - "manifest": "3ae96f8b5579d7015c7ae616b98b942d", - "setup": "229c0103ca254f7cd51ca66efe73a79f", + "spec": "555158aefe9c8370012d317cde054eae", + "manifest": "9a5dd37917d235d9bfd40117f7e252dd", + "setup": "3cbd58d6404d01885426d768a8feea72", "schemas": [ { "identifier": "create_change_request/schema.py", @@ -109,7 +109,7 @@ }, { "identifier": "incident_changed/schema.py", - "hash": "b1827c050539a2e013a2d3d7d221d657" + "hash": "7aaa8b786a0ae6920053b440d5616ff4" }, { "identifier": "incident_created/schema.py", diff --git a/plugins/servicenow/bin/icon_servicenow b/plugins/servicenow/bin/icon_servicenow index 95bee336d9..01ba80e6a3 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 = "8.0.1" +Version = "9.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 cbd4a8dde0..6265bc71ae 100644 --- a/plugins/servicenow/help.md +++ b/plugins/servicenow/help.md @@ -1471,6 +1471,7 @@ This trigger is used to reports changes of the given fields in the given Inciden | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | |interval|integer|5|False|How often to detect changes to the given Incident (in minutes)|None|5|None|None| |monitored_fields|string|None|True|Comma-separated list of fields to be monitored (e.g. resolved,resolved_by)|None|resolved,resolved_by|None|None| +|query|string|None|None|Non-encoded query string (e.g. number=INC0000055^ORshort_description=New bug)|None|number=INC0000055^ORshort_description=New bug|None|None| |system_ids|[]string|None|False|List of system IDs of the incident records to monitor|None|["9de5069c5afe602b2ea0a04b66beb2c0"]|None|None| Example input: @@ -1479,6 +1480,7 @@ Example input: { "interval": 5, "monitored_fields": "resolved,resolved_by", + "query": "number=INC0000055^ORshort_description=New bug", "system_ids": [ "9de5069c5afe602b2ea0a04b66beb2c0" ] @@ -1686,6 +1688,7 @@ Example output: # Version History +* 9.0.0 - Add new input for Incident Changed Trigger * 8.0.1 - Update Setuptool to version 70.0.0 | Update SDK to version 6.0.0 * 8.0.0 - `Incident Created, Vulnerability Updated`: Updated triggers to allow users to check a list of system_ids or all of them * 7.4.1 - `Incident Created`: Resolved issue related to trigger not working. Updated SDK diff --git a/plugins/servicenow/icon_servicenow/triggers/incident_changed/schema.py b/plugins/servicenow/icon_servicenow/triggers/incident_changed/schema.py index 19d1365f98..9a9d7fc66c 100644 --- a/plugins/servicenow/icon_servicenow/triggers/incident_changed/schema.py +++ b/plugins/servicenow/icon_servicenow/triggers/incident_changed/schema.py @@ -10,6 +10,7 @@ class Component: class Input: INTERVAL = "interval" MONITORED_FIELDS = "monitored_fields" + QUERY = "query" SYSTEM_IDS = "system_ids" @@ -29,7 +30,7 @@ class IncidentChangedInput(insightconnect_plugin_runtime.Input): "title": "Interval", "description": "How often to detect changes to the given Incident (in minutes)", "default": 5, - "order": 3 + "order": 4 }, "monitored_fields": { "type": "string", @@ -37,6 +38,12 @@ class IncidentChangedInput(insightconnect_plugin_runtime.Input): "description": "Comma-separated list of fields to be monitored (e.g. resolved,resolved_by)", "order": 2 }, + "query": { + "type": "string", + "title": "Query", + "description": "Non-encoded query string (e.g. number=INC0000055^ORshort_description=New bug)", + "order": 3 + }, "system_ids": { "type": "array", "title": "System IDs", diff --git a/plugins/servicenow/icon_servicenow/triggers/incident_changed/trigger.py b/plugins/servicenow/icon_servicenow/triggers/incident_changed/trigger.py index a22448a587..a7572682c4 100644 --- a/plugins/servicenow/icon_servicenow/triggers/incident_changed/trigger.py +++ b/plugins/servicenow/icon_servicenow/triggers/incident_changed/trigger.py @@ -21,15 +21,16 @@ def run(self, params={}): interval = params.get(Input.INTERVAL, 5) monitored_fields = params.get(Input.MONITORED_FIELDS, "") system_ids = params.get(Input.SYSTEM_IDS, []) + query = params.get(Input.QUERY, "") # END INPUT BINDING - DO NOT REMOVE # Initial pull of all the incidents with conversion generators to dict. # We need to store all of them in memory for the comparison. - previous_incidents = dict(self.get_all_incidents(monitored_fields, system_ids=system_ids)) + previous_incidents = dict(self.get_all_incidents(monitored_fields, system_ids=system_ids, query=query)) while True: # Pull all the incidents - current_incidents = self.get_all_incidents(monitored_fields, system_ids=system_ids) + current_incidents = self.get_all_incidents(monitored_fields, system_ids=system_ids, query=query) # Compare previous and new incident results. Using dict to speed up compute time. # After comparison the previous_incidents variable is being updated to current_incidents diff --git a/plugins/servicenow/plugin.spec.yaml b/plugins/servicenow/plugin.spec.yaml index a0eb0be8cb..e4f8b957db 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: 8.0.1 +version: 9.0.0 connection_version: 8 supported_versions: ["2023-10-28 Tokyo"] vendor: rapid7 @@ -45,6 +45,7 @@ references: - "[ServiceNow Operators](https://docs.servicenow.com/bundle/quebec-platform-user-interface/page/use/common-ui-elements/reference/r_OpAvailableFiltersQueries.html)" - "[ServiceNow Plugin Setup Guide](https://docs.rapid7.com/insightconnect/servicenow)" version_history: + - "9.0.0 - Add new input for Incident Changed Trigger" - "8.0.1 - Update Setuptool to version 70.0.0 | Update SDK to version 6.0.0" - "8.0.0 - `Incident Created, Vulnerability Updated`: Updated triggers to allow users to check a list of system_ids or all of them" - "7.4.1 - `Incident Created`: Resolved issue related to trigger not working. Updated SDK" @@ -1489,6 +1490,11 @@ triggers: type: string required: true example: resolved,resolved_by + query: + title: Query + description: Non-encoded query string (e.g. number=INC0000055^ORshort_description=New bug) + type: string + example: number=INC0000055^ORshort_description=New bug interval: title: Interval description: How often to detect changes to the given Incident (in minutes) diff --git a/plugins/servicenow/setup.py b/plugins/servicenow/setup.py index 736641182a..bed5705e26 100644 --- a/plugins/servicenow/setup.py +++ b/plugins/servicenow/setup.py @@ -3,7 +3,7 @@ setup(name="servicenow-rapid7-plugin", - version="8.0.1", + version="9.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="",