sqlx 0.7.4 is affected by RUSTSEC-2024-0363 / GHSA-xmrp-424f-vfpx (binary protocol
misinterpretation from truncating or overflowing casts), fixed in 0.8.1.
Bump every sqlx crate to 0.8.6 and rename the two sqlx-core features that moved:
the bare `rustls` feature is now `_tls-rustls`, and sqlx-macros/sqlx-macros-core
expose only the explicit provider features, so they take `_tls-rustls-ring-webpki`.
Resolution also lifts libsqlite3-sys 0.27 -> 0.30.1, clearing its advisory, and
drops sqlx-core from the rustls 0.21 dependents.
## 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 -->
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 -->
## What was wrong
The support-tool's `kinovi_web generate_video` command caches media in
`/tmp/media_files` by default, and
`artcraft_client::download_media_file` writes downloads into it.
- Another local user could pre-create that shared directory and plant
entries. `fs::File::create` follows a planted symlink, so a download
could create or truncate any file the operator can write.
- `find_cached_file` followed symlinks when picking up cached files, so
a planted link could make the operator read, and upload, a private file.
- In directory mode the filename came from the media token unchanged, so
a token containing `/` or `..` could write outside the directory.
## What changed
- The default cache is now
`~/.cache/storyteller-support-tool/media_files`, created with mode 0700.
Any cache directory (default or `--download_path`) must be a real
directory with no group/other permission bits, or the command stops with
a `chmod 700` hint. An owner-only directory belonging to someone else is
unreadable to us, so this rules out foreign-controlled caches without a
uid lookup.
- Cached entries are inspected with `symlink_metadata` and must be
regular files.
- `download_media_file` removes any existing destination entry (a
symlink is removed, not followed) and creates the file with
`create_new`. The token and extension in derived filenames are limited
to `[A-Za-z0-9_-]`.
## Checks
- Run: `cargo test -p artcraft_client download_media_file` (4 passed,
incl. a traversal-token case); `cargo test -p support-tool
download_dir_tests` (1 passed: 0700 accepted, 0777 and a symlinked dir
rejected).
## Summary
Replaces blocking calls inside `async fn`s in the production CLI tools
with their tokio equivalents. This resolves 16 SonarCloud findings:
**rust:S7493** (blocking file operation in async code) and
**rust:S7488** (`std::thread::sleep` in async code).
| Tool | File | Rule | Change |
|---------------------|-------------------------------------------------------------------------|-------|--------|
| `support-tool` | `kinovi_web/subcommands/audit_credits.rs`,
`audit_orders.rs`, `audit_payments.rs` | S7493 × 9 | `std::fs::metadata`
/ `OpenOptions::open` / `writeln!` → `tokio::fs` + `AsyncWriteExt` |
| `elasticsearch-cli` | `plans/create_all_tts_documents.rs`,
`media_files/create_dimensional_media_file_documents.rs`,
`model_weights/create_all_model_weight_documents.rs` | S7493 × 3 |
`std::fs::read_to_string` → `tokio::fs::read_to_string(..).await` |
| `db-cleanup` | `delete_all_anonymous_user_images.rs`,
`migrate_media_files_enum_values/query_pair.rs` | S7488 × 2 |
`thread::sleep` → `tokio::time::sleep(..).await` |
| `migration-tool` | `tts_models_to_weights/migrate.rs`,
`voice_conversion_to_weights/migrate.rs` | S7488 × 2 | `thread::sleep` →
`tokio::time::sleep(..).await` |
In the three `support-tool` audit commands, the CSV is still opened in
append mode, the header is still written only when the file is new or
empty, and the file is still flushed after every page. The row helpers
(`write_*_row`) stay synchronous and now write into a per-page
`Vec<u8>`. That buffer is appended to the file with one
`write_all(..).await` before the per-page flush, so rows reach disk at
the same points as before.
Sleep durations are unchanged. The `tokio` features each crate now needs
(`fs`, `io-util`, `time`) are declared in its `Cargo.toml`. `Cargo.lock`
does not change.
## Not included (overlap with open PRs)
- `db-cleanup/.../delete_user_files.rs:71` (S7488): #324 edits the lines
around this `thread::sleep`.
- `support-tool/.../kinovi_web/subcommands/generate_video.rs:349`
(S7493): #308 rewrites this media-cache write.
#253 also touches `delete_all_anonymous_user_images.rs`, but only the
query filter near the top of the loop (lines 17–57). The sleep at line
65 is outside its hunks.
## Testing
Run locally on Linux x86_64 with stable Rust and `SQLX_OFFLINE=true`:
- `cargo check -p support-tool -p elasticsearch-cli -p db-cleanup -p
migration-tool` passes.
- `cargo test` on the same four crates passes (13 unit tests).
- `cargo clippy` on the same crates, run with `-A
clippy::deprecated_semver` for a pre-existing error in `enums`, reports
nothing on the changed lines.
No new tests are added. The changed functions talk to MySQL,
Elasticsearch or the Kinovi web API, and have no offline harness. The
switch to non-blocking calls does not change observable behaviour, so
there is no test that fails before the change and passes after it.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Refactor**
* Database cleanup and migration tasks now wait asynchronously between
attempts, helping keep command execution responsive.
* Search-index setup and support-tool audit exports now use asynchronous
file operations.
* Audit reports continue to append to existing files, add headers when
needed, and include the same qualifying records; output is written in
batches.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
- move a lot of "deprecated" crates so we don't use them
- kill several dead crates
- rename crates to be more semantic/clear
- roll back broken sha3 version bump