mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8798] [MERGED] fix(server): hold Professor Mari's mari images sources to her read rule and their app folders #8812
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8812
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8798
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/hardening-mari-images-source📝 Commits (2)
8ece0c9fix(server): hold Professor Mari's mari images file sources to her read rulea5b66e6fix(server): read mari images app and asset sources only inside their folder📊 Changes
4 files changed (+125 additions, -23 deletions)
View changed files
📝
packages/server/src/services/mari-db/mari-db.service.ts(+8 -1)📝
packages/server/src/services/mari-db/mari-images.service.ts(+44 -17)📝
packages/server/src/services/professor-mari/workspace-commands.ts(+3 -1)📝
scripts/regressions/professor-mari/direct-mari-file-flags.regression.ts(+70 -4)📄 Description
Linked issue
Closes #8797
Why this change
This follows up CodeRabbit's minor finding on #8771. Simple
maricommands run in the server process, outside the shell sandbox. #8771 held the --json-file, --file and --css-file paths to the read tool's rule.mari imagesalso reads a file in two cases, and neither read was held to a boundary:These flags also take non-file forms, so an argv scan can't check them. Each form is checked where its file is actually read.
What changed
mari imagessource. This covers --source, --source-image and --from, and an --asset value that matches no preview asset. To use such an image, upload it in the app or put it in the workspace, then point Mari at it.mari imagesno longer reads an app image (an /api/... URL) or a preview asset whose file is a link pointing out of its app folder, or that sits in an app folder that is itself a link. This applies to Professor Mari and to your own mari CLI. To use such an image, replace the link with the real image file.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
mari images assign --target background --source <workspace image>still shows a dry-run with that file as its source.mari images editwith an asset id frommari images generate, or with a target's existing avatar or background, still finds its source image.mari imagessource pointing outside the workspace, or at .env, is refused with the read tool's message.mari images assign --source /api/backgrounds/file/<existing>.pngstill works.Agent-run checks (for reference; the regression was shown to fail without the fix):
node ./scripts/pnpm-runner.mjs build:shared: passednode ./scripts/run-regressions.mjs --filter direct-mari-file-flags (new rows, before the source edit, and again with the HEAD mari-images.service.ts swapped in): failed as expected, 0/1: AssertionError on --source /api/backgrounds/file/linked.png, which returned a successful dry-runtemporary per-row probe (deleted afterwards) against the old and fixed service: old code: all 4 new rows were read or rejected only after reading; fixed code: all 8 refused rows refusednode ./scripts/run-regressions.mjs --filter direct-mari-file-flags (with fix): 1/1 passednode ./scripts/run-regressions.mjs --filter professor-mari/: 26/26 passednode ./scripts/run-regressions.mjs --filter regressions/mari/: 39/39 passednode ./scripts/run-regressions.mjs --filter sprite-list-security / sprite-generated-save / mari-guard-sibling-paths / mari-write-readback: each 1/1 passedcd packages/server && node ../../scripts/pnpm-runner.mjs run lint: passed (tsc -b shared, tsc --noEmit, regressions tsconfig)npx prettier --check on the 4 changed files: All matched files use Prettier code styleIndependent adversarial review, then a fix-up pass for its findings.
Known limits and risks:
Low to moderate. The main risk is the intended behaviour change: images Mari could take from outside the workspace are now refused. It is listed first under What changed, with a way back.
App-folder rule. It is slightly stricter than the app's own media routes. Those accept a link anywhere inside the data dir; mari images accepts only a file inside the form's own folder. A hand-made link from one app folder to another (for example backgrounds to gallery) still displays in the app but is now refused by mari images. The rule also applies to the user's own mari CLI over the HTTP route, because app-URL and asset sources mean app images there too. The file-form rule (resolveReadPath) is still set only by Professor Mari's direct runtime.
Check-then-read window. The real path is checked and then read by that checked path. A folder swapped for a link in between is not caught. This is marked with a
ponytail:comment, and the upgrade path is opening each path part with O_NOFOLLOW.How the regression differs from the reviewer's request. It places the links with fs directly and keeps DATA_DIR outside the workspace, reached through a link. The reviewer asked for a row with DATA_DIR inside the workspace. The check never looks at the workspace, only at the real data dir and the form's folder, so where DATA_DIR sits does not change the result. The reviewer already reproduced the sandboxed shell placing the link under seatbelt; I did not rerun that.
Known remaining paths, outside this finding, not fixed and not tested. mari images also writes through links in the same folders: the preview manifest, background meta.json, and assigned avatar, background, sprite and lorebook files. It also reads the manifest and meta.json JSON through them. A follow-up issue should be filed to give those reads and writes the same real-folder check.
Other existing ceilings. The text-file flags still use #8771's argv scan; the ponytail comment names resolveReadPath as their upgrade path. A target's stored image that is a bare filesystem path (none found in current flows) is now held to the workspace rule.
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.