mirror of
https://github.com/storytold/artcraft-services.git
synced 2026-11-19 08:53:03 +01:00
main
15370
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f4416f8f7f | Point the Omni API docs at the Cloudflare Worker and drop the Netlify rollback build | ||
|
|
1ce37b5f28 | Serve the API docs on storyteller-docs.artcraft.team from a Cloudflare Worker | ||
|
|
999b402564 |
Stop rebuilding the website during wrangler deploy (#410)
## What the log shows
The Cloudflare build for `artcraft-services` succeeded, then failed
during
deploy:
```
04:52:46 Success: Build command completed
04:52:47 Executing user deploy command: npx wrangler deploy
04:52:56 [custom build] Running: npm run build <-- build runs again
04:53:35 [custom build] Generating static Linux repositories and Flatpak OCI catalog...
04:53:46 [custom build] DOMException [TimeoutError] at fetchHeadPackageSize (linux-repos.ts:274)
[custom build] Error: Command failed: ... generate-static-repos.mjs
✘ [ERROR] Running custom build `npm run build` failed.
```
Two things combine:
1. The root `wrangler.jsonc` declared `"build": { "command": "npm run
build" }`.
Workers Builds already runs the project's build command, so `wrangler
deploy`
rebuilt the entire static export a second time.
2. The second pass re-probed every published package on GitHub (523
package
redirects, 19 OCI repos). `fetchHeadPackageSize` treats one 10s HEAD
timeout
as fatal, so the repeat pass — running ~50s behind the first burst of
identical requests — failed the deploy.
This is not a regression from #408 or #409: neither touches the website
build.
The `build.command` has been in the config since #354, and the failing
probe is
pre-existing.
## Changes
- `wrangler.jsonc`: remove `build.command`, with a comment explaining
why. The
deploy now uploads the `out/` that Workers Builds just produced,
matching how
the webapp and dashboard Workers already behave. A manual `wrangler
deploy`
needs `npm run build:website` first.
- `linux-repos.ts`: `fetchHeadPackageSize` retries three times with a
short
backoff instead of failing the export on a single unanswered HEAD.
## Verification
- `npm ci --ignore-scripts && npm run typecheck` in
`frontend/apps/artcraft-website-next` — exit 0.
- `wrangler deploy --dry-run --config wrangler.jsonc` against a
placeholder
`out/` parses the config and skips straight to bundling: no `[custom
build]`
pass, which is the behavior this PR is after. The dry-run cannot
complete
locally because `worker/index.mjs` imports `generated-catalog.mjs`,
which the
full build generates.
- Not run: the Playwright `test:repos` suite, which needs the deployed
preview.
## Risk
- Deploying the website by hand now needs an explicit build first:
`npm run build:website && npm run deploy:website`. On a clean checkout
`wrangler deploy` fails loudly ("Could not resolve
./generated-catalog.mjs")
because both `out/` and `worker/generated-catalog.mjs` are gitignored
build
artifacts.
- This assumes the Worker keeps a build command configured in Workers
Builds
(the failing log shows `npm run build`). If that field is cleared, the
deploy
step has no artifacts to upload.
|
||
|
|
590ecaf9b1 |
Deploy artcraft-dashboard without the website's signing keys (#409)
## Why
`artcraft-dashboard` was documented (and configured) with the shared
Cloudflare
commands:
| Setting | Value |
|----------------|-----------------------------------|
| Build command | `npm run build` |
| Deploy command | `npm run deploy` |
| Build variable | `ARTCRAFT_APP=artcraft-dashboard` |
Both scripts fall back to `ARTCRAFT_APP=artcraft-website`, so a
dashboard deploy
that was missing the build variable did two wrong things:
- the build ran the website's static export, including
`signLauncherCatalog()`, so the deployment failed without
`LAUNCHER_CATALOG_SIGNING_KEY`;
- the deploy handed Wrangler the **root** config instead of the
dashboard's:
```
✘ [ERROR] The directory specified by the "assets.directory" field in your
configuration file does not exist:
/opt/buildhome/repo/frontend/apps/artcraft-website-next/out
```
## What changed
- The dashboard README now configures the Worker with `npm run
build:dashboard`
and `npm run deploy:dashboard`. Those npm scripts set
`ARTCRAFT_APP=artcraft-dashboard` inline and pass
`frontend/apps/artcraft-dashboard/wrangler.jsonc` to Wrangler, so the
Worker
needs no build variable at all beyond `NODE_VERSION=22`.
- Added a "Build secrets" section stating the dashboard reads neither
`LAUNCHER_CATALOG_SIGNING_KEY` nor `LINUX_SIGNING_KEY`, and that plain
`npm run build` / `npm run deploy` must not be used for this Worker.
- The root README table now lists the per-app build/deploy commands
instead of an
`ARTCRAFT_APP` column, and documents the same trap.
- `cloudflare_app.sh` header comment updated to match.
- Added the missing `deploy:website` script so all three apps have a
symmetric
`build:<app>` / `deploy:<app>` pair.
No build logic changed: `artcraft-dashboard` never referenced the
signing keys
before this PR either. The change removes the misconfiguration path that
made
them appear to be required.
## Verification
- `env -u LAUNCHER_CATALOG_SIGNING_KEY -u LINUX_SIGNING_KEY pnpm install
--frozen-lockfile && pnpm build`
in `frontend/apps/artcraft-dashboard` — exit 0, `dist/` produced without
`_redirects`.
- `wrangler deploy --dry-run --config
frontend/apps/artcraft-dashboard/wrangler.jsonc`
— reads 5 files from `dist/`, binds `env.ASSETS`, clean exit.
- `node -e require('./package.json')` parses; `bash -n` on
`cloudflare_app.sh` and
`build_cloudflare.sh` passes.
## After merge
In the Cloudflare `artcraft-dashboard` Worker, set build command
`npm run build:dashboard`, deploy command `npm run deploy:dashboard`,
and drop
the `ARTCRAFT_APP` build variable. Keep `NODE_VERSION=22`. No signing
secret
needs to be added to this Worker.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Documentation**
* Clarified the app-specific Cloudflare build and deployment commands
for the website, webapp, and dashboard, including that the bare commands
default to the website and require `ARTCRAFT_APP` to select another app.
* Added dashboard Workers Builds guidance, including its Node.js version
requirement and app-specific Wrangler configuration.
* Clarified that only the website build uses signing credentials and its
launcher assets, and warned against deploying the dashboard with the
default Wrangler command.
* **Deployment**
* Added a dedicated command for deploying the website.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
766ead6629 |
Configure artcraft-dashboard for Cloudflare at dashboard.artcraft.team (#408)
## Problem The admin dashboard is deployed only to Netlify (`artcraft-dashboard.netlify.app`), while the rest of the frontends deploy to Cloudflare from this repository. Move it to Cloudflare and serve it at `dashboard.artcraft.team`. ## Change - **`frontend/apps/artcraft-dashboard/wrangler.jsonc`** — `artcraft-dashboard` static-assets Worker: SPA `not_found_handling`, `run_worker_first: ["/api/*"]`, custom domain `dashboard.artcraft.team`. - **`cloudflare_worker/index.ts`** — same-origin `/api/*` proxy to `https://api.storyteller.ai`. The dashboard calls the API with `credentials: "include"`, so its session cookie has to stay first-party; `api.storyteller.ai` is a different site than `dashboard.artcraft.team`, so a direct cross-site call would have the cookie dropped by browsers. This replaces Netlify's `/api/*` rewrite. - **`script/website/cloudflare_app.sh` + root `package.json`** — `ARTCRAFT_APP=artcraft-dashboard`, plus `npm run build:dashboard` / `npm run deploy:dashboard`. - **`_redirects`** moved from `public/` to the app root and copied into `dist/` by `netlify_build.sh`, so the Cloudflare upload never contains the `/* /index.html 200` loop or the external-host proxy that Workers reject. Netlify keeps working unchanged as the rollback target. - **CORS** — `https://dashboard.artcraft.team` allowlisted in `artcraft_admin_dashboard.rs`, the regression table, and the production product-origin test. - **`tsconfig.app.json`** — excludes spec files. `DebugLogCard.spec.ts` imports `vitest`, which only resolved through the parent workspace's `node_modules`; the standalone Cloudflare build never installs those, so `tsc -b` failed. - Docs: dashboard README (deploy, proxy rationale, rollback) and the root README Worker table. ## Cloudflare settings | Setting | Value | |----------------|-----------------------------------| | Build command | `npm run build` | | Deploy command | `npm run deploy` | | Build variable | `ARTCRAFT_APP=artcraft-dashboard` | | Build variable | `NODE_VERSION=22` | `VITE_API_HOST` is deliberately not set: the dashboard keeps calling `/api`, and the Worker proxies it. ## Checklist before cutover - [ ] `artcraft.team` is a zone in the Cloudflare account (Workers custom domains require the zone). - [ ] `artcraft-dashboard` Worker created from this repo with the settings above. - [ ] Domain attached; log in and confirm the session works at `https://dashboard.artcraft.team`. A `*.workers.dev` URL is not CORS-allowlisted, so test through the domain (or add the test host to the CORS config first). - [ ] Netlify site kept for rollback; reverting is pointing the domain back at it. ## Testing - `cargo test -p actix_cors_configs` — 81 passed, including the new `dashboard_domain` case and the allowlist regression table. - `pnpm install --frozen-lockfile && pnpm build` in `frontend/apps/artcraft-dashboard` — succeeds (9014 modules); `dist/` has no `_redirects`. - `wrangler deploy --dry-run --config frontend/apps/artcraft-dashboard/wrangler.jsonc` — clean: 5 assets, `env.ASSETS` binding, no config warnings. - Not run: an actual deploy, since there are no Cloudflare credentials or account access in this environment. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * The ArtCraft Admin Dashboard is now available at `dashboard.artcraft.team`, with dashboard API requests routed through the new deployment. * The dashboard’s production origin is now allowed for cross-origin requests. * **Documentation** * Added deployment and build guidance for the dashboard, including its Cloudflare hosting and API routing details. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
896824e56f |
Build the webapp on Cloudflare without the website's signing keys (#407)
## Problem app.getartcraft.com serves `Hello world`. Its `artcraft-webapp` Worker builds this repository with `npm run build`, which always built **artcraft-website-next** and failed on the website's `LAUNCHER_CATALOG_SIGNING_KEY`. The Worker never got a successful deploy, so it kept its placeholder. ## Change - `npm run build` / `npm run deploy` choose the app from the `ARTCRAFT_APP` build variable via `script/website/cloudflare_app.sh`. The default, `artcraft-website`, is the old behaviour, so the website Worker needs no changes. - `ARTCRAFT_APP=artcraft-webapp` builds only the Nx webapp. It needs **no signing keys**. - `frontend/apps/artcraft-webapp/wrangler.jsonc` is now a static-assets Worker (`artcraft-webapp`). It uses SPA `not_found_handling` and the `app.getartcraft.com` custom domain, replacing the unused Pages `app-new` config. - The Cloudflare `public/_redirects` no longer has the `/* /index.html 200` fallback, since Workers assets reject it as a loop. Netlify's `_redirects` is untouched. - `nx build --skipSync` plus the `nx sync` output for pagedraw/pagescene. Nx refused to build in CI without those references, and that also fails on current `main`. ## Cloudflare settings for the artcraft-webapp Worker | Setting | Value | |----------------|-----------------------------------------| | Build command | `npm run build` | | Deploy command | `npm run deploy` | | Build variable | `ARTCRAFT_APP=artcraft-webapp` | | Build variable | `VITE_GOOGLE_CLIENT_ID` (as on Netlify) | ## Testing - `ARTCRAFT_APP=artcraft-webapp CI=true npm run build` with no signing keys in the environment: succeeds, 239 files, none over 25 MiB. - `wrangler deploy --config frontend/apps/artcraft-webapp/wrangler.jsonc --dry-run`: clean, no `_redirects` warnings. - An unknown `ARTCRAFT_APP` exits 1 with usage. - Not run: the website build path, which is the unchanged command moved into the script. |
||
|
|
bb8ec12a47 | fix: require the internal API key on the GPT image job callback (#287) | ||
|
|
de65625356 | fix: refuse to start production with the public fallback secrets (#300) | ||
|
|
3fce0f73ae | fix: bill and run Veo 3.1 with the same default duration; bound router downloads (#314) | ||
|
|
23e4f021bc | fix: exclude never-paid Stripe statuses from active subscriptions; keep URL options for test DB bootstrap (#327) | ||
|
|
f6a3dd6b9c | fix: cap decompressed size when extracting PMX zip archives (#383) | ||
|
|
499462fe07 | fix: reject mesh generation without a model before resolving media (#386) | ||
|
|
06272d654b | fix: authorize profile edits by user token, not cached username (#388) | ||
|
|
ad03b98ed6 | ci: let Dependabot maintain GitHub Actions dependencies (#393) | ||
|
|
e4be25b4fd | security: drop rustls 0.22 and lettre's rustls 0.21 edge (#405) | ||
|
|
4c72ed5437 |
chore: update Craft Launcher and app release versions (#391)
## Summary Automatically synchronize the Craft Launcher and Crafting Apps versions with the latest stable published releases in their respective GitHub repositories. ## Changes - Update versions from published stable releases only. - Ignore prereleases, drafts, and tags outside vX.Y.Z. - Validate all required release assets before updating the catalog. - Preserve catalog entries explicitly set to null. - Support pinned versions for intentional rollbacks. - Keep the existing release asset configuration unchanged. Generated by the `Update Craft Release Versions` workflow. Co-authored-by: dylanmtaylor <277927+dylanmtaylor@users.noreply.github.com> |
||
|
|
294a566c93 |
chore: update Craft Launcher and app release versions (#390)
## Summary Automatically synchronize the Craft Launcher and Crafting Apps versions with the latest stable published releases in their respective GitHub repositories. ## Changes - Update versions from published stable releases only. - Ignore prereleases, drafts, and tags outside vX.Y.Z. - Validate all required release assets before updating the catalog. - Preserve catalog entries explicitly set to null. - Support pinned versions for intentional rollbacks. - Keep the existing release asset configuration unchanged. Generated by the `Update Craft Release Versions` workflow. Co-authored-by: dylanmtaylor <277927+dylanmtaylor@users.noreply.github.com> |
||
|
|
b08ef44a86 |
ci: don't fail release sync when the Studio version is already current (#387)
## Summary The hourly `Update Craft Release Versions` workflow has failed every run since 2026-11-07 with: ``` Error: Could not find ARTCRAFT_STUDIO_VERSION in github_download_links.ts. ``` The declaration exists. The workflow decided it was missing by comparing `github_download_links.ts` before and after the replace. #352 set `ARTCRAFT_STUDIO_VERSION = "0.41.1"` by hand, and 0.41.1 is the latest Studio release, so the replace is a no-op and the check throws. The run stops before updating the launcher or any Crafting App. That freezes `crafting-app-releases.ts` and everything built from it, including the Flatpak OCI index at `/index/static`. Right now the index still serves Craft Launcher 0.15.0, but 0.19.0 is published to GHCR as `stable-x86_64`. Related: #361 (that issue's original missing-assets error was fixed by #371, which exposed this one). ## Change Test for the declaration with the pattern, as the launcher and app updates already do, then replace. ## Verification I ran the workflow's `github-script` body locally against live release data from `gh api`: - Before the change: fails with the error above. - After the change: completes and bumps the launcher to 0.19.0 and every Crafting App to its latest release. - With the `ARTCRAFT_STUDIO_VERSION` line removed: still fails with "Could not find ARTCRAFT_STUDIO_VERSION". <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed release version updates so an already-current version is recognized correctly. The update process now reports an error only when the version declaration is actually missing, preventing a false failure when no change is needed. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
e585d12bfd |
ci: use StepSecurity's maintained actions (#382)
Each third-party action that StepSecurity publishes a secure drop-in replacement for now uses that replacement, pinned to a commit with its version as a comment. Versions follow what we used: the newest StepSecurity release in the same major, or the closest major they publish. dtolnay/rust-toolchain refs that named a toolchain (stable, nightly, 1.76) become the replacement's `toolchain` input. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Chores** * Updated the automation integrations used for pull request creation and container registry sign-in. * Existing workflow settings and registry credentials remain unchanged. Some container build workflow steps remain inactive. * These maintenance updates do not change the app’s features or behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
4c9f1b98f5 |
fix: refuse to show desktop-login approval inside a frame (#266)
## What was wrong The desktop-login consent page (`/login/desktop`, `DesktopLoginApproval`) could be rendered inside a cross-origin frame. The webapp's `netlify.toml` sends no `frame-ancestors` or `X-Frame-Options` for it, and the component did not check for framing. An attacker can start a login challenge for their own desktop, embed the verification URL in a page they control, hide the frame under decoy content, and steer the signed-in victim's click onto "Approve desktop login". The backend then issues the victim's session to the attacker's device-token holder (clickjacking, CWE-1021). ## What changed - `apps/artcraft-webapp/netlify.toml`: `/login/desktop` and `/login/desktop/*` are served with `Content-Security-Policy: frame-ancestors 'none'` and `X-Frame-Options: DENY`. This is scoped to the approval route so other webapp pages are unaffected. - `libs/login/.../desktop-login-approval.tsx`: if `window.self !== window.top` (or that check throws), the component renders "Open this login link directly in your browser to approve it." It does not fetch the review and `decide` is a no-op. This covers deployments that do not send the headers. - New webapp test: a framed render shows no Approve button and makes no API call. ## Blast radius Only the desktop-login approval route. Opening the link top-level (browser, QR code) behaves as before. Any legitimate flow that frames `/login/desktop` would stop working; none exists in this repo. ## Checks run - `NODE_OPTIONS=--no-experimental-webstorage npx vitest run --root apps/artcraft-webapp src/pages/login`: 20/20 pass, including the new framed case. Under Node 26 the flag is needed, or jsdom's `sessionStorage` is shadowed and every test in this file fails, before and after this change. - `npx vitest run --root libs/login`: pass. - `netlify.toml` parses as TOML. ## Checks not run - `tsc -p libs/login/tsconfig.lib.json`: only the pre-existing TS6305 errors for the unbuilt `@storyteller/api` `dist`. - Netlify deploy preview header verification. Addresses CodeRabbit security findings (CWE-1021). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Desktop login approval pages displayed inside a frame now instruct visitors to open the link directly in a browser. The page does not load or submit a login challenge, or offer approval or decline actions. * Browser security headers prevent desktop login pages from being displayed within frames, including when framed pages involve cross-origin access. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
9101e4e9d7 |
fix(webapp): restrict onboarding redirect_to to same-origin paths (#289)
## What was wrong `onboarding.tsx` decoded the `redirect_to` query parameter and passed it straight to `navigate()`. A protocol-relative value such as `//evil.example` (or its encoded form) made the router fall back to a full browser navigation, so an onboarding link could send a freshly signed-up user to an external site (open redirect, CWE-601). ## What changed - `redirect_to` is decoded once (a malformed encoding is kept as-is instead of throwing) and validated with the existing `safeAuthReturnPath` from `lib/login-bridge-context`; anything that is not a same-origin path becomes `/`. - Both navigation paths and the status text use that validated value. ## Blast radius Onboarding page only. Real values (`/checkout/success`, `/checkout/cancel`, `/pricing`, `/`) pass through unchanged. ## Checks run - `tsc -p apps/artcraft-webapp/tsconfig.app.json`: no new errors compared with `main`. ## Checks not run - No new test: the change only calls the existing `safeAuthReturnPath`, which already has coverage in `desktop-login.spec.tsx`. - Manual walk through the onboarding flow. |
||
|
|
f13f35644d |
ci: run Harden-Runner on every job (#381)
Adds step-security/harden-runner (audit, pinned to v2.22.4 like craft-common-actions) as the first step of each job that did not have it, so every workflow in the org's public repos reports its egress to StepSecurity. Audit, not block: block-mode allow lists come from each job's observed traffic. |
||
|
|
3d75db28e3 |
fix: parse Forwarded for= nodes and match disabled endpoints on the routed path (#322)
What was wrong: (1) the Forwarded fallback returned the whole first list element (e.g. `for=1.2.3.4;proto=http`), so exact IP bans never matched. (2) The disabled-endpoint filter compared the raw URI path while actix routes on the percent-decoded path, so an equivalent encoded spelling bypassed it. Change: Forwarded values are parsed per RFC 7239 (first for= node, quotes/brackets/port stripped); X-Forwarded-For is unchanged. The filter now checks request.match_info().as_str(), the path actix routes with. Blast radius: crates/lib/actix_helpers (ban filter and disabled-endpoint middleware). Behavior changes: requests using a Forwarded header now yield a bare IP; encoded spellings of a disabled path are now blocked. Checks run: cargo test -p actix_helpers (new Forwarded test). Checks not run: clippy -D warnings (91 pre-existing errors in this crate on main); no integration test of the middleware against an encoded URI. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Forwarded IP addresses are now read from the first `for` parameter, including quoted values and IPv6 addresses. Other supported IP headers retain their existing parsing behavior. * Disabled-endpoint checks now use the matched route rather than the raw request path, improving checks for requests handled through routed endpoints. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
094a662fba |
fix: hide job result locations the caller may not read (#277)
## What was wrong
`GET /v1/jobs/job/{token}` is public and joined the job's result media
by token alone. A known job token kept disclosing the result's media
token, bucket path and CDN links after the creator made the result
private or it was soft-deleted.
## What changed
For `media_file` results the handler now resolves the session and
re-reads the media through `get_media_file` (moderators see deleted
rows, others do not). `maybe_result_details` is dropped from the
response unless the media is readable by the caller: not private, or the
caller is the creator (user token or anonymous visitor token), or a
moderator. Status, progress and failure fields are unchanged, so polling
keeps working for everyone.
## Blast radius
One handler; one extra media lookup per status poll of a completed
media-file job. Legacy TTS / voice-conversion result types are not
affected.
## Checks
- Run: `SQLX_OFFLINE=true cargo check -p storyteller-web` (exit 0).
- Not run: the job status tests need a live MySQL.
|
||
|
|
ffc4c469ad |
fix: require read access to the source image before background removal (#276)
## What was wrong `POST /v1/generate/image/remove_background` looked up the caller-supplied `media_file_token` and submitted its CDN URL to Fal without checking the media's visibility. Anyone who knew another user's **private** image token could run background removal on it and collect the derivative through the job the handler created for them. ## What changed After the media lookup, the handler now requires that the source is readable by the requester: not `Private`, or the requester is its creator (session user token, or the anonymous visitor token for anonymous uploads), or a moderator (`can_delete_other_users_tts_results`, the convention the media read handlers use). Otherwise it returns `NotFound`, so a private token's existence is not confirmed. ## Blast radius One handler. Public and hidden sources behave as before; only private sources belonging to someone else are now rejected. ## Checks - Run: `SQLX_OFFLINE=true cargo check -p storyteller-web` (exit 0). - Not run: the handler tests need a live MySQL. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Background removal requests now check access to the source image before processing. Non-private images remain accessible. Private images are available to moderators and their creator, or to a visitor presenting the matching anonymous visitor credential when no creator credential is present. Requests without the required access receive a not-found response. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
b72e0e26cb |
fix: check cover image access when setting and serving covers (#267)
## What was wrong
`POST /v1/media_files/cover_image/{token}` (and the model weight
equivalent) accepted any image token as a cover after checking only that
it was an image. Listings then joined the cover by token alone and
returned its bucket path and CDN links. A user could attach another
user's **private** image as the cover of their own media and read its
storage location from any listing of that media. Covers that were later
deleted or made private also kept being served.
## What changed
- New helper `media_files/helpers/may_use_as_cover_image.rs`: a private
image may be used as a cover only by the user who created it. Public and
hidden images behave as before. Both cover setters
(`set_media_file_cover_image_handler`,
`set_model_weight_cover_image_handler`) use it and answer `NotFound` on
refusal, the same as a missing token.
- Every media-file cover join in `mysql_queries` (get, batch get, list,
featured, for-user, session, project, batch-generated, source job, tags,
files-without-folder, Elasticsearch backfill) now joins the cover only
when it is live and either not private or owned by the same creator as
the media file it decorates. Existing bad associations stop leaking
without a data migration.
- `.sqlx` entries for the 16 changed `query!` macros were regenerated
against a local schema built from `_database/sql/migrations`. Column
metadata was kept from the existing MySQL entries; only the query text,
hash and parameters changed.
## Blast radius
- Public and hidden covers, and a creator's own private covers on their
own media, render as before.
- A cover that is deleted, or private and owned by someone other than
the media's creator, now comes back as no cover.
- Not changed: the `batch_get_media_files_by_tokens` and folder-listing
cover joins (those files are touched by #227/#229 and the folder PR, so
they are left to avoid conflicts), and the model-weight cover joins in
the weights list queries. The setters now block new associations there;
read-time checks for those queries are a follow-up.
## Checks run
- `SQLX_OFFLINE=true cargo test -p mysql_queries --lib --no-run`:
compiles against the updated `.sqlx` cache
- `SQLX_OFFLINE=true cargo test -p storyteller-web --features
skip_database_tests --bin storyteller-web -- may_use_as_cover_image`:
builds the full crate, 2 new tests pass
- Every changed query was described successfully by sqlx against a local
MariaDB 11.8 loaded with all migrations
## Checks not run
- `cargo sqlx prepare` against production-equivalent MySQL (sqlx-cli is
not installed and only MariaDB was available. Please re-run it if the
cache flags differ.)
- Endpoint integration tests against MySQL
Addresses CodeRabbit security findings (CWE-863).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Deleted cover images are no longer displayed.
* Private images are used as covers only when they belong to the same
creator as the media file; public and hidden images remain eligible.
* Cover-image selection in media and model-weight workflows now respects
private-image access rules.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
a083615cd3 |
fix: keep other users' private media out of folders (#254)
## What was wrong
Folder bulk-add and bulk-move only checked that each media token existed
and wasn't deleted. A user who knew another user's private media token
could put it in their own folder, and the folder list (`GET
/v1/folders/media_files/{folder}`) and folder thumbnails
(`last_media_thumbnails`) then returned that file's CDN URLs and
metadata.
## What changed
- `filter_existing_media_file_tokens` takes `viewer_user_token` and only
keeps private files created by that user. Bulk add and bulk move pass
the session user.
- `batch_get_media_file_thumbnails_by_tokens` takes an optional
`maybe_restrict_private_to_creator`. Folder thumbnails pass the session
user, so memberships that already exist (or files made private later)
stop showing. The Elasticsearch thumbnail-version lookup passes `None`;
it returns no URLs.
- `list_folder_media_files_handler` re-checks private rows on each page
and drops the ones the viewer didn't create. The pagination cursor is
still taken from the unfiltered page.
All new SQL uses `QueryBuilder` with bound parameters, so no `.sqlx`
metadata changes.
## Blast radius
Folders are owner-only. Behaviour changes: another user's private file
can no longer be added to a folder (it is silently skipped, as missing
tokens already are), and such files already in a folder no longer appear
in its listing or thumbnails. A page of the folder list can be shorter
than the limit when rows are hidden.
## Checks
- Run: `SQLX_OFFLINE=true cargo check -p storyteller-web -p db-cleanup
--tests`.
- Not run: endpoint/query tests; they need a live MySQL.
Addresses CodeRabbit security findings (CWE-862).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Folder listings now hide private media files that the viewer cannot
access, while preserving access to their own private files and eligible
non-private files.
* Folder thumbnails no longer reveal private media belonging to another
user.
* Adding or moving media into folders silently skips private files the
viewer cannot access.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
75361b0560 |
fix: hide unreadable context media on prompt reads (#231)
> Stacked on **#228** → **#229** (merge in that order). This PR needs
`MediaReadScope` and `media_read_policy` from those branches; it rebases
onto `main` cleanly once they land.
## Summary
`GET /v1/prompts/{token}` lists the prompt's context items (reference
images, style images, uploads) and built a CDN link and media token for
each from `list_prompt_context_items`, which selects storage locations
only. The media's own visibility was never consulted, so reading a
prompt — including a prompt that was shared or public — exposed the
storage URLs and tokens of another user's **private** media.
The handler now resolves the context media through the shared read scope
and drops items the requester may not read. The prompt still renders its
readable context; private media referenced by it stays private and is no
longer linkable through the prompt.
## Notes
- Moderation goes through `can_ban_users`, matching the existing
moderator-fields logic in this handler.
- `maybe_user_session` is now borrowed rather than moved, since the
scope needs it after the moderator check.
- One extra media query per prompt read (only when the prompt has
context items).
## Checks
- `SQLX_OFFLINE=true cargo check -p storyteller-web` — finished clean,
exit 0.
- No tests run: the prompt endpoint tests need a live MySQL.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Prompt responses now include context media only when it is readable
under the current session’s media access policy. Failed media lookups no
longer prevent a response from being returned.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
a6b5f738af |
fix: enforce private media visibility on token batch reads (#228)
## Summary `GET /v1/media_files/batch` takes a list of media tokens and returned every matching record — storage paths, titles, transcripts, original filenames — to any caller. The session was read only to decide whether deleted records were visible; it played no part in authorizing private ones. The handler now keeps only records the requester may read: - private records are returned to their creator and to moderators, - private records are **dropped** for everyone else, rather than the request failing, so a batch of guessed tokens discloses neither content nor which token matched. The rule lives in a new shared helper, `util/lookup/media_read_policy.rs::ensure_may_read_media`, returning `NotFound` for a private record the caller may not read. It matches the check in `get_weight_handler.rs` and is intended for the other media read paths too, so the policy is not re-derived per endpoint. ## Blast radius `batch_get_media_files` has exactly one caller (this handler), so the endpoint is fully covered. Public and hidden media behave as before; response order is preserved for the remaining records, and the `results` array may be shorter than the requested token list. ## Checks - `SQLX_OFFLINE=true cargo check -p storyteller-web` — finished clean. - No tests run: the media endpoint tests need a live MySQL, which this environment does not provide. Worth adding a case for anonymous callers requesting another user's private token before merging. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Batch media requests now omit private media that the viewer is not authorized to access. Private media remains available to its creator and moderators, while other viewers receive no indication that the restricted item exists. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
ec461047a5 |
fix: enforce private media visibility for reads and batch lists (#226)
## Summary Two endpoints returned private media records without comparing `creator_set_visibility` against the requester, so knowing a token was enough to read another user's private media, including its storage locations and transcripts. **Single-file lookup** (`media_files/get/get_media_file_handler.rs`) - The handler now passes the viewer's `user_token` into both lookup branches. - A shared `ensure_may_read_media` helper returns `NotFound` for `Visibility::Private` records unless the viewer is the creator or a moderator. The same policy now applies to the legacy `TR:` TTS emulation branch, which previously had no check at all. - `NotFound` rather than `NotAuthorized` avoids confirming that a private token exists. This mirrors the check in `get_weight_handler.rs`. **Batch listing** (`media_files/list/list_media_files_by_batch_token_handler.rs`) - The endpoint hard-coded `ViewAs::Author` with a "this is wrong, but gotta go fast" TODO, so any caller holding a batch token received every record in the batch regardless of visibility. - Scope now derives from the session: `Moderator` for moderators, `Author` for other logged-in users, `AnotherUser` for anonymous callers. - `maybe_creator_user_token` is selected with the page so private records are dropped for anyone who is neither the creator nor a moderator. ## Notes - Public and hidden media behave as before; only private access changes. - For non-moderators the batch page can be shorter than `page_size`, and `total_page_count` still counts records the caller may not read, because filtering happens after the query. Fixing that properly needs visibility-aware SQL and is left for a follow-up. - Verified with `SQLX_OFFLINE=true cargo check -p storyteller-web` (finished clean). No tests were added or run: the media endpoints are covered by integration tests that need a live MySQL, which is not available here. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Private media files are visible only to their creator or a moderator. Other viewers will not see private files in batch listings, and direct requests return not found. * Access rules apply consistently to standard media files and legacy text-to-speech results. * Viewer identity is recognized from an authenticated session or a viewer token, allowing creators to access their private media without signing in. * Public media remains accessible according to existing permissions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
dc36ccb6ba |
fix: stop generation from reading other users' private media (#229)
> **Stacked on #228**, which adds `util/lookup/media_read_policy.rs`.
Merge that first; this PR then rebases onto `main` cleanly.
## Summary
Every generation endpoint takes media tokens from the request
(`start_frame_media_token`, `reference_image_media_tokens`, inpainting
sources, image-to-3D inputs, …) and resolved them through
`batch_get_media_files_by_tokens`, which only filtered on existence and
soft deletion. Possession of a token therefore authorised use of the
record: another user's private image could be submitted as a generation
input, and several paths (`lookup_image_urls_as_map`,
`lookup_image_urls_as_optional_list`,
`lookup_media_files_as_cdn_url_list_and_map`) handed back a CDN URL for
it too.
## Changes
- `batch_get_media_files_by_tokens` (all three wrappers) takes a
`MediaReadScope { viewer_user_token, is_mod }` and adds, for
non-moderators:
`AND (m.creator_set_visibility <> 'Private' OR
m.maybe_creator_user_token IS NULL OR m.maybe_creator_user_token = ?)`
Records with no creator are system intermediates that generation depends
on; they are not anyone's private data, so they remain readable. Tokens
are still bound, not interpolated.
- The five lookup helpers forward the scope;
`fetch_reference_video_sources` and the query wrappers take it as a
parameter.
- Call sites supply the requester: `scope_for_session` for cookie
sessions (so moderators keep their access), `scope_for_user_token` for
API-key/SSO callers, `MediaReadScope::ANONYMOUS` for the two genuinely
unauthenticated paths (the cost-quote duration probe and the curated
pinned-media list).
- `get_character_handler` previously read no session at all; it now
resolves one so a creator can still see their own private uploads while
anonymous callers cannot.
## Behaviour changes worth reviewing
- A generation request naming someone else's private token now fails as
"media not found" rather than generating from it.
- Private media can no longer be used as a generation input, even by a
logged-in non-owner. That is the point of the fix, but it is a real
behaviour change for any client that reused tokens across accounts.
- Anonymous callers no longer resolve private media for pinned lists or
cost quotes.
## Checks
- `SQLX_OFFLINE=true cargo check -p storyteller-web` — finished clean,
exit 0.
- No tests run: the media query and endpoint tests need a live MySQL,
which this environment does not provide. The 58-file diff is almost
entirely one added argument per call site; a reviewer should spot-check
the two `ANONYMOUS` sites and the `get_character_handler` session
addition.
|
||
|
|
b8b09b5990 |
fix(db-cleanup): include concrete image types in anonymous image cleanup (#253)
## What was wrong `db-cleanup`'s `delete_all_anonymous_user_images` listed only media files with the legacy coarse `Image` type, then re-checked `MediaFileType::Image` before deleting. Anonymous uploads made through `POST /v1/media_files/upload/image` are stored with a MIME-derived type (`Jpg`, `Png`, `Gif`, `Webp`), so the cleanup skipped them and they never got the moderator-deletion marker. ## What changed - The listing filter now includes every type `MediaFileType::is_image()` accepts (`Image`, `Jpg`, `Png`, `Gif`, `Webp`). - The per-record check uses `is_image()`, so the filter and the check agree. - Small unit test that the selected set matches `is_image()`. ## Blast radius Operator CLI only. Running the command now also soft-deletes (as moderator) anonymous images with concrete types, which is what the command says it does. Files with a creator are still skipped. ## Checks - Run: `SQLX_OFFLINE=true cargo check -p storyteller-web -p db-cleanup --tests` (combined with the other fixes in this batch). - Not run: the command itself against a database. Addresses CodeRabbit security findings (data retention policy gap). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Anonymous-image cleanup now recognizes JPEG, PNG, GIF, and WebP files alongside legacy image files, so these formats are included when cleaning up images without a creator token. * Non-image files are skipped during cleanup. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
d4033df996 |
fix: enforce the bucket request timeout, cap debug sleeps, fix db-cleanup batch paging (#324)
What was wrong: - LegacyBucketClient called Bucket::set_request_timeout, which rust-s3 (tokio backend) ignores: the HTTP client is built in the constructor. A storage peer that stalled a response held a worker forever. - The video-style-transfer, face-fusion and video-style-transfer-workflow jobs slept for a request-header-supplied number of milliseconds with no maximum, parking a worker. - db-cleanup delete_user_files advanced an offset over a listing that shrinks as files are deleted, so it skipped every other batch. Change: when a timeout is configured, the bucket is rebuilt with with_request_timeout (it applies to the whole request, including body). Debug sleeps go through debug_sleep_duration, capped at 60 s. db-cleanup always reads offset 0 (deleted files are excluded from the listing). Blast radius: cloud_storage, inference-job (3 call sites), db-cleanup. Behavior changes: callers that pass Some(timeout) (jobs default to 5 min via BUCKET_TIMEOUT_SECONDS, web 60 s-ish via env) now actually get that limit per request, so very large transfers longer than the configured value will fail instead of running unbounded. Debug sleeps above 60 s are clamped. Checks run: cargo check -p cloud_storage -p db-cleanup -p inference-job; cargo test -p inference-job --bin inference-job debug_sleep. Checks not run: fmt/clippy, db-cleanup against a database, incomplete-download file cleanup on timeout (not changed). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * File cleanup now processes remaining files in batches without relying on page offsets. * Debug delays in face-fusion and video-style-transfer jobs are capped at 60 seconds, preventing excessively long waits. * Cloud storage bucket requests now apply a timeout only when one is configured, with client setup errors propagated. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
3577dda534 |
fix: enforce owner TTS delete permission, case-insensitive reserved usernames, escape log values (#323)
What was wrong:
- delete_tts_model: the owner branch ignored the session's
can_delete_own_tts_models permission, so a role denying owner deletion
could still delete.
- create_account: reserved usernames were checked on the submitted text
before the lowercase/trim applied when the account is stored, so e.g.
"Admin" passed.
- list_media_files_for_user (v1/v2) and upload_url_to_media_file logged
request-supplied username/URL with {} so CR/LF could forge log lines.
Change: owners must have can_delete_own_tts_models (moderators
unaffected); is_reserved_username trims and lowercases itself; the log
arguments use {:?}. User-visible URL error strings are unchanged.
Blast radius: three handlers plus is_reserved_username (only used by
account creation validation).
Behavior changes: owners whose role lacks can_delete_own_tts_models now
get NotAuthorized; mixed-case/space-padded reserved names are now
rejected.
Checks run: cargo check -p storyteller-web (exit 0).
Checks not run: handler/unit tests (need MySQL; a new unit test for
case-insensitive reserved names was added but not executed), fmt/clippy.
|
||
|
|
cc6d88e10d |
fix: extract OBJ from Fal ZIP packages (application/zip) (#155)
## Summary Fixes https://github.com/storytold/artcraft/issues/1327 Handle single-OBJ ZIP packages on the Fal mesh-upload path by storing the **extracted raw OBJ**, not ZIP bytes under an OBJ extension. Stored size, SHA-256, `model/obj` MIME, `.obj` extension and `MediaFileType::Obj` all describe the same extracted bytes. The original incident's producing endpoint/output remains unknown; this is **not a verified reproduction** of #1327. ## Scope and safeguards Exactly **seven files**: - Four Fal mesh-path Rust files: `mod.rs`, `download_mesh_file.rs`, `resolve_mesh_file_metadata.rs`, and `process_model_mesh_payload.rs`. - Two `mysql_queries` files: `get_media_file_storage_metadata.rs` and its `get/mod.rs` declaration. - One matching `.sqlx` cache entry. **No workflow files are included in this PR.** Preserved ZIP safeguards include safe enclosed paths, backslash rejection, rejection of symlinks/special files, a 1,024-entry maximum, the existing companion-extension allow-list, exactly one nonempty OBJ, and nested/disguised-format rejection. Limits are: - **256 MiB** total declared uncompressed package size. - **128 MiB** actually extracted OBJ bytes. - A separate **256 MiB actual streamed mesh-download bound**, including after gzip decompression—not merely `Content-Length`. Both initial download and retry are bounded. Non-ZIP metadata precedence and the shared/non-mesh downloader remain unchanged. Typed rejection reasons retain actionable logging, including unsupported MIME diagnostics. The DB test remains compiled under `#[cfg(test)]`, with individual `#[cfg_attr(feature = "skip_database_tests", ignore)]` gating. Its size/checksum query now uses a `sqlx::query_as!` helper in `mysql_queries`, backed by genuine matching MySQL-generated `.sqlx` metadata—not fabricated cache data. ## Intentional appearance limitation — maintainer decision requested Only raw OBJ is retained. Accepted MTL/texture companions are deliberately discarded, with a warning reporting the actual discarded-file count when nonzero. **Materials/textures and their appearance are not retained.** Existing `mtllib` references can remain unresolved; the OBJ bytes are not rewritten to repair them. Explicit maintainer acceptance of this geometry-only storage policy is still requested. ## Validation Current PR head: `3a7d6dce7246653f4f42b4d43bb5b5c51c677043`. [Current validation run 42058895273](https://github.com/Alex72-py/artcraft-services/actions/runs/42058895273) completed **SUCCESS**. Its log records `PR155_CHECKED_OUT_SHA=3a7d6dce7246653f4f42b4d43bb5b5c51c677043`—the PR source commit, not the separate runner head. Verified on that exact source: - `cargo check -p storyteller-web --tests` and `cargo check -p mysql_queries` passed with `SQLX_OFFLINE=true`. - **21 resolver + 8 downloader tests on each of three binaries**, plus **1 MySQL uploader/query integration test**: **30 unique targeted tests, 88 executions, zero failures or ignored tests**. - **Four-file rustfmt, including the uploader**, and `git diff --exit-code` passed. Full-crate fmt and strict clippy were intentionally skipped in validate mode; the limitations below remain applicable. This is targeted backend validation, not the full workspace test suite. The [previous verified functional run, 42052717146](https://github.com/Alex72-py/artcraft-services/actions/runs/42052717146), checked out `18a2b23786414f6b6c0883c798699ed2a7e64732` and passed: - Backend/test-target and query-crate offline checks. - **21 resolver + 8 downloader tests on each of three binaries**, plus **1 MySQL uploader/query integration test**: **30 unique targeted tests, 88 executions, zero failures or ignored tests**. - Its then-three-file rustfmt check and final git-diff check. That integration test verifies raw stored OBJ bytes and consistent database metadata using isolated MySQL and a test bucket—not live Fal/browser end-to-end coverage. **Broader lint limitations:** Full-crate fmt on [18a](https://github.com/Alex72-py/artcraft-services/actions/runs/42053921289) and [main](https://github.com/Alex72-py/artcraft-services/actions/runs/42053962625) failed, exposing PR uploader formatting alongside shared baseline drift. Follow-up `3a7d6dc` applies all **18 actual uploader rustfmt hunks**, formatting only; other baseline files were not cleaned. Strict clippy failed on both sources with the **same 28 vendored Symphonia errors**, blocking completion of the backend lint assessment. It was **not rerun on `3a7d6dc`**; clippy is not claimed clean. ## Authentic Fal evidence limit #1327 provides only the error and a sign-in-required Rootly alert, without a model/output sample. The inspected Hunyuan2.1 fixture ZIP contains three OBJs—`white_mesh_remesh.obj`, `demo_textured.obj`, `demo.obj`—and two GLBs—`demo_textured.glb`, `demo_textured_pbr.glb`—plus companions. Normal dispatch prefers the GLB and skips its mesh ZIP. It is **neither the original reproduction nor evidence of an accepted single-OBJ Fal ZIP**. The Rapid fixture is raw OBJ with separate companions. The original producing endpoint and authentic single-OBJ ZIP for the affected mesh path remain unknown. ## Outstanding upstream gate The separate backend-CI workflow PR is [#349](https://github.com/storytold/artcraft-services/pull/349). Its [workflow run 42267776142](https://github.com/storytold/artcraft-services/actions/runs/42267776142) is waiting for maintainer approval (`action_required`); it has not run and has zero jobs. **Manual fork runs are supporting technical evidence only. They do not satisfy reviewer request 1's upstream, current-head backend-CI gate.** That gate and the appearance-policy decision remain outstanding; this description does not claim approval or merge-readiness. |
||
|
|
5a01d59775 |
Keep bookmark counts in step with each user's bookmarks (#225)
`entity_stats.bookmark_count` drifts away from the real number of
bookmarks during normal use. Both the create and delete handlers decide
whether to change the count from a bookmark that
`get_user_bookmark_transactional_locking` looks up, and both lookups can
return the wrong bookmark.
- **Create:** the lookup by entity isn't filtered by user (`WHERE
b.entity_type = ? AND b.entity_token = ?` with `fetch_one`). Once anyone
has bookmarked an entity, every later user finds that live bookmark, and
the handler skips the increment.
- **Delete:** the lookup by bookmark token joins the bookmark against
every bookmark of the same entity (to lock them), but selects the
columns from the joined row, so it returns an arbitrary bookmark of that
entity. The handler then decrements whenever that row is live. That
includes when the token belongs to someone else, in which case the
delete itself (`WHERE token = ? AND user_token = ?`) matches nothing.
## How to trigger it
1. User A bookmarks a media file: the count becomes 1.
2. User B bookmarks it: the count stays 1, with 2 bookmarks.
3. B removes their bookmark: the count drops to 0, while A's bookmark is
still there.
Separately, `POST /v1/user_bookmarks/delete/{token}` with someone else's
bookmark token (the entity bookmark list returns tokens) lowers the
count without deleting anything.
The count is shown in the media file and weight responses
(`stats.bookmark_count`).
## Fix
- **Create** keeps the same entity-wide `SELECT ... FOR UPDATE`, adding
`ORDER BY (b.user_token = ?) DESC LIMIT 1` so that only the caller's
bookmark comes back. If the caller has none, the row returned is someone
else's and is discarded. Sorting on an expression makes MySQL read, and
so lock, every bookmark of the entity before applying the limit. I
checked with `performance_schema.data_locks` that the lock set is
identical to `main`'s: all of the entity's bookmark records plus the
next gap, and its `entity_stats` row.
`BookmarkIdentifier::EntityTypeAndToken` becomes
`UserAndEntity(user_token, entity_token)`, and the lookup takes a named
args struct.
- **The lookup by token** selects the requested bookmark (`b1`) instead
of the joined row. The self-join and locking are unchanged.
- **Delete** only decrements when the bookmark is live and belongs to
the caller.
The response bodies and status codes are unchanged. Deleting someone
else's bookmark still returns `success: true`, as before; it just no
longer changes the count. The two changed queries have new `.sqlx`
entries, generated by sqlx from a migrated database, in place of the
stale ones.
## Tests
`application_routes/user_bookmarks_endpoint_tests.rs` drives the real
create, delete and media file routes with signed sessions against the
test database, and reads the stored count back through `GET
/v1/media_files/file/{token}`:
- `each_users_bookmark_is_counted`
- `deleting_a_bookmark_removes_only_that_users_count` (it also deletes
the same bookmark a second time)
- `deleting_someone_elses_bookmark_does_not_change_the_count`
- `repeated_bookmark_and_delete_count_once`
The first three fail on `main` and pass with this change. The last one
is a regression check for repeated create and delete calls, and passes
on both.
These tests take `acquire_serial_test_lock()`, which goes beyond the
lock's documented use, so here is why. When they ran in parallel, InnoDB
deadlocks turned a bookmark request into a 500 (seen with `SHOW ENGINE
INNODB STATUS`):
- two `INSERT INTO user_bookmarks` waiting on each other's gap lock in
`index_entity_type_entity_token`;
- separately, two `entity_stats` `INSERT ... ON DUPLICATE KEY UPDATE`
statements doing the same.
Both come from the existing locking, which this change keeps as it was.
A `FOR UPDATE` lookup that finds no rows locks a gap, and the following
insert goes into that gap. In the nearly empty test tables, unrelated
new entities share the same gaps. In production the same deadlock is
possible when two entities that are adjacent in the index get their
first bookmark at the same moment.
- MySQL 8.0.45, `cargo test -p storyteller-web`: 698 passed, 12 failed,
8 ignored. The 12 failures are the login challenge and user media
endpoint tests, which use `IsolatedTestDatabase`. It connects only
through the Homebrew socket `/tmp/mysql.sock`, which doesn't exist on
this machine. None of them touch bookmarks.
- `SQLX_OFFLINE=true cargo test -p mysql_queries`: 81 passed, 0 failed,
14 ignored.
- `cargo clippy --no-deps --all-targets` reports nothing on the changed
lines.
## After deploying
Counts that have already drifted stay wrong. Until they are recounted, a
delete by a user who was never counted can push a count to 0, and
`ABS(bookmark_count - 1)` then bounces it back to 1. A one-off recount
of live rows per entity from `user_bookmarks WHERE deleted_at IS NULL`
would correct them.
## Not fixed here
When a user bookmarks something they had bookmarked and removed before,
`upsert_user_bookmark` revives the existing row but returns a newly
generated token that was never stored. Deleting with that token returns
404. I left that out to keep this change to the counts.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Bookmark updates now correctly distinguish bookmarks by both the user
and the bookmarked item.
* Deleting a bookmark only changes the item’s bookmark count when it
belongs to the signed-in user and has not already been deleted. Repeated
deletions no longer reduce the count again.
* Repeatedly bookmarking the same item counts only once, and deleting
and recreating a bookmark updates the count correctly.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
de764c9d81 |
fix: persist the requested visibility when importing TTS and voice conversion models (#326)
What was wrong: the download job processors (tacotron, VITS, RVC v2,
So-VITS-SVC, SoftVC) hard-coded Visibility::Public ("TODO: All models
default to public") instead of the creator's queued choice, and
insert_tts_model_from_download_job /
insert_voice_conversion_model_from_download_job accepted
creator_set_visibility but never wrote it. A model imported as Private
or Hidden became public.
Change: both INSERTs now write creator_set_visibility, and the
processors pass job.creator_set_visibility (the hifigan vocoder
processors already did). The two changed sqlx::query! statements have
updated .sqlx offline entries (old entries removed; written by hand from
the same describe data, one extra bind parameter, hash = sha256 of the
new text, and verified by an offline compile).
Blast radius: two mysql_queries insert functions, five download-job
processors. The model_weights inserts already persisted the field.
Behavior changes: imports queued as Private/Hidden are now stored that
way instead of Public. Imports queued as Public are unchanged.
Checks run: cargo check -p download-job (SQLX_OFFLINE=true).
Checks not run: DB tests (need MySQL), fmt/clippy, `cargo sqlx prepare
--check` (no database; entries not regenerated by tooling).
|
||
|
|
9cd544adef |
fix: bound decoded downloads, linear tag recount, ban/ownership checks on legacy handlers (#316)
## What was wrong - `http_download_url_to_bytes` enabled gzip and collected the whole decoded body with `bytes()` and no size limit, so a small compressed response from an attacker-chosen media origin could exhaust memory. - `apply_tags` merged previously linked tag tokens into a growing `Vec` with `contains` per token (quadratic CPU on attacker-accumulated history, inside a transaction). ## What changed - The downloader reads chunks and returns a new `DownloadFileToBytesError::TooLarge` once decoded bytes pass 1 GiB (generous headroom over legitimate media). Error-status bodies are bounded the same way. - `apply_tags` uses a `HashSet` for membership; resulting order and contents are identical. ## Behavior changes Downloads larger than 1 GiB now fail. Nothing else for valid input. ## Checks - run: `cargo check -p storyteller-web --tests` - not run: DB-backed tests (need MySQL); clippy -D warnings (fails on unmodified main in `enums`); no test for the 1 GiB cap (would need to serve that much). ## Second part: authorization fixes ### What was wrong - The five legacy text-to-image handlers (flux 1 dev/schnell, flux pro 1.1/ultra, gpt-image-1) accepted any valid session, including banned accounts. - `terminate_inference_job_handler` only compared owners when the caller also had a session; omitting the cookie made an account-owned job fall back to IP equality, so anyone behind the same IP could cancel it. - `change_media_file_engine_category_handler` returned category-specific errors (existence/engine details) before checking the caller may edit the file. ## What changed - Banned sessions get `NotAuthorized` in those five handlers. - Account-owned jobs require the owning session; the IP rule remains only for anonymous jobs. - Creator-or-moderator check moved directly after loading the record. ## Behavior changes Banned users lose access to those routes (intended); a signed-out caller can no longer cancel an account-owned job from the same IP; non-owners now get NotAuthorized instead of validation messages. ## Checks - run: `cargo check -p storyteller-web --tests` - not run: handler tests (need MySQL); clippy -D warnings (fails on unmodified main in `enums`). Findings: 46338003, 44b859e9, 56186c57, 1f1f2f34, 5456374d Not touched: media-lookup/mesh dedup (09045369, 0355e215; files in #229) and the missing wallet deduction on legacy Flux Dev/Hunyuan (owner). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Banned accounts can no longer submit text-to-image generation requests. * Terminating an inference job now requires a matching signed-in session when the job has a creator. IP-based checks remain for jobs without a creator. * Media-file engine category changes now check permissions before validating category selections. * URL downloads follow up to 10 redirects and are limited to 1 GiB; oversized downloads are rejected. Non-success responses continue to report the response details. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
ab32c3aec6 |
fix: bound decompressed bytes when extracting studio-shot frames (#303)
## What was wrong The studio-shot upload extracts frame images from a ZIP into a temp directory with an unbounded `std::io::copy`. The 8,000-file cap limits entry count, not decompressed size, so a small, highly compressible archive could expand to many gigabytes of temp writes and decompression work inside the request. ## What changed Each member is copied through `copy_within_budget`, which reads at most one byte past the limit and fails with a new `ExtractFramesError::TooLarge` when a frame exceeds `MAX_FRAME_BYTES` (64 MiB) or the upload exceeds `MAX_TOTAL_EXTRACTED_BYTES` (4 GiB). The handler maps it to an error response like the other extraction errors. The constants sit next to the existing `TOO_MANY_FILES_COUNT`. ## Checks - Run: `cargo test -p storyteller-web extract_frames_from_zip` (3 passed: a frame exactly at the limit, one byte over, and the running total); `SQLX_OFFLINE=true cargo check -p storyteller-web` (exit 0). - Not run: the upload endpoint test (needs a live MySQL). - Not done: moving extraction off the request worker (the finding's second suggestion). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * ZIP uploads now reject frames larger than 64 MiB and combined extracted frames exceeding 4 GiB, with a clear error message when archive contents are too large. * Errors while reading or writing extracted frames are reported as extraction failures. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
11242401eb |
fix: reject expired web sessions (#230)
## Summary `get_api_or_web_session_user_by_session_token` is the lookup behind cookie authentication. It joined `user_sessions` and filtered on `deleted_at` and the user's own deletion state, but never compared `expires_at`. The signed cookie payload carries no expiry claim either, so an expired session row kept authenticating every request — a hijacked or long-lived cookie stayed valid until someone deleted the row. The lookup now also requires: ```sql AND (user_sessions.expires_at IS NULL OR user_sessions.expires_at > UTC_TIMESTAMP()) ``` The `IS NULL` arm keeps any legacy row without an expiry non-expiring rather than silently logging everyone out; if `expires_at` is `NOT NULL` in production it is simply dead. ## Note on the `.sqlx` cache `sqlx::query!` is compile-checked against `.sqlx/`, and this environment has no MySQL, so `cargo sqlx prepare` could not run. I generated the replacement cache entry the way `prepare` does (same column metadata, `hash = sha256(query)`), and the crate compiles offline against it. **Please run `cargo sqlx prepare` against a real database before merging** to confirm the entry matches what the tool would produce. ## Checks - `SQLX_OFFLINE=true cargo check -p storyteller-web` — finished clean, exit 0. - No tests run: `mysql_testing` fixtures (including `expire_user_session`) need a live MySQL. A regression test that expires a session and expects a 401 would be worth adding here. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Expired sessions are no longer accepted during session lookup, including sessions that expire at the current time. * Sessions without an expiration time remain eligible for lookup. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
a3f7204180 |
fix: reject passwords longer than bcrypt's 72-byte input (#302)
## What was wrong bcrypt only uses the first 72 bytes of a password. Account creation, password change and password reset accepted longer passwords and hashed them, so everything after byte 72 was silently ignored. A user who changed only the tail of a long password hadn't really changed it, and a long passphrase was weaker than it looked. ## What changed - `password` crate: new `BCRYPT_MAX_PASSWORD_BYTES = 72`. `bcrypt_hash_password` returns a new `PasswordHashError::PasswordTooLong` instead of truncating (with a unit test at 72 and 73 bytes). - `validate_passwords` (account creation, password change) rejects longer passwords with a clear 400 message. - Password reset redemption rejects them with a new `PasswordTooLong` 400 error. Login (`bcrypt_confirm_password`) is unchanged, so existing accounts with longer passwords can still sign in; they just can't set a new one over 72 bytes. ## Checks - Run: `cargo test -p password` (6 passed); `SQLX_OFFLINE=true cargo check -p storyteller-web` (exit 0). - Not run: endpoint tests (need a live MySQL). |
||
|
|
80440b43fe |
fix: answer password reset requests before doing account-dependent work (#312)
## What was wrong `POST /v1/password_reset/request` returns the same body whether or not the account exists, but not in the same time. For unknown accounts it returned right after the lookup. For real accounts it first created the reset record, inserted the email job, and awaited the external Resend email send. The response time difference (often hundreds of ms) lets anyone enumerate registered emails and usernames. ## What changed After the lookup, the account-dependent work moves unchanged into `issue_password_reset`, which runs on a spawned task (`actix_web::rt::spawn`). The handler returns the success response immediately in both cases. Failures in the background task are logged (`error!`) instead of returned. Callers couldn't act on them anyway, and unknown accounts already got a plain success. ## Blast radius One handler. A reset email that fails to send no longer produces a 500 for the requester; it shows up in logs instead. #217 touches the lookup lines above this change; any rebase is trivial. ## Checks - Run: `SQLX_OFFLINE=true cargo check -p storyteller-web` (exit 0). - Not run: endpoint tests (need a live MySQL and email provider). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Password reset requests now return the same success response whether or not the account exists. * Requests for known accounts are acknowledged immediately while the reset email is processed in the background. Processing failures do not change the response. * When reset processing is at capacity, requests still receive the same success response. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
147f9a7fa7 |
fix: revoke existing sessions when a password reset is redeemed (#310)
## What was wrong
Redeeming a password reset changed the password (and bumped
`password_version`) but left every existing session valid, and session
checks don't look at `password_version`. Someone who already had a
session on the account (the reason for recovering it, often) kept access
after recovery and could even change the password again.
## What changed
`change_password_from_password_reset` now also soft-deletes all of the
user's live `user_sessions` rows inside the same transaction as the
password update, rolling back if that fails. The redeem handler already
creates a fresh session for the person who completed the reset, after
commit.
It's a runtime `sqlx::query` (no new `.sqlx` offline entry needed).
Sessions already cached in Redis expire within the cache TTL
(`REDIS_CACHE_TTL_SECONDS`, 60s by default).
- A password login now creates its session with one conditional insert:
it succeeds only if `password_version` still matches the version the
password was verified against, under a row lock on the user. A login
that races a reset is answered as invalid credentials instead of leaving
a live session behind.
## Checks
- Run: `SQLX_OFFLINE=true cargo check -p storyteller-web` (exit 0).
- Not run: the reset flow tests (need a live MySQL).
- Not changed: ordinary password changes (`change_password_handler`)
still keep other sessions.
## Review round (
|
||
|
|
28e7caa573 |
fix: reject other users' private images as Veo 2, Veo 3 Fast and Kling 2.1 Master sources (#319)
## What was wrong The legacy image-to-video handlers for Veo 2, Veo 3 Fast and Kling 2.1 Master loaded the caller-supplied source image by token without checking visibility, so anyone holding another user's private image token could send it to the provider and receive derived output. ## What changed Same check as #283 (Veo 3): a Private source is usable only by its creator or a moderator (`can_delete_other_users_tts_results`); otherwise `NotFound`, so existence is not confirmed. ## Behavior changes Using someone else's private image as a source now returns 404. Public/unlisted and own images unchanged. ## Not covered fcdeb392 also lists Kling 1.6 Pro, Kling 2.1 Pro, Seedance 1.0 lite/pro and the Beeble edit handler; they load media through different code paths (batch lookup / video sources) and are left open for a follow-up. Veo 3 is #283. ## Checks - run: `cargo check -p storyteller-web --tests` - not run: handler tests (need MySQL); clippy -D warnings (fails on unmodified main in `enums`). Finding: fcdeb392 (partial) |
||
|
|
2394ab8070 |
fix: refuse another user's private image as a weight cover (#318)
## What was wrong Both weight cover setters (`set_model_weight_cover_image_handler` and the `cover_image_media_file_token` branch of `update_weight_handler`) authorized the weight but only checked that the chosen media file exists and is an image. A weight owner who knew another user's private image token could make it the cover and publish its storage links. ## What changed A Private image that the caller did not create is rejected with `NotFound` (same rule as the cover-image read paths in #267: not private, or same creator). Own private images and any non-private image still work. ## Behavior changes Setting someone else's private image as a cover now returns 404. ## Checks - run: `cargo check -p storyteller-web --tests` - not run: handler tests (need MySQL); clippy -D warnings (fails on unmodified main in `enums`). Findings: 58119149, 2490367c |
||
|
|
307026f29b |
fix: hide unreadable results on batch and Omni API job status (#309)
## What was wrong
Three job-status reads return a completed job's result media token,
bucket path and CDN links to anyone holding the job token, without
checking the result media's current visibility or deletion:
- `GET /v1/jobs/batch` (public, cookie session optional)
- `GET /v1/omni_api/job_status/{token}` and the Omni API batch route
(API-key authenticated, but the authenticated user was discarded)
So results the creator later made private, or deleted, stayed reachable
through any known job token.
## What changed
New shared helper `util::lookup::hide_unreadable_job_results` takes the
job records, the viewer's user token and moderator flag, loads all media
results in one `batch_get_media_files_by_tokens` query (deleted rows
only for moderators), and clears `maybe_result_details` for results that
are deleted, or private and not the viewer's. Status, progress and
failure fields are untouched.
- Web batch: viewer from the cookie session; moderators via
`can_delete_other_users_tts_results`.
- Omni API single and batch: viewer is the API key's user
(`require_api_key_user` already returned it).
The single web job route (`/v1/jobs/job/{token}`) is handled in #277.
## Notes for review
- #229 adds a read-scope parameter to `batch_get_media_files_by_tokens`.
Whichever merges second needs a one-line update here (passing
`MediaReadScope` or keeping `can_see_deleted`).
- Anonymous (visitor-token) creators of private media aren't matched
here; private results are normally owned by logged-in users.
## Checks
- Run: `SQLX_OFFLINE=true cargo check -p storyteller-web`; `cargo test
-p storyteller-web hide_unreadable_job_results` (1 passed, covers
public/hidden/private, creator, other user, moderator, missing creator).
- Not run: endpoint tests (need a live MySQL).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Job status responses now hide media results that the viewer isn’t
permitted to access, while retaining other status information.
* Private media results are shown only to their creator or a moderator.
Public and hidden media results remain visible, and missing media
results are hidden.
* If media lookup fails, result details are hidden rather than exposing
potentially inaccessible results.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
eff0b1e676 |
fix: check access to job inputs before enqueueing legacy media jobs (#271)
## What was wrong The legacy enqueue routes took media tokens from the request and queued them without checking who owned them: - `/v1/conversion/enqueue_fbx_to_gltf` - `/v1/animation/face_animation/create` - `/v1/animation/rerender/create` - the live portrait / face mirror routes - the face fusion route - the studio and VST workflow routes - `/v1/workflow/comfy/create` - the GPT-SoVITS model download (cover image) The workers download those objects with the service's bucket credentials and publish the result under the requester. Anyone holding another user's private media token could therefore get a converted, animated or restyled copy of it. With GPT-SoVITS, they could attach it as a model cover that anyone can read. The live portrait worker also reads deleted inputs. ## What changed - New `util::job_input_access`. It allows an input only when it exists, is not deleted, and is either non-private or created by the requester. Moderators (`can_ban_users`) are allowed. Records with no creator user follow the same rule as the batch media read policy in #229. - Every route listed above now checks each input token before inserting the job. A media-file, media-upload or voice-conversion-result token that fails the check gets a not-found or bad-input response. - New query `media_uploads::get_media_upload_access_info`. Legacy media uploads need their creator token for this check, and existing queries don't return it. It is a runtime query because `maybe_creator_user_token` on that table has no offline cache entry. Swap it for `query_as!` after the next `cargo sqlx prepare`. ## Blast radius Only callers who name media they cannot read are affected. Their jobs are no longer enqueued. Jobs on your own media, public media or hidden media are unchanged. ## Not covered here - The workers do not recheck access before downloading. Any job already in the queue, or any job inserted by another path, is still processed. - The video style transfer worker follows `original source` references. That lookup is not rechecked. - The weight read path still serves the cover links that are already stored on weights. Addresses CodeRabbit security findings (CWE-639). ## Checks run - `SQLX_OFFLINE=true cargo check -p storyteller-web -p mysql_queries` - Unit tests for the visibility rule (`job_input_access`) are included; results to follow in a comment once the shared build host frees up. ## Checks not run - Handler and query tests against a live MySQL. - End-to-end worker runs. They need GPUs and the bucket. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Job submissions now check whether referenced media, uploads, and voice-conversion results are available to the requester before creating a job. * Public and hidden items are usable by any requester. Private items are usable by their creator or a moderator; private items without a creator are also usable by any requester. * Missing, deleted, or inaccessible inputs are rejected as not found. Access-check errors are reported as server errors. * Checks cover animation, workflow, conversion, and model-download submissions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
d1c203236f |
fix: hide private and deleted media from public bookmark lists (#257)
## What was wrong
`GET /v1/user_bookmarks/list/user/{username}` is public. Its query joins
`media_files` for media bookmarks and returned the bucket hash, prefix,
extension and creator for every bookmarked file, regardless of the
file's visibility or deletion state. Anyone could list another user's
bookmarks and get CDN URLs for private (or deleted) media.
## What changed
- `list_user_bookmarks_by_maybe_entity_type` takes
`maybe_viewer_user_token` and `viewer_is_moderator`.
- For non-moderators, rows that join a media file are kept only if the
file is not deleted and is either non-private or created by the viewer.
Non-media bookmarks are unaffected. The count query uses the same
filter, so page counts stay consistent.
- The handler resolves the optional session; moderators
(`can_delete_other_users_tts_results`, as in `get_media_file_handler`)
see the list unfiltered.
- Unit tests on the generated SQL.
## Blast radius
Public bookmark lists lose private/deleted media entries for anonymous
and non-owner viewers. Model-weight bookmarks are not filtered by weight
visibility here.
## Checks
- Run: `SQLX_OFFLINE=true cargo check -p storyteller-web -p db-cleanup
--tests`.
- Not run: the new `mysql_queries` unit tests and endpoint tests (need
MySQL for the latter).
Addresses CodeRabbit security findings (CWE-862).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Bookmarked media now follows visibility and deletion rules: private or
deleted media is hidden from viewers who aren’t allowed to see it.
* Creators can still see their own private bookmarked media, and
moderators can view bookmarks without these filters.
* Bookmark lists and totals reflect the viewer’s access, with anonymous
viewers handled without a signed-in session.
* If session lookup fails, bookmark lists can still be shown without
signed-in access.
* Bookmark responses are marked as private and are not stored in caches.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
357d4705b9 |
fix: don't use a private imageref as the cover of a shared result (#256)
## What was wrong For mesh/splat results with no thumbnail, the FAL webhook attaches the prompt's first image reference as the result's cover (`try_to_attach_prompt_imageref_cover`). It never looked at the reference's visibility, so a private source image could become the cover of a public result, and every response that shows the result's cover then exposed the private image's bucket path and URL. ## What changed Before attaching, the helper loads the imageref and the target media file: - non-private imageref: attach as before; - private imageref: attach only if the result is also private and has the same creator; - any lookup error or missing row: skip (the helper already fails open on the webhook, closed on the cover). Unit tests cover the decision table. ## Blast radius Webhook cover fallback only. Results generated from a private image now get no cover unless they are private too. Covers attached before this change are not cleaned up, and cover links in media responses still don't apply the cover's own visibility. ## Checks - Run: `SQLX_OFFLINE=true cargo check -p storyteller-web -p db-cleanup --tests`. - Not run: the new unit tests (the crate's test build is heavy here) and a webhook replay (needs MySQL). Addresses CodeRabbit security findings (CWE-863). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Prompt image covers are now displayed only when their visibility is compatible with the result. Private images appear only on private results created by the same person. * Covers are skipped when image details are unavailable or cannot be checked, preventing potentially restricted images from appearing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
5569669446 |
fix: confine the Comfy workflow output path to the job's output directory (#246)
## What was wrong `POST /v1/workflow/comfy/create` accepts `maybe_output_path` from the caller. The inference worker: - joined it onto the Comfy output directory, - copied the input video to it (`SKIP-PROCESS-VIDEO`), - deleted it, or the directory, during cleanup, - and spliced it into `bash -c` command lines for audio restoration (`FfmpegAudioReplaceArgs`) and watermarking. Because of this, an absolute path or `..` escaped the output directory (CWE-22), and shell metacharacters ran commands as the worker (CWE-78). ## What changed `check_and_validate_job` now rejects any output path that is not made only of plain relative segments of `[A-Za-z0-9._-]`. That means no empty, `.` or `..` segments, no leading `/` or `-`, and at most 255 bytes. The check runs before the job does any work. The default path `vid2vid/SparseUpscaleInterp_00001.mp4` and the paths legacy clients send still pass. ## Blast radius Only jobs from the legacy Comfy route that send unusual output paths are affected. Those jobs now fail validation instead of running. Studio and VST jobs do not set an output path, so they are unchanged. Addresses CodeRabbit security findings (CWE-22, CWE-78). ## Checks run - `cargo test -p inference-job --bins check_and_validate_job` (new unit tests for traversal, absolute paths and shell metacharacters) ## Checks not run - An end-to-end worker run. It needs ComfyUI, a GPU and the bucket. - Replacing `bash -c` with direct process arguments in `CommandRunner`. That would be a wider refactor of the deprecated worker. With this change the paths it receives are already inert. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **Bug Fixes** - Output paths for video style transfer jobs are now checked for valid format and length. Invalid paths—including absolute paths, traversal segments, unsupported characters, and paths that are too long—are rejected with an error identifying the path. Valid relative paths continue to be accepted. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |