Skip to content

Commit 3cffad7

Browse files
authored
Merge pull request #92 from atlassian-labs/fix-validators
fix: account for validators API changes
2 parents 1a0cbda + 7529e91 commit 3cffad7

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ verify_ssl = true
55

66
[dev-packages]
77
pytest-cov = "*"
8-
flake8 = "*"
98
pytest = "*"
9+
flake8 = "*"
1010

1111
[packages]
1212
requests = "2.31"
1313
fire = "0.5.0"
1414
jsonobject = "2.1"
1515
jinja2 = "3.1.6"
1616
markdown2 = "2.4.9"
17-
validators = "0.21.0"
17+
validators = "0.21.1"
1818
pyjwt = "2.7.0"
1919
sslyze = "5.1.3"
2020
python-json-logger = "2.0.7"

Pipfile.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_csrt_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def teardown_module(module):
1717
def test_session_timeout():
1818
session = create_csrt_session(timeout=5)
1919

20-
with pytest.raises(requests.exceptions.ReadTimeout) as wrapped_e:
20+
with pytest.raises((requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError)) as wrapped_e:
2121
session.get('https://httpstat.us/200?sleep=50000')
2222

23-
assert wrapped_e.type == requests.exceptions.ReadTimeout
23+
assert wrapped_e.type in (requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError)

tests/test_hsts_scan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_hsts_timeout():
4646
base_url = 'https://httpstat.us/200?sleep=50000'
4747
scanner = HstsScan(base_url, 5)
4848

49-
with pytest.raises(requests.exceptions.ReadTimeout) as wrapped_e:
49+
with pytest.raises((requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError)) as wrapped_e:
5050
scanner.scan()
5151

52-
assert wrapped_e.type == requests.exceptions.ReadTimeout
52+
assert wrapped_e.type in (requests.exceptions.ReadTimeout, requests.exceptions.ConnectionError)

utils/app_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _get_and_request_descriptor(self) -> Optional[dict]:
2828
return descriptor
2929

3030
def _validate_base_url(self) -> bool:
31-
res = validators.url(self.descriptor['baseUrl'], public=True)
31+
res = validators.url(self.descriptor['baseUrl'], rfc_1034=True)
3232
if not res:
3333
logging.error(f"{self.descriptor['baseUrl']} was not a valid URL.")
3434
return bool(res)

utils/csrt_session.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
# a timeout on all requests
1313
class TimeoutHTTPAdapter(HTTPAdapter):
1414
def __init__(self, *args, **kwargs):
15-
if "timeout" in kwargs:
16-
self.timeout = kwargs["timeout"]
17-
del kwargs["timeout"]
15+
timeout = kwargs.get("timeout", 30)
1816
super().__init__(*args, **kwargs)
17+
self.timeout = timeout
1918

2019
def send(self, request, **kwargs):
2120
timeout = kwargs.get("timeout")

0 commit comments

Comments
 (0)