-
Notifications
You must be signed in to change notification settings - Fork 5
Feat/evault file manager #654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6db2131
chore: move file manager
coodos 50978ea
feat: synchronization between file manager & eSigner
coodos 3b7ee37
feat: signature sync
coodos 24272fd
chore: better UX
coodos 657b1dd
fix: file manager UX
coodos e4456d4
fix: refresh automatically on upload
coodos af30f95
chore: add base url to .env
coodos 1796a38
fix: lint
coodos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
platforms/esigner-api/src/web3adapter/mappings/file.mapping.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "tableName": "files", | ||
| "schemaId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", | ||
| "ownerEnamePath": "users(owner.ename)", | ||
| "ownedJunctionTables": [], | ||
| "localToUniversalMap": { | ||
| "name": "name", | ||
| "displayName": "displayName", | ||
| "description": "description", | ||
| "mimeType": "mimeType", | ||
| "size": "size", | ||
| "md5Hash": "md5Hash", | ||
| "data": "data", | ||
| "ownerId": "users(owner.id),ownerId", | ||
| "createdAt": "__date(createdAt)", | ||
| "updatedAt": "__date(updatedAt)" | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
platforms/esigner-api/src/web3adapter/mappings/signature.mapping.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "tableName": "signature_containers", | ||
| "schemaId": "b2c3d4e5-f6a7-8901-bcde-f12345678901", | ||
| "ownerEnamePath": "users(user.ename)", | ||
| "ownedJunctionTables": [], | ||
| "localToUniversalMap": { | ||
| "fileId": "files(file.id),fileId", | ||
| "userId": "users(user.id),userId", | ||
| "md5Hash": "md5Hash", | ||
| "signature": "signature", | ||
| "publicKey": "publicKey", | ||
| "message": "message", | ||
| "createdAt": "__date(createdAt)", | ||
| "updatedAt": "__date(updatedAt)" | ||
| } | ||
| } | ||
|
Comment on lines
+1
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL: This mapping file is identical to the one in file-manager-api. Both
This raises several concerns:
Verify the intended architecture and either:
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Race condition (TOCTOU) in single-use enforcement.
Between checking for existing signature containers (lines 31-33) and creating invitations (lines 52-96), concurrent requests can both pass the validation and proceed, violating the single-use constraint. This is a classic time-of-check to time-of-use vulnerability.
🔎 Recommended fix: Wrap in transaction with appropriate isolation
async inviteSignees( fileId: string, userIds: string[], invitedBy: string ): Promise<FileSignee[]> { + return await AppDataSource.transaction(async (transactionalEntityManager) => { + const signatureRepository = transactionalEntityManager.getRepository(SignatureContainer); + const fileRepository = transactionalEntityManager.getRepository(File); + const fileSigneeRepository = transactionalEntityManager.getRepository(FileSignee); + const userRepository = transactionalEntityManager.getRepository(User); + // Verify file exists and user is owner - const file = await this.fileRepository.findOne({ + const file = await fileRepository.findOne({ where: { id: fileId, ownerId: invitedBy }, + lock: { mode: "pessimistic_write" }, }); if (!file) { throw new Error("File not found or user is not the owner"); } // Check if file already has signatures (single-use enforcement) - const existingSignatures = await this.signatureRepository.find({ + const existingSignatureCount = await signatureRepository.count({ where: { fileId }, }); - if (existingSignatures.length > 0) { + if (existingSignatureCount > 0) { throw new Error("This file has already been used in a signature container and cannot be reused"); } // ... rest of the method using transactionalEntityManager repositories + }); }This approach:
count()instead offind()🤖 Prompt for AI Agents