Uh oh!
There was an error while loading. Please reload this page.
fs: move ToNamespacedPath to c++ - #52135
Conversation
nodejs-github-bot
commented
Mar 18, 2024
Review requested:
|
003590b to
2d120caCompareanonrig
commented
Mar 18, 2024
cc @nodejs/platform-windows Any idea where this error/warning is thrown from? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
LiviaMedeiros
commented
Mar 18, 2024
AFAICT the changes are implying that |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
anonrig
commented
Mar 18, 2024
getValidatedPath() result is called with |
d93f610 to
5c62bf2CompareLiviaMedeiros
commented
Mar 18, 2024
Sorry, I read the changes wrong. It doesn't affect js-side |
nodejs-github-bot
commented
Mar 18, 2024
RafaelGSS
commented
Mar 19, 2024
This should land first #52148. |
RafaelGSS
left a comment
There was a problem hiding this comment.
As @joyeecheung suggested on my initial PR for node::pathResolve, I suggest you do the same for path.toNamespacePath. Change the bindings in a different PR and run the tests to see if it works.
Example: #51295
anonrig
commented
Mar 19, 2024
@RafaelGSS the function signature is not 1 to 1. We're always using BufferValue in node:fs. |
I think this is different from #51295 in that, the other PR only used the C++ version in a not very well-tested branch (only when permission is enabled) so if it's broken, we may not be able to know due to the low test coverage. This PR however changed most fs bindings so if it's broken, it's probably more likely that some tests would fail on Windows. That said I think we already don't have enough test cases to check the kind of paths that are need to be handled specially by |
8ab9cf7 to
a611c98Compareanonrig
commented
Jun 17, 2024
@RafaelGSS can you look into the permission model changes? I removed an unnecessary test since we don't use path.toNamespacedPath anymore in JS world, and updated several paths and surrounded them with |
nodejs-github-bot
commented
Jun 17, 2024
| })); | ||
| } | ||
| // Monkey-patching path module should also not allow path traversal. |
There was a problem hiding this comment.
Regardless if we are moving the implementation to C++ I believe path.toNamespacedPath will always exist through an API right? If so, I don't think we should remove this test, it won't fail anyway.
There was a problem hiding this comment.
I think its not needed but on top of that It fails because win32 path resolves return "." for cwd, but previously it didn't.
| assert.strictEqual(fs.existsSync(pathname), true); | ||
| assert.strictEqual(fs.statSync(pathname).isDirectory(), true); | ||
| assert.strictEqual(p, firstPathCreated); | ||
| assert.strictEqual(p, path.toNamespacedPath(firstPathCreated)); |
There was a problem hiding this comment.
Can you explain why we are changing the comparison to include the path.toNamespacedPath? Did tmpdir.resolve API change somehow? If so, isn't it a breaking change?
There was a problem hiding this comment.
Technically it isn't since both paths are the same and from Windows perspective having a path with namespaced value does not really have any difference with without the prefix.
PS: Namespaced paths are used to avoid "path is too long" errors on Windows. If you look into this file, you'll see that we already check the value surrounded by toNamespacedPath in several places already. I feel like this is more complete.
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Jun 18, 2024
nodejs-github-bot
commented
Jun 19, 2024
nodejs-github-bot
commented
Jun 20, 2024
Landed in 399eb33 |
Co-Authored-By: Daniel Lemire <daniel@lemire.me> PR-URL: #52135 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Co-Authored-By: Daniel Lemire <daniel@lemire.me> PR-URL: nodejs#52135 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This is a step forward to move all
node:fsimplementation to C++. Since we now have support forwin32.pathResolve()in C++, we can move forward with movingToNamespacedPathfunctions to C++.In a follow up pull-request, I'll move
FromNamespacedPath()from node_url.cc to path.cccc @nodejs/fs @RafaelGSS