Skip to content

Commit

Permalink
PAPP-33317: ServiceNow - updated pagination logic (#18)
Browse files Browse the repository at this point in the history
* Servicenow: PAPP-29359 Added new action - search sources

* Update README.md

* Adding empty commit

* Minor Changes

* Discarding the changes of connector and const file

* Discarding the changes of connector and const file

* Discarding the changes of connector and const file

* Adding the changes of connector and const file

* targetting static test failure

* updated paginatin logic

* updated copyright version and linting issues

* Update README.md

* empty commit

* updated app version and release note

* Update README.md

* precommit changes

* updated request params in get varaible action

* updated logic for pagination

* linitng changes

* updated linting changes

* Update README.md

* updated pagination logic

* Added pagination for search sources action

* add verbose for search source and updated SERVICENOW_ERROR_FROM_SERVER message

* Update README.md

* Removed limit and page key-value from result and also add result if there is no records

* Checking and breaking the loop if we got 1000 empty pages

* Upodate search sources pagination logic based on pages and use sysparam_query key in get variable action based on API doc

* Revert changes of get_variable action and update min_phantom_version

* Update README.md

* Updated min_phantom_version

* Update README.md

* Update example_values for search sources action

* Update README.md

* Update release notes

* succinct the comments

---------

Co-authored-by: dhwanis-crest <[email protected]>
Co-authored-by: splunk-soar-connectors-admin <admin@splunksoar>
Co-authored-by: mmomin-crest <[email protected]>
  • Loading branch information
4 people authored Jun 25, 2024
1 parent 4fd9111 commit b921589
Show file tree
Hide file tree
Showing 20 changed files with 630 additions and 79 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/phantomcyber/dev-cicd-tools
rev: v1.16
rev: v1.18
hooks:
- id: org-hook
- id: package-app-dependencies
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--no-verify', '--exclude-files', '^servicenow.json$']
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright (c) 2016-2023 Splunk Inc.
Copyright (c) 2016-2024 Splunk Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
14 changes: 1 addition & 13 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
Splunk SOAR ServiceNow
Copyright (c) 2016-2023 Splunk Inc.
Copyright (c) 2016-2024 Splunk Inc.

Third-party Software Attributions:

Library: beautifulsoup4
Version: 4.9.1
License: MIT
Copyright 2004-2017 Leonard Richardson
Copyright 2004-2019 Leonard Richardson
Copyright 2018 Isaac Muse

Library: python-magic
Version: 0.4.18
License: MIT
Expand All @@ -21,8 +14,3 @@ License: MIT
License: Zope
Copyright 1987-2006 implementation only works for dates between
Copyright 2003-2019 Stuart Bishop <[email protected]>

Library: requests
Version: 2.25.0
License: Apache 2.0
Kenneth Reitz
94 changes: 85 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# ServiceNow

Publisher: Splunk
Connector Version: 2.5.0
Connector Version: 2.6.0
Product Vendor: ServiceNow
Product Name: ServiceNow
Product Version Supported (regex): ".\*"
Minimum Product Version: 6.1.0
Minimum Product Version: 6.2.1

This app integrates with ServiceNow to perform investigative and generic actions

Expand Down Expand Up @@ -211,6 +211,7 @@ VARIABLE | REQUIRED | TYPE | DESCRIPTION
[get variables](#action-get-variables) - Get variables for a ticket/record
[run query](#action-run-query) - Gets object data according to the specified query
[query users](#action-query-users) - Gets user data according to the specified query, username, or system ID
[search sources](#action-search-sources) - Search for records across multiple tables
[on poll](#action-on-poll) - Ingest tickets from SNOW

## action: 'test connectivity'
Expand Down Expand Up @@ -302,7 +303,7 @@ action_result.data.\*.depreciated_amount | string | | $0.00
action_result.data.\*.depreciation | string | |
action_result.data.\*.depreciation_date | string | |
action_result.data.\*.description | string | | My computer is not detecting the headphone device. It could be an issue with the USB port.
action_result.data.\*.display_name | string | | SW000077 - Microsoft ASP.NET 2011
action_result.data.\*.display_name | string | | SW000077 Test
action_result.data.\*.disposal_reason | string | |
action_result.data.\*.due | string | |
action_result.data.\*.due_date | string | |
Expand All @@ -329,7 +330,7 @@ action_result.data.\*.location | string | |
action_result.data.\*.made_sla | string | | true
action_result.data.\*.managed_by | string | |
action_result.data.\*.merged_into | string | |
action_result.data.\*.model.display_value | string | | Microsoft ASP.NET 2011
action_result.data.\*.model.display_value | string | | ASP.NET 2011
action_result.data.\*.model.link | string | | https://dev78070.service-now.com/api/now/table/cmdb_model/81bfae3f37601000deeabfc8bcbe5d2d
action_result.data.\*.model_category.display_value | string | | Software License
action_result.data.\*.model_category.link | string | | https://dev78070.service-now.com/api/now/table/cmdb_model_category/35bf2d4137101000deeabfc8bcbe5dbd
Expand Down Expand Up @@ -401,7 +402,7 @@ action_result.data.\*.upon_approval | string | | Proceed to Next Task
action_result.data.\*.upon_reject | string | | Cancel all future Tasks
action_result.data.\*.urgency | string | | 2 - Medium
action_result.data.\*.user_input | string | |
action_result.data.\*.vendor.display_value | string | | Microsoft
action_result.data.\*.vendor.display_value | string | | PRB000050 Test
action_result.data.\*.vendor.link | string | `url` | https://dev78070.service-now.com/api/now/table/core_company/0e8b8e650a0a0b3b004f285ffbb1a4fc
action_result.data.\*.warranty_expiration | string | |
action_result.data.\*.watch_list | string | |
Expand Down Expand Up @@ -1418,7 +1419,7 @@ PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS
DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES
--------- | ---- | -------- | --------------
action_result.status | string | | success failed
action_result.parameter.description | string | | Investigative actions to check for the presence of phapp_servicenow
action_result.parameter.description | string | | Switch occasionally drops connections
action_result.parameter.fields | string | | {"made_sla":true,"severity":3,"description":"This is testing description"}
action_result.parameter.short_description | string | | phapp_servicenow, Multiple action need to be taken
action_result.parameter.table | string | `servicenow table` | incident
Expand Down Expand Up @@ -2258,9 +2259,9 @@ action_result.data.\*.work_end | string | |
action_result.data.\*.work_notes | string | |
action_result.data.\*.work_notes_list | string | |
action_result.data.\*.work_start | string | |
action_result.summary.total_tickets | numeric | | 2 68
action_result.summary.total_tickets | numeric | | 2
action_result.message | string | | Important data: value
summary.total_objects | numeric | | 1 2
summary.total_objects | numeric | | 1
summary.total_objects_successful | numeric | | 1

## action: 'query users'
Expand Down Expand Up @@ -2297,7 +2298,7 @@ action_result.data.\*.date_format | string | |
action_result.data.\*.default_perspective | string | |
action_result.data.\*.department.link | string | `url` | https://dev116432.service-now.com/api/now/table/cmn_department/a581ab703710200044e0bfc8bcbe5de8
action_result.data.\*.department.value | string | `md5` | a581ab703710200044e0bfc8bcbe5de8
action_result.data.\*.email | string | `email` | herman@phantom.us
action_result.data.\*.email | string | `email` | abc@pqr.us
action_result.data.\*.employee_number | string | |
action_result.data.\*.enable_multifactor_authn | string | | false
action_result.data.\*.failed_attempts | string | | 0
Expand Down Expand Up @@ -2349,6 +2350,81 @@ action_result.message | string | | Total tickets: 1
summary.total_objects | numeric | | 1
summary.total_objects_successful | numeric | | 1

## action: 'search sources'
Search for records across multiple tables

Type: **investigate**
Read only: **True**

To find the list of search source IDs for the <b>sysparm_search_sources</b> parameter, follow this path in servicenow UI: All > Workspace Experience > Administration > Search Sources. Once there, click with two fingers/right click on the source name and copy the sys_id.

#### Action Parameters
PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS
--------- | -------- | ----------- | ---- | --------
**sysparm_term** | required | Search record for the given term | string |
**sysparm_search_sources** | required | SYS ID of search sources, Comma-separated list allowed | string | `servicenow ticket sysid`

#### Action Output
DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES
--------- | ---- | -------- | --------------
action_result.status | string | | success failed
action_result.parameter.sysparm_search_sources | string | `servicenow ticket sysid` | tec681c771testfedf0bcbe2c2606c
action_result.parameter.sysparm_term | string | | Resolved
action_result.data.\*.result_count | numeric | |
action_result.data.\*.search_results.\*.fields.\*.label | string | | Number
action_result.data.\*.search_results.\*.fields.\*.label_plural | string | | Numbers
action_result.data.\*.search_results.\*.fields.\*.max_length | numeric | | 40
action_result.data.\*.search_results.\*.fields.\*.name | string | | number
action_result.data.\*.search_results.\*.fields.\*.reference | string | | sys_user_group
action_result.data.\*.search_results.\*.fields.\*.type | string | | string
action_result.data.\*.search_results.\*.label | string | | Problem
action_result.data.\*.search_results.\*.limit | numeric | | 20
action_result.data.\*.search_results.\*.page | numeric | | 1
action_result.data.\*.search_results.\*.query | string | | 123TEXTQUEtest=Fix Applied
action_result.data.\*.search_results.\*.record_count | numeric | |
action_result.data.\*.search_results.\*.records.\*.data.assignment_group.display | string | |
action_result.data.\*.search_results.\*.records.\*.data.assignment_group.value | string | |
action_result.data.\*.search_results.\*.records.\*.data.caller_id.display | string | | System Administrator
action_result.data.\*.search_results.\*.records.\*.data.caller_id.value | string | | 6816f7test016401c5a33be04be441
action_result.data.\*.search_results.\*.records.\*.data.category.display | string | | Inquiry / Help
action_result.data.\*.search_results.\*.records.\*.data.category.value | string | | inquiry
action_result.data.\*.search_results.\*.records.\*.data.cmdb_ci.display | string | |
action_result.data.\*.search_results.\*.records.\*.data.cmdb_ci.value | string | |
action_result.data.\*.search_results.\*.records.\*.data.number.display | string | | INC000001
action_result.data.\*.search_results.\*.records.\*.data.number.value | string | | INC000001
action_result.data.\*.search_results.\*.records.\*.data.opened_at.display | string | | 2023-04-05 00:59:28
action_result.data.\*.search_results.\*.records.\*.data.opened_at.value | string | | 2023-04-05 07:59:28
action_result.data.\*.search_results.\*.records.\*.data.priority.display | string | | 5 - Planning
action_result.data.\*.search_results.\*.records.\*.data.priority.value | string | | 5
action_result.data.\*.search_results.\*.records.\*.data.related_incidents.display | string | | 0
action_result.data.\*.search_results.\*.records.\*.data.related_incidents.value | string | | 0
action_result.data.\*.search_results.\*.records.\*.data.resolution_code.value | string | |
action_result.data.\*.search_results.\*.records.\*.data.state.display | string | | New
action_result.data.\*.search_results.\*.records.\*.data.state.value | string | | 1
action_result.data.\*.search_results.\*.records.\*.data.sys_id.display | string | | c673edctest1106401f1e3f153af11
action_result.data.\*.search_results.\*.records.\*.data.sys_id.value | string | | td673test1106401f1e3f153af11
action_result.data.\*.search_results.\*.records.\*.metadata.description | string | |
action_result.data.\*.search_results.\*.records.\*.metadata.thumbnail_url | string | |
action_result.data.\*.search_results.\*.records.\*.metadata.title | string | | hello
action_result.data.\*.search_results.\*.records.\*.record_class_name | string | | incident
action_result.data.\*.search_results.\*.records.\*.record_url | string | | /incident.do?sys_id=test978221106401f1e99f11&sysparm_view=text_search
action_result.data.\*.search_results.\*.records.\*.sys_id | string | | c673ettest97822119953af11
action_result.data.\*.search_results.\*.records.\*.table | string | | incident
action_result.data.\*.search_results.\*.sys_id | string | | test897862996401f1e3f1990e
action_result.data.\*.search_results.\*.term | string | | Resolved
action_result.data.\*.sources.\*.condition.display | string | |
action_result.data.\*.sources.\*.condition.value | string | |
action_result.data.\*.sources.\*.name.display | string | | Tasks-Tickets
action_result.data.\*.sources.\*.name.value | string | | Tasks-Tickets
action_result.data.\*.sources.\*.source_table | string | | Problem
action_result.data.\*.sources.\*.sys_id | string | `servicenow ticket sysid` | test8699964099f153af0e99
action_result.data.\*.term | string | | Resolved
action_result.summary | string | |
action_result.summary.total_records | numeric | | 1
action_result.message | string | | Total records: 0
summary.total_objects | numeric | | 1
summary.total_objects_successful | numeric | | 1

## action: 'on poll'
Ingest tickets from SNOW

Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# File: __init__.py
#
# Copyright (c) 2016-2023 Splunk Inc.
# Copyright (c) 2016-2024 Splunk Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 2 additions & 0 deletions release_notes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**Unreleased**
* Fixed bug in pagination logic [PAPP-33317]
* Added new 'search sources' action support [PAPP-30131]
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
beautifulsoup4==4.9.1
python-magic==0.4.18
pytz==2021.1
Loading

0 comments on commit b921589

Please sign in to comment.