Skip to content
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

Open-Url Block - Bug Fix for Over Quota #28465

Merged
merged 4 commits into from May 10, 2019
Merged

Open-Url Block - Bug Fix for Over Quota #28465

merged 4 commits into from May 10, 2019

Conversation

epeach
Copy link

@epeach epeach commented May 10, 2019

Today we went over our quota for the api requests in our Open-Url Block. We requested (and got approved) for doubling our quota through Google Console. However, if this situation happens again, this PR should protect us by classifying responses returned as bad-requests or rate-limits as 'approved' to open. This means the user will receive a message letting them know what site they are going to and the user can make an informed choice.

Screenshot from 2019-03-06 12-04-38

Includes tests

@@ -52,6 +52,8 @@ def self.determine_safe_to_open(url_to_check)

# Safe Browsing API returns empty JSON object is no threat matches found
# Do not determine safe if response is nil
response.nil? ? false : response_value
# Determine safe if bad request (response code is 400) or if rate-limited (429)
error_response = response.nil? ? false : (response.code === '400' || response.code === '429')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is == more appropriate as a comparison operator here instead of ===?
I didn’t even realize Ruby had an === operator, so I had to look up how it’s used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - I just defaulted to JavaScript equality at first. Updated.

@epeach epeach merged commit c0d3467 into staging May 10, 2019
@epeach epeach deleted the open-url-bug-fix branch July 2, 2019 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants