Allow load_verify_locations with only cadata passed (#133299)
parent
2a49378f4c
commit
e951511132
|
@ -50,6 +50,12 @@ def _check_sleep_call_allowed(mapped_args: dict[str, Any]) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _check_load_verify_locations_call_allowed(mapped_args: dict[str, Any]) -> bool:
|
||||||
|
# If only cadata is passed, we can ignore it
|
||||||
|
kwargs = mapped_args.get("kwargs")
|
||||||
|
return bool(kwargs and len(kwargs) == 1 and "cadata" in kwargs)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(slots=True, frozen=True)
|
@dataclass(slots=True, frozen=True)
|
||||||
class BlockingCall:
|
class BlockingCall:
|
||||||
"""Class to hold information about a blocking call."""
|
"""Class to hold information about a blocking call."""
|
||||||
|
@ -158,7 +164,7 @@ _BLOCKING_CALLS: tuple[BlockingCall, ...] = (
|
||||||
original_func=SSLContext.load_verify_locations,
|
original_func=SSLContext.load_verify_locations,
|
||||||
object=SSLContext,
|
object=SSLContext,
|
||||||
function="load_verify_locations",
|
function="load_verify_locations",
|
||||||
check_allowed=None,
|
check_allowed=_check_load_verify_locations_call_allowed,
|
||||||
strict=False,
|
strict=False,
|
||||||
strict_core=False,
|
strict_core=False,
|
||||||
skip_for_tests=True,
|
skip_for_tests=True,
|
||||||
|
|
|
@ -429,6 +429,12 @@ async def test_protect_loop_load_verify_locations(
|
||||||
context.load_verify_locations("/dev/null")
|
context.load_verify_locations("/dev/null")
|
||||||
assert "Detected blocking call to load_verify_locations" in caplog.text
|
assert "Detected blocking call to load_verify_locations" in caplog.text
|
||||||
|
|
||||||
|
# ignore with only cadata
|
||||||
|
caplog.clear()
|
||||||
|
with pytest.raises(ssl.SSLError):
|
||||||
|
context.load_verify_locations(cadata="xxx")
|
||||||
|
assert "Detected blocking call to load_verify_locations" not in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_protect_loop_load_cert_chain(
|
async def test_protect_loop_load_cert_chain(
|
||||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
|
|
Loading…
Reference in New Issue