allow fetching file urls when experimental permissions are enabled#3775
allow fetching file urls when experimental permissions are enabled#3775KhafraDev wants to merge 3 commits intonodejs:mainfrom
Conversation
|
I think there are a few rough edges to fix still, but this is fine currently.
Fetching file URLs is heavily requested and leads to things that work in the browser, Deno, and Bun, but not node ( What I am getting at: this is practically useless in its current state. Should I remove the requirement on the permission system? Or, should we use permissions if they're available, and allow fetching any file URL if they aren't? |
Developers put unsanitized URLs in fetch() all the time. This is security vs DX, and this time I don't think we can support DX.
We could if we added another option like I think this would be the best option. If so, print an experimental warning. |
|
My biggest issue is definitely the fourth point: having to explicitly enable every permission if you use any permissions. As in, to allow fetching file URLs, without changing your app's functionality, you need to do:
Then of course you might limit reading files, so I assume most people will |
|
Adding an option seems like a false sense of security to me. If any dependency/sub-dependency uses the option, the same vulnerabilities will exist as if we disregarded permissions. When the |
|
Note that if they only limit reading the current folder, or just a few files in it, this will be safe to use. |
There was a problem hiding this comment.
I think we don't need to enforce permission model here. It should be up to the user.
My suggestion is:
- Allow user to opt-in to the fetch file URLs through a config option (as Matteo suggested)
- If permission model is enabled we check if the user has access to the file request
- If don't, a custom message is exhibited (the current state) -
Access to ${fileURL.href} is not permitted
- If don't, a custom message is exhibited (the current state) -
I don't think a library should change its behavior based on permission model state. It should be transparent to users.
|
@KhafraDev are you ok if we land this in v8? |
RafaelGSS
left a comment
There was a problem hiding this comment.
permission is no longer experimental
Co-authored-by: Rafael Gonzaga <rafael.nunu@hotmail.com>
5b273c0 to
b416293
Compare
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3775 +/- ##
==========================================
- Coverage 92.90% 92.86% -0.04%
==========================================
Files 112 112
Lines 35638 35651 +13
==========================================
Hits 33109 33109
- Misses 2529 2542 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Sorry for the late response, I am going to close this in favor of #4907 |
this enables fetching file urls when permissions are enabled and we have
fs.readaccess to the file.