fix(rest): no plain-HTTP login for a switch with a pinned certificate
driver / standard (pull_request) Successful in 19s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m11s
driver / test (3.12) (pull_request) Failing after 1m9s
driver / test (3.13) (pull_request) Failing after 1m0s
driver / lowest (pull_request) Failing after 29s
driver / build (pull_request) Successful in 37s
driver / security (pull_request) Successful in 1m17s
CI / driver (pull_request) Failing after 3m1s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 19s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m11s
driver / test (3.12) (pull_request) Failing after 1m9s
driver / test (3.13) (pull_request) Failing after 1m0s
driver / lowest (pull_request) Failing after 29s
driver / build (pull_request) Successful in 37s
driver / security (pull_request) Successful in 1m17s
CI / driver (pull_request) Failing after 3m1s
driver / publish (pull_request) Skipped
The probe falls back to HTTP when HTTPS does not answer. For a switch known by its certificate that is a downgrade anyone who blocks port 443 can force: the login would go out in clear text, unchecked. With a pinned fingerprint the REST API is skipped then and the CLI transports are tried; without one, plain HTTP is used as before. Refs #17
This commit is contained in:
1 parent
cb7268b89c
commit
e51ddcd151
5 files changed
+46
-4
No files matched your search
@@ -209,3 +209,34 @@ class TestUnreachable:
|
||||
driver.open()
|
||||
fetch.assert_not_called()
|
||||
assert driver._transport == "api"
|
||||
|
||||
|
||||
class TestNoPlainHttpWhenPinned:
|
||||
"""A switch known by its certificate is not logged in to over plain HTTP.
|
||||
|
||||
Blocking port 443 would otherwise downgrade the login to clear text, unchecked.
|
||||
"""
|
||||
|
||||
def test_a_pinned_switch_that_answers_only_http_gets_no_rest_login(self):
|
||||
driver = _driver([], known=SWITCH_FP)
|
||||
cli = MagicMock()
|
||||
cli.base_prompt = "switch"
|
||||
with (
|
||||
patch(PROBE, return_value=("v7", "http")),
|
||||
patch.object(requests.Session, "post") as post,
|
||||
patch.object(ProcurveDriver, "_ssh_connect", return_value=cli),
|
||||
):
|
||||
driver.open()
|
||||
post.assert_not_called()
|
||||
assert driver._transport == "ssh"
|
||||
assert any("plain HTTP" in a for a in driver._attempts)
|
||||
|
||||
def test_without_a_pin_plain_http_is_used_as_before(self):
|
||||
driver = _driver([])
|
||||
with (
|
||||
patch(PROBE, return_value=("v7", "http")),
|
||||
patch.object(requests.Session, "post", return_value=_login_ok()) as post,
|
||||
):
|
||||
driver.open()
|
||||
assert post.call_count == 1
|
||||
assert driver._transport == "api"
|
||||
Reference in new issue
Block a user