Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Richly and accurately typed wrapper around the Discord REST API.
The best way to use wumpy-rest
is to import APIClient
:
import anyio
from wumpy.rest import APIClient
TOKEN = 'ABC123.XYZ789'
async def main():
async with APIClient(TOKEN) as api:
print(await api.fetch_my_user())
anyio.run(main)
APIClient
is a class that implements all routes of the Discord API. This is
made up of multiple route classes. You can create your own class with the
routes you use:
from wumpy.rest import (
ApplicationCommandRequester, InteractionRequester,
HTTPXRequester
)
class MyAPIClient(ApplicationCommandRequester, InteractionRequester, HTTPXRequester):
__slots__ = () # Save some memory for this class
Some endpoints support uploading files, for these a file-like object is
expected that's been opened in binary-mode (for example 'rb'
).
For the message/interaction endpoints, remember to include a matching
attachment
object with 'id'
set to the index of the file.
You can pass a custom ratelimiter to the requester if you want to customize
that behaviour. For more, read the documentation.
Here's an example of a ratelimiter that does no ratelimiting and does not
handle any kind of 429
-responses.
from contextlib import asynccontextmanager
from typing import (
Any, AsyncContextManager, AsyncGenerator, Awaitable, Callable, Coroutine,
Mapping
)
import anyio
from wumpy.rest import APIClient
class NoOpRatelimiter:
"""Ratelimiter implementation that does nothing; a no-op implementation."""
async def __aenter__(self):
return self
async def __aexit__(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]
) -> object:
pass
@asynccontextmanager
async def __call__(self, route: Route) -> AsyncGenerator[
Callable[[Mapping[str, str]], Coroutine[Any, Any, object]],
None
]:
# The return type may look a little weird, but this is how
# @asynccontextmanager works. You pass it a function that returns an
# async generator (which yields what the asynchronous context manager
# then returns).
yield self.update
async def update(self, headers: Mapping[str, str]) -> object:
pass
async def main():
async with APIClient(TOKEN, ratelimiter=NoOpRatelimiter()) as api:
print(await api.fetch_my_user())
anyio.run(main)
FAQs
Reusable and richly typed wrapper over the Discord REST API
We found that wumpy-rest 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.