Skip to content

[azure,o365,m365_defender] ECS mapping improvements #14085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

chrisberkhout
Copy link
Contributor

@chrisberkhout chrisberkhout commented May 30, 2025

Proposed commit message

[azure,o365,m365_defender] ECS mapping improvements

Various suggested ECS field mapping updates to improve correlation of
ingested events with other security telemetry, for the integrations
azure, o365 and m365_defender.

Discussion

Can be read commit-by-commit.

Suggested mappings done:

  • Suggestion: azure.signinlogs.properties.user_principal_name -> user.email
    Done, whenever the value contains @.

  • Suggestion: azure.signinlogs.properties.service_principal_name -> service.name
    Done, whenever it's populated.

  • Suggestion: azure.identityprotection.properties.user_principal_name -> user.email
    Suggestion: azure.identityprotection.properties.user_display_name -> user.full_name
    Suggestion: azure.identityprotection.properties.user_id -> user.id
    All done. Matched to the handling in the signinlogs data stream.

  • Suggestion: o365.audit.OriginatingDomain -> url.domain
    Suggestion: o365.audit.Application -> process.name
    Suggestion: o365.audit.Sha1 -> file.hash.sha1
    Suggestion: o365.audit.Sha256 -> file.hash.sha256
    Suggestion: o365.audit.FileExtension -> file.extension
    Suggestion: o365.audit.Parameters.From -> email.from.address
    All done. Field defintion and mapping logic added.

  • Suggestion: o365.audit.DeviceName -> host.name
    Done. DeviceName is now the first source for host.name and two other sources will be tried if it’s empty.

  • Suggestion: o365.audit.TargetFilePath -> file.path
    Done. Also FilePath.

  • Suggestion: o365.audit.FileSize -> file.size
    Done. Field definition for FileSize added. New mapping logic tries FileSizeBytes first and falls back to FileSize.

  • Suggestion: o365.audit.Parameters.ForwardAsAttachmentTo -> email.to.address
    Suggestion: o365.audit.Parameters.ForwardTo -> email.to.address
    Suggestion: o365.audit.Parameters.RedirectTo -> email.to.address
    All done. Mapping logic added.

Suggested mappings not done:

  • Suggestion: o365.audit.UserId -> user.email
    No change. UserId was already mapped to user.id here, and set in user.email if the value has @ in it, here. The user.email field can get other values if UserId is not set.

  • Suggestion: m365_defender.incident.alerts.evidence.user_account.azure_ad_user_id -> user.id
    Suggestion: m365_defender.incident.alerts.evidence.user_account.user_sid -> user.id
    Suggestion: m365_defender.incident.alerts.evidence.user_account.user_principal_name -> user.email
    Not done. These aren't the user the event relates to. The incident can have related alerts, each with several pieces of related evidence, each with a related user account. These IDs/names are already copied to related.user, which should facilitate matching in searches and rules. Duplicating this information in user.* seems inappropriate.

  • Suggestion: m365_defender.alert.evidence.p1_sender.display_name -> user.full_name
    Suggestion: m365_defender.alert.evidence.p2_sender.display_name -> user.full_name
    Not done. As above, these are already added to related.user. This is the case in both the alert and incident data streams.

  • Suggestion: m365_defender.incident.alerts.evidence.display_name -> user.full_name
    Not done. This is not always a user name. For example, it's a group name in this case. This could be revisited if we have the data to know exactly when it's a user.

Suggested mappings done with adjustments:

  • Suggestion: m365_defender.incident.alerts.evidence.user_account.display_name -> user.full_name
    Added this to related.user, to match the handling of azure_ad_user_id, user_sid, and user_principal_name.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Related issues

@chrisberkhout chrisberkhout self-assigned this May 30, 2025
@chrisberkhout chrisberkhout added enhancement New feature or request Integration:azure Azure Logs Integration:o365 Microsoft Office 365 Integration:m365_defender Microsoft Defender XDR Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels May 30, 2025
@chrisberkhout chrisberkhout force-pushed the ecs-suggested-mapping-improvments branch 2 times, most recently from 920c94b to 469ab90 Compare May 30, 2025 14:29
@chrisberkhout chrisberkhout marked this pull request as ready for review May 30, 2025 14:29
@chrisberkhout chrisberkhout requested review from a team as code owners May 30, 2025 14:29
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@andrewkroh andrewkroh added the Team:Obs-InfraObs Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations] label May 30, 2025
Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if you are happy with the queries?

Comment on lines 73 to 82
- gsub:
field: file.size
pattern: ','
replacement: ''
ignore_missing: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they always localized to non-European thousands separators?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. One value was provided with the suggestion; "3,818,355".

