Skip to content

Commit

Permalink
[Zscaler] isTimeSensitive (demisto#34151)
Browse files Browse the repository at this point in the history
* init

* RN

* update

* updated rn and revert demistomock

* updated is_time_sensitive

* Update Packs/Zscaler/ReleaseNotes/1_3_20.md

Co-authored-by: dorschw <[email protected]>

* Update 1_3_20.md

* timeout

* add debug

* add `time_sensitive` variable

* Update Packs/Zscaler/Integrations/Zscaler/Zscaler.py

Co-authored-by: dorschw <[email protected]>

* Update Packs/Zscaler/Integrations/Zscaler/Zscaler.py

Co-authored-by: dorschw <[email protected]>

---------

Co-authored-by: dorschw <[email protected]>
  • Loading branch information
2 people authored and pal-xmco committed Jun 19, 2024
1 parent d68a60f commit 3e8b73a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
27 changes: 11 additions & 16 deletions Packs/Zscaler/Integrations/Zscaler/Zscaler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import urllib3

import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401

# disable insecure warnings
urllib3.disable_warnings()

""" GLOBAL VARS """
ADD = "ADD_TO_LIST"
Expand All @@ -24,8 +20,6 @@
PROXY = demisto.params().get("proxy", True)
REQUEST_TIMEOUT = int(demisto.params().get("requestTimeout", 15))
DEFAULT_HEADERS = {"content-type": "application/json"}
EXCEEDED_RATE_LIMIT_STATUS_CODE = 429
MAX_SECONDS_TO_WAIT = 100
SESSION_ID_KEY = "session_id"
ERROR_CODES_DICT = {
400: "Invalid or bad request",
Expand Down Expand Up @@ -78,7 +72,7 @@ class AuthorizationError(DemistoException):

def error_handler(res):
"""
Deals with unsuccessfull calls
Deals with unsuccessful calls
"""
if res.status_code in (401, 403):
raise AuthorizationError(res.content)
Expand All @@ -94,23 +88,24 @@ def error_handler(res):
else:
if res.status_code in ERROR_CODES_DICT:
raise Exception(
"Your request failed with the following error: {}.\nMessage: {}".format(
ERROR_CODES_DICT[res.status_code], res.text
)
f"The request failed with the following error: {ERROR_CODES_DICT[res.status_code]}.\nMessage: {res.text}"
)
else:
raise Exception(
"Your request failed with the following error: {}.\nMessage: {}".format(
res.status_code, res.text
)
f"The request failed with the following error: {res.status_code}.\nMessage: {res.text}"
)


def http_request(method, url_suffix, data=None, headers=None, resp_type='json'):
time_sensitive = is_time_sensitive()
demisto.debug(f'{time_sensitive=}')
retries = 0 if time_sensitive else 3
status_list_to_retry = None if time_sensitive else [429]
timeout = 2 if time_sensitive else REQUEST_TIMEOUT
try:
res = generic_http_request(method=method,
server_url=BASE_URL,
timeout=REQUEST_TIMEOUT,
timeout=timeout,
verify=USE_SSL,
proxy=PROXY,
client_headers=DEFAULT_HEADERS,
Expand All @@ -119,8 +114,8 @@ def http_request(method, url_suffix, data=None, headers=None, resp_type='json'):
data=data or {},
ok_codes=(200, 204),
error_handler=error_handler,
retries=3,
status_list_to_retry=[429],
retries=retries,
status_list_to_retry=status_list_to_retry,
resp_type=resp_type)

except Exception as e:
Expand Down
6 changes: 6 additions & 0 deletions Packs/Zscaler/ReleaseNotes/1_3_20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### Zscaler Internet Access

Updated the ***ip*** and ***url*** commands to not retry, and decreased the timeout, when used for auto-enrichment and called with `auto-extract=inline`.
2 changes: 1 addition & 1 deletion Packs/Zscaler/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Zscaler Internet Access",
"description": "Zscaler is a cloud security solution built for performance and flexible scalability.",
"support": "xsoar",
"currentVersion": "1.3.19",
"currentVersion": "1.3.20",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 3e8b73a

Please sign in to comment.