Closed alorence closed 8 months ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
modernrpc/apps.py | 6 | 10 | 60.0% | ||
<!-- | Total: | 6 | 10 | 60.0% | --> |
Totals | |
---|---|
Change from base Build 8065652169: | -0.5% |
Covered Lines: | 737 |
Relevant Lines: | 752 |
Thanks @atodorov for your feedbacks. I just implemented some of them, and renamed a few things. Some documentations and comments were also added. In addition, I updated the way tests are run around this change, and I dropped the need to define a custom live_server fixture. So basically, we do not need to drop Django 2.1 support anymore...
This change was originally suggested by @atodorov, thanks to him for this contribution.
Currently, django-modern-rpc uses builtin
xmlrpc.client.loads()
function to parse incoming requests. But this can cause a security issue when an attacker send a valid but malicious XML-RPC request.A Python package can help to mitigate this kind of attack, defusedxml (GitHub repo).
The goal of this PR is to implement
defusedxml
support in django-modern-rpcCurrently:
defusedxml.xmlrpc.monkey_patch()
is called fromModernRpcConfig.ready()
when available<!ENTITY key "value">
syntax in XML-RPC request is disabled and raise an exception on parsing stepdefusedxml.xmlrpc.monkey_patch()
is not called, or whendefusedxml.xmlrpc.unmonkey_patch()
is called after project initializationRemaining
Drawbacks
Due to a limitation in the wayedit: this is not true anymorelive_server
fixture has been customized for these tests, Django 2.1 cannot be supported anymore