Skip to content

[zscaler_zia] In web v8, use b64 fields to avoid encoding issues - #10855

Merged
chrisberkhout merged 3 commits into
elastic:mainfrom
chrisberkhout:zia-b64-urls
Aug 23, 2024
Merged

[zscaler_zia] In web v8, use b64 fields to avoid encoding issues#10855
chrisberkhout merged 3 commits into
elastic:mainfrom
chrisberkhout:zia-b64-urls

Conversation

@chrisberkhout

@chrisberkhout chrisberkhout commented Aug 22, 2024

Copy link
Copy Markdown
Contributor

Proposed commit message

[zscaler_zia] In web v8, use b64 fields to avoid encoding issues (#)

In the web data stream, the v7 response format requested the
hex-encoded fields `eurl`, `eurlpath`, `ereferer`, and `erefererpath`.
Although those fields have non-printable characters encoded, they
aren't fully URL-encoded (e.g. they don't encode `%`), and they may
still include characters that can break JSON (including `"`).

URLs and their paths sometimes include characters that break the v7
processing, so the following changes have been made in the v8 response
format and pipeline.

We switch from `eurl` to `b64url` and from `ereferer` to `b64referer`.

We no longer request the `eurlpath` and `erefererpath` fields. They
have no base64-encoded equivalents. Paths and query strings are
present in the URL fields.

From the output we remove the `zscaler_zia.web.url.path` and
`zscaler_zia.web.referer.path` fields. However, use of the `uri_parts`
processor to populate `url.path` and other `url.*` fields remains
intact.

The ingest pipeline will tolerate absent fields, so the updated
package will accept any v7 data that isn't broken by problematic
characters and simply skip population of url/path fields.

A new `"version":"v8"` field is inserted at the start of the response
format to aid future debugging. No validation or use of that field has
been added to the ingest pipeline.

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.

Review tips

The following diff compares pretty-printed versions of the v7 and v8 formats:

1a2
>   "version": "v8",
29,30c30
<     "refererurl": "%s{ereferer}",
<     "refererpath": "%s{erefererpath}",
---
>     "b64referer": "%s{b64referer}",
48,49c48
<     "eurl": "%s{eurl}",
<     "urlpath": "%s{eurlpath}",
---
>     "b64url": "%s{b64url}",

You can generate diffs of the the pipeline test files in-pretty printed form as follows, from the package directory:

diff <(git show main:packages/zscaler_zia/data_stream/web/_dev/test/pipeline/test-web-http-endpoint.log | jq .) \
     <(jq . data_stream/web/_dev/test/pipeline/test-web-http-endpoint.log)
diff <(git show main:packages/zscaler_zia/data_stream/web/_dev/test/pipeline/test-web.log | jq .) \
     <(jq . data_stream/web/_dev/test/pipeline/test-web.log)

Note that in one example, I combined a URL value and path in the b64 version, since it seems that URL fields do have the full URL, not only the base.

I did a non-strict URL-decode and Base64 encode on the old values using this CyberChef recipe.

@chrisberkhout chrisberkhout added bugfix Pull request that fixes a bug issue Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Aug 22, 2024
@chrisberkhout
chrisberkhout requested a review from kcreddy August 22, 2024 17:00
@chrisberkhout chrisberkhout self-assigned this Aug 22, 2024
@chrisberkhout
chrisberkhout requested a review from a team as a code owner August 22, 2024 17:00
@elasticmachine

Copy link
Copy Markdown

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

@andrewkroh andrewkroh added the Integration:zscaler_zia Zscaler Internet Access label Aug 22, 2024
@elasticmachine

Copy link
Copy Markdown

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @chrisberkhout

@chrisberkhout
chrisberkhout merged commit d6e0c6f into elastic:main Aug 23, 2024
@chrisberkhout
chrisberkhout deleted the zia-b64-urls branch August 23, 2024 11:37
@elasticmachine

Copy link
Copy Markdown

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

