diff --git a/msticpy/data/queries/m365d/kql_m365_file.yaml b/msticpy/data/queries/m365d/kql_m365_file.yaml index 6d4c3e68a..52a6f3785 100644 --- a/msticpy/data/queries/m365d/kql_m365_file.yaml +++ b/msticpy/data/queries/m365d/kql_m365_file.yaml @@ -81,7 +81,7 @@ sources: {table} | where {time_column} >= datetime({start}) | where {time_column} <= datetime({end}) - | where DeviceName == "{host_name}" or DeviceID == "{device_id}" + | where DeviceName == "{host_name}" or DeviceId == "{device_id}" {add_query_items}' uri: None parameters: diff --git a/msticpy/data/queries/mde/kql_mdatp_file.yaml b/msticpy/data/queries/mde/kql_mdatp_file.yaml index 75415ce5b..016eb3a54 100644 --- a/msticpy/data/queries/mde/kql_mdatp_file.yaml +++ b/msticpy/data/queries/mde/kql_mdatp_file.yaml @@ -132,7 +132,7 @@ sources: {table} | where {time_column} >= datetime({start}) | where {time_column} <= datetime({end}) - | where DeviceName == "{host_name}" or DeviceID == "{device_id}" + | where DeviceName == "{host_name}" or DeviceId == "{device_id}" {add_query_items}' uri: None parameters: diff --git a/tests/data/drivers/test_odata_drivers.py b/tests/data/drivers/test_odata_drivers.py index 9b0ad5323..3e12e7448 100644 --- a/tests/data/drivers/test_odata_drivers.py +++ b/tests/data/drivers/test_odata_drivers.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- """Miscellaneous data provider driver tests.""" import sys +from datetime import datetime, timezone from unittest.mock import Mock, patch import pandas as pd @@ -79,6 +80,23 @@ def test_MDE_driver(env, api, cloud: None): check.greater_equal(len(qry_prov.list_queries()), 40) +@pytest.mark.parametrize("family", ["MDE", "M365D"]) +def test_mde_file_events_for_host_query(family): + """Test list_file_events_for_host filters on the DeviceId column.""" + with custom_mp_config(MP_PATH): + qry_prov = QueryProvider("MDE") + query = getattr(qry_prov, family).list_file_events_for_host( + "print", + host_name="host1", + device_id="0123456789abcdef", + start=datetime(2024, 1, 1, tzinfo=timezone.utc), + end=datetime(2024, 1, 2, tzinfo=timezone.utc), + ) + # KQL column names are case-sensitive and the table column is DeviceId + check.is_in('DeviceId == "0123456789abcdef"', query) + check.is_not_in("DeviceID", query) + + # Test helper functions for MDE tests def _mde_pre_checks(mde_drv, api): check.is_instance(mde_drv, MDATPDriver)