Compare commits

...

3 Commits

Author SHA1 Message Date
herel dd9bdf84f3 fix: update dependencies (1.4.1) 2026-07-01 16:09:24 +02:00
herel 80f4b4047c chore(deploy): 512Mi ram 2026-07-01 15:56:08 +02:00
herel cc64d126be fix(api): Add upper bound validation to num_exercises
The /generate and /generate-operations endpoints accepted num_exercises
without an upper bound, allowing DoS via excessively large values.
Add Field(le=100) to both ExerciseRequest and OperationExerciseRequest
Pydantic models to cap exercises at 100.

Fixes vuln-0001
2026-07-01 15:07:10 +02:00
4 changed files with 26 additions and 26 deletions
+4 -4
View File
@@ -8,7 +8,7 @@ from typing import List
from fastapi import FastAPI, Request, Form
from fastapi.responses import HTMLResponse, RedirectResponse, StreamingResponse
from fastapi.templating import Jinja2Templates
from pydantic import BaseModel
from pydantic import BaseModel, Field
from fpdf import FPDF
import logging
@@ -68,13 +68,13 @@ class MathExercisesPDF(FPDF):
class ExerciseRequest(BaseModel):
min_table: int
max_table: int
num_exercises: int = 15
num_exercises: int = Field(15, ge=1, le=100)
multiplication_only: bool = False
max_first_operand: int = 12 # New parameter for the maximum value of the first operand
max_first_operand: int = Field(12, ge=1, le=12) # New parameter for the maximum value of the first operand
class OperationExerciseRequest(BaseModel):
num_exercises: int = 20
num_exercises: int = Field(20, ge=1, le=100)
def generate_exercises(
+1 -1
View File
@@ -41,7 +41,7 @@ spec:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
memory: "512Mi"
cpu: "500m"
# Liveness probe
livenessProbe:
@@ -13,7 +13,7 @@ resources:
images:
- name: math-exercises
newName: harbor.cl1.parano.ch/library/math-exercice
newTag: 1.4.0
newTag: 1.4.1
# Production-specific labels
+20 -20
View File
@@ -1,32 +1,32 @@
annotated-doc==0.0.4
annotated-types==0.7.0
anyio==4.12.0
boto3==1.42.6
boto3-stubs==1.42.6
botocore==1.42.6
botocore-stubs==1.42.6
click==8.3.1
anyio==4.14.1
boto3==1.43.38
boto3-stubs==1.43.38
botocore==1.43.38
botocore-stubs==1.43.14
click==8.4.2
defusedxml==0.7.1
fastapi==0.124.0
fonttools==4.61.0
fpdf2==2.8.5
fastapi==0.138.2
fonttools==4.63.0
fpdf2==2.8.7
h11==0.16.0
idna==3.11
idna==3.18
Jinja2==3.1.6
jmespath==1.0.1
jmespath==1.1.0
MarkupSafe==3.0.3
pillow==12.0.0
pydantic==2.12.5
pydantic_core==2.41.5
pillow==12.3.0
pydantic==2.13.4
pydantic_core==2.46.4
python-dateutil==2.9.0.post0
python-multipart==0.0.20
s3transfer==0.16.0
python-multipart==0.0.32
s3transfer==0.19.0
six==1.17.0
sniffio==1.3.1
starlette==0.50.0
types-awscrt==0.29.2
starlette==0.46.2
types-awscrt==0.34.1
types-s3transfer==0.16.0
typing-inspection==0.4.2
typing_extensions==4.15.0
urllib3==2.6.1
uvicorn==0.38.0
urllib3==2.7.0
uvicorn==0.49.0