Skip to content

fix(screenscraper): inject user credentials for all standard media downloads#3438

Merged
gantoine merged 5 commits into
rommapp:masterfrom
Spinnich:fix/screenscraper-std-media-credentials
May 26, 2026
Merged

fix(screenscraper): inject user credentials for all standard media downloads#3438
gantoine merged 5 commits into
rommapp:masterfrom
Spinnich:fix/screenscraper-std-media-credentials

Conversation

@Spinnich
Copy link
Copy Markdown
Contributor

Description
PR #3414 added add_ss_auth_to_url() and wired it up for extra media
downloads (store_media_file — fanart, bezels, etc.), but the three standard
media fields — url_cover, url_manual, and url_screenshots — were left
unguarded in both the scan socket and the ROM update endpoint. Those downloads
were hitting screenscraper.fr without ssid/sspassword, consuming the shared
anonymous/dev quota instead of the user's quota.

  • ss_handler.py — adds a screenscraper.fr domain guard to
    add_ss_auth_to_url so it is safe to call unconditionally on any URL;
    non-SS URLs (IGDB, LaunchBox, etc.) are returned unchanged, preventing
    credential leakage to third-party servers
  • endpoints/sockets/scan.py — applies add_ss_auth_to_url to
    url_cover, url_manual, and url_screenshots in _identify_rom
  • endpoints/roms/__init__.py — same at all three call sites in update_rom
  • handler/scan_handler.py — fixes a DetachedInstanceError caused by
    accessing the deferred multi_file column_property on a detached Rom
    instance; replaces rom.has_nested_single_file or rom.has_multiple_files
    with fs_rom["nested"], which carries the same meaning and is always
    populated from the filesystem scan

Checklist

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

@Spinnich
Copy link
Copy Markdown
Contributor Author

Sorry for needing to iterate on this one last time. I think we're truly covering all media types now however.

Also, I don't quite understand why this is failing but it seems to be related to PR #3437

@Spinnich Spinnich requested a review from gantoine May 26, 2026 20:43
…reenshot downloads

Standard media fields (url_cover, url_manual, url_screenshots) were downloaded
using the stored credential-less URLs, causing them to count against the anonymous
IP quota instead of the user's SS account. Apply add_ss_auth_to_url() at each
download call site in the scan and ROM update paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

fix(screenscraper): guard add_ss_auth_to_url against non-SS URLs

Only inject ssid/sspassword into screenscraper.fr URLs to prevent
leaking user credentials to third-party sources (IGDB, LaunchBox, etc.)
when url_cover/url_manual/url_screenshots originate from other providers.

Add tests for the non-SS no-op and empty-string edge cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

test(screenscraper): verify SS credentials injected for all media download paths

- TestAddSsAuthToUrl: add guards for non-SS URLs (IGDB, LaunchBox) and
  empty string inputs
- test_update_rom: verify ssid/sspassword appear in url_cover and
  url_manual args passed to get_cover/get_manual for screenscraper.fr
  URLs; verify IGDB URLs are NOT decorated with SS credentials
- TestScanCredentialInjection: verify the scan-path ternary pattern
  correctly applies add_ss_auth_to_url to cover and screenshot URLs,
  and that a None cover URL passes through without error

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

test(screenscraper): empirical audit — every SS request carries ssid/sspassword

Intercepts both HTTP clients at the transport/session level to verify
that every outgoing screenscraper.fr request is decorated with the user's
ssid and sspassword credentials:

  aiohttp (API calls via auth_middleware):
  - jeuInfos.php, jeuRecherche.php, ssinfraInfos.php, ssuserInfos.php

  httpx (media downloads via FSResourcesHandler):
  - get_cover          → url_cover
  - get_manual         → url_manual
  - get_rom_screenshots → url_screenshots (each URL)
  - store_media_file   → extra media (fanart, bezel, etc.)

Also verifies the domain guard: IGDB URLs passed through add_ss_auth_to_url
are NOT decorated with SS credentials.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Spinnich Spinnich force-pushed the fix/screenscraper-std-media-credentials branch 2 times, most recently from 4ca595a to 3c2f421 Compare May 26, 2026 22:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to ensure ScreenScraper media downloads use user credentials at download time while keeping stored URLs credential-free, and includes a scan logging fix plus dependency resolution metadata updates.

Changes:

  • Applies add_ss_auth_to_url() to standard cover, manual, and screenshot downloads in scan/update paths.
  • Adds a ScreenScraper URL guard before injecting credentials.
  • Updates scan logging to avoid detached ORM property access and adjusts uv locking configuration.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
backend/handler/metadata/ss_handler.py Adds domain gating to ScreenScraper credential injection helper.
backend/endpoints/sockets/scan.py Injects ScreenScraper auth for standard media during scan and tightens special media handling.
backend/endpoints/roms/__init__.py Injects ScreenScraper auth for standard media during ROM updates and tightens special media handling.
backend/handler/scan_handler.py Uses filesystem scan metadata instead of detached ROM properties for nested file logging.
pyproject.toml Adds a package-specific uv exclude-newer override for Starlette.
uv.lock Updates uv exclude-newer lock metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/handler/metadata/ss_handler.py Outdated
@gantoine gantoine merged commit 830902c into rommapp:master May 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants