Skip to content
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

[Backport 4.2.x] Enforce upload size limit on putResourceFromUrl api #8601

Merged
merged 28 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e726edf
Check content-length of resource at url
tylerjmchugh Dec 13, 2024
e600d52
Remove unnecessary throw
tylerjmchugh Dec 13, 2024
6359d88
Fallback to InputStream.available() if content length is not found or…
tylerjmchugh Dec 17, 2024
7eb477c
Fallback maxUploadSize for unit tests
tylerjmchugh Dec 17, 2024
6fbc933
Fix default value always used
tylerjmchugh Dec 18, 2024
19a3535
Remove content-length check as it cannot be trusted
tylerjmchugh Dec 18, 2024
358d2dd
Download file to a temp file to check size
tylerjmchugh Dec 20, 2024
369bf7e
Add back the content-length check as a preliminary check
tylerjmchugh Dec 30, 2024
88fee39
Stream file instead of using temp file
tylerjmchugh Dec 30, 2024
3490b3f
Rollback for JCloud
tylerjmchugh Dec 30, 2024
09787de
Fix rollback for JCloud
tylerjmchugh Dec 30, 2024
0c0abed
Fix abstract store and implement jcloud rollback
tylerjmchugh Jan 2, 2025
f052cdd
Fix typo and remove unused import
tylerjmchugh Jan 2, 2025
9745308
Fix unit tests
tylerjmchugh Jan 2, 2025
ee19d04
Fix tests (mock response code)
tylerjmchugh Jan 2, 2025
8ceab27
Fix unit test, refactor, and add docs
tylerjmchugh Jan 2, 2025
99f7259
Fix exception handling and use bounded input stream instead of custom…
tylerjmchugh Jan 3, 2025
4a926d5
Improvements
tylerjmchugh Jan 6, 2025
ba4e77d
Add documentation
tylerjmchugh Jan 6, 2025
4aa0f76
Rename exception
tylerjmchugh Jan 6, 2025
54ed3cf
Remove unneeded changes
tylerjmchugh Jan 6, 2025
658cb47
Update docs
tylerjmchugh Jan 6, 2025
f2caf1c
Fix comment
tylerjmchugh Jan 7, 2025
7d70fbf
Update exception handling
tylerjmchugh Jan 9, 2025
4b6b35f
Update jcloud exception handling and comments
tylerjmchugh Jan 10, 2025
bd8670c
Add file header
tylerjmchugh Jan 13, 2025
6b3462e
Add comment
tylerjmchugh Jan 13, 2025
2a0be80
Fix whitespace
tylerjmchugh Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add comment
tylerjmchugh authored and github-actions[bot] committed Jan 14, 2025
commit 6b3462ea0237b0e338a4c46a3623e945035cbac3
Original file line number Diff line number Diff line change
@@ -163,6 +163,8 @@ public ApiError maxFileExceededHandler(final Exception exception, final HttpServ
((InputStreamLimitExceededException) exception).getRemoteFileSize() :
request.getContentLengthLong();

// This can occur if the content length header is present on a resource but does not reflect the actual file size.
// This could indicate an attempt to bypass the maximum upload size.
if (contentLength > 0 && contentLength < maxUploadSize) {
Log.warning(Geonet.RESOURCES, "Request content length is less than the maximum upload size but still caused an exception.");
}