-
Notifications
You must be signed in to change notification settings - Fork 60
Fix relative file path verification on Windows #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add isTrulyAbsolute helper to distinguish between truly absolute paths and rooted relative paths - On Windows, paths starting with / or \ followed by .. or . are now correctly treated as relative - On Unix, paths starting with /../ or /./ are also correctly treated as relative - Add comprehensive unit tests for path resolution logic - All existing tests still pass Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
- Extract startsWithRelativeMarker helper function to avoid code duplication - Remove redundant checks after path normalization - Both Windows and Unix platforms now use the same helper for consistency Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
sergey-tihon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix CI build
Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Fixed in commit 3e1ed8b. The build was failing because Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot fix tests |
The unit tests (123 tests in SwaggerProvider.Tests) are passing successfully. However, the provider integration tests (SwaggerProvider.ProviderTests) are failing during compilation because the type providers need to fetch OpenAPI schemas from external URLs like This is a network/environment issue rather than a code issue with the relative path fix. The provider tests would need network access or local schema files to build successfully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a Windows-specific issue where relative file path verification was failing when paths containing parent directory references (..) were concatenated with __SOURCE_DIRECTORY__. The fix introduces more nuanced path classification logic that correctly distinguishes between truly absolute paths and rooted paths with relative markers.
Key changes:
- Introduced
startsWithRelativeMarkerandisTrulyAbsolutehelper functions to properly classify paths across Windows and Unix - Modified
getAbsolutePathto handle rooted paths with drive letters vs. rooted paths without drive letters differently - Added comprehensive unit tests to verify path resolution behavior across platforms
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/SwaggerProvider.DesignTime/Utils.fs |
Added helper functions startsWithRelativeMarker and isTrulyAbsolute to correctly identify absolute vs. relative paths; updated getAbsolutePath logic to handle Windows paths with drive letters and Unix paths with proper security checks for path traversal attempts |
tests/SwaggerProvider.Tests/PathResolutionTests.fs |
New test file with comprehensive coverage of path resolution scenarios including concatenated paths with parent directory references, relative paths, absolute paths (both Windows and Unix), URLs, and real-world __SOURCE_DIRECTORY__ usage patterns |
tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj |
Added reference to the new test file PathResolutionTests.fs in the compilation order |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.