Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Mar 29, 2023
2 parents cad33b7 + 4220d32 commit 58bfd44
Show file tree
Hide file tree
Showing 553 changed files with 31,382 additions and 10,358 deletions.
10 changes: 7 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

# Notify some committers of changes in the components

/superset-frontend/src/components/Select/ @michael-s-molina @geido @ktmud
/superset-frontend/src/components/MetadataBar/ @michael-s-molina
/superset-frontend/src/components/DropdownContainer/ @michael-s-molina
/superset-frontend/src/components/Select/ @michael-s-molina @geido @kgabryje
/superset-frontend/src/components/MetadataBar/ @michael-s-molina @geido @kgabryje
/superset-frontend/src/components/DropdownContainer/ @michael-s-molina @geido @kgabryje

# Notify Helm Chart maintainers about changes in it

Expand All @@ -23,3 +23,7 @@
# Notify E2E test maintainers of changes

/superset-frontend/cypress-base/ @jinghua-qa @geido @eschutho @rusackas @betodealmeida

# Notify PMC members of changes to Github Actions

/.github/ @villebro @geido @eschutho @rusackas @betodealmeida @nytai @mistercrunch @craig-rueda @john-bodley @kgabryje
2 changes: 2 additions & 0 deletions .github/workflows/superset-python-unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
mkdir ${{ github.workspace }}/.temp
- name: Python unit tests
if: steps.check.outcome == 'failure'
env:
SUPERSET_TESTENV: true
run: |
pytest --durations-min=0.5 --cov-report= --cov=superset ./tests/common ./tests/unit_tests --cache-clear
- name: Upload code coverage
Expand Down
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ repos:
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.941
rev: v1.0.1
hooks:
- id: mypy
args: [--check-untyped-defs]
additional_dependencies: [types-all]
- repo: https://github.com/peterdemin/pip-compile-multi
rev: v2.4.1
rev: v2.6.2
hooks:
- id: pip-compile-multi-verify
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.4.0
hooks:
- id: check-docstring-first
- id: check-added-large-files
Expand All @@ -41,7 +42,7 @@ repos:
- id: trailing-whitespace
args: ["--markdown-linebreak-ext=md"]
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
language_version: python3
Expand Down
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
# Node stage to deal with static asset construction
######################################################################
ARG PY_VER=3.8.16-slim
FROM node:16-slim AS superset-node

# if BUILDPLATFORM is null, set it to 'amd64' (or leave as is otherwise).
ARG BUILDPLATFORM=${BUILDPLATFORM:-amd64}
FROM --platform=${BUILDPLATFORM} node:16-slim AS superset-node

ARG NPM_BUILD_CMD="build"
ENV BUILD_CMD=${NPM_BUILD_CMD}
Expand Down Expand Up @@ -114,7 +117,14 @@ COPY ./requirements/*.txt ./docker/requirements-*.txt/ /app/requirements/
USER root

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends libnss3 libdbus-glib-1-2 libgtk-3-0 libx11-xcb1 wget
&& apt-get install -y --no-install-recommends \
libnss3 \
libdbus-glib-1-2 \
libgtk-3-0 \
libx11-xcb1 \
libasound2 \
libxtst6 \
wget

# Install GeckoDriver WebDriver
RUN wget https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O /tmp/geckodriver.tar.gz && \
Expand Down
3 changes: 2 additions & 1 deletion RELEASING/Dockerfile.from_local_tarball
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ RUN pip install --upgrade setuptools pip \
RUN flask fab babel-compile --target superset/translations

ENV PATH=/home/superset/superset/bin:$PATH \
PYTHONPATH=/home/superset/superset/:$PYTHONPATH
PYTHONPATH=/home/superset/superset/:$PYTHONPATH \
SUPERSET_TESTENV=true
COPY from_tarball_entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion RELEASING/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _get_pull_request_details(self, git_log: GitLog) -> Dict[str, Any]:
title = pr_info.title if pr_info else git_log.message
pr_type = re.match(SUPERSET_PULL_REQUEST_TYPES, title)
if pr_type:
pr_type = pr_type.group().strip('"')
pr_type = pr_type.group().strip('"') # type: ignore

labels = (" | ").join([label.name for label in pr_info.labels])
is_risky = self._is_risk_pull_request(pr_info.labels)
Expand Down
1 change: 1 addition & 0 deletions RELEASING/from_tarball_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set -ex

echo "[WARNING] this entrypoint creates an admin/admin user"
echo "[WARNING] it should only be used for lightweight testing/validation"
if $SUPERSET_TESTENV then echo "SUPERSET IS RUNNING IN TEST MODE"

# Create an admin user (you will be prompted to set username, first and last name before setting a password)
superset fab create-admin \
Expand Down
1 change: 0 additions & 1 deletion RESOURCES/FEATURE_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ These features are **finished** but currently being tested. They are usable, but
- DASHBOARD_FILTERS_EXPERIMENTAL
- DASHBOARD_NATIVE_FILTERS
- DYNAMIC_PLUGINS: [(docs)](https://superset.apache.org/docs/installation/running-on-kubernetes)
- ENABLE_FILTER_BOX_MIGRATION
- ENABLE_JAVASCRIPT_CONTROLS
- GENERIC_CHART_AXES
- GLOBAL_ASYNC_QUERIES [(docs)](https://github.com/apache/superset/blob/master/CONTRIBUTING.md#async-chart-queries)
Expand Down
15 changes: 15 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ assists people when migrating to a new version.

## Next

- [23226](https://github.com/apache/superset/pull/23226) Migrated endpoint `/estimate_query_cost/<int:database_id>` to `/api/v1/sqllab/estimate/`. Corresponding permissions are can estimate query cost on SQLLab. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22809](https://github.com/apache/superset/pull/22809): Migrated endpoint `/superset/sql_json` and `/superset/results/` to `/api/v1/sqllab/execute/` and `/api/v1/sqllab/results/` respectively. Corresponding permissions are `can sql_json on Superset` to `can execute on SQLLab`, `can results on Superset` to `can results on SQLLab`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22931](https://github.com/apache/superset/pull/22931): Migrated endpoint `/superset/get_or_create_table/` to `/api/v1/dataset/get_or_create/`. Corresponding permissions are `can get or create table on Superset` to `can get or create dataset on Dataset`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22882](https://github.com/apache/superset/pull/22882): Migrated endpoint `/superset/filter/<datasource_type>/<int:datasource_id>/<column>/` to `/api/v1/datasource/<datasource_type>/<datasource_id>/column/<column_name>/values/`. Corresponding permissions are `can filter on Superset` to `can get column values on Datasource`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22789](https://github.com/apache/superset/pull/22789): Migrated endpoint `/superset/recent_activity/<user_id>/` to `/api/v1/log/recent_activity/<user_id>/`. Corresponding permissions are `can recent activity on Superset` to `can recent activity on Log`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22913](https://github.com/apache/superset/pull/22913): Migrated endpoint `/superset/csv` to `/api/v1/sqllab/export/`. Corresponding permissions are `can csv on Superset` to `can export csv on SQLLab`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22496](https://github.com/apache/superset/pull/22496): Migrated endpoint `/superset/slice_json/<int:layer_id>` to `/api/v1/chart/<int:id>/data/`. Corresponding permissions are `can slice json on Superset` to `can read on Chart`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22496](https://github.com/apache/superset/pull/22496): Migrated endpoint `/superset/annotation_json/<int:layer_id>` to `/api/v1/chart/<int:id>/data/`. Corresponding permissions are `can annotation json on Superset` to `can read on Chart`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22624](https://github.com/apache/superset/pull/22624): Migrated endpoint `/superset/stop_query/` to `/api/v1/query/stop`. Corresponding permissions are `can stop query on Superset` to `can read on Query`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22579](https://github.com/apache/superset/pull/22579): Migrated endpoint `/superset/search_queries/` to `/api/v1/query/`. Corresponding permissions are `can search queries on Superset` to `can read on Query`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22501](https://github.com/apache/superset/pull/22501): Migrated endpoint `/superset/tables/<int:db_id>/<schema>/` to `/api/v1/database/<int:id>/tables/`. Corresponding permissions are `can tables on Superset` to `can read on Database`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [22611](https://github.com/apache/superset/pull/22611): Migrated endpoint `/superset/queries/` to `api/v1/query/updated_since`. Corresponding permissions are `can queries on Superset` to `can read on Query`. Make sure you add/replace the necessary permissions on any custom roles you may have.
- [23186](https://github.com/apache/superset/pull/23186): Superset will refuse to start if a default `SECRET_KEY` is detected on a non Flask debug setting.
- [22022](https://github.com/apache/superset/pull/22022): HTTP API endpoints `/superset/approve` and `/superset/request_access` have been deprecated and their HTTP methods were changed from GET to POST
- [20606](https://github.com/apache/superset/pull/20606): When user clicks on chart title or "Edit chart" button in Dashboard page, Explore opens in the same tab. Clicking while holding cmd/ctrl opens Explore in a new tab. To bring back the old behaviour (always opening Explore in a new tab), flip feature flag `DASHBOARD_EDIT_CHART_IN_NEW_TAB` to `True`.
- [20799](https://github.com/apache/superset/pull/20799): Presto and Trino engine will now display tracking URL for running queries in SQL Lab. If for some reason you don't want to show the tracking URL (for example, when your data warehouse hasn't enabled access for to Presto or Trino UI), update `TRACKING_URL_TRANSFORMER` in `config.py` to return `None`.
Expand All @@ -44,6 +57,8 @@ assists people when migrating to a new version.

### Other

- [23118](https://github.com/apache/superset/pull/23118): Previously the "database access on <database>" permission granted access to all datasets on the underlying database, but they didn't show up on the list views. Now all dashboards, charts and datasets that are accessible via this permission will also show up on their respective list views.

## 2.0.1

- [21895](https://github.com/apache/superset/pull/21895): Markdown components had their security increased by adhering to the same sanitization process enforced by Github. This means that some HTML elements found in markdowns are not allowed anymore due to the security risks they impose. If you're deploying Superset in a trusted environment and wish to use some of the blocked elements, then you can use the HTML_SANITIZATION_SCHEMA_EXTENSIONS configuration to extend the default sanitization schema. There's also the option to disable HTML sanitization using the HTML_SANITIZATION configuration but we do not recommend this approach because of the security risks. Given the provided configurations, we don't view the improved sanitization as a breaking change but as a security patch.
Expand Down
1 change: 1 addition & 0 deletions docker/.env-non-dev
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ REDIS_PORT=6379
FLASK_ENV=production
SUPERSET_ENV=production
SUPERSET_LOAD_EXAMPLES=yes
SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
CYPRESS_CONFIG=false
SUPERSET_PORT=8088
MAPBOX_API_KEY=''
2 changes: 2 additions & 0 deletions docs/docs/contributing/local-backend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pip install -r requirements/testing.txt
pip install -e .

# Initialize the database
# Note: For generating a SECRET_KEY if you haven't done already, you can use the command:
# echo "SECRET_KEY='$(openssl rand -base64 42)'" | tee -a superset_config.py
superset db upgrade

# Create an admin user in your metadata database (use `admin` as username to be able to load the examples)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ to get visual feedback.
<img src={useBaseUrl("/img/tutorial/tutorial_explore_run.jpg" )} />

In the following screenshot, we craft a grouped Time-series Bar Chart to visualize
our quarterly sales data by product line just be clicking options in drop-down menus.
our quarterly sales data by product line just by clicking options in drop-down menus.

<img src={useBaseUrl("/img/tutorial/tutorial_explore_settings.jpg" )} />

Expand Down
14 changes: 7 additions & 7 deletions docs/docs/installation/alerts-reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ creator if either is contained within the list of owners, otherwise the first ow
will be used) and finally `THUMBNAIL_SELENIUM_USER`, set as follows:

```python
from superset.reports.types import ReportScheduleExecutor
from superset.tasks.types import ExecutorType

ALERT_REPORTS_EXECUTE_AS = [
ReportScheduleExecutor.CREATOR_OWNER,
ReportScheduleExecutor.CREATOR,
ReportScheduleExecutor.MODIFIER_OWNER,
ReportScheduleExecutor.MODIFIER,
ReportScheduleExecutor.OWNER,
ReportScheduleExecutor.SELENIUM,
ExecutorType.CREATOR_OWNER,
ExecutorType.CREATOR,
ExecutorType.MODIFIER_OWNER,
ExecutorType.MODIFIER,
ExecutorType.OWNER,
ExecutorType.SELENIUM,
]
```

Expand Down
12 changes: 8 additions & 4 deletions docs/docs/installation/configuring-superset.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ SUPERSET_WEBSERVER_PORT = 8088
# Your App secret key will be used for securely signing the session cookie
# and encrypting sensitive information on the database
# Make sure you are changing this key for your deployment with a strong key.
# You can generate a strong key using `openssl rand -base64 42`
# You can generate a strong key using `openssl rand -base64 42`.
# Alternatively you can set it with `SUPERSET_SECRET_KEY` environment variable.
SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY'
# The SQLAlchemy connection string to your database backend
Expand Down Expand Up @@ -285,7 +285,11 @@ If you want to rotate the SECRET_KEY(change the existing secret key), follow the
Add the new SECRET_KEY and PREVIOUS_SECRET_KEY to `superset_config.py`:

```python
PREVIOUS_SECRET_KEY = 'CURRENT_SECRET_KEY' # The default SECRET_KEY for deployment is '21thisismyscretkey12eyyh'
SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY'
PREVIOUS_SECRET_KEY = 'CURRENT_SECRET_KEY'
# To find out 'CURRENT_SECRET_KEY' follow these steps
# 1. Got to superset shell : $ superset shell
# 2. Run the command : >>> from flask import current_app; print(current_app.config["SECRET_KEY"])

SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY' # Generate a secure SECRET_KEY usng "openssl rand -base64 42"
```
Then run `superset re-encrypt-secrets`
8 changes: 7 additions & 1 deletion docs/docs/installation/installing-superset-from-scratch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ We don't recommend using the system installed Python. Instead, first install the
[homebrew](https://brew.sh/) manager and then run the following commands:

```
brew install readline pkg-config libffi openssl mysql postgres
brew install readline pkg-config libffi openssl mysql postgresql
```

You should install a recent version of Python (the official docker image uses 3.8.16). We'd recommend using a Python version manager like [pyenv](https://github.com/pyenv/pyenv) (and also [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv)).
Expand Down Expand Up @@ -138,6 +138,12 @@ superset load_examples
# Create default roles and permissions
superset init
# Build javascript assets
cd superset-frontend
npm ci
npm run build
cd ..
# To start a development web server on port 8088, use -p to bind to another port
superset run -p 8088 --with-threads --reload --debugger
```
Expand Down
47 changes: 42 additions & 5 deletions docs/docs/installation/sql-templating.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ made available in the Jinja context:
For example, to add a time range to a virtual dataset, you can write the following:

```sql
SELECT * from tbl where dttm_col > '{{ from_dttm }}' and dttm_col < '{{ to_dttm }}'
SELECT *
FROM tbl
WHERE dttm_col > '{{ from_dttm }}' and dttm_col < '{{ to_dttm }}'
```

You can also use [Jinja's logic](https://jinja.palletsprojects.com/en/2.11.x/templates/#tests)
Expand Down Expand Up @@ -64,6 +66,41 @@ JINJA_CONTEXT_ADDONS = {
}
```

Default values for jinja templates can be specified via `Parameters` menu in the SQL Lab user interface.
In the UI you can assign a set of parameters as JSON

```json
{
"my_table": "foo"
}
```
The parameters become available in your SQL (example: `SELECT * FROM {{ my_table }}` ) by using Jinja templating syntax.
SQL Lab template parameters are stored with the dataset as `TEMPLATE PARAMETERS`.

There is a special ``_filters`` parameter which can be used to test filters used in the jinja template.

```json
{
"_filters": [
{
"col": "action_type",
"op": "IN",
"val": ["sell", "buy"]
}
]
}
```

```sql
SELECT action, count(*) as times
FROM logs
WHERE action in {{ filter_values('action_type'))|where_in }}
GROUP BY action
```

Note ``_filters`` is not stored with the dataset. It's only used within the SQL Lab UI.


Besides default Jinja templating, SQL lab also supports self-defined template processor by setting
the `CUSTOM_TEMPLATE_PROCESSORS` in your superset configuration. The values in this dictionary
overwrite the default Jinja template processors of the specified database engine. The example below
Expand Down Expand Up @@ -174,7 +211,7 @@ Here's a concrete example:

- You write the following query in SQL Lab:

```
```sql
SELECT count(*)
FROM ORDERS
WHERE country_code = '{{ url_param('countrycode') }}'
Expand All @@ -185,15 +222,15 @@ Here's a concrete example:
and your coworker in the USA the following SQL Lab URL `www.example.com/superset/sqllab?countrycode=US`
- For your coworker in Spain, the SQL Lab query will be rendered as:

```
```sql
SELECT count(*)
FROM ORDERS
WHERE country_code = 'ES'
```

- For your coworker in the USA, the SQL Lab query will be rendered as:

```
```sql
SELECT count(*)
FROM ORDERS
WHERE country_code = 'US'
Expand Down Expand Up @@ -222,7 +259,7 @@ This is useful if:

Here's a concrete example:

```
```sql
SELECT action, count(*) as times
FROM logs
WHERE
Expand Down
18 changes: 11 additions & 7 deletions docs/docs/security.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ For example, the filters `client_id=4` and `client_id=5`, applied to a role,
will result in users of that role having `client_id=4` AND `client_id=5`
added to their query, which can never be true.

### Content Security Policiy (CSP)
### Content Security Policy (CSP)

[Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) is an added
layer of security that helps to detect and mitigate certain types of attacks, including
Expand All @@ -146,12 +146,16 @@ A policy is described using a series of policy directives, each of which describ
a certain resource type or policy area. You can check possible directives
[here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy).

It's extremely important to correclty configure a Content Security Policy when deploying Superset to
prevent many types of attacks. For that matter, Superset provides the ` TALISMAN_CONFIG` key in `config.py`
where admnistrators can define the policy. When running in production mode, Superset will check for the presence
of a policy and if it's not able to find one, it will issue a warning with the security risks. For environments
It's extremely important to correctly configure a Content Security Policy when deploying Superset to
prevent many types of attacks. Superset provides two variables in `config.py` for deploying a CSP:

- `TALISMAN_ENABLED` defaults to `False`; set this to `True` in order to implement a CSP
- `TALISMAN_CONFIG` holds the actual the policy definition (*see example below*).

When running in production mode, Superset will check at startup for the presence
of a CSP. If one is not found, it will issue a warning with the security risks. For environments
where CSP policies are defined outside of Superset using other software, administrators can disable
the warning using the `CONTENT_SECURITY_POLICY_WARNING` key in `config.py`.
this warning using the `CONTENT_SECURITY_POLICY_WARNING` key in `config.py`.

#### CSP Requirements

Expand All @@ -161,7 +165,7 @@ the warning using the `CONTENT_SECURITY_POLICY_WARNING` key in `config.py`.
default-src 'self' 'unsafe-eval' 'unsafe-inline'
```

* Some dashbaords load images using data URIs and require `data:` in their `img-src`
* Some dashboards load images using data URIs and require `data:` in their `img-src`

```
img-src 'self' data:
Expand Down
Loading

0 comments on commit 58bfd44

Please sign in to comment.