Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion msticpy/data/queries/m365d/kql_m365_file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion msticpy/data/queries/mde/kql_mdatp_file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions tests/data/drivers/test_odata_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down