Skip to content
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

Fix 4 security vulnerabilities #4390

Merged
merged 6 commits into from
Feb 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def get_git_sha():
'thrift>=0.9.3',
'thrift-sasl>=0.2.1',
'unidecode>=0.04.21',
'bleach==2.1.2',
],
extras_require={
'cors': ['Flask-Cors>=2.0.0'],
Expand Down
6 changes: 6 additions & 0 deletions superset/assets/javascripts/dashboard/components/GridCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ class GridCell extends React.PureComponent {
annotationQuery={annotationQuery}
/>
</div>
{
/* This usage of dangerouslySetInnerHTML is safe since it is being used to render
markdown that is sanitized with bleach. See:
https://github.com/apache/incubator-superset/pull/4390
and
https://github.com/apache/incubator-superset/commit/b6fcc22d5a2cb7a5e92599ed5795a0169385a825 */}
<div
className="slice_description bs-callout bs-callout-default"
style={isExpanded ? {} : { display: 'none' }}
Expand Down
2 changes: 1 addition & 1 deletion superset/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def import_datasources(path, sync, recursive=False):
with f.open() as data_stream:
dict_import_export_util.import_from_dict(
db.session,
yaml.load(data_stream),
yaml.safe_load(data_stream),
sync=sync_array)
except Exception as e:
logging.error('Error when importing datasources from file %s', f)
Expand Down
10 changes: 6 additions & 4 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,12 @@ class CeleryConfig(object):
SQL_CELERY_RESULTS_DB_FILE_PATH = os.path.join(DATA_DIR, 'celery_results.sqlite')

# static http headers to be served by your Superset server.
# The following example prevents iFrame from other domains
# and "clickjacking" as a result
# HTTP_HEADERS = {'X-Frame-Options': 'SAMEORIGIN'}
HTTP_HEADERS = {}
# This header prevents iFrames from other domains and
# "clickjacking" as a result
HTTP_HEADERS = {'X-Frame-Options': 'SAMEORIGIN'}
# If you need to allow iframes from other domains (and are
# aware of the risks), you can disable this header:
# HTTP_HEADERS = {}

# The db id here results in selecting this one as a default in SQL Lab
DEFAULT_DB_ID = None
Expand Down
8 changes: 8 additions & 0 deletions superset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import uuid
import zlib

import bleach
import celery
from dateutil.parser import parse
from flask import flash, Markup, redirect, render_template, request, url_for
Expand Down Expand Up @@ -433,11 +434,18 @@ def error_msg_from_exception(e):


def markdown(s, markup_wrap=False):
safe_markdown_tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'b', 'i',
'strong', 'em', 'tt', 'p', 'br', 'span',
'div', 'blockquote', 'code', 'hr', 'ul', 'ol',
'li', 'dd', 'dt', 'img', 'a']
safe_markdown_attrs = {'img': ['src', 'alt', 'title'],
'a': ['href', 'alt', 'title']}
s = md.markdown(s or '', [
'markdown.extensions.tables',
'markdown.extensions.fenced_code',
'markdown.extensions.codehilite',
])
s = bleach.clean(s, safe_markdown_tags, safe_markdown_attrs)
if markup_wrap:
s = Markup(s)
return s
Expand Down