fix(helpers): relax URI decode fuzz invariant#736
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdates to URI decoding comments, unit tests, and fuzz tests: idempotence assertions removed; wording changed to emphasize parse-boundary/preserved percent-escapes and scheme-handling; new double-encoded percent test case added to fuzz corpus and unit tests. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/helpers/uris_fuzz_test.go (1)
74-88: Strengthen Property 4 to assert unknown schemes are unchanged.Right now it only verifies scheme identity, so payload/path mutation could slip through for unsupported schemes. Adding an explicit unknown-scheme equality check would align this fuzz target with the updated fuzz guidance.
Suggested invariant tightening
- // Property 4: Should preserve scheme if present and valid + // Property 4: Unknown schemes should remain unchanged + if strings.HasPrefix(uri, "example://") && result != uri { + t.Errorf("Unknown scheme changed: %q -> %q", uri, result) + } + + // Property 5: Should preserve scheme if present and valid if strings.Contains(uri, "://") && !virtualpath.ContainsControlChar(uri) { schemeEnd := strings.Index(uri, "://") schemeEnd2 := strings.Index(result, "://")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/helpers/uris_fuzz_test.go` around lines 74 - 88, The test currently only asserts that valid schemes are preserved; extend Property 4 in pkg/helpers/uris_fuzz_test.go to also assert that when origScheme is not valid (virtualpath.IsValidScheme(origScheme) == false) the entire scheme substring (origScheme) and the following "://" are preserved exactly in result (i.e., origScheme == resultScheme or equivalently the prefix up to schemeEnd2 matches), and fail the fuzz case with t.Errorf if they differ; locate the existing block using variables uri, result, schemeEnd, schemeEnd2, origScheme and resultScheme and add the additional branch that enforces equality for unknown/unsupported schemes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/helpers/uris_fuzz_test.go`:
- Around line 74-88: The test currently only asserts that valid schemes are
preserved; extend Property 4 in pkg/helpers/uris_fuzz_test.go to also assert
that when origScheme is not valid (virtualpath.IsValidScheme(origScheme) ==
false) the entire scheme substring (origScheme) and the following "://" are
preserved exactly in result (i.e., origScheme == resultScheme or equivalently
the prefix up to schemeEnd2 matches), and fail the fuzz case with t.Errorf if
they differ; locate the existing block using variables uri, result, schemeEnd,
schemeEnd2, origScheme and resultScheme and add the additional branch that
enforces equality for unknown/unsupported schemes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1605636e-834a-4ab3-aa8c-7d38545527c5
📒 Files selected for processing (4)
pkg/helpers/uris.gopkg/helpers/uris_fuzz_test.gopkg/helpers/uris_test.gopkg/testing/FUZZ_TESTING.md
Summary
%25000fuzz input and keep custom virtual path preservation focused on parse boundaries.Fixes #735
Fixes #723
Summary by CodeRabbit
Documentation
Tests