superset: Talisman Config not updated from superset_config.py
When setting content-security-policy options through the superset_config file these are not accepted during startup
I am running superset from scratch (3.0.0. installed via pipenv from pypi) und python3.10. my superset config file as dev environment
How to reproduce the bug
- Go to superset_config and amend / change the talisman content-security policy with 3rd party websites like (I copied this also under TALISMAN_DEV_CONFIG):
TALISMAN_CONFIG = {
"content_security_policy": {
"default-src": ["'self'"],
"frame-src": ["'self'", "https://service.xxxx.com"]
"img-src": ["'self'", "data:", "https://service.xxxx.com"],
"worker-src": ["'self'", "blob:"],
"connect-src": [
"'self'",
"https://api.mapbox.com",
"https://events.mapbox.com",
],
"object-src": "'none'",
"style-src": [
"'self'",
"'unsafe-inline'",
"https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css",
],
"script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'"],
},
"content_security_policy_nonce_in": ["script-src"],
"force_https": False,```
- Start superset
- Create markdown chart with img-src / frame-src pointing to third party website
<center> <img width = 20px style="padding-bottom:5px;padding-top:10px" src="data:image/png;base64...."> </br> <img height = 70px src="https://service.xxxx.com/icons/Pfeil_oben_links.svg"> <p style="font-size: 35px;font-weight:bold;padding-top:0px;padding-bottom:00px">-</p> </center>
- Load page
- Links are NOT loaded and browser console shows (directive in error message does NOTinclude changes to content-security-policy):
Refused to load the image '<URL>' because it violates the following Content Security Policy directive: "img-src 'self' data:".
- However changing the config.py code directly can be used as a workaround:
- change the superset/config.py file directly in the package directory.
- Repeat steps 2 & 4 with fully refreshing browser - content is loaded
Expected results
content-security-policy should be read from the superset_config.py file and b e considered during startup
Actual results
settings are ignored and can only be changed in superset source code directly
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
- browser type and version: Edge Version 117.0.2045.60 (64-Bit)
- superset version:
3.0.0 - python version:
3.10.13 - node.js version:
node not installed - any feature flags active:
Checklist
Make sure to follow these steps before submitting your issue - thank you!
- [ x] I have checked the superset logs for python stacktraces and included it here as text if there are any.
- [ x] I have reproduced the issue with at least the latest released version of superset.
- [ x] I have checked the issue tracker for the same issue and I haven’t found one similar.
Additional context
Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 17 (12 by maintainers)
For anyone still facing this, I had
DEBUG=Truein my Superset configs, which makesTALISMAN_DEV_CONFIGoverrideTALIMAN_CONFIG:https://github.com/apache/superset/blob/18c2376b5022afb9214314289636b0480081806a/superset/initialization/__init__.py#L617
In general for every deployment method it would be nice if we added both instructions specific to that method for where to put superset_config.py (I have a PR open to make this clearer for PyPI) and a troubleshooting step for users trying to verify that file is getting picked up.
I have sometimes advised people to enable a feature flag, then look to see if that corresponding functionality is enabled in the application. But we can do better and this comes up a lot.
I don’t know if there is such a guide, actually. I also don’t use Helm (I live in a luxurious world where @craig-rueda and @dpgaspar do the infra magic for Preset), but maybe @villebro or @nytai can suggest something. If this does get resolved, we’d love to see the addition of more details in the documentation if you’re up for it (cc @sfirke).
TALISMAN_CONFIG is in there by default now, so it shouldn’t be crashing (we would hear a LOT about that). You should be able to set
img-srcto be'self' data: <URL>and it should work. Closing this since it’s a config issue rather than a bug, but happy to revisit if needed.