In the MS documentation* I see:
image

In existing pipeline test input we have this (it's a different place in the document):

{
  "ExchangeMetaData": {
    "FileSize": 13405,
    ...
  },
  ...
}

I think more resilient logic would be:

  • convert to string (to add)
  • remove non-digits (this gsub modified)
  • convert to long (existing)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also changed the new field definition to keyword.

@chrisberkhout chrisberkhout force-pushed the ecs-suggested-mapping-improvments branch from fae9079 to e5a7d70 Compare June 2, 2025 08:19
@chrisberkhout chrisberkhout requested a review from efd6 June 2, 2025 08:20
@elastic-vault-github-plugin-prod
Copy link

elastic-vault-github-plugin-prod bot commented Jun 2, 2025

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@chrisberkhout chrisberkhout force-pushed the ecs-suggested-mapping-improvments branch 2 times, most recently from 2a59c2f to 3b51ff3 Compare June 3, 2025 10:08
- set:
field: user.email
copy_from: azure.identityprotection.properties.user_principal_name
if: "(ctx.azure?.identityprotection?.properties?.user_principal_name ?: '') =~ /^[^@]+@[^@]+$/"
Copy link
Contributor

@efd6 efd6 Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm disinclined to do more than checking for an @; "I am the @ man"@gmail.com is a valid email address per the RFC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good to know.

Switched back to the simpler check.

@chrisberkhout chrisberkhout force-pushed the ecs-suggested-mapping-improvments branch from 3b51ff3 to 0624b35 Compare June 4, 2025 07:32
@chrisberkhout chrisberkhout enabled auto-merge (squash) June 4, 2025 07:35
@chrisberkhout chrisberkhout disabled auto-merge June 4, 2025 07:35
Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM

Copy link
Contributor

@muthu-mps muthu-mps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let a comment to modify the changelog description.
Reviewed Azure signinlogs, LGTM!

field: file.size
copy_from: o365audit.FileSize
ignore_empty_value: true
override: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can only one of filesize and filesizebytes can exist ?

Copy link
Contributor Author

@chrisberkhout chrisberkhout Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current API documentation includes FileSize, with the description "Size for the file in bytes", so I think these fields have the same meaning.

The FileSizeBytes mapping was added in a community PR, based on production data. I don't see the field in the documentation. It may be that the field name changed or that it only exists in certain cases.

We have a user request to parse FileSize, so I want to prefer that but I to fall back to the original FileSizeBytes parsing in case it does appear with a different version or configuration, or in older data.

- convert:
tag: convert_file_size_to_long
field: file.size
type: long
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting to string before and then to long ?
Could you explain more ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to have logic that works for values from two sources:

  • FileSize: documented as a string, provided sample value of "3,818,355"
  • FileSizeBytes: undocumented, mapped as a long with no conversion

But on second thought, we can remove the string conversion and limit the removal of non-digit characters to values that are already strings, so I've done that.

Note: there is an issue (elastic/beats#43659, elastic/elasticsearch#128160) with converting numbers of a certain size to long, but both versions have that and it's being fixed in ES.

chrisberkhout and others added 2 commits June 5, 2025 11:24
Co-authored-by: muthu-mps <101238137+muthu-mps@users.noreply.github.com>
@elasticmachine
Copy link

💚 Build Succeeded

History

cc @chrisberkhout

Copy link

@chrisberkhout chrisberkhout requested a review from ishleenk17 June 5, 2025 11:54
Copy link
Contributor

@zmoog zmoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@chrisberkhout chrisberkhout merged commit c5b49d5 into elastic:main Jun 7, 2025
8 checks passed
@elastic-vault-github-plugin-prod

Package azure - 1.26.0 containing this change is available at https://epr.elastic.co/package/azure/1.26.0/

@elastic-vault-github-plugin-prod

Package m365_defender - 3.9.0 containing this change is available at https://epr.elastic.co/package/m365_defender/3.9.0/

@elastic-vault-github-plugin-prod

Package o365 - 2.18.0 containing this change is available at https://epr.elastic.co/package/o365/2.18.0/

@andrewkroh andrewkroh added the documentation Improvements or additions to documentation. Applied to PRs that modify *.md files. label Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation. Applied to PRs that modify *.md files. enhancement New feature or request Integration:azure Azure Logs Integration:m365_defender Microsoft Defender XDR Integration:o365 Microsoft Office 365 Team:Obs-InfraObs Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations] Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[azure,o365,m365_defender] ECS mapping improvements
7 participants