Conversation
To validate file sizes in the event of a rogue client, Azure event webhooks will be hooked up to AzureValidateFile. Sends outside of a grace size will be deleted as non-compliant. TODO: LocalSendFileStorageService direct upload method/endpoint.
These shouldn't happen, but might if some errant get requests occur
It turns out that multipartHttpStreams do not have a length until read. this causes all long files to be "invalid". We need to write the entire stream, then validate length, just like Azure. the difference is, We can return an exception to local storage admonishing the client for lying
| var sendId = new Guid(CoreHelpers.Base64UrlDecode(encodedSendId)); | ||
| var send = await _sendRepository.GetByIdAsync(sendId); | ||
|
|
||
| if (send == null) |
There was a problem hiding this comment.
Also missing a check here as to whether the Send is enabled or has exceeded it's access count. Although not sure if the access count parameter gets another check here since it would have already been incremented by 1 before downloading the file (assuming).
There was a problem hiding this comment.
Pretty sizable changes to fix this, but I think I hit the points we discussed. there's still a bit of a data leak in that you learn the name and size of the file without incrementing AccessCount, but for now that seems a small issue
| } | ||
| } | ||
|
|
||
| private void DeleteDirectoryIfExists(string path) |
There was a problem hiding this comment.
Not sure I like the idea of deleting directories and/or storing Send files in a directory per Send.
There was a problem hiding this comment.
I can revert, not married to the idea. I just liked matching the file structure to Azure. There I have good reasons to want SendId in the blob path.
Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
cscharf
left a comment
There was a problem hiding this comment.
Looks good, just 1 minor thing
Co-authored-by: Chad Scharf <3904944+cscharf@users.noreply.github.com>
|
Split this PR into a download-side PR (#1174), with some simple preparations for this work (send blob locations). This is held up by Azure/azure-sdk-for-js/issues/14025 blocking upload on Desktop. I'm working through a REST-based upload scheme, but that's not yet ready. I will reopen this PR when this issue is solved |
Overview
This PR creates endpoints to allow direct upload to Azure blob storage and local storage.
Files Changed
sendfilescontainer should have permissions set to offRequired Azure Changes
sendfilescontainer should have permissions set to off<<apiUrl>>/sends/file/validate/azureTesting requirements
Need to test upload and download to both local and Azure hosted environments.
I've tested lying about file size, but a second set of eyes on that is a good idea.
The above require access to bitwarden/web#853