Repository navigation
fix(seclang): use slash paths for fs.FS include roots on Windows - #1784
Conversation
FromFile joined relative Include paths and derived the include directory with filepath, so on Windows an fs.Sub, embed or mergefs root was handed backslash names that io/fs rejects. The same directory becomes ConfigDir, so @pmFromFile data next to an included file could not be found either. Convert those names to slashes unless the root is io.OSFS, which takes OS paths. UNC and device paths are left as they are. Nothing changes where the separator is already a slash.
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
fzipi
left a comment
There was a problem hiding this comment.
Thanks, this is the right spot: every include path (Include, WithDirectivesFromFile) goes through FromFile, and the operators already path.Join ConfigDir, so this also fixes @pmFromFile data under an fs.FS root. On Linux and macOS fsPath is a no-op, so nothing changes there. Checked go test ./internal/seclang/... plus GOOS=windows go vet/go test -c locally.
Our CI only runs on Linux, so no test here fails without the fix; noting that the Windows result was checked by hand.
Non-blocking follow-up: in fsPath, the UNC/device check (len(filepath.VolumeName(name)) > 2) only runs for roots that are not io.OSFS, but the comment says only an OS-backed root can open those paths. If no non-OS root can open them, the condition can go; otherwise the comment could name the root type it protects.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1784 +/- ##
=======================================
Coverage 88.58% 88.58%
=======================================
Files 180 180
Lines 9601 9605 +4
=======================================
+ Hits 8505 8509 +4
Misses 824 824
Partials 272 272
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
On Windows,
Parser.FromFilebuilt relativeIncludepaths and the include directory withfilepath, sofs.Sub,embedand mergefs roots (coraza-caddy loads CRS this way) got backslash names, whichio/fsrejects. That directory also becomesConfigDir, which broke@pmFromFiledata next to an included file.Both are now converted to slashes unless the root is
io.OSFS, which takes OS paths. UNC and device paths are left alone, and nothing changes on Linux or macOS. This follows #1135 by @jabdr, without the build-tagged reader.TestEmbedFSandTestGlobIncludeFromSubdirectoryalready fail on Windows before this change and pass after, so I did not add a test. Tested with the seclang tests on Windows, and on Linux under the default, no_memoize, multiphase and no_regex_multiline tags.Part of #1140.
Summary by CodeRabbit