WUT_Computer_Science/Programming
Krzysztof kuhy Rudnicki f58f55f68b
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (push) Waiting to run
runnability / runnability (push) Waiting to run
ERSMS-project: zero findings, and the SQL is parameterised now
156 ruff findings to 0. That takes the whole archive to 0, from 9,281.

Six of those findings were SQL injection, and they were the real ones. The
connector interpolated a username and an OAuth id straight out of the URL into
f-string SQL. With psycopg2 installed, the difference is not theoretical:

  username = "x'; DROP TABLE users; --"
  old:  select * from users where username='x'; DROP TABLE users; --';
  new:  select * from users where username='x''; DROP TABLE users; --';

The old form is two statements and the second one runs. The new one is a
parameter, so the whole thing stays a string literal. Every query in that file
is parameterised now.

`get_recommendations` also called
`cursor.execute("... oauth_ID='{}'", oauth_ID)`, which is wrong twice over:
psycopg2 wants %s rather than {}, and its second argument must be a sequence,
not a bare string. That route could never have worked.

Ten blind `except Exception` handlers turned every programming error into a
500 with the message hidden. They are now the exceptions each block can
actually raise -- verified against the installed libraries, where
InvalidIdTokenError and ExpiredIdTokenError really are FirebaseError
subclasses -- and the handlers log a traceback instead of printing the
exception's str().

Three services bound `host="localhost"`. Each of them runs in a container with
a published port, on a compose bridge network, so binding loopback makes them
unreachable from both the host and their siblings. All four now read
ERSMS_HOST, which docker-compose sets to 0.0.0.0, and default to loopback when
run outside Docker. Flask's debug console executes arbitrary code, so that is
opt-in via FLASK_DEBUG too.

`movie_recommender.py` fitted the model at import: reading two CSVs and
building a 4803x4803 similarity matrix as a side effect of `import`. It failed
outright here, since the datasets are not committed. It is in `main()` now, and
the module imports cleanly. `error_decorator` was dead code that swallowed its
wrapped function's return value; it is gone.

Verified: all four modules import (the backend still needs its Firebase
credential JSON, which is not committed, exactly as before), the recommender's
helpers still pick the director out of a crew list, trim cast to three, fold
"Tom Hanks" to "tomhanks" and join a soup in the same order, and every route
parameter rename was matched by the URL rule it comes from.

Three of the four services are clean under mypy --strict. The backend keeps
four errors: flask-sqlalchemy builds `db.Model` dynamically, so `--strict`
refuses to subclass it. Migrating to a typed DeclarativeBase would rewrite both
models in an app that cannot be run here, so those four are reported in
TODO-refactor-remaining.md rather than hidden.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-29 08:30:01 +02:00
..
AIS Split 19 over-cap LaTeX reports, proving each PDF is unchanged 2026-08-28 19:47:12 +02:00
BD2 Add a run.sh to every course, and fix the code that would not build 2026-08-28 18:37:55 +02:00
BSS Run all 33 safe courses; fix what that broke 2026-08-28 18:52:31 +02:00
E-PSYOPS Run all 33 safe courses; fix what that broke 2026-08-28 18:52:31 +02:00
EADS Add a run.sh to every course, and fix the code that would not build 2026-08-28 18:37:55 +02:00
EARIN PORR runs in 28s, and three checks so the next pass cannot repeat my mistakes 2026-08-28 20:50:46 +02:00
ECOAR Add a run.sh to every course, and fix the code that would not build 2026-08-28 18:37:55 +02:00
ECOTE ECOTE and ECRYPT_PROJECT: zero findings, tests still green 2026-08-28 20:03:01 +02:00
ECRYPT Hold the coursework to the same lint bar as the tooling 2026-08-28 19:53:04 +02:00
ECRYPT_PROJECT ECOTE and ECRYPT_PROJECT: zero findings, tests still green 2026-08-28 20:03:01 +02:00
EGUI Add a run.sh to every course, and fix the code that would not build 2026-08-28 18:37:55 +02:00
EOOP Run all 33 safe courses; fix what that broke 2026-08-28 18:52:31 +02:00
EOPSY Split 19 over-cap LaTeX reports, proving each PDF is unchanged 2026-08-28 19:47:12 +02:00
EPFU Add a run.sh to every course, and fix the code that would not build 2026-08-28 18:37:55 +02:00
ERSMS-project ERSMS-project: zero findings, and the SQL is parameterised now 2026-08-29 08:30:01 +02:00
NLP PORR: zero findings, 18 tests still passing after every refactor 2026-08-28 21:01:13 +02:00
PBAD PBAD: zero findings across three notebooks, outputs bit-for-bit intact 2026-08-29 08:15:56 +02:00
PORR PORR: zero findings, 18 tests still passing after every refactor 2026-08-28 21:01:13 +02:00
PSD PSD: zero findings, and four modules that no longer run on import 2026-08-29 08:22:57 +02:00
psd_project Add a run.sh to every course, and fix the code that would not build 2026-08-28 18:37:55 +02:00
TRAK TRAK: zero findings, and a byte-identical render proving it 2026-08-29 07:54:51 +02:00
twm_4 twm_4: zero findings, with the notebook's outputs proved untouched 2026-08-29 08:10:31 +02:00
USD Add a run.sh to every course, and fix the code that would not build 2026-08-28 18:37:55 +02:00
WDWR Hold the coursework to the same lint bar as the tooling 2026-08-28 19:53:04 +02:00
ZPOB Make ZPOB build: its essay was handed in without a bibliography 2026-08-28 19:18:11 +02:00