from dodgygithubproject import *
import requests
I wish to log the connection info (user agent/header etc) for every request made by dodgygithubproject.
Is that a job for contextmanager? How can I be sure that every connection gets logged in the sub-classes etc?
See this answer from elsewhere on stackoverflow, if you're sure that all requests are using the requests package:
https://stackoverflow.com/a/16337639/6709958
Essentially, you just need to activate logging.
You shouldn't expect application code to be called in a certain way (especially not something you think is malicious), instead, you should monitor outgoing HTTP requests externally, for example via Wireshark (related question on Super User).
If you have the code to somedodgygithubproject, you would have to read all of it, and all of its dependencies, in order to see what it does. For example, it would only take a simple import os; os.system('curl https://some-site') to not get noticed by any python code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With