Files
pruefwerk/fixtures/nightly/eco/py-pipenv/app.py
T
sharang 44a48957c1
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Dashboard (push) Skipped
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Skipped
CI / Deploy Agent (push) Successful in 3m53s
feat(ci): JavaScript/TypeScript and Python fixtures for the nightly (#310) (#331)
2026-09-23 08:15:00 +00:00

47 lines
1.2 KiB
Python

"""Customer records service. Planted for the scan regression."""
import hashlib
import os # noqa-free on purpose: ruff reports this unused import (F401)
import subprocess
import yaml
from flask import Flask, request
app = Flask(__name__)
@app.route("/import", methods=["POST"])
def import_records():
# Unsafe deserialisation: the loader executes tags in the payload.
records = yaml.load(request.data, Loader=yaml.Loader)
# Personal data written to the log (GDPR pattern).
for record in records:
app.logger.info(
"imported %s <%s> national_id=%s",
record["full_name"],
record["email"],
record["national_id"],
)
return {"imported": len(records)}
@app.route("/report")
def report():
name = request.args.get("customer", "")
# Shell command built from request input.
out = subprocess.check_output("report-for " + name, shell=True)
return out
def fingerprint(value: str) -> str:
# Weak hash used as an identifier.
return hashlib.md5(value.encode()).hexdigest()
def load_settings(path: str) -> dict:
try:
with open(path) as handle:
return yaml.safe_load(handle)
except: # ruff reports the bare except (E722)
return {}