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
Python: Aiohttp improvements #13731
base: main
Are you sure you want to change the base?
Python: Aiohttp improvements #13731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me
The one major thing about the addition of remote-flow-sources based off type-annotations is that we will introduce new shorter paths. In the example below, it's much more interesting to see the whole path starting at handler with a bad sanitizer, than seeing the path that only starts at the req parameter in foo. Would like to think a little about this aspect
@routes.post(...)
async def handler(request: aiotthp.web.Request):
if request.host == "127.0.0.1":
foo(request)
...
async def foo(req: aiohttp.web.Request):
db.cursor().execute(await req.content.read())Can you please add tests? I expect in these two files
- python/ql/test/library-tests/frameworks/aiohttp/client_request.py
- pyhton/ql/test/library-tests/frameworks/aiohttp/response_test.py
- python/ql/test/library-tests/frameworks/aiohttp/taint_test.py (for the new remote-flow-source)
|
Actually, we should also add a test in python/ql/test/library-tests/frameworks/aiohttp/taint_test.py (for the new remote-flow-source) |
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
|
Thanks @RasmusWL, I added the tests, but not sure how the inline tests expect. Can you please take a look? |
But notice that keyword argument is not handled yet
However, notice that the concepts tests use the HttpResponse location for the `responseBody` tag, which seems a little odd in this situation, where they are actually separate. Will fix in next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. I fixed up tests a bit (checking if we handle keyword arguments as well), and while I had the code checked out locally, I improved the modeling a little more as well.
Overall this LGTM, but let us just think a little more about the potential problem with what paths are shwon before merging. (will also run a performance test, just to be sure)
|
Thanks for fixing the tests @RasmusWL! As for the heuristic sources, in JS they have in a different file that you can enable to opt-in for more results. Perhaps thats a way to implement it until the subflow filtering is implemented |
I think calling it a "heuristic sources" is not doing enough justice to what you're doing here. For me, a heuristic source would be something like: "we see that a parameter is called request, so it's probably an incoming HTTP request, and we'll model all attributes as tainted". So I think 100% we should include the new sources, it's just a matter of question how to do it. |
|
Evaluation was fine I've made a minor naming update to highlight that this is not a heuristic source, and changed the char-pred so it's not overlapping with |


Few improvements for the aiohttp framework support:
FileResponseClientSession.ws_connect