This repository is a demo for the DASH24 DevSecOps workshop. It contains a sample application with an API written in Python/Flask. This application is used to show how to find and fix security issues early in the software development lifecycle.
Note for workshop attendees: Ignore the instructions in this README and follow the instructions in your lab environment.
Bootstrap the project
- If not installed, install the
venvmodule:apt-get install python3-venv - Install
sqlite3:apt-get install sqlite3 - Create a virtual environment
python -mvenv venv - Use the virtual environment
source venv/bin/activate - Install all dependencies
pip install -r requirements.txt - Init the database
rm -f db.sqlite ; sqlite3 db.sqlite < init.sql
Start the project, invoke
python service.pyTo list all products from the API, use
curl http://127.0.0.1:5000/api/product/listTo add a product via the API< use
curl -H "Content-Type: application/json" -X POST --data '{"name": "<product-name>"}' http://localhost:5000/api/product/addNavigate to
- Navigate to your repository settings
- Add a secrets for
DD_API_KEYandDD_APP_KEY
- You can find the value in your terminal by clicking
- Navigate to https://app.datadoghq.com/ci/setup/code-analysis
- Create a GitHub App
- Create
.github/workflows/datadog-sca.ymlwith the content from the onboarding page - Create
.github/workflows/datadog-static-analysis.ymlwith the content from the onboarding page - Commit your changes and the YML files
- Check the actions are correctly running in your GitHub Actions
- You should see resutls on the Datadog page
- Inspect the static analysis violations and dependencies violations
- Open the IDE
- Open the folder that contains the code
- Open the
service.pyfile and fix the violation - Open the
database.pyand fix the violation, including the SQL violation - Once all issues fixed, commit your results:
git commit -m"update flask" && git push - No violation should be found in Datadog for the static analysis
- Open the datadog interface and see the violation
- See the new version that fixes the issue
- Open
requirements.txtin your IDE - Update the
flaskdependency to3.0.3 - Commit your result:
git commit -m"update flask" && git push - See the result in your Datadog code analysis page