Commit Graph
285 Commits
Author SHA1 Message Date
Dylan M. Taylor 7de990e87d security: upgrade sqlx to 0.8.6
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.
2026-11-14 14:29:51 -05:00
Dylan M. Taylor 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 -->
2026-11-11 11:22:39 -05:00
Dylan M. Taylor 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 -->
2026-11-11 11:22:32 -05:00
Dylan M. Taylor c41edee6a7 fix: keep the support-tool media cache private and stop following planted links (#308)
## 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).
2026-11-11 11:17:54 -05:00
FredApps 9818c45071 cli: use tokio file I/O and sleep inside async functions (Sonar S7493/S7488) (#365)
## 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 -->
2026-11-10 18:28:26 +01:00
Brandon Thomas 55ab800542 more performant list user files endpoint 2026-09-27 15:02:19 -04:00
Brandon Thomas cfa8264642 debug tool 2026-09-18 18:54:10 -04:00
Brandon Thomas ef2710fcc8 wip 2026-09-14 15:40:33 -04:00
Brandon Thomas ad08682610 support seedance 2.5 quicktime output 2026-09-14 15:40:32 -04:00
Brandon ThomasandHanashi 7fb81500a7 rename CLAUDE.md to AGENTS.md (#1940)
Co-authored-by: Hanashi <shared2@storyteller.ai>
2026-09-10 21:55:17 -04:00
Hanashi 5cacd89ab8 fix build error 2026-08-12 23:16:27 -04:00
hanashi 9737f0ef88 rename client (#1824) 2026-07-31 15:10:30 -04:00
Brandon Thomas f708402e8a grab billing data for reports (#1810) 2026-07-27 10:03:13 -04:00
Brandon Thomas cb6d0fe27c new tags system (replacing the old one) (#1770) 2026-07-10 05:21:49 -04:00
Brandon Thomas 1d5d63fda1 media files: stop reading and writing deprecated fields and values (#1758) 2026-07-08 21:41:45 -04:00
Brandon Thomas 3e4f998599 payments informatics (part 1) (#1704) 2026-06-29 17:49:28 -04:00
Brandon Thomas fef420129d fix seedance client again - nullable width/height (#1682) 2026-06-23 16:13:54 -04:00
Brandon Thomas ac2e728000 seedance bitrate (#1675) 2026-06-22 08:24:29 -04:00
Brandon Thomas 7d8d9462d1 rename legacy bucket client (#1670) 2026-06-19 23:52:30 -04:00
Brandon Thomas 345c25cb07 add more (and correct) metadata to media_files records (#1552) 2026-05-22 21:14:03 -04:00
Brandon Thomas f7500a3026 gmi + cli tooling improvements (#1533) 2026-05-17 19:32:45 -04:00
Brandon Thomas 0ec9c0ce16 signup - use db executor, not pool (#1510) 2026-05-13 18:28:22 -04:00
Brandon Thomas 7355394494 referral program backend (#1509) 2026-05-13 13:08:01 -04:00
Brandon Thomas 9d38b45bc2 prompting tool for artcraft (#1470) 2026-05-03 00:26:38 -04:00
Brandon Thomas 4b5e171261 generate cli tool (#1469) 2026-05-02 20:32:29 -04:00
Brandon Thomas 9842734ce7 more cleanup of deprecated or orphaned code (#1305) 2026-04-05 02:35:55 -04:00
Brandon Thomas b4e1e3ea57 marketing tracking (#1297) 2026-04-03 15:06:38 -04:00
Brandon Thomas a92ad2eb3a remove unused enum imports (#1192) 2026-03-22 18:27:00 -04:00
Brandon Thomas 58d2665f0e seedance2pro -> kinovi domain name migration (#1181) 2026-03-19 13:49:43 -04:00
Brandon Thomas 2063434304 centralized dependency configuration (#1169) 2026-03-18 21:45:42 -04:00
Brandon Thomas 2da5fbcc58 cleanup refactor #2 (#1164)
- 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
2026-03-18 20:32:50 -04:00
Brandon Thomas 7d20ac3d16 grab bag of refactoring, cleanup, etc. (#1160)
- rename seedance2pro crate
- deprecate methods
- remove smtp client
- etc.
2026-03-18 13:36:29 -04:00
Brandon Thomas 0ac57a5448 thumbnail job (#1157) 2026-03-18 02:59:18 -04:00
Brandon Thomas b39f208bd3 add robust job failure reasons to seedance (#1129) 2026-03-10 19:30:31 -04:00
Brandon Thomas 53f34061b6 CLI tool for support issues (#1128) 2026-03-10 17:06:38 -04:00
Brandon Thomas f342befb0b user signup referrer (#1105)
see last PR
2026-03-05 20:07:38 -05:00
Brandon Thomas 6b94196f2b cleanup root directory (#996) 2026-01-19 23:08:39 -05:00
Brandon Thomas 0a5f220a7d remove openssl / native-tls in favor of rustls -- this lets Artcraft run on Linux! (#907) 2025-11-20 22:46:05 -05:00
Brandon Thomas 9bc24ac216 introduce sqlite with Tauri; task tracking database (#712) 2025-07-13 18:48:47 -04:00
Brandon Thomas 324bfc0964 move api clients crate to top-level of workspace for visibility 2025-07-01 18:50:51 -04:00
Brandon Thomas f4e998d945 cleanup deps (#635) 2025-05-26 01:38:27 -04:00
Brandon Thomas 3d807fdeb2 refactor database crates 2025-05-25 22:33:18 -04:00
Brandon Thomas b3a62cce64 refactor packages 2025-05-25 22:09:59 -04:00
Brandon Thomas 8845b177be rename workspace hack 2025-04-09 20:39:36 -04:00
Brandon Thomas ce0448edca move rust code back to root directory 2025-02-11 21:58:04 -05:00
Brandon Thomas 495b161cae move storyteller-rust files into subdir for merge 2025-02-11 21:09:22 -05:00
Brandon Thomas db05b61c51 search algorithm evaluation 2024-10-01 20:27:33 -04:00
Brandon Thomas 7141aa028f assert on popular voices 2024-10-01 20:19:58 -04:00
Brandon Thomas 90bfb2c2bf query testing harness 2024-10-01 20:03:42 -04:00
Brandon Thomas 7f43e98f07 refactor es search 2024-10-01 10:53:47 -04:00