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.
The goal of this package is to help you to implement the Health Check API pattern.
pip install fastapi-health
Create the health check endpoint dynamically using different conditions. Each condition is a callable, and you can even have dependencies inside of it:
from fastapi import FastAPI, Depends
from fastapi_health import health
def get_session():
return True
def is_database_online(session: bool = Depends(get_session)):
return session
app = FastAPI()
app.add_api_route("/health", health([is_database_online]))
The health()
method receives the following parameters:
conditions
: A list of callables that represents the conditions of your API, it can return either bool
or a dict
.success_output
: An optional dictionary that will be the content response of a successful health call.failure_output
: An optional dictionary analogous to success_output
for failure scenarios.success_status
: An integer that overwrites the default status (200) in case of success.failure_status
: An integer that overwrites the default status (503) in case of failure.It's important to notice that you can have a peculiar behavior in case of hybrid return statements (bool
and dict
) on the conditions.
For example:
from fastapi import FastAPI
from fastapi_health import health
def healthy_condition():
return {"database": "online"}
def sick_condition():
return False
app = FastAPI()
app.add_api_route("/health", health([healthy_condition, sick_condition]))
This will generate a response composed by the status being 503 (default failure_status
), because sick_condition
returns False
, and the JSON body {"database": "online"}
. It's not wrong, or a bug. It's meant to be like this.
This project is licensed under the terms of the MIT license.
FAQs
Heath check on FastAPI applications.
We found that fastapi-health 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.