Commit Graph

3488 Commits

Author SHA1 Message Date
Georges-Antoine Assi
acd101816d some stuff 2026-04-09 20:57:05 -04:00
Georges-Antoine Assi
09878c2718 manual cleanup 2026-04-09 18:31:26 -04:00
Georges-Antoine Assi
1117f87adf Pass op explicitly to migration helpers instead of importing internally
Makes the helpers pure functions that receive their dependencies rather
than reaching for the global alembic op proxy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 17:47:20 -04:00
Georges-Antoine Assi
8374f152a7 cleanup 2026-04-09 17:37:48 -04:00
Georges-Antoine Assi
8189d7af4d Guard column add/drop in migrations against interrupted runs
Same DDL auto-commit problem as table creation: ALTER TABLE ADD/DROP
COLUMN can't be rolled back on MySQL/MariaDB. Adds
add_column_if_not_exists and drop_column_if_exists helpers and applies
them across all 36 migration files that use column operations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 15:31:18 -04:00
Georges-Antoine Assi
fb874c5c07 Make migrations resilient to interrupted table creation
On MySQL/MariaDB, DDL statements auto-commit and cannot be rolled back.
If a migration is interrupted after CREATE TABLE but before the Alembic
version stamp is written, the next run crashes with "table already exists"
causing a boot loop. This adds existence checks via create_table_if_not_exists
and drop_table_if_exists helpers to make all migrations re-runnable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 12:54:03 -04:00
Georges-Antoine Assi
6db9d45928 actually fix 2026-04-07 22:53:44 -04:00
Georges-Antoine Assi
5529fdad7b Merge branch 'master' into romm-3232 2026-04-07 22:39:22 -04:00
Georges-Antoine Assi
f227a3145d changes from bot review 2026-04-07 22:32:40 -04:00
Georges-Antoine Assi
6c88e098ba [ROMM-3232] Fix content_hash not updated 2026-04-07 21:48:51 -04:00
Alex Vanderveen
6aca8fdfcf Parse Content-Type essence before validating resource downloads
Problem
_check_content_type used the full Content-Type header string (lowercased) and matched it with startswith(...) against allowed prefixes.

That is mostly fine when the server sends a bare type like application/pdf. It breaks down when vendors send parameters on the same header (e.g. name="…", charset=…). In theory application/force-download; name="…" should still start with application/force-download, but in practice you can get:

Leading whitespace or a UTF‑8 BOM before the type token, so the string no longer starts with your prefix even though the MIME type is correct.
Confusing logs: logging only the lowercased full header is fine, but the decision should be based on the standardized MIME essence (type + subtype, no parameters), which is what other stacks use for “what is this?”
So the fix is to parse the header the usual way and only then apply your allowlist.

What changed
_content_type_essence(header_value)

Takes everything before the first ; (the essence).
Strips whitespace, lowercases, strips a leading BOM (\ufeff) so odd clients/proxies don’t break the check.
_check_content_type

Reads the raw content-type header once.
Runs startswith on the essence, not on the full header with parameters.
Rejects if the essence is empty (missing or useless header).
Logging uses the raw header string (or (missing header)), so operators still see exactly what the server sent.
Call sites and allowed prefixes (image/, application/pdf, etc.) are unchanged; only how the string is normalized before comparison changes.

Security / SSRF
This does not replace URL / SSRF controls; it only makes post-fetch type checking consistent with how Content-Type is defined (essence vs parameters). You are not widening the allowlist—same prefixes, stricter handling of “empty” and clearer matching on the actual type token.

Risk / regression
Low: same allowed prefixes, strictly more tolerant of benign formatting (whitespace, BOM, parameters). The only stricter case is empty essence after strip (e.g. malformed header), which correctly fails the check.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I have reviewed the proposal and these edits will handle cases where the string we match against for the content_type is cleaned up more before comparing against the allow list of content_types.

