
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.
# Python 3.9+
pip install starlette-context
starlette>=0.27.0
import uvicorn
from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.requests import Request
from starlette.responses import JSONResponse
from starlette.routing import Route
from starlette_context import context, plugins
from starlette_context.middleware import ContextMiddleware
async def index(request: Request):
# Access and store data in context
context["custom_value"] = "example"
return JSONResponse(context.data)
# Define routes
routes = [
Route("/", endpoint=index)
]
# Configure middleware
middleware = [
Middleware(
ContextMiddleware,
plugins=(
plugins.RequestIdPlugin(),
plugins.CorrelationIdPlugin()
)
)
]
# Create application with routes and middleware
app = Starlette(
routes=routes,
middleware=middleware
)
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0")
In this example the response contains a JSON with:
{
"X-Correlation-ID": "5ca2f0b43115461bad07ccae5976a990",
"X-Request-ID": "21f8d52208ec44948d152dc49a713fdd",
"custom_value": "example"
}
Context can be updated and accessed at anytime if it's created in the middleware.
A huge thank you to Adverity for sponsoring the development of this OSS library.
See the contributing guide.
FAQs
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.
We found that starlette-context 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.