Skip to content

Commit

Permalink
fix: remove length check in pastebinscraper error checking
Browse files Browse the repository at this point in the history
The check for the length is not really useful and does not give a significant performance boost.
  • Loading branch information
d-Rickyy-b committed Jul 5, 2020
1 parent 0f60fba commit c251b34
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pastepwn/scraping/pastebin/pastebinscraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PastebinScraper(BasicScraper):
"""Scraper class for pastebin"""
name = "PastebinScraper"
api_base_url = "https://scrape.pastebin.com"
pastebin_error_pattern = re.compile(r"^YOUR IP: ((\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})|((([0-9A-Fa-f]{1,4}:){7})([0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,6}:)(([0-9A-Fa-f]{1,4}:){0,4})([0-9A-Fa-f]{1,4}))) DOES NOT HAVE ACCESS\.\s+VISIT: https:\/\/pastebin\.com\/doc_scraping_api TO GET ACCESS!")

def __init__(self, paste_queue=None, exception_event=None, api_hit_rate=None):
super().__init__(exception_event)
Expand All @@ -37,9 +38,7 @@ def __init__(self, paste_queue=None, exception_event=None, api_hit_rate=None):

def _check_error(self, body, key=None):
"""Checks if an error occurred and raises an exception if it did"""
pattern = r"^YOUR IP: ((\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})|((([0-9A-Fa-f]{1,4}:){7})([0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,6}:)(([0-9A-Fa-f]{1,4}:){0,4})([0-9A-Fa-f]{1,4}))) DOES NOT HAVE ACCESS\.\s+VISIT: https:\/\/pastebin\.com\/doc_scraping_api TO GET ACCESS!"

if 131 >= len(body) and re.match(pattern, body):
if self.pastebin_error_pattern.match(body):
self._exception_event.set()
raise IPNotRegisteredError(body)

Expand Down

0 comments on commit c251b34

Please sign in to comment.