Skip to content

Commit 4b9367f

Browse files
Fixing azure_monitor_driver for deprecated httpx API (#809)
* Fixing azure_monitor_driver to handle deprecated httpx API call. Also fixed a doc bug in process_tree_utils and initializer in host_logon_session. * Update typing * Replace hardcoded value --------- Co-authored-by: Florian BRACQ <[email protected]> Co-authored-by: FlorianBracq <[email protected]>
1 parent 7000f4a commit 4b9367f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

msticpy/data/drivers/azure_monitor_driver.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import pandas as pd
2525
from azure.core.exceptions import HttpResponseError
2626
from azure.core.pipeline.policies import UserAgentPolicy
27-
from packaging.version import parse as parse_version
27+
from packaging.version import Version, parse as parse_version
2828

2929
from ..._version import VERSION
3030
from ...auth.azure_auth import AzureCloudConfig, az_connect
@@ -605,13 +605,25 @@ def _get_schema(self) -> Dict[str, Dict]:
605605
token = credentials.modern.get_token(f"{mgmt_endpoint}/.default")
606606
headers = {"Authorization": f"Bearer {token.token}", **mp_ua_header()}
607607
logger.info("Schema request to %s", fmt_url)
608-
response = httpx.get(
609-
fmt_url,
610-
headers=headers,
608+
609+
# Handle proxies (parameter changes in httpx 0.25.0)
610+
httpx_version: Version = parse_version(httpx.__version__)
611+
proxies: dict[str, str] = self._def_proxies or {}
612+
httpx_proxy_kwargs: dict[str, Any] = {}
613+
if proxies:
614+
if httpx_version < parse_version("0.25.0"):
615+
httpx_proxy_kwargs = {"proxies": proxies}
616+
else:
617+
httpx_proxy_kwargs = {"mounts": proxies}
618+
with httpx.Client(
611619
timeout=get_http_timeout(),
612-
proxies=self._def_proxies or {},
613-
)
614-
if response.status_code != 200:
620+
**httpx_proxy_kwargs,
621+
) as httpx_client:
622+
response: httpx.Response = httpx_client.get(
623+
fmt_url,
624+
headers=headers,
625+
)
626+
if response.status_code != httpx.codes.OK:
615627
logger.info("Schema request failed. Status code: %d", response.status_code)
616628
return {}
617629
tables = response.json()

msticpy/datamodel/entities/host_logon_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(
7575
self.StartTimeUtc: datetime = datetime.min
7676
self.EndTimeUtc: datetime = datetime.min
7777
self.Host: Optional[Host] = None
78-
self.SessionId: str | None = ""
78+
self.SessionId: str | None = None
7979
super().__init__(src_entity=src_entity, **kwargs)
8080

8181
if src_event is not None:

msticpy/transform/process_tree_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def tree_to_text(
423423
Raises
424424
------
425425
ValueError
426-
If neither of
426+
If neither schema nor template are supplied as parameters.
427427
428428
"""
429429
if not schema and not template:

0 commit comments

Comments
 (0)