fix: avoid double-encoding alert URLs - #6653
Merged
shahargl merged 1 commit intoJul 28, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6653 +/- ##
===========================================
+ Coverage 30.49% 46.43% +15.93%
===========================================
Files 101 178 +77
Lines 11741 18694 +6953
===========================================
+ Hits 3581 8681 +5100
- Misses 8160 10013 +1853 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4737
📑 Description
Alert URL validation encoded the
%in existing%HHsequences each time an alert DTO was reconstructed. It also encoded#, which broke hash-based URLs such as Wazuh agent links.This change preserves valid percent escapes and fragments while encoding malformed percent signs exactly once. It adds regression coverage for encoded Unicode, hash fragments, raw unsafe characters, scheme-less URLs, raw Unicode paths, and malformed percent escapes, including reconstruction idempotence.
✅ Checks
ℹ Additional Information
Validation completed:
pytest tests/test_alert_dto.py -k url_encoding_is_idempotent --noconftest -o addopts='' -qpytest tests/test_alert_dto.py -k 'not test_alert_started_at' -o addopts='' -qruff check keep/api/models/alert.py tests/test_alert_dto.pyisort --check-only keep/api/models/alert.py tests/test_alert_dto.pyblack --check tests/test_alert_dto.py