Python/Flask, intentionally outdated dependencies (flask 2.0.1, requests 2.25.1, urllib3 1.26.4) for SCA demo. CWE-89, CWE-327, CWE-798, CWE-22 in legacy_billing.py.
27 lines
659 B
Python
27 lines
659 B
Python
from flask import Flask, jsonify, request
|
|
import legacy_billing
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route("/health")
|
|
def health():
|
|
return jsonify(status="healthy")
|
|
|
|
|
|
@app.route("/api/payments/<int:payment_id>")
|
|
def get_payment(payment_id):
|
|
return jsonify(id=payment_id, amount=1250, currency="CZK", status="settled")
|
|
|
|
|
|
@app.route("/api/payments", methods=["POST"])
|
|
def create_payment():
|
|
data = request.get_json(silent=True) or {}
|
|
if "amount" not in data:
|
|
return jsonify(error="Missing amount"), 400
|
|
return jsonify(id=1001, amount=data["amount"], status="pending"), 201
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0", port=5000)
|