Skip to content

Commit

Permalink
PAPP-30822: Updated requests modules (#12)
Browse files Browse the repository at this point in the history
* Updated requests modules

* Update README.md

* updated copyright right version and constant names for static failures

* updated json data

* updated notice file

* pre-commit chnages

* empty commit

* updated release notes

* empty commit

* empty commit to trigger pipelines

---------

Co-authored-by: splunk-soar-connectors-admin <admin@splunksoar>
Co-authored-by: hardik-crest <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2023
1 parent e681481 commit d5de11c
Show file tree
Hide file tree
Showing 18 changed files with 288 additions and 327 deletions.
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) 2014-2022 Splunk Inc.
Copyright (c) 2014-2023 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.
7 changes: 1 addition & 6 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Splunk SOAR Cisco ISE
Copyright (c) 2014-2022 Splunk Inc.
Copyright (c) 2014-2023 Splunk Inc.

Third-party Software Attributions:

Expand All @@ -8,11 +8,6 @@ Version: 1.3.4
License: ISC
Copyright 2012-2016 Nicola Iarocci

Library: requests
Version: 2.25.0
License: Apache 2.0
Kenneth Reitz

Library: xmltodict
Version: 0.12.0
License: MIT
Expand Down
480 changes: 243 additions & 237 deletions README.md

Large diffs are not rendered by default.

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) 2014-2022 Splunk Inc.
# Copyright (c) 2014-2023 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
48 changes: 4 additions & 44 deletions ciscoise.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"publisher": "Splunk",
"type": "network security",
"main_module": "ciscoise_connector.py",
"app_version": "3.0.1",
"app_version": "3.0.2",
"utctime_updated": "2022-03-11T04:16:56.000000Z",
"package_name": "phantom_ciscoise",
"product_vendor": "Cisco Systems",
Expand All @@ -14,7 +14,7 @@
"min_phantom_version": "5.1.0",
"logo": "logo_cisco.svg",
"logo_dark": "logo_cisco_dark.svg",
"license": "Copyright (c) 2014-2022 Splunk Inc.",
"license": "Copyright (c) 2014-2023 Splunk Inc.",
"python_version": "3",
"fips_compliant": true,
"latest_tested_version": [
Expand Down Expand Up @@ -1903,30 +1903,10 @@
"module": "Cerberus",
"input_file": "wheels/py3/Cerberus-1.3.4-py3-none-any.whl"
},
{
"module": "certifi",
"input_file": "wheels/shared/certifi-2021.10.8-py2.py3-none-any.whl"
},
{
"module": "chardet",
"input_file": "wheels/shared/chardet-3.0.4-py2.py3-none-any.whl"
},
{
"module": "idna",
"input_file": "wheels/shared/idna-2.10-py2.py3-none-any.whl"
},
{
"module": "requests",
"input_file": "wheels/shared/requests-2.25.0-py2.py3-none-any.whl"
},
{
"module": "setuptools",
"input_file": "wheels/py3/setuptools-59.6.0-py3-none-any.whl"
},
{
"module": "urllib3",
"input_file": "wheels/shared/urllib3-1.26.8-py2.py3-none-any.whl"
},
{
"module": "xmltodict",
"input_file": "wheels/shared/xmltodict-0.12.0-py2.py3-none-any.whl"
Expand All @@ -1939,34 +1919,14 @@
"module": "Cerberus",
"input_file": "wheels/py3/Cerberus-1.3.4-py3-none-any.whl"
},
{
"module": "certifi",
"input_file": "wheels/shared/certifi-2021.10.8-py2.py3-none-any.whl"
},
{
"module": "chardet",
"input_file": "wheels/shared/chardet-3.0.4-py2.py3-none-any.whl"
},
{
"module": "idna",
"input_file": "wheels/shared/idna-2.10-py2.py3-none-any.whl"
},
{
"module": "requests",
"input_file": "wheels/shared/requests-2.25.0-py2.py3-none-any.whl"
},
{
"module": "setuptools",
"input_file": "wheels/py3/setuptools-60.8.2-py3-none-any.whl"
},
{
"module": "urllib3",
"input_file": "wheels/shared/urllib3-1.26.8-py2.py3-none-any.whl"
"input_file": "wheels/py3/setuptools-69.0.2-py3-none-any.whl"
},
{
"module": "xmltodict",
"input_file": "wheels/shared/xmltodict-0.12.0-py2.py3-none-any.whl"
}
]
}
}
}
38 changes: 19 additions & 19 deletions ciscoise_connector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# File: ciscoise_connector.py
#
# Copyright (c) 2014-2022 Splunk Inc.
# Copyright (c) 2014-2023 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 Expand Up @@ -87,11 +87,11 @@ def _validate_integers(self, action_result, parameter, key, allow_zero=False):
if parameter is not None:
try:
if not float(parameter).is_integer():
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_INVALID_PARAM.format(key)), None
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_INVALID_PARAM.format(key)), None
parameter = int(parameter)

