Skip to content
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

o365,sentinel_one_cloud_funnel,sysmon_linux,system,windows: tighten ipv4 extraction #11052

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented Sep 10, 2024

Proposed commit message

Make sure that the prefix of the IP address is ::ffff in all cases.

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.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Screenshots

@efd6 efd6 added enhancement New feature or request Integration:windows Windows Integration:system System Integration:o365 Microsoft Office 365 Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team [elastic/elastic-agent-data-plane] Team:Obs-InfraObs Label for the Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations] Integration:sysmon_linux Sysmon for Linux Integration:sentinel_one_cloud_funnel SentinelOne Cloud Funnel Team:Security-Service Integrations Security Service Integrations Team [elastic/security-service-integrations] Team:Security-Linux Platform Linux Platform Security team [elastic/sec-linux-platform] Team:Security-Windows Platform Security Windows Platform Team [elastic/sec-windows-platform] labels Sep 10, 2024
@efd6 efd6 self-assigned this Sep 10, 2024
@elasticmachine
Copy link

elasticmachine commented Sep 10, 2024

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@efd6 efd6 marked this pull request as ready for review September 10, 2024 03:26
@efd6 efd6 requested review from a team as code owners September 10, 2024 03:26
@efd6 efd6 requested review from AndersonQ and leehinman September 10, 2024 03:26
@elasticmachine
Copy link

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@elasticmachine
Copy link

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

@elasticmachine
Copy link

Pinging @elastic/sec-linux-platform (Team:Security-Linux Platform)

@elasticmachine
Copy link

Pinging @elastic/sec-windows-platform (Team:Security-Windows Platform)

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

I'm ok with code as proposed but I'm wondering about the value of an improvement.
Because the regex could match things like 999.999.999.999, maybe it would be a good idea to save the IP address to a temp field, and then use the convert processor to make sure it is a valid IP address. We could make the regex tighter, but that gets harder and harder for the human to read

@efd6
Copy link
Contributor Author

efd6 commented Sep 10, 2024

There are multiple things that are wrong with this approach, but they all boil down to attempting to parse IPs by RE. The intention here is not to filter incorrect IP values (e.g. a 999.999.999.999), but rather to ensure that correctly formatted IPs that are not IP4-mapped IPv6 addresses are not treated as though they are. The risk of that is low even without this change as noted in the original PR, but I thought that this was a reasonably straightforward addition that would prevent it.

@andrewkroh
Copy link
Member

/test benchmark fullreport

(wondering why sentinel_one_cloud_funnel wasn't included in the earlier output)

@efd6
Copy link
Contributor Author

efd6 commented Sep 12, 2024

/test

@efd6
Copy link
Contributor Author

efd6 commented Sep 12, 2024

I am unable to replicate this failure locally.

@efd6
Copy link
Contributor Author

efd6 commented Sep 12, 2024

/test

Copy link
Contributor

@chrisberkhout chrisberkhout left a comment

Choose a reason for hiding this comment

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

Should it accept enclosing square brackets without a port?
If so I'd suggest this:

-         pattern: '^\[?::ffff:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(?:\]:[0-9]+)?$'
+         pattern: '^\[?::ffff:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\]?(?::[0-9]+)?$'

Would be handy to see a list of example values for it to parse.

@efd6
Copy link
Contributor Author

efd6 commented Sep 14, 2024

From a defensive programming perspective, I think that's a good idea. Though it should be '^\[?::ffff:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(?:\](?::[0-9]+)?)?$' to ensure that the port being present implies the bracket is present.

@AndersonQ AndersonQ removed their request for review September 18, 2024 06:01
@efd6
Copy link
Contributor Author

efd6 commented Sep 18, 2024

/test

…pv4 extraction

Make sure that the prefix of the IP address is ::ffff in all cases.
@elasticmachine
Copy link

💚 Build Succeeded

History

  • 💔 Build #15906 failed 76e589319a321ea3edb39c73df81c24a35ca73fe
  • 💔 Build #15861 failed fb5129cf0b02466d57fcab8c2dc15a302ce3cf66
  • 💔 Build #15860 failed 465526f680ac9e31347e7f61414d5755b1aa1dcc
  • 💔 Build #15858 failed 465526f680ac9e31347e7f61414d5755b1aa1dcc
  • 💔 Build #15854 failed 465526f680ac9e31347e7f61414d5755b1aa1dcc

cc @efd6

@efd6 efd6 requested a review from chrisberkhout September 23, 2024 20:46
@efd6 efd6 merged commit 2930e19 into elastic:main Sep 25, 2024
5 checks passed
@elastic-vault-github-plugin-prod

Package o365 - 2.6.0 containing this change is available at https://epr.elastic.co/search?package=o365

@elastic-vault-github-plugin-prod

Package sentinel_one_cloud_funnel - 1.5.0 containing this change is available at https://epr.elastic.co/search?package=sentinel_one_cloud_funnel

@elastic-vault-github-plugin-prod

Package sysmon_linux - 1.7.0 containing this change is available at https://epr.elastic.co/search?package=sysmon_linux

@elastic-vault-github-plugin-prod

Package system - 1.61.0 containing this change is available at https://epr.elastic.co/search?package=system

@elastic-vault-github-plugin-prod

Package windows - 2.1.0 containing this change is available at https://epr.elastic.co/search?package=windows

pattern: '::ffff:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'
replacement: '$1'
pattern: '^\[?::ffff:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(?:\](:[0-9]+)?)?$'
replacement: '$1$2'
Copy link
Contributor

Choose a reason for hiding this comment

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

@efd6 - curious why you have $2 in this integration but only $1 in the rest. Care to elaborate for my understanding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one actually uses the port value, the rest only check that it's there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Integration:o365 Microsoft Office 365 Integration:sentinel_one_cloud_funnel SentinelOne Cloud Funnel Integration:sysmon_linux Sysmon for Linux Integration:system System Integration:windows Windows Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team [elastic/elastic-agent-data-plane] Team:Obs-InfraObs Label for the Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations] Team:Security-Linux Platform Linux Platform Security team [elastic/sec-linux-platform] Team:Security-Service Integrations Security Service Integrations Team [elastic/security-service-integrations] Team:Security-Windows Platform Security Windows Platform Team [elastic/sec-windows-platform]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants