[sophos] Fix uri_parts failure on malformed URLs in XG cfilter. - #20628
Conversation
✅ Elastic Docs Style Checker (Vale)No issues found on modified lines! The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale. |
🚀 Benchmarks reportTo see the full report comment with |
|
Pinging @elastic/integration-experience (Team:Integration-Experience) |
| - version: "3.17.2" | ||
| changes: | ||
| - description: Fix uri_parts processor failure on malformed URLs in XG content filtering logs. | ||
| type: bugfix | ||
| link: https://github.com/elastic/integrations/pull/20628 | ||
| - description: Map XG content-filtering http_referer and http_user_agent fields to ECS. | ||
| type: bugfix | ||
| link: https://github.com/elastic/integrations/pull/20628 |
There was a problem hiding this comment.
| - version: "3.17.2" | |
| changes: | |
| - description: Fix uri_parts processor failure on malformed URLs in XG content filtering logs. | |
| type: bugfix | |
| link: https://github.com/elastic/integrations/pull/20628 | |
| - description: Map XG content-filtering http_referer and http_user_agent fields to ECS. | |
| type: bugfix | |
| link: https://github.com/elastic/integrations/pull/20628 | |
| - version: "3.17.2" | |
| changes: | |
| - description: Fix uri_parts processor failure on malformed URLs in XG content filtering logs. Map XG content-filtering http_referer and http_user_agent fields to ECS. Add field mapping for sophos.xg.fw_rule_name and sophos.xg.fw_rule_section. | |
| type: bugfix | |
| link: https://github.com/elastic/integrations/pull/20628 |
Since all of them are bugfix, we can merge them to a single entry.
|
Other than the one suggestion in |
|
✅ All changelog entries have the correct PR link. |
|
🟢 No issues across the latest commits fd18eb1…044a7a9 (137 commits). Review summaryIssues found across earlier commits 3b59d79 — 1 low
Issues found across earlier commits bfb7509 — 2 medium, 2 low
🤖 AI-Generated Review | Vera Review Bot - v0.2.6 | 📚 Knowledge base: integration-skills
|
💚 Build Succeeded
History
cc @haetamoudi |
|
Package sophos - 3.17.2 containing this change is available at https://epr.elastic.co/package/sophos/3.17.2/ |
Executive summary
The
uri_partsprocessor in the Sophos XGcfilteringest pipeline previously terminated document ingestion when it encountered malformed URLs (e.g., URLs containing spaces such ashttps://example .com/path). The fix adds anon_failurehandler to that processor which appends a_sophos_xg_uri_parse_failuretag to the event instead of failing, allowing the document to be ingested with partial URL fields populated. Three new field mappings (sophos.xg.fw_rule_name,sophos.xg.fw_rule_section,sophos.xg.http_referer) are also added to cover fields present in real-world XG content filtering logs that were previously undefined.Proposed commit message
Root cause
The
uri_partsprocessor incfilter.ymlhas noignore_failure: trueand its guard condition only checksctx.url?.original != null— it does not validate URI well-formedness. Sophos XG content-filtering logs can contain URLs with embedded quotes or Unicode replacement characters (U+FFFD) that survive KV parsing as a truncated, non-URI string, causinguri_partsto throw and the entire event to be routed to the pipeline-levelon_failurehandler.Approach
Add
ignore_failure: trueand anon_failureblock to theuri_partsprocessor (tag:uri_parts_url_original_to_url_cc5cc83f) incfilter.yml. The on_failure block appends a_sophos_xg_uri_parse_failuretag to the document for observability. This prevents malformedurl.originalvalues — produced when the upstream KV parser truncates URLs containing embedded quotes or Unicode replacement characters — from failing the entire event and routing it to the pipeline-levelon_failurehandler. Additionally, add a sanitized test fixture reproducing the malformed-URL case so the fix is regression-tested.Implementation
packages/sophos/data_stream/xg/elasticsearch/ingest_pipeline/cfilter.yml, locate theuri_partsprocessor at line 110 (tag:uri_parts_url_original_to_url_cc5cc83f) and addignore_failure: trueplus anon_failureblock that appends_sophos_xg_uri_parse_failureto thetagsfield withallow_duplicates: false.packages/sophos/data_stream/xg/_dev/test/pipeline/test-xg-cfilter-new.log, append a new test log line using the sanitized event from the issue (url contains a space, making it an invalid URI):<30>device_name="host-1.example.local" timestamp="2026-06-26T17:38:04+0200" device_model="XGS4500" device_serial_id="SN000000000001" log_id="050901616001" log_type="Content Filtering" log_component="HTTP" log_subtype="Allowed" log_version=1 severity="Information" fw_rule_id="26" fw_rule_name="LAN to WAN allow Webaccess" fw_rule_section="Local rule" web_policy_id=13 http_category="InvalidUrl" url="https://example .com/path?ip=198.51.100.85&id=example-id" content_type="application/octet-stream" src_ip="198.51.100.85" dst_ip="203.0.113.137" protocol="TCP" src_port=50215 dst_port=443 bytes_sent=3727 bytes_received=1129 domain="example.com" http_user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0" http_status="200" transaction_id="89a1d5c1-2b3e-4f67-8a9b-0c1d2e3f4a5b" http_referer="https://example.com/" con_id=2068019904 app_is_cloud="FALSE" used_quota="0" src_zone_type="LAN" src_zone="LAN" dst_zone_type="WAN" dst_zone="WAN" src_country="JPN" dst_country="USA" app_risk=77 app_category="5593"packages/sophos/data_stream/xg/_dev/test/pipeline/test-xg-cfilter-new.log-expected.jsonby runningelastic-package test pipeline --generateand verify that: (a) the new test case does NOT haveevent.kind: pipeline_error, (b)url.originalis preserved as the malformed URL string, (c) thetagsarray contains_sophos_xg_uri_parse_failure, and (d) all pre-existing test cases still pass.packages/sophos/changelog.ymlwith version3.17.2, typebugfix, and descriptionFix uri_parts processor failure on malformed URLs in XG content filtering logs.packages/sophos/manifest.ymlto bumpversionfrom3.17.1to3.17.2.Pipeline changes
ignore_failure: trueto theuri_partsprocessor (tag:uri_parts_url_original_to_url_cc5cc83f) incfilter.ymlon_failureblock to the sameuri_partsprocessor that appends_sophos_xg_uri_parse_failureto thetagsfield withallow_duplicates: falseField / mapping changes
—
Sanitized error message
Processor 'uri_parts' with tag 'uri_parts_url_original_to_url_cc5cc83f' in pipeline 'logs-sophos.xg-cfilter' failed with message '[on_failure_message]'Sanitized log (
event_sanitizedexcerpt)Reviewer concerns
_sophos_xg_uri_parse_failurewill haveurl.domainandurl.fullpopulated (from earlier pipeline processors) but will be missingurl.scheme,url.path,url.query, andurl.portthaturi_partswould normally produce; any Kibana queries or detection rules that assume those subfields are always present for Content Filtering events should be reviewed.fw_rule_name,fw_rule_section,http_referer) are defined infields.ymland appear in the expected test output, but the diff does not show the KV/dissect processor that extracts them — a reviewer should confirm those fields are correctly extracted by the existing pipeline KV step rather than silently dropped.linkfield for version 3.17.2 contains a placeholder URL (https://github.com/elastic/integrations/pull/1) that must be updated to the real PR number before merge.Self-review findings
Self-review invoked: no (0 cycles)
Final validation passed: yes
Risk and classification
Links
616e1a4d91e0a368