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
File node: Add fileWorkingDirectory to customise how relative paths are resolved #2932
Conversation
I like this, I was talking about how securely add a persistent volume to a multi-tenant system earlier to allow the use of the file nodes and this was one of the things that came up. It might be worth looking to see if we can add a mode to force absolute paths to be rooted to here as well. e.g. |
@hardillb - where does inputPath come from ? At the same time as above we should block relative paths to prevent path traversal escapes. |
@dceejay it was just meant to represent what ever the user had configured. And yes we can use something like I'll try and find an hour to have a poke at the code properly |
Personally I think we should also block access to the in use .node-red directory to prevent access to creds files settings etc - either accidentally or maliciously. |
It should also display(but not allow edit) the setting in the html file so the user knows where they are appending to. |
This setting is just about being able to define the root path rather than leaving it to the working directory of the Node-RED process. That's it. I agree there's a separate option that would be useful to restrict the file nodes to only that directory - but it is a separate option that needs defining.
I understand what you mean, but I'm not sure it's that simple. For example, there are plenty of legitimate reasons for a flow to read/write to the A combination of |
Agreed - a specific node could do whatever it wants so can use .node-red - but I think the generic file node should be safe by default. It could be exactly that dir and not include children so .node-red/public could be allowed. Not sure it needs an extra setting. |
There is the suggestion of an extra setting to limit access to whatever If we do any sort of restriction by default of the |
ok - so re fileWorkingDirectory specifically
|
Proposed changes
Currently if a relative path is used in the File nodes, it is resolved relative to the working directory of the Node-RED process.
That is non-obvious to new users and they don't necessarily know what the cwd is.
This change introduces
RED.settings.fileWorkingDirectory
that allows the user to set a specific directory to be used to resolve relative paths.This PR only touches the File nodes. We should review other nodes that handle local paths and update them to honour this setting.
Checklist
grunt
to verify the unit tests pass