Restrict exception-node deserialization to known classes without importing the stored name#68511
Open
potiuk wants to merge 1 commit into
Open
Restrict exception-node deserialization to known classes without importing the stored name#68511potiuk wants to merge 1 commit into
potiuk wants to merge 1 commit into
Conversation
3baa424 to
0e8d29d
Compare
0e8d29d to
653105f
Compare
Member
Author
|
@ashb - would that be a good enough check ? |
653105f to
2523f45
Compare
2523f45 to
8719b77
Compare
… name
When deserializing AIRFLOW_EXC_SER / BASE_EXC_SER nodes, BaseSerialization
resolved the exception class with import_string() on a name taken from the
serialized blob. Resolve it against in-memory classes instead, so a stored
DAG never imports a class named in the blob:
- AIRFLOW_EXC_SER: look the name up in a map of loaded AirflowException
subclasses, built once from the in-memory subclass tree; a name that is
not a registered AirflowException subclass is rejected.
- BASE_EXC_SER: resolve against the fixed {KeyError, AttributeError} set
that the encoder is the only producer of.
Unknown or disallowed names raise DeserializationError instead of being
imported. The trigger-node branch is handled separately.
Generated-by: Claude Opus 4.8 following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
8719b77 to
83485d9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When deserializing
AIRFLOW_EXC_SER/BASE_EXC_SERnodes, the exception class was resolved byimport_string()on a name taken from the serialized blob. This resolves it against in-memory classes instead, so deserializing a stored DAG never imports a class named in the blob:AIRFLOW_EXC_SER— looked up in a map of loadedAirflowExceptionsubclasses, built once from the in-memory subclass tree and never rebuilt; a name that isn't a registeredAirflowExceptionsubclass is rejected.BASE_EXC_SER— resolved against the fixed{KeyError, AttributeError}set, which is all the encoder ever emits for this node type.Unknown or disallowed names raise
DeserializationErrorinstead of being imported. The trigger-node branch is handled separately in #67926.Tests
AIRFLOW_EXC_SERname that isn't a registeredAirflowExceptionsubclass is rejected (not imported)AirflowExceptionsubclass round-trips via the registryBASE_EXC_SERname outside{KeyError, AttributeError}(e.g.eval,ValueError) rejectedKeyError/AttributeErrorstill round-tripWas generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.8 following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions