Repository navigation
fix(report): keep finding zip names on a rune boundary - #322
Merged
Merged
Conversation
FindingFilename cut the name at 120 bytes, which can split a multi-byte character. archive/zip only sets the UTF-8 flag on valid names, so the entry was written without it and unzip tools decoded the whole name as CP437, garbling every non-ASCII character in it.
BaaRai
approved these changes
Nov 18, 2026
BaaRai
left a comment
Owner
There was a problem hiding this comment.
The cut now lands on a rune boundary, and the test asserts the zip writer keeps the UTF-8 flag, which is the actual failure: one invalid byte makes readers decode the whole name as CP437. Thanks.
|
sha256:ed07d43bbd92b95476859ab02c670ca765e8ba56d5e26731067aa95b1d477397 |
1 similar comment
|
sha256:ed07d43bbd92b95476859ab02c670ca765e8ba56d5e26731067aa95b1d477397 |
|
__ |
shantidevi876422-beep
approved these changes
Nov 18, 2026
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.
Exporting findings as a Markdown zip garbles the file name of any finding whose name is long and not ASCII. With a finding named
用户资料页面个人简介富文本编辑器存在存储型跨站脚本漏洞可窃取管理员会话令牌并接管账户(severity high), the zip entry is listed byunzip/Python'szipfileashigh_τö¿µê╖Φ╡äµûÖ…µ.md.FindingFilenamecaps the name at 120 bytes withname[:120], which can cut a multi-byte character in half (here the name ends in a stray\xe8).archive/ziponly sets the UTF-8 flag (general purpose bit 11) when the entry name is valid UTF-8, so the entry is written without it and readers fall back to CP437 for the whole name, not just the last character. Names that fit in 120 bytes are unaffected, which is why short Chinese names export fine.The fix drops the trailing partial character after the cut with
strings.ToValidUTF8, so the name stays valid UTF-8 and at most 120 bytes.I added
TestFindingsZipLongNonASCIINameStaysUTF8, which builds the archive throughwriteFindingsEvidenceZip(what themd-zipexport serves) and reads the entry back. Before the fix it fails withNonUTF8=trueand the name ending in\xe8; after it passes, and the exported entry reads back ashigh_用户资料页面…令牌并.mdwith flag0x808.go test ./reportstill passes.Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.