I have tested this, and confirm that I do not get any errors loading PDFs for game manuals using this.  Please consider this, as this should be compatible with the existing content type allowlist, and easily work with any new types added to it.
2026-04-07 20:25:55 -04:00
Georges-Antoine Assi
b36a8b0cdf manual types should support octet-stream and force-download response 2026-04-07 14:22:43 -04:00
Georges-Antoine Assi
0e7a75010b fix tests 2026-04-06 12:34:49 -04:00
Georges-Antoine Assi
bc58425fc9 fix tests 2026-04-06 11:29:33 -04:00
Georges-Antoine Assi
2dc1678931 changes from bot review 2026-04-06 11:22:44 -04:00
Georges-Antoine Assi
f2619ac0d1 Merge branch 'master' into pegasus-metadata-export 2026-04-06 11:06:08 -04:00
Georges-Antoine Assi
a9cc7cb543 fix migrations 2026-04-06 10:48:59 -04:00
Georges-Antoine Assi
21eee327b0 Merge branch 'master' into save-sync 2026-04-06 09:09:53 -04:00
Georges-Antoine Assi
26387c3bc1 fix check 2026-04-06 09:09:46 -04:00
Georges-Antoine Assi
e50f157987 fix check 2026-04-06 08:56:36 -04:00
Georges-Antoine Assi
af69630481 more self review 2026-04-05 23:17:57 -04:00
Georges-Antoine Assi
1501f45220 more changes from review 2026-04-05 23:15:42 -04:00
Georges-Antoine Assi
da3cd453e2 thing 2026-04-05 22:41:34 -04:00
Georges-Antoine Assi
4b7e83a8b6 restore 0070 2026-04-05 22:38:39 -04:00
Georges-Antoine Assi
fafb804bc6 mega cleanup 2026-04-05 22:35:37 -04:00
Georges-Antoine Assi
a61ff81e22 Merge branch 'master' into gamelist-customize 2026-04-05 22:11:02 -04:00
Georges-Antoine Assi
9b5feefb4f fix migrations 2026-04-05 22:06:04 -04:00
Georges-Antoine Assi
f2e8e337b2 Merge branch 'master' into save-sync 2026-04-05 21:47:53 -04:00
Georges-Antoine Assi
ea63639317 Merge pull request #3223 from rommapp/copilot/fix-age-ratings-parsing-issue
Fix age_ratings Pydantic validation error on MySQL/MariaDB for single-element arrays
2026-04-05 20:21:43 -04:00
Georges-Antoine Assi
6837070512 again 2026-04-05 20:15:06 -04:00
Georges-Antoine Assi
6c2c1db7b0 remove unused test 2026-04-05 20:06:18 -04:00
Georges-Antoine Assi
b79bcbcfce remove clud meta ID 2026-04-05 19:50:37 -04:00
Georges-Antoine Assi
8664f6203f bad removal 2026-04-05 19:19:06 -04:00
Georges-Antoine Assi
e0214f100d more bot cleanup 2026-04-05 19:15:33 -04:00
Georges-Antoine Assi
c20544f40a cleanup 2026-04-05 18:22:38 -04:00
Georges-Antoine Assi
1275b79f71 simplify 2026-04-05 17:59:53 -04:00
Georges-Antoine Assi
7c41fb5bac revert fs_name sibling roms 2026-04-05 17:57:48 -04:00
copilot-swe-agent[bot]
743b803042 Remove unnecessary migration, keep only the field validator fix
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/93332b65-c6ca-44c5-9efb-8eab5389935b

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-05 21:14:10 +00:00
copilot-swe-agent[bot]
d317b841b3 Fix age_ratings validation error for MySQL/MariaDB single-element arrays
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/27b57bfb-107a-4c4a-9d4e-89da20b98926

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-05 20:05:10 +00:00
Georges-Antoine Assi
cb96c861a6 display default entries separate 2026-04-04 14:49:37 -04:00
Georges-Antoine Assi
ef35ecaea9 props rom updte endpoint 2026-04-04 14:16:00 -04:00
Georges-Antoine Assi
494af9e4c8 Merge pull request #3217 from rommapp/copilot/fix-get-api-tasks-status-error
Fix GET /api/tasks/status 500 on expired job TTL (NoSuchJobError)
2026-04-03 14:37:21 -04:00
Georges-Antoine Assi
25362cf80b Merge pull request #3216 from rommapp/copilot/fix-delete-roms-in-subdirectories
fix: correctly delete nested (subdirectory) ROMs from filesystem
2026-04-03 14:37:07 -04:00
Georges-Antoine Assi
6cd213fc2b changes from bot review 2026-04-03 14:26:00 -04:00
Georges-Antoine Assi
dbb3b9e469 run trunk fmt 2026-04-03 14:23:45 -04:00
copilot-swe-agent[bot]
ddb0ee7699 Fix 500 error on /api/tasks/status after cleanup_missing_roms task completes
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/f7f2aeec-91a7-482f-a4f6-a921d4bdab66

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-03 17:34:25 +00:00
copilot-swe-agent[bot]
ce42957162 style: use consistent positional args for remove_file call
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/303f2c27-6b65-41a9-b201-c055142b1edb

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-03 17:33:06 +00:00
copilot-swe-agent[bot]
674061c1d3 fix: narrow OSError catch and clean up test mock
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/303f2c27-6b65-41a9-b201-c055142b1edb

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-03 17:31:14 +00:00
copilot-swe-agent[bot]
394799d7c3 fix: wrap empty parent dir cleanup in try-except and add test coverage for it
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/303f2c27-6b65-41a9-b201-c055142b1edb

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-03 17:28:50 +00:00
copilot-swe-agent[bot]
e540d7c1a2 fix: handle nested ROM directories in delete endpoint and reorder FS/DB operations
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/303f2c27-6b65-41a9-b201-c055142b1edb

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-04-03 17:26:22 +00:00