Repository navigation
Fix DeviceId column name in list_file_events_for_host queries - #968
Open
Guillermo Tosetti (GTosetti) wants to merge 1 commit into
Open
Guillermo Tosetti (GTosetti) wants to merge 1 commit into
Guillermo Tosetti (GTosetti) wants to merge 1 commit into
Conversation
The MDE, MDATP and M365D list_file_events_for_host queries filtered on DeviceID. The DeviceFileEvents column is DeviceId and KQL column names are case-sensitive, so the query failed to compile whatever host name or device ID was passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MDE.list_file_events_for_host,MDATP.list_file_events_for_host(same source as MDE) andM365D.list_file_events_for_hostfilter onDeviceID(kql_mdatp_file.yaml#L135, kql_m365_file.yaml#L84). The column inDeviceFileEventsisDeviceId(table reference), and KQL identifiers are case-sensitive (entity names).With
host_name="host1"anddevice_id="0123456789abcdef"the query renders as:The column name does not resolve, so the query cannot compile, whichever of the two parameters is passed. The
M365DGraphandMSSentinelproviders load the same m365d file. The line has been in place since #680 (555b58a).The change fixes the column name in both files. It also adds a test in
tests/data/drivers/test_odata_drivers.pythat renders the query with theprintoption for theMDEandM365Dfamilies.Running
python -m pytest tests/data/drivers/test_odata_drivers.py -k file_events_for_hostbefore the change gives2 failed; after it,2 passed. The whole file gives46 passed, 1 skipped. The rendered MDATP, MDE and M365D queries were also checked with Microsoft.Azure.Kusto.Language 12.4.1, using theDeviceFileEventscolumns from the table reference. Before the change it reports diagnostic KS142,The name 'DeviceID' does not refer to any known column, table, variable or function., for each one; after it, no errors.Not checked: the queries were not run against a Defender or Sentinel workspace.
Prepared with Claude Code (AI-assisted).
🤖 Generated with Claude Code