Repository navigation
[INFRA-1222] fix: validate editor asset ids before API calls - #10306
Conversation
An editor file node's src is stored document content. Only a plain asset id (UUID) is now used to build an asset API path, and it is encoded where it is interpolated; any other non-http src results in no request. For legacy http sources the asset key is read from a parsed URL and must be a single plain path segment.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
sriramveeraghanta
left a comment
There was a problem hiding this comment.
LGTM. Real uuid4 asset ids pass, and the undefined return is handled in web, space and the pages assets tab. Non-blocking: the old getAssetIdFromUrl in apps/space/helpers/file.helper.ts is now unused.
An editor file node's src is stored document content. Only a plain asset id (UUID) is now used to build an asset API path, and it is encoded where it is interpolated; any other non-http src results in no request. For legacy http sources the asset key is read from a parsed URL and must be a single plain path segment.
…ne#10306) An editor file node's src is stored document content. Only a plain asset id (UUID) is now used to build an asset API path, and it is encoded where it is interpolated; any other non-http src results in no request. For legacy http sources the asset key is read from a parsed URL and must be a single plain path segment. (cherry picked from commit bdb24bc)
…dpoint Image nodes whose src is the resolved /api/assets/v2/.../<asset_id>/ URL (e.g. images copied from a rendered editor) were routed to the legacy file-assets restore endpoint because the src starts with "http". That endpoint looks the asset up by storage key, so it always returned 404 and the soft-deleted asset was never restored. Extract the asset id from absolute v2 asset URLs (only when the path is a v2 asset path ending in a valid asset id) and restore it through the v2 endpoint, in both the web and space editors. Only the validated plain asset id reaches the API path, consistent with makeplane#10306. Fixes makeplane#9993 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Description
The
srcof an editor file node is stored document content, but the editor's file handlers placed it straight into API request paths (duplicate, delete, restore, existence check, and the source/download URL builders). Asrcthat is not a plain asset id could therefore choose the path of a request made by whoever opened or edited the document.The rule is now: a node
srcreaches an API path only if it is a valid asset id, and it is always encoded when interpolated.packages/utils: newisValidAssetId(UUID).getEditorAssetSrcandgetEditorAssetDownloadSrcreturnundefinedfor anything else and encode the id.apps/webandapps/spacefile handlers:delete,restoreandcheckIfAssetExistsmake no request for an invalid non-httpsrc; the duplicate path is guarded induplicateEditorAsset, and the image node view does not start duplication for an invalidsrc.httpsources: both copies ofgetAssetIdFromUrlread the key from a parsed URL (so dot segments and backslashes are resolved first), and refuse non-http(s) schemes, empty keys and encoded path separators. The legacy delete/restore calls make no request when there is no key.Behaviour for valid asset ids is unchanged.
Behavior change:
srcis neither a valid asset id nor an http(s) URL shows the "Add an image" placeholder instead of "Error loading image".isValidAssetIduses theuuidpackage'svalidate, which is RFC-strict on the version and variant bits. Server-generated uuid4 ids pass; a hand-written id such as00000000-0000-0000-0000-000000000001would not.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
packages/services/src/file/helper.test.ts: added cases for the legacy key derivation (27 passed; the new cases fail without the fix).@plane/utils,@plane/services,@plane/editor,webandspace.packages/utilshas no test runner, so the predicate and URL builders have no committed test.Not run in a browser. Please check manually:
httpsource still loads, deletes and restores.References
Created with Claude Code