Skip to content

[sophos] Fix add_locale handling in xg data stream - #15482

Merged
taylor-swanson merged 3 commits into
elastic:mainfrom
taylor-swanson:fix/sophos-xg-timezone
Sep 26, 2025
Merged

[sophos] Fix add_locale handling in xg data stream#15482
taylor-swanson merged 3 commits into
elastic:mainfrom
taylor-swanson:fix/sophos-xg-timezone

Conversation

@taylor-swanson

@taylor-swanson taylor-swanson commented Sep 26, 2025

Copy link
Copy Markdown
Contributor

Proposed commit message

  • Fixed handling of time zones added by add_locale (which sets event.timezone) in the Sophos XG data stream. As add_locale will set the local timezone of the agent in event.timezone, this prevented the real time zone in the log from being set as there was a check to prevent event.timezone from being overridden.
  • Added a pipeline test to test this scenario

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

How to test this PR locally

cd packages/sophos
elastic-package test
- Fixed handling of time zones added by add_locale (which sets event.timezone)
in the Sophos XG data stream. As add_locale will set the local timezone of the
agent in event.timezone, this prevented the real time zone in the log from being
set as there was a check to prevent event.timezone from being overridden.
- Added a pipeline test to test this scenario
@taylor-swanson taylor-swanson self-assigned this Sep 26, 2025
@taylor-swanson taylor-swanson added Integration:sophos Sophos bugfix Pull request that fixes a bug issue Team:Integration-Experience Security Integrations Integration Experience [elastic/integration-experience] labels Sep 26, 2025
{
"message": "<30>device=\"SFW\" date=2020-05-18 time=14:38:48 timezone=\"CEST\" device_name=\"XG230\" device_id=1234567890123456 log_id=041101618035 log_type=\"Anti-Spam\" log_component=\"SMTP\" log_subtype=\"Allowed\" status=\"\" priority=Information fw_rule_id=0 user_name=\"\" av_policy_name=\"None\" from_email_address=\"firewall@firewallgate.com\" to_email_address=\"Sysadmin@elasticuser.com\" email_subject=\"*ALERT* Sophos XG Firewall\" mailid=\"qkW2Y6-LxBk6U-vH-1590055245\" mailsize=19728 spamaction=\"QUEUED\" reason=\"Email has been accepted by Device and queued for scanning.\" src_domainname=\"elasticuser.com\" dst_domainname=\"\" src_ip=\"\" src_country_code=\"\" dst_ip=\"\" dst_country_code=\"\" protocol=\"TCP\" src_port=0 dst_port=0 sent_bytes=0 recv_bytes=0 quarantine_reason=\"Other\"\n",
"event": {
"timezone": "-05:00"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This simulates what is set by add_locale in filebeat.

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@taylor-swanson
taylor-swanson marked this pull request as ready for review September 26, 2025 16:33
@taylor-swanson
taylor-swanson requested a review from a team as a code owner September 26, 2025 16:33
@elasticmachine

Copy link
Copy Markdown

Pinging @elastic/integration-experience (Team:Integration-Experience)

@qcorporation qcorporation left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, approved.
Great that you add tags on the code that you touched.
Can you add a tag for the last set, where you removed the if statement
if: ctx.event?.timezone == null

@taylor-swanson

Copy link
Copy Markdown
Contributor Author

Looks good, approved. Great that you add tags on the code that you touched. Can you add a tag for the last set, where you removed the if statement if: ctx.event?.timezone == null

Good catch! Added.

@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @taylor-swanson

@taylor-swanson
taylor-swanson merged commit 65ee9e7 into elastic:main Sep 26, 2025
9 checks passed
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

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

tehbooom pushed a commit to tehbooom/integrations that referenced this pull request Nov 19, 2025
- Fixed handling of time zones added by add_locale (which sets event.timezone)
in the Sophos XG data stream. As add_locale will set the local timezone of the
agent in event.timezone, this prevented the real time zone in the log from being
set as there was a check to prevent event.timezone from being overridden.
- Added a pipeline test to test this scenario
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:sophos Sophos Team:Integration-Experience Security Integrations Integration Experience [elastic/integration-experience]

3 participants