Repository navigation
fix(delete-user-data): enforce path boundary on Cloud Storage deletion - #3369
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the user data deletion extension to handle storage path boundaries more safely, ensuring directories are deleted cleanly using trailing slashes without affecting other users sharing a UID prefix. It adds comprehensive unit tests to verify these boundaries and introduces checks for empty UIDs and prefixes. The review feedback suggests extending the empty uid guard globally to protect other deletion functions (Firestore and RTDB) from accidental root-level deletions, and safely handling potential non-standard errors in the catch block using optional chaining.
ajperel
left a comment
There was a problem hiding this comment.
Can you also update the version number and CHANGELOG.
|
Bumped version to 0.1.32 in delete-user-data/extension.yaml and added the changelog entry in delete-user-data/CHANGELOG.md (0eb585c). |
Summary
Enforce exact object and directory boundary matching in
clearStorageDataso deleting a user whose custom UID is a prefix of another user's UID (e.g.,1vs12) cannot delete sibling users' objects in Cloud Storage.Changes
delete-user-data/functions/src/index.ts:prefixdoes not end with/, delete the exact object (bucket.file(prefix).delete({ ignoreNotFound: true })) and the directory prefix (bucket.deleteFiles({ prefix:${prefix}/})) instead of callingbucket.deleteFiles({ prefix })without a boundary.uidand emptyprefixsegments (e.g.,{DEFAULT}/or trailing commas) to prevent bucket-wide deletion.delete-user-data/extension.yamlanddelete-user-data/README.md:{DEFAULT}/media/{UID}to{DEFAULT}/media/{UID}/and note that directory paths should use trailing slashes and custom UIDs should not contain/.delete-user-data/functions/__tests__/clearStorageData.test.ts:Verification
tsccompilation succeeded with no errors.jest __tests__/clearStorageData.test.ts --verbose: 5/5 tests passed.