
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
A decorator for measuring asynchronous/synchronous function execution time (in seconds) is offered by this Python module.
from sandclock import sandclock
@sandclock(3) #execute f1() 3 times.
def f1(x):
print("f1: ", x)
f1("hello world")
Results:
Sandclock: synchronous <function f1 at 0x7f89eaca7e50> with args ('hello world',) {}
Sandclock: iteration: 0 started, <function f1 at 0x7f89eaca7e50> with args ('hello world',) {}
f1: hello world
Sandclock: iteration: 0 finished, <function f1 at 0x7f89eaca7e50> in 0.000823 second(s)
Sandclock: iteration: 1 started, <function f1 at 0x7f89eaca7e50> with args ('hello world',) {}
f1: hello world
Sandclock: iteration: 1 finished, <function f1 at 0x7f89eaca7e50> in 0.000075 second(s)
Sandclock: iteration: 2 started, <function f1 at 0x7f89eaca7e50> with args ('hello world',) {}
f1: hello world
Sandclock: iteration: 2 finished, <function f1 at 0x7f89eaca7e50> in 0.000151 second(s)
Sandclock: total time: 0.001050, total iterations: 3```
import aiohttp
import asyncio
from sandclock import sandclock
async def status(session: aiohttp.ClientSession, url: str) -> int:
async with session.get(url) as result:
return result.status
#execute f2() 2 times, 3 precisions, printing details of each function call.
@sandclock(2, 3, True)
async def f2():
async with aiohttp.ClientSession() as session:
urls = ['https://google.com', 'xxx://bad-request.com']
tasks = [status(session, url) for url in urls]
results = await asyncio.gather(*tasks, return_exceptions=True)
exceptions = [res for res in results if isinstance(res, Exception)]
successful_results = [res for res in results if not isinstance(res, Exception)]
print(f'All results: {results}')
print(f'Finished successfully: {successful_results}')
print(f'Threw exceptions: {exceptions}')
asyncio.run(f2())
Results:
Sandclock: coroutine <function f2 at 0x7f632fd3e430> with args () {}
Sandclock: iteration: 0 started, <function f2 at 0x7f632fd3e430> with args () {}
All results: [200, AssertionError()]
Finished successfully: [200]
Threw exceptions: [AssertionError()]
Sandclock: iteration: 0 finished, <function f2 at 0x7f632fd3e430> in 2.400 second(s)
Sandclock: iteration: 1 started, <function f2 at 0x7f632fd3e430> with args () {}
All results: [200, AssertionError()]
Finished successfully: [200]
Threw exceptions: [AssertionError()]
Sandclock: iteration: 1 finished, <function f2 at 0x7f632fd3e430> in 2.385 second(s)
Sandclock: total time: 4.785 second(s), total iterations: 2
FAQs
A decorator for examining the execution time of asynchronous/synonymous function.
We found that sandclock 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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.