kcreddy added a commit that referenced this pull request Aug 28, 2024
…gs (#10874)

Remove `department` field and fix parsing errors in web logs.

The `department` value is already being ingested from `dept` field. This PR removes the 
hex-encoded `department` field in favour of `dept` due to noticed improper hex-encoding in 
fields prefixed with `e` [here](#10855 (comment)). 

Remove `urldecode` processor on parsing urls causing parsing errors. The `b64url` 
field is already being decoded by `script` processor. 

Also adds `on_failure` clause on `urldecode` processors to continue pipeline execution 
to prevent parsing errors on hex-encoded values to stop running rest of the pipeline.
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
…stic#10855)

In the web data stream, the v7 response format requested the
hex-encoded fields `eurl`, `eurlpath`, `ereferer`, and `erefererpath`.
Although those fields have non-printable characters encoded, they
aren't fully URL-encoded (e.g. they don't encode `%`), and they may
still include characters that can break JSON (including `"`).

URLs and their paths sometimes include characters that break the v7
processing, so the following changes have been made in the v8 response
format and pipeline.

We switch from `eurl` to `b64url` and from `ereferer` to `b64referer`.

We no longer request the `eurlpath` and `erefererpath` fields. They
have no base64-encoded equivalents. Paths and query strings are
present in the URL fields.

From the output we remove the `zscaler_zia.web.url.path` and
`zscaler_zia.web.referer.path` fields. However, use of the `uri_parts`
processor to populate `url.path` and other `url.*` fields remains
intact.

The ingest pipeline will tolerate absent fields, so the updated
package will accept any v7 data that isn't broken by problematic
characters and simply skip population of url/path fields.

A new `"version":"v8"` field is inserted at the start of the response
format to aid future debugging. No validation or use of that field has
been added to the ingest pipeline.
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
…gs (elastic#10874)

Remove `department` field and fix parsing errors in web logs.

The `department` value is already being ingested from `dept` field. This PR removes the 
hex-encoded `department` field in favour of `dept` due to noticed improper hex-encoding in 
fields prefixed with `e` [here](elastic#10855 (comment)). 

Remove `urldecode` processor on parsing urls causing parsing errors. The `b64url` 
field is already being decoded by `script` processor. 

Also adds `on_failure` clause on `urldecode` processors to continue pipeline execution 
to prevent parsing errors on hex-encoded values to stop running rest of the pipeline.
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
…stic#10855)

In the web data stream, the v7 response format requested the
hex-encoded fields `eurl`, `eurlpath`, `ereferer`, and `erefererpath`.
Although those fields have non-printable characters encoded, they
aren't fully URL-encoded (e.g. they don't encode `%`), and they may
still include characters that can break JSON (including `"`).

URLs and their paths sometimes include characters that break the v7
processing, so the following changes have been made in the v8 response
format and pipeline.

We switch from `eurl` to `b64url` and from `ereferer` to `b64referer`.

We no longer request the `eurlpath` and `erefererpath` fields. They
have no base64-encoded equivalents. Paths and query strings are
present in the URL fields.

From the output we remove the `zscaler_zia.web.url.path` and
`zscaler_zia.web.referer.path` fields. However, use of the `uri_parts`
processor to populate `url.path` and other `url.*` fields remains
intact.

The ingest pipeline will tolerate absent fields, so the updated
package will accept any v7 data that isn't broken by problematic
characters and simply skip population of url/path fields.

A new `"version":"v8"` field is inserted at the start of the response
format to aid future debugging. No validation or use of that field has
been added to the ingest pipeline.
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
…gs (elastic#10874)

Remove `department` field and fix parsing errors in web logs.

The `department` value is already being ingested from `dept` field. This PR removes the 
hex-encoded `department` field in favour of `dept` due to noticed improper hex-encoding in 
fields prefixed with `e` [here](elastic#10855 (comment)). 

Remove `urldecode` processor on parsing urls causing parsing errors. The `b64url` 
field is already being decoded by `script` processor. 

Also adds `on_failure` clause on `urldecode` processors to continue pipeline execution 
to prevent parsing errors on hex-encoded values to stop running rest of the pipeline.
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