Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Very fast, lightweight Python asyncio http client
Here is some documentation.
There is a performance script in tests folder which shows very nice numbers
» python tests/performance.py
doing tests...
{
"aiosonic": "1000 requests in 105.53 ms",
"aiosonic cyclic": "1000 requests in 104.08 ms",
"aiohttp": "1000 requests in 184.51 ms",
"requests": "1000 requests in 1644.21 ms"
}
aiosonic is 74.84% faster than aiohttp
aiosonic is 1457.99% faster than requests
aiosonic is -1.38% faster than aiosonic cyclic
This is a very basic, dummy test, machine dependant. If you look for performance, test and compare your code with this and other packages like aiohttp.
You can perform this test by installing all test dependencies with pip install -e ".[test]"
and doing python tests/performance.py
in your own machine
pip install aiosonic
import asyncio
import aiosonic
import json
async def run():
client = aiosonic.HTTPClient()
# ##################
# Sample get request
# ##################
response = await client.get('https://www.google.com/')
assert response.status_code == 200
assert 'Google' in (await response.text())
# ##################
# Post data as multipart form
# ##################
url = "https://postman-echo.com/post"
posted_data = {'foo': 'bar'}
response = await client.post(url, data=posted_data)
assert response.status_code == 200
data = json.loads(await response.content())
assert data['form'] == posted_data
# ##################
# Posted as json
# ##################
response = await client.post(url, json=posted_data)
assert response.status_code == 200
data = json.loads(await response.content())
assert data['json'] == posted_data
# ##################
# Sample request + timeout
# ##################
from aiosonic.timeout import Timeouts
timeouts = Timeouts(
sock_read=10,
sock_connect=3
)
response = await client.get('https://www.google.com/', timeouts=timeouts)
assert response.status_code == 200
assert 'Google' in (await response.text())
print('success')
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
Install packages with poetry
Reference: https://python-poetry.org/docs/
poetry install
It is advised that you should install poetry in a serparate virtualenv (I suggest to install it with apt/pacman/etc.), other than the one you may use for development in aiosonic.
I do configure poetry with poetry config virtualenvs.in-project true
so it uses a virtualenv created in .venv/
, in aiosonic folder.
poetry run py.test
feature/your_feature
Thanks :)
FAQs
Async http client
We found that aiosonic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.