except Exception:
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_INVALID_PARAM.format(key)), None
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_INVALID_PARAM.format(key)), None

if parameter < 0:
return action_result.set_status(phantom.APP_ERROR,
Expand Down Expand Up @@ -132,7 +132,7 @@ def _call_ers_api(self, endpoint, action_result, data=None, allow_unknown=True,
request_func = getattr(requests, method)
except AttributeError as e:
self.debug_print("Exception occurred: {}".format(e))
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_REST_API, e), ret_data
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_REST_API, e), ret_data
try:
headers = {"Content-Type": "application/json", "ACCEPT": "application/json"}
resp = request_func( # nosemgrep: python.requests.best-practice.use-timeout.use-timeout
Expand All @@ -144,7 +144,7 @@ def _call_ers_api(self, endpoint, action_result, data=None, allow_unknown=True,
)
except Exception as e:
self.debug_print("Exception occurred: {}".format(e))
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_REST_API, e), ret_data
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_REST_API, e), ret_data

if not (200 <= resp.status_code < 399):
error_message = resp.text
Expand All @@ -156,7 +156,7 @@ def _call_ers_api(self, endpoint, action_result, data=None, allow_unknown=True,
return (
action_result.set_status(
phantom.APP_ERROR,
CISCOISE_ERR_REST_API_ERR_CODE,
CISCOISE_REST_API_ERROR_CODE,
code=resp.status_code,
message=error_message
),
Expand Down Expand Up @@ -190,13 +190,13 @@ def _call_rest_api(self, endpoint, action_result, schema=None, data=None, allow_
auth=self._auth)
except Exception as e:
self.debug_print("Exception occurred: {}".format(e))
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_REST_API, e), ret_data
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_REST_API, e), ret_data

if resp.status_code != 200:
return (
action_result.set_status(
phantom.APP_ERROR,
CISCOISE_ERR_REST_API_ERR_CODE,
CISCOISE_REST_API_ERROR_CODE,
code=resp.status_code,
message=resp.text,
),
Expand All @@ -210,14 +210,14 @@ def _call_rest_api(self, endpoint, action_result, schema=None, data=None, allow_
response_dict = xmltodict.parse(xml)
except Exception as e:
self.debug_print("Exception occurred: {}".format(e))
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_UNABLE_TO_PARSE_REPLY, e), ret_data
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_UNABLE_TO_PARSE_REPLY, e), ret_data

ret_data = response_dict

if schema is not None:
v = Validator(schema, allow_unknown=allow_unknown)
if v.validate(ret_data) is False:
action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_UNABLE_TO_PARSE_REPLY)
action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_UNABLE_TO_PARSE_REPLY)
action_result.append_to_message(v.errors)
return action_result.get_status(), ret_data

Expand Down Expand Up @@ -372,15 +372,15 @@ def _logoff_system(self, param):
remote_coa = ret_data.get("remoteCoA")

if remote_coa is None:
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_PARSE_REPLY)
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_PARSE_REPLY)

result = remote_coa.get("results")

if result is None:
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_PARSE_REPLY)
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_PARSE_REPLY)

if result == "false":
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_LOGOFF_SYSTEM)
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_LOGOFF_SYSTEM)

return action_result.set_status(phantom.APP_SUCCESS)

Expand Down Expand Up @@ -412,15 +412,15 @@ def _terminate_session(self, param):
remote_coa = ret_data.get("remoteCoA")

if remote_coa is None:
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_PARSE_REPLY)
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_PARSE_REPLY)

result = remote_coa.get("results")

if result is None:
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_PARSE_REPLY)
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_PARSE_REPLY)

if result == "false":
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_TERMINATE_SESSION)
return action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_TERMINATE_SESSION)

return action_result.set_status(phantom.APP_SUCCESS, CISCOISE_SUCC_SESSION_TERMINATED)

Expand Down Expand Up @@ -602,7 +602,7 @@ def _handle_policy_change(self, action_result, param, change_type="apply"):
payload["OperationAdditionalData"]["additionalData"][0]["name"] = "ipAddress"
else:
return (
action_result.set_status(phantom.APP_ERROR, CISCOISE_ERR_MAC_AND_IP_NOT_SPECIFIED),
action_result.set_status(phantom.APP_ERROR, CISCOISE_ERROR_MAC_AND_IP_NOT_SPECIFIED),
ret_data,
)

Expand Down Expand Up @@ -708,14 +708,14 @@ def _test_connectivity_to_device(self, base_url, verify=True):
verify=verify)
except Exception as e:
self.debug_print("Exception is test connectivity: {}".format(e))
return self.set_status_save_progress(phantom.APP_ERROR, CISCOISE_ERR_TEST_CONNECTIVITY_FAILED)
return self.set_status_save_progress(phantom.APP_ERROR, CISCOISE_ERROR_TEST_CONNECTIVITY_FAILED)

if resp.status_code == 200:
return self.set_status_save_progress(phantom.APP_SUCCESS, CISCOISE_SUCC_TEST_CONNECTIVITY_PASSED)
else:
return self.set_status_save_progress(
phantom.APP_ERROR,
CISCOISE_ERR_TEST_CONNECTIVITY_FAILED_ERR_CODE,
CISCOISE_TEST_CONNECTIVITY_FAILED_ERROR_CODE,
code=resp.status_code
)

Expand Down
24 changes: 12 additions & 12 deletions ciscoise_consts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# File: ciscoise_consts.py
#
# Copyright (c) 2014-2022 Splunk Inc.
# Copyright (c) 2014-2023 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 Expand Up @@ -33,22 +33,22 @@
ERS_POLICIES = ":9060/ers/config/ancpolicy"

# Error/Success
CISCOISE_ERR_TEST_CONNECTIVITY_FAILED = "Test connectivity failed"
CISCOISE_ERR_TEST_CONNECTIVITY_FAILED_ERR_CODE = "Test connectivity failed with status code: '{code}'"
CISCOISE_ERROR_TEST_CONNECTIVITY_FAILED = "Test connectivity failed"
CISCOISE_TEST_CONNECTIVITY_FAILED_ERROR_CODE = "Test connectivity failed with status code: '{code}'"
CISCOISE_SUCC_TEST_CONNECTIVITY_PASSED = "Test connectivity passed"
CISCOISE_ERR_REST_API = "REST Api error"
CISCOISE_ERR_REST_API_ERR_CODE = "REST Api error with status code: {code}, Message from server: {message}"
CISCOISE_ERR_UNABLE_TO_PARSE_REPLY = "Parsing error, Unable to convert xml reply to json"
CISCOISE_ERROR_REST_API = "REST Api error"
CISCOISE_REST_API_ERROR_CODE = "REST Api error with status code: {code}, Message from server: {message}"
CISCOISE_ERROR_UNABLE_TO_PARSE_REPLY = "Parsing error, Unable to convert xml reply to json"
CISCOISE_SUCC_SESSION_TERMINATED = "Session terminated"
CISCOISE_ERR_PARSE_REPLY = "Error parsing reply"
CISCOISE_ERR_TERMINATE_SESSION = "Session termination failed. Session possibly not found"
CISCOISE_ERR_LOGOFF_SYSTEM = "System Logoff failed"
CISCOISE_ERR_MAC_AND_IP_NOT_SPECIFIED = "Please specify a valid mac or ip address to execute action"
CISCOISE_ERR_ACTION_FAILED = "Action failed with error code: {error_code}"
CISCOISE_ERROR_PARSE_REPLY = "Error parsing reply"
CISCOISE_ERROR_TERMINATE_SESSION = "Session termination failed. Session possibly not found"
CISCOISE_ERROR_LOGOFF_SYSTEM = "System Logoff failed"
CISCOISE_ERROR_MAC_AND_IP_NOT_SPECIFIED = "Please specify a valid mac or ip address to execute action"
CISCOISE_ERROR_ACTION_FAILED = "Action failed with error code: {error_code}"
CISCOISE_SUCC_LIST_ENDPOINTS = "{0} Endpoints found"
CISCOISE_SUCC_GET_ENDPOINT = "Endpoint found"
CISCOISE_SUCC_UPDATE_ENDPOINT = "Endpoint updated"
CISCOISE_ERR_INVALID_PARAM = "Please provide a non-zero positive integer in {param}"
CISCOISE_ERROR_INVALID_PARAM = "Please provide a non-zero positive integer in {param}"
CISCOISE_MAP_IP_ABSENT_ERROR = "Please provide either mac address or ip address"
CISCOISE_ERS_CRED_MISSING = "ERS credentials in asset configuration are required for this action"
DEFAULT_MAX_RESULTS = 7
Expand Down
8 changes: 4 additions & 4 deletions manual_readme_content.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[comment]: # " File: README.md"
[comment]: # " Copyright (c) 2014-2022 Splunk Inc."
[comment]: # " Copyright (c) 2014-2023 Splunk Inc."
[comment]: # ""
[comment]: # " SPLUNK CONFIDENTIAL - Use or disclosure of this material in whole or in part"
[comment]: # " without a valid written license from Splunk Inc. is PROHIBITED."
Expand Down Expand Up @@ -82,7 +82,7 @@
"name": "guestUser",
"guestInfo": {
"userName": "DS3ewdsa34wWE",
"password": "asdlkj324ew",
"password": "asdlkj324ew", # pragma: allowlist secret
"enabled": true
},
"guestAccessInfo": {
Expand Down Expand Up @@ -110,7 +110,7 @@
"enabled": true,
"password": "*******",
"changePassword": true,
"passwordIDStore": "Internal Users"
"passwordIDStore": "Internal Users" # pragma: allowlist secret
}
}
Expand Down Expand Up @@ -140,7 +140,7 @@
"pushIdSupport": false
},
"tacacsSettings": {
"sharedSecret": "aaa"
"sharedSecret": "aaa" # pragma: allowlist secret
},
"profileName": "Cisco",
"NetworkDeviceIPList": [
Expand Down
1 change: 1 addition & 0 deletions release_notes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**Unreleased**
* Updated requests and certifi dependencies in order to use platform packages [PAPP-30822,PAPP-31096]
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Cerberus==1.3.4
requests==2.25.0
xmltodict==0.12.0
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[flake8]
max-line-length = 145
max-complexity = 28
ignore = F403,E128,E126,E111,E121,E127,E731,E201,E202,F405,E722,D,W292
extend-ignore = F403,E128,E126,E111,E121,E127,E731,E201,E202,F405,E722,D,W292

[isort]
line_length = 145
Binary file removed wheels/py3/setuptools-60.8.2-py3-none-any.whl
Binary file not shown.
Binary file added wheels/py3/setuptools-69.0.2-py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file removed wheels/shared/chardet-3.0.4-py2.py3-none-any.whl
Binary file not shown.
Binary file removed wheels/shared/idna-2.10-py2.py3-none-any.whl
Binary file not shown.
Binary file removed wheels/shared/requests-2.25.0-py2.py3-none-any.whl
Binary file not shown.
Binary file removed wheels/shared/urllib3-1.26.8-py2.py3-none-any.whl
Binary file not shown.

0 comments on commit d5de11c

Please sign in to comment.