Skip to content

DeliciousBounty/Vulnerable-FastAPI

Repository files navigation

FastApi E-commerce Applications Endpoints 👋

Code Samples

Just to show you how the flow works here is the working example of the get_item/id endpoint.

main.py

@app.get("/get_item/{id}", response_model=schemas.ItemAInfo)
def get_user(id, db:Session = Depends(get_db)):
    db_item = crud.get_item_by_id(db, id=id)
    if db_item is None:
        raise HTTPException(status_code=400, detail="No item found")
    return db_item

The above piece of code handles the endpoint and calls the function get_item_by_id in the crud.py file for further processing.

crud.py

def get_item_by_id(db: Session, id: int):
    return db.query(models.ItemInfo).filter(models.ItemInfo.id == id).first()

The above piece of code handles the get_item_by_id call and queries the DB for an item with the id passed in the parameter

Install

This Application works with mysql database, you need to create a database, check the database.py file for more information. To create a new database:

mysql 
CREATE DATABASE restapi;

Then

git clone 
source fastapienv/bin/activate
pip3 install -r requirements.txt
pip3 install mysql-connector-python

cd sql_app

Usage

uvicorn main:app --reload

Vulnerabilies

To test for vulnerabilities use the openapi_version1.json and buid Cherrybomb from the branch dev_last_nathan

Give a ⭐️ if this project helped you!

About

vulnerable app written in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published