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.
pip3 install aioproperty
You can find documentation here
aioproperty presents async properties with both async getter and setter in one place.
from aioproperty import aioproperty
import asyncio
class SomeClass:
@aioproperty
async def hello(self, value):
await asyncio.sleep(1)
return value
some_obj = SomeClass()
some_obj.hello = 'hello'
async def run():
print(await some_obj.hello)
asyncio.run(run())
aioproperty is not a property in a classic meaning, it keeps values inside asincio tasks. Once you set a new value, it is scheduled in a task. If any task is running now, it will wait untill it is finished. When you get value, you actually get a current task, and you can await it to get a value. More of that: you can use math without awaiting like that:
other = some_obj.hello + ' byby'
print(await other)
We also introduce chaining:
class SomeClass:
@aioproperty
async def hello(self, value):
await asyncio.sleep(1)
return value
@hello.chain
async def some_more(self, value):
push_value(value)
Chains works like a reducer. It applies each function to a new value iteratively. It can return value or return nothing.
If nothing is return, the value will be kept asis. Any chained
function is inserted by default in the end of chain, but
you can control it with a priority parameter, or with is_first parameter. If is_first is True, it will be inserted in the
beginning of the chain.
You can also use inheritance and modify inhereted properties with our special decorator inject
:
class Parent:
@aioproperty
async def hello(self, value):
await asyncio.sleep(1)
return value
@hello.chain
async def some_more(self, value):
push_value(value)
class Child(Parent):
@inject(Parent.hello, priority=100)
async def injected_method(self, value):
print('hello from injection')
#another form of injection using name of a property
@inject('hello')
async def injected_method_2(self, value):
print('hello from injection 2')
Read more in our docs
FAQs
truely async properties
We found that aioproperty 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.