-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Release 8.0.2 #38353
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
Closed
Closed
Release 8.0.2 #38353
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
77e46f3
Bump 8.0.2
rocketchat-github-ci 93a4db7
fix: imported fixes 02-18-2026-004 (#38839)
dionisio-bot[bot] 66b0165
fix: imported fixes 02-18-2026-003 (#38840)
dionisio-bot[bot] ac92478
fix: imported fixes 02-18-2026-001 (#38787)
dionisio-bot[bot] dadf9fd
fix: imported fixes 02-18-2026-002 (#38984)
dionisio-bot[bot] 0940df9
fix: comment step out to check babel module (#38351)
dionisio-bot[bot] 77478a8
Release 8.0.2
rocketchat-github-ci 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,10 +11,25 @@ const settingsGetMap = new Map(); | |
| const messagesModelStub = { | ||
| find: sinon.stub(), | ||
| }; | ||
| const usersModelStub = { | ||
| findOneByIdAndLoginToken: sinon.stub(), | ||
| }; | ||
| const subscriptionsModelStub = { | ||
| findOneByRoomIdAndUserId: sinon.stub(), | ||
| }; | ||
| const validateAndDecodeJWTStub = sinon.stub(); | ||
| const systemLoggerStub = { | ||
| error: sinon.stub(), | ||
| }; | ||
| const roomCoordinatorStub = { | ||
| getRoomDirectives: sinon.stub(), | ||
| }; | ||
|
|
||
| const { FileUpload, FileUploadClass } = proxyquire.noCallThru().load('./FileUpload', { | ||
| '@rocket.chat/models': { | ||
| Messages: messagesModelStub, | ||
| Users: usersModelStub, | ||
| Subscriptions: subscriptionsModelStub, | ||
| }, | ||
| 'meteor/check': sinon.stub(), | ||
| 'meteor/meteor': sinon.stub(), | ||
|
|
@@ -23,14 +38,19 @@ const { FileUpload, FileUploadClass } = proxyquire.noCallThru().load('./FileUplo | |
| 'stream-buffers': sinon.stub(), | ||
| './streamToBuffer': sinon.stub(), | ||
| '../../../../server/lib/i18n': sinon.stub(), | ||
| '../../../../server/lib/logger/system': sinon.stub(), | ||
| '../../../../server/lib/rooms/roomCoordinator': sinon.stub(), | ||
| '../../../../server/lib/logger/system': { SystemLogger: systemLoggerStub }, | ||
| '../../../../server/lib/rooms/roomCoordinator': { roomCoordinator: roomCoordinatorStub }, | ||
| '../../../../server/ufs': sinon.stub(), | ||
| '../../../../server/ufs/ufs-methods': sinon.stub(), | ||
| '../../../settings/server': { settings: settingsStub }, | ||
| '../../../utils/lib/mimeTypes': sinon.stub(), | ||
| '../../../utils/server/lib/JWTHelper': sinon.stub(), | ||
| '../../../utils/server/lib/JWTHelper': { | ||
| validateAndDecodeJWT: validateAndDecodeJWTStub, | ||
| generateJWT: sinon.stub(), | ||
| }, | ||
| '../../../utils/server/restrictions': sinon.stub(), | ||
| '../../../api/server/lib/MultipartUploadHandler': sinon.stub(), | ||
| '@rocket.chat/account-utils': { hashLoginToken: sinon.stub().callsFake((token) => `hashed_${token}`) }, | ||
| }); | ||
|
|
||
| describe('FileUpload', () => { | ||
|
|
@@ -44,6 +64,13 @@ describe('FileUpload', () => { | |
| messagesModelStub.find.reset(); | ||
| fakeStorageModel.findOneById.reset(); | ||
| fakeStorageModel.deleteFile.reset(); | ||
| usersModelStub.findOneByIdAndLoginToken.reset(); | ||
| subscriptionsModelStub.findOneByRoomIdAndUserId.reset(); | ||
| validateAndDecodeJWTStub.reset(); | ||
| systemLoggerStub.error.reset(); | ||
| roomCoordinatorStub.getRoomDirectives.reset(); | ||
| settingsGetMap.clear(); | ||
| settingsGetMap.set('FileUpload_Storage_Type', 'fakeStorage'); | ||
| }); | ||
|
|
||
| it('should not remove any file if no room id is provided', async () => { | ||
|
|
@@ -100,4 +127,165 @@ describe('FileUpload', () => { | |
| expect(fakeStorageModel.deleteFile.calledWith('file-id')).to.be.true; | ||
| expect(fakeStorageModel.deleteFile.calledWith('thumbnail-id')).to.be.true; | ||
| }); | ||
|
|
||
| describe('requestCanAccessFiles', () => { | ||
| it('should allow access if FileUpload_ProtectFiles is false', async () => { | ||
| settingsGetMap.set('FileUpload_ProtectFiles', false); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: '/file-upload/test-file-id/test-file.png', | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request); | ||
| expect(result).to.be.true; | ||
| }); | ||
|
|
||
| it('should allow access if no url is provided', async () => { | ||
| settingsGetMap.set('FileUpload_ProtectFiles', true); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: undefined, | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request); | ||
| expect(result).to.be.true; | ||
| }); | ||
|
|
||
| it('should deny access if FileUpload_Enable_json_web_token_for_files is true but no token is provided', async () => { | ||
| settingsGetMap.set('FileUpload_ProtectFiles', true); | ||
| settingsGetMap.set('FileUpload_Enable_json_web_token_for_files', true); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: '/file-upload/test-file-id/test-file.png', | ||
| } as any; | ||
|
|
||
| const file = { | ||
| _id: 'test-file-id', | ||
| rid: 'test-room-id', | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request, file); | ||
| expect(result).to.be.false; | ||
| }); | ||
|
|
||
| it('should deny access if FileUpload_json_web_token_secret_for_files is not configured', async () => { | ||
| settingsGetMap.set('FileUpload_ProtectFiles', true); | ||
| settingsGetMap.set('FileUpload_Enable_json_web_token_for_files', true); | ||
| settingsGetMap.set('FileUpload_json_web_token_secret_for_files', ''); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: '/file-upload/test-file-id/test-file.png?token=some-token', | ||
| } as any; | ||
|
|
||
| const file = { | ||
| _id: 'test-file-id', | ||
| rid: 'test-room-id', | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request, file); | ||
| expect(result).to.be.false; | ||
| expect(systemLoggerStub.error.calledOnce).to.be.true; | ||
| }); | ||
|
|
||
| it('should deny access if an invalid token is provided', async () => { | ||
| settingsGetMap.set('FileUpload_ProtectFiles', true); | ||
| settingsGetMap.set('FileUpload_Enable_json_web_token_for_files', true); | ||
| settingsGetMap.set('FileUpload_json_web_token_secret_for_files', 'test-secret'); | ||
| validateAndDecodeJWTStub.returns(null); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: '/file-upload/test-file-id/test-file.png?token=invalid-token', | ||
| } as any; | ||
|
|
||
| const file = { | ||
| _id: 'test-file-id', | ||
| rid: 'test-room-id', | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request, file); | ||
| expect(result).to.be.false; | ||
| expect(validateAndDecodeJWTStub.calledOnce).to.be.true; | ||
| }); | ||
|
|
||
| it('should deny access if token is invalid or payload cannot be decoded', async () => { | ||
|
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. P3: This test is practically identical to the preceding test and should be removed to reduce duplicate code. Prompt for AI agents |
||
| settingsGetMap.set('FileUpload_ProtectFiles', true); | ||
| settingsGetMap.set('FileUpload_Enable_json_web_token_for_files', true); | ||
| settingsGetMap.set('FileUpload_json_web_token_secret_for_files', 'test-secret'); | ||
| validateAndDecodeJWTStub.returns(null); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: '/file-upload/test-file-id/test-file.png?token=valid-token', | ||
| } as any; | ||
|
|
||
| const file = { | ||
| _id: 'test-file-id', | ||
| rid: 'test-room-id', | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request, file); | ||
| expect(result).to.be.false; | ||
| }); | ||
|
|
||
| it('should deny access if the fileId and rid in the token do not match the requested file', async () => { | ||
| settingsGetMap.set('FileUpload_ProtectFiles', true); | ||
| settingsGetMap.set('FileUpload_Enable_json_web_token_for_files', true); | ||
| settingsGetMap.set('FileUpload_json_web_token_secret_for_files', 'test-secret'); | ||
| validateAndDecodeJWTStub.returns({ fileId: 'different-file-id', rid: 'different-room-id', userId: 'test-user-id' }); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: '/file-upload/test-file-id/test-file.png?token=valid-token', | ||
| } as any; | ||
|
|
||
| const file = { | ||
| _id: 'test-file-id', | ||
| rid: 'test-room-id', | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request, file); | ||
| expect(result).to.be.false; | ||
| }); | ||
|
|
||
| it('should deny access if file object is not provided when using JWT', async () => { | ||
| settingsGetMap.set('FileUpload_ProtectFiles', true); | ||
| settingsGetMap.set('FileUpload_Enable_json_web_token_for_files', true); | ||
| settingsGetMap.set('FileUpload_json_web_token_secret_for_files', 'test-secret'); | ||
| validateAndDecodeJWTStub.returns({ fileId: 'test-file-id', rid: 'test-room-id', userId: 'test-user-id' }); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: '/file-upload/test-file-id/test-file.png?token=valid-token', | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request, undefined); | ||
| expect(result).to.be.false; | ||
| }); | ||
|
|
||
| it('should allow access when everything is valid: token is valid, secret configured, and file/room match', async () => { | ||
| settingsGetMap.set('FileUpload_ProtectFiles', true); | ||
| settingsGetMap.set('FileUpload_Enable_json_web_token_for_files', true); | ||
| settingsGetMap.set('FileUpload_json_web_token_secret_for_files', 'test-secret'); | ||
| validateAndDecodeJWTStub.returns({ fileId: 'test-file-id', rid: 'test-room-id', userId: 'test-user-id' }); | ||
|
|
||
| const request = { | ||
| headers: {}, | ||
| url: '/file-upload/test-file-id/test-file.png?token=valid-token', | ||
| } as any; | ||
|
|
||
| const file = { | ||
| _id: 'test-file-id', | ||
| rid: 'test-room-id', | ||
| } as any; | ||
|
|
||
| const result = await FileUpload.requestCanAccessFiles(request, file); | ||
| expect(result).to.be.true; | ||
| expect(validateAndDecodeJWTStub.calledOnceWith('valid-token', 'test-secret')).to.be.true; | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
P3: Remove the duplicated patch note entry to keep the 8.0.2 changelog accurate and non-redundant.
Prompt for AI agents