feat: serve static files similar to the notebook #361
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
but limited by whitelist and blacklist rules.
Issue
When using the following in a Jupyter notebook:
The Jupyter notebook server will happily serve the svg file.
However, in voila, we consider this a security risk, since we do not assume the users are trusted (we don't want to give users access to our files). However, in voila, we'd like this to work as well.
Solution
This PR solves this by having whitelist and blacklist regexes that protect the content that is served. Each request for a file needs to match at least one whitelist regex and NO blacklist regex
E.g. to serve all files, except those starting with private, or notebook files:
To serve only images:
Uncertain
I think that we should not always redirect in the handler.py, since it tells users that a file exists (this gives an attacker information which files exists). I think we should check the rules in two places.
Should the default be as it is now (images, and notebooks/py files always blacklisted)?
TODO: