Skip to content
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
2 changes: 1 addition & 1 deletion airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ core:
description: |
What classes can be imported during deserialization. This is a multi line value.
The individual items will be parsed as regexp. Python built-in classes (like dict)
are always allowed
are always allowed. Bare "." will be replaced so you can set airflow.* .
version_added: 2.5.0
type: string
default: 'airflow\..*'
Expand Down
2 changes: 1 addition & 1 deletion airflow/config_templates/default_airflow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ enable_xcom_pickling = False

# What classes can be imported during deserialization. This is a multi line value.
# The individual items will be parsed as regexp. Python built-in classes (like dict)
# are always allowed
# are always allowed. Bare "." will be replaced so you can set airflow.* .
allowed_deserialization_classes = airflow\..*

# When a task is killed forcefully, this is the amount of time in seconds that
Expand Down
1 change: 1 addition & 0 deletions airflow/serialization/serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def _compile_patterns():

_patterns.clear() # ensure to reinit
for p in patterns:
p = re.sub(r"(\w)\.", r"\1\..", p)
_patterns.append(re.compile(p))


Expand Down
11 changes: 11 additions & 0 deletions tests/serialization/test_serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
SCHEMA_ID,
VERSION,
_compile_patterns,
_match,
deserialize,
serialize,
)
Expand Down Expand Up @@ -181,6 +182,16 @@ def test_allow_list_for_imports(self):

assert f"{qualname(Z)} was not found in allow list" in str(ex.value)

@conf_vars(
{
("core", "allowed_deserialization_classes"): "tests.*",
}
)
def test_allow_list_replace(self):
_compile_patterns()
assert _match("tests.airflow.deep")
assert _match("testsfault") is False

def test_incompatible_version(self):
data = dict(
{
Expand Down