Codebase hardening: 102 fixes across 35+ files

Deep audit identified 106 findings; 102 fixed, 4 deferred. Covers 8 areas:

- Settings & deploy: env-gated DEBUG/SECRET_KEY, HTTPS headers, gunicorn, celery worker
- Auth (registered_user): password write_only, request.data fixes, transaction safety, proper HTTP status codes
- Workout app: IDOR protection, get_object_or_404, prefetch_related N+1 fixes, transaction.atomic
- Video/scripts: path traversal sanitization, HLS trigger guard, auth on cache wipe
- Models (exercise/equipment/muscle/superset): null-safe __str__, stable IDs, prefetch support
- Generator views: helper for registered_user lookup, logger.exception, bulk_update, transaction wrapping
- Generator core (rules/selector/generator): push-pull ratio, type affinity normalization, modality checks, side-pair exact match, word-boundary regex, equipment cache clearing
- Generator services (plan_builder/analyzer/normalizer): transaction.atomic, muscle cache, bulk_update, glutes classification fix

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-27 22:29:14 -06:00
parent 63b57a83ab
commit c80c66c2e5
58 changed files with 3363 additions and 1049 deletions

View File

@@ -1,4 +1,5 @@
from django.db import models
from django.conf import settings
from exercise.models import *
from registered_user.models import RegisteredUser
@@ -21,7 +22,7 @@ class Workout(models.Model):
RegisteredUser,
on_delete=models.CASCADE
)
estimated_time = models.FloatField(max_length=255, blank=True, null=True)
estimated_time = models.FloatField(blank=True, null=True)
def __str__(self):
return str(self.id) + ": " + self.name + " - " + (self.description or "") + " - by: " + str(self.registered_user.first_name) + " - on: " + str(self.created_at)
@@ -39,9 +40,9 @@ class WorkoutExercise(models.Model):
on_delete=models.CASCADE,
related_name='workout_exercise_exercise'
)
weight = models.IntegerField(null=True, blank=True, max_length=4)
reps = models.IntegerField(null=True, blank=True, max_length=4)
duration = models.IntegerField(null=True, blank=True, max_length=4)
weight = models.IntegerField(null=True, blank=True)
reps = models.IntegerField(null=True, blank=True)
duration = models.IntegerField(null=True, blank=True)
def __str__(self):
return self.workout.name + " : " + self.exercise.name