Skip to content

Commit

Permalink
When skip checks is true ignore whitelisted hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
marcwickenden committed Oct 5, 2023
1 parent 09124fb commit 70914a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sricheck/sricheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def set_skip_checks(self, skip_checks):
self.skip_checks = skip_checks

def is_whitelisted(self, netloc):
# Don't check whitelist if skip_checks is True
if self.skip_checks is True:
return True

for pattern in self.whitelisted_hosts:
# file deepcode ignore reDOS: Intended functionality
if re.search(pattern, netloc):
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def test_hubspot_is_whitelisted(self):
check = SRICheck("https://www.4armed.com")
self.assertEqual(check.is_whitelisted("js.hs-scripts.com"), True)

def test_google_fonts_is_not_whitelisted_when_skip_checks_is_true(self):
check = SRICheck("https://www.4armed.com")
check.set_skip_checks(True)
self.assertEqual(check.is_whitelisted("fonts.googleapis.com"), True)

def test_target_url_is_whitelisted(self):
check = SRICheck("https://www.4armed.com")
self.assertEqual(check.is_whitelisted("www.4armed.com"), True)
Expand Down

0 comments on commit 70914a4

Please sign in to comment.