-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
The allowed_deserialization_classes regex is broken #34093
Comments
Agree. It makes very little sense how it is defined. Especially the comment I think - if we wanted to do it more intuitively (but keep the regexp compatibility) we should do it differently
I believe this will strike the right balance between the intuitiveness of full-class specification, ability to glob-match when you want to exclude whole packages while keeping the power of regular expressions (both 1) and 2) are highly unlikely to be specified with the intention of being regular expressions). @kaxil @bolkedebruin - does it cover the intentions of the #28829 ? I believe that was the intention. The |
Thanks @potiuk. The ultimate aim of That said, I think we should do the following:
A note on (4) above: I do not advocate for trying string match, then glob match and then regex. This is way too complex for what is aimed at securing the system. It opens up a can of worms. Rather, let's just use
What do you think? |
I am also fine for that. Regexp fallback was only there as a compatibility measure and I am perfectly fine to do "glob-only" - that would by my way of implemeting it if I were to implement it from scratch. However indeed this is an obscure feature (I'd say) and using regexp was (somewhat - not completely) broken since that change and this is the first time we hear something about it, so I would not be surprised if the feature is hardly used. So it's really on the border of "is it really breaking someone's workflow". We could really treat it as a bugfix and add release notes /significant newsfragment that announcing that this feature was using regexp was a bug that is going to be fixed in the new release. I think also the radius blast of it is very limited - the worst thing that happens, the serialisation errors will fail everything if the match stops working and we can even likely update the error message to explain that this might be due to the bugfixing of the parameter and link to documentation explaining how to fix it. @kaxil @bolkedebruin - WDYT? |
@potiuk Thanks for the reply. I have just one final question (mainly because I am new to the AirFlow community): How does it work from here? Would you like me to submit a PR (which would take me some time to set up things - but would be a pleasure to help out the community) or will someone just pick this up? |
Absolutely - feel free to open a new PR (even now before getting feedback from the others). We can always iterate over the PR and get to the final solution there. And we have quite good CONTRIBUTING doss to get you started (just find it in the top level of the repo) - including some useful guidelines on setting up your IDEs and we also have |
Apache Airflow version
Other Airflow 2 version (please specify below)
What happened
In #28829, the
allowed_deserialization_classes
regex was made more intuitive. It's aim (I guess) was to ensure that a period.
be treated as a period and not as the wildcard regex character. The justification (given in #28829) was the following:To correct the above, the following substitution was provided to each space separated string provided by
allowed_deserialization_classes
:Now, assume I have a class that I want to be serialized called
this.is.an.example
. Here is the results of the following inputs toallowed_deserialization_classes
this.is.an.example
--> This would not match (note it is the identical class name). The regular expression would change it tothis\\..is\\..an\\..example
. Which means that there is an extra wildcard.
that would need be matched.this.is.an*
--> This would not match. The regular expression would change it tothis\\..is\\..an*
which suffer from the problem in the first example.this.*
--> This would match (note that this example is given in the unit tests for Make allowed_deserialization_classes more intuitive #28829). The regular expression would would change it tothis\\..*
. It will match because it will look for the word this followed by . and then the wildcard character with the wildstar character (which will match zero or all of anything). To note that this is THE only way to make things match without altering the input string.In order to make a match for
this.is.an.example
, I need to put as input inallowed_deserialization_classes
this[.]is[.]an[.]example:.
).
by doing this\.is\.an\.example which would have the identical result.In fact, any correct regex would match (even this[.]is[.]an*) as long as
re.sub(r"(\w)\.", r"\1\..", p)
does NOT alter things.What I think should happen
It is dubious to alter a regex in the first place. Airflow is aimed at technical people, and as such, proper documentation would suffice. There I suggest the following:
re.sub(r"(\w)\.", r"\1\..", p)
hello.*
obviously means match anything after hello, andhello.world.*
means match the first period as a period, but the second one as a wildcard... You see how tough this is. Because regex can have multiple reserved symbols. A better way to do it would be look forward. Maybe something like this (although regex experts, please weigh in):re.sub(r"\.(\w)", r"\\.\1", p)
(this will only escape a period if a word started directly afterwards).How to reproduce
I reproduced by copying the logic and putting it in a test task. I did the following:
Operating System
MacOS
Versions of Apache Airflow Providers
The change was introduced in #28829 which was from AirFlow
2.6.0
Deployment
Amazon (AWS) MWAA
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: