-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have i been Pwned fix #4185
Have i been Pwned fix #4185
Conversation
# Conflicts: # Integrations/Pwned-V2/CHANGELOG.md
@kirbles19 please review the CHANGELOG.md file please |
@teizenman @ronykoz Done. Please check for technical accuracy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have an integration configuration of a max time for retries. Also retry should try in a loop up to max time.
# Conflicts: # Tests/conf.json
# Conflicts: # Tests/conf.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why aren't you handling the retries inside the http function?
Integrations/Pwned-V2/Pwned-V2.py
Outdated
@@ -33,6 +35,8 @@ | |||
EMAIL_TRUNCATE_VERIFIED_SUFFIX = '?truncateResponse=false&includeUnverified=true' | |||
DOMAIN_TRUNCATE_VERIFIED_SUFFIX = '&truncateResponse=false&includeUnverified=true' | |||
|
|||
retries_end_time = datetime.min |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
global should be upper case
Integrations/Pwned-V2/Pwned-V2.py
Outdated
@@ -48,7 +52,13 @@ def http_request(method, url_suffix, params=None, data=None): | |||
|
|||
if res.status_code == 404: | |||
return None | |||
elif not res.status_code == 200: | |||
elif res.status_code == 429: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for elif
after return
Integrations/Pwned-V2/Pwned-V2.py
Outdated
records_found = False | ||
|
||
md = '### Have I Been Pwned query for ' + query_type.lower() + ': *' + query_arg + '*\n' | ||
|
||
if hibp_res and len(hibp_res) > 0: | ||
if api_res and len(api_res) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both expressions check the same thing
if api_res and len(api_res) > 0: | |
if api_res: |
Integrations/Pwned-V2/Pwned-V2.py
Outdated
verified_breach = 'Verified' if breach['IsVerified'] else 'Unverified' | ||
md += '#### ' + breach['Title'] + ' (' + breach['Domain'] + '): ' + str(breach['PwnCount']) + \ | ||
' records breached [' + verified_breach + ' breach]\n' | ||
md += 'Date: **' + breach['BreachDate'] + '**\n\n' | ||
md += html_description_to_human_readable(breach['Description']) + '\n' | ||
md += 'Data breached: **' + ','.join(breach['DataClasses']) + '**\n' | ||
|
||
if hibp_paste_res and len(hibp_paste_res) > 0: | ||
if api_paste_res and len(api_paste_res) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
Integrations/Pwned-V2/Pwned-V2.py
Outdated
@@ -187,6 +197,29 @@ def domain_to_entry_context(domain, hibp_res): | |||
return comp_domain | |||
|
|||
|
|||
def rate_limit_retry(amount_of_seconds, request_type): | |||
if datetime.now() > retries_end_time: | |||
return_error('Max retry time has exceeded') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return_error('Max retry time has exceeded') | |
return_error('Max retry time has exceeded.') |
Integrations/Pwned-V2/Pwned-V2.py
Outdated
|
||
def retry_needed(api_res, api_paste_res=None): | ||
global retries_end_time | ||
if retries_end_time == datetime.min and not MAX_RETRY_ALLOWED == -1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if retries_end_time == datetime.min and not MAX_RETRY_ALLOWED == -1: | |
if retries_end_time == datetime.min and MAX_RETRY_ALLOWED != -1: |
@kirbles19 I removed the docs-approved label since I added something new that needs to be reviewed. |
@teizenman Done. |
Status
Ready
Related Issues
fixes: https://github.com/demisto/etc/issues/18102
fixes: https://github.com/demisto/etc/issues/18781
Description
Removed 'Mandatory' tag from commands' arguments