Skip to content

zscaler_zia: Fix url parsing in Web logs. - #10517

Merged
kcreddy merged 69 commits into
elastic:mainfrom
kcreddy:zscaler_url
Jul 23, 2024
Merged

zscaler_zia: Fix url parsing in Web logs.#10517
kcreddy merged 69 commits into
elastic:mainfrom
kcreddy:zscaler_url

Conversation

@kcreddy

@kcreddy kcreddy commented Jul 17, 2024

Copy link
Copy Markdown
Contributor

Proposed commit message

Fix url parsing in Web logs.

3.0.0 version introduced a bug in url parsing due to lack of url.scheme.
Earlier versions had logic to add url.scheme to `eurl` field to 
generate `url.full`. When the field changed from `eurl` to `url` in 3.0.0, 
this logic was removed. This leads to erroneous values in ECS `url` 
fields. This PR fixes the issue.

   - Add `network.protocol` as scheme to `url` field to fully 
     generate `url.full`.
   - If `network.protocol` is missing, add default `https` as scheme. 
     This is required to properly run `uri_parts` processor.

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.

How to test this PR locally

@kcreddy
kcreddy marked this pull request as ready for review July 17, 2024 15:13
@kcreddy
kcreddy requested a review from a team as a code owner July 17, 2024 15:13
@kcreddy kcreddy self-assigned this Jul 17, 2024
@kcreddy kcreddy added Integration:zscaler_zia Zscaler Internet Access bugfix Pull request that fixes a bug issue Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Jul 17, 2024
@elasticmachine

Copy link
Copy Markdown

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

@andrewkroh andrewkroh added Integration:Zscaler (Deprecated) Use ZIA or ZPA specific labels. [Integration not found in source] and removed Integration:Zscaler (Deprecated) Use ZIA or ZPA specific labels. [Integration not found in source] labels Jul 19, 2024
def url = ctx.zscaler_zia.web.url.name;
if (!regex.matcher(url).matches()) {
if (ctx.network?.protocol != null) {
url = ctx.network.protocol + '://' + url;

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.

There may be some additional work required to cover edge cases; from the docs, the proto log field (which becomes network.protocol) is not a direct mapping to a scheme. Though maybe that should happen in the assignment to network.protocol.

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.

@efd6, could you please review if this seems valid:

I updated the logic to derive network.protocol, first based on alpn_protocol log field as it closely matches the ECS definition. If alpn_protocol is absent, I added a mapping to derive the network.protocol for different values of proto log field to cover edge cases.
Changes in 8ff679f.

@elasticmachine

elasticmachine commented Jul 22, 2024

Copy link
Copy Markdown

🚀 Benchmarks report

Package zscaler_zia 👍(4) 💚(1) 💔(3)

Expand to view
Data stream Previous EPS New EPS Diff (%) Result
alerts 3412.97 2785.52 -627.45 (-18.38%) 💔
firewall 1490.31 1027.75 -462.56 (-31.04%) 💔
web 1162.79 951.47 -211.32 (-18.17%) 💔

To see the full report comment with /test benchmark fullreport

@kcreddy
kcreddy requested a review from efd6 July 23, 2024 02:12
description: Set network.protocol from prototype, if not already set.
tag: script_set_network_protocol
params:
dns-over-https: dns

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.

Worth having a source link for the origin of this table, though I can't find a good source that includes all the protocols that are here, so if it doesn't exist, never mind.

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.

I also couldn't find a mapping table, but I will add link to the list of uri schemes

@elastic-sonarqube

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
65.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @kcreddy

@kcreddy
kcreddy merged commit 3abd313 into elastic:main Jul 23, 2024
@elasticmachine

Copy link
Copy Markdown

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

@kcreddy
kcreddy deleted the zscaler_url branch February 7, 2025 09:12
orestisfl pushed a commit to orestisfl/integrations that referenced this pull request May 15, 2026
Fix url parsing in Web logs.

3.0.0 version introduced a bug in url parsing due to lack of url.scheme.
Earlier versions had logic to add url.scheme to `eurl` field to 
generate `url.full`. When the field changed from `eurl` to `url` in 3.0.0, 
this logic was removed. This leads to erroneous values in ECS `url` 
fields. This PR fixes the issue.

   - Add `network.protocol` as scheme to `url` field to fully 
     generate `url.full`.
   - If `network.protocol` is missing, add default `https` as scheme. 
     This is required to properly run `uri_parts` processor.
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:zscaler_zia Zscaler Internet Access Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

4 participants