| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
… protections (pythonGH-139368) Expose the XML Expat 2.7.2 APIs to tune protections against "billion laughs" [1] attacks. The exposed APIs are available on Expat parsers, that is, parsers created by `xml.parsers.expat.ParserCreate()`, as: - `parser.SetBillionLaughsAttackProtectionActivationThreshold(threshold)`, and - `parser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor)`. This completes the work in f04bea4, and improves the existing related documentation. [1]: https://en.wikipedia.org/wiki/Billion_laughs_attack (cherry picked from commit 6661123) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Documentation build overview393 files changed · ± 376 modified · - 17 deleted ± Modified
- Deleted
|
Sorry, something went wrong.
| self.assert_root_parser_failure(setter, 123.45) | ||
|
|
||
|
|
||
| @unittest.skipIf(expat.version_info < (2, 4, 0), "requires Expat >= 2.4.0") |
There was a problem hiding this comment.
I think we had a recent issue where this check was not sufficient and tests needed to be disabled in another way using hasattr() checks. Can you check how it's currently done on main please?
Sorry, something went wrong.
There was a problem hiding this comment.
It's identical on main?
cpython/Lib/test/test_pyexpat.py
Lines 1265 to 1266 in d8ff4f8
Sorry, something went wrong.
There was a problem hiding this comment.
Ah indeed, but the problem was for the other API:
@unittest.skipIf(not hasattr(expat.XMLParserType,
"SetAllocTrackerMaximumAmplification"),
"requires Python compiled with Expat >= 2.7.2")
So I think the version check for billion laughs is also wrong and should be changed to the same as for SetAllocTrackerMaximumAmplification. But let's address this separately later in a follow-up PR (so as to ease backports)
Sorry, something went wrong.
|
LGTM but I'd appreciate if @hartwork could have a quick glance just for wordings. I hope every backport has been merged properly (if we are matching against 3.15 then it should good). It's just that I remember that the work was split across multiple PRs... |
Sorry, something went wrong.
@StanFromIreland I have just had a quick look through the lense of… # diff -u1 <(git diff 666112376d574c7802646ee1df6244062671cd61{^,}) <(git diff upstream-readonly/3.14...StanFromIreland/backport-6661123-3.14) | ydiff …and I see:
Are these intended or accidental? |
Sorry, something went wrong.
I think I updated these at some points but I don't remember in which direction. I would say: pick the style that we currently have on main, it doesn't matter. I just don't want to have docs that are different across versions. |
Sorry, something went wrong.
|
@picnixz +1 from me for being in line with main 👍 |
Sorry, something went wrong.
| capi->SetAllocTrackerActivationThreshold = NULL; | ||
| capi->SetAllocTrackerMaximumAmplification = NULL; |
There was a problem hiding this comment.
the else is the wrong here actually, it's SetBillionLaughsAttackProtectionActivationThreshold
Sorry, something went wrong.
There was a problem hiding this comment.
It's the same on main:
Lines 2548 to 2554 in 9fdbade
Sorry, something went wrong.
There was a problem hiding this comment.
I wrote #151147 for main/3.15, for here:
| capi->SetAllocTrackerActivationThreshold = NULL; | |
| capi->SetAllocTrackerMaximumAmplification = NULL; | |
| capi->SetBillionLaughsAttackProtectionActivationThreshold = NULL; | |
| capi->SetBillionLaughsAttackProtectionMaximumAmplification = NULL; |
Sorry, something went wrong.
There was a problem hiding this comment.
Oh!
Sorry, something went wrong.
There was a problem hiding this comment.
Now I think we're good. If docs need to be amended we'll do it but C should be ok.
Sorry, something went wrong.
|
Fuzzer failures are unrelated (ast and plistlib). |
Sorry, something went wrong.
|
Thanks @StanFromIreland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
|
Sorry, @StanFromIreland, I could not cleanly backport this to 3.13 due to a conflict. cherry_picker c078637e8642783d90b33c6b983fa15ff29c24d6 3.13 |
Sorry, something went wrong.
|
GH-151151 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Expose the XML Expat 2.7.2 APIs to tune protections against "billion laughs" 1 attacks.
The exposed APIs are available on Expat parsers, that is, parsers created by xml.parsers.expat.ParserCreate(), as:
This completes the work in f04bea4, and improves the existing related documentation.