refactor: improve remote image resource handling#914
Open
psxjoy wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Introduces a configurable security policy for fetching remote images from URL cells, adding SSRF/redirect/size controls and corresponding unit tests.
Changes:
- Added
UrlImageFetchPolicyto define allowed schemes, private-network allowlists (hosts/CIDRs), redirect limits, and maximum image size. - Refactored
UrlImageConverterto enforce the policy (scheme/host validation, redirect handling, byte limit, and image-type validation). - Added
CidrBlockutility and a new JUnit test suite covering key policy behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| fesod-sheet/src/test/java/org/apache/fesod/sheet/converter/UrlImageConverterTest.java | Adds tests for scheme restrictions, private-host/CIDR allowlisting, redirect behavior, content-type rejection, and size limits. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/url/UrlImageFetchPolicy.java | Adds the policy model + builder with normalization/validation for hosts/schemes and limit settings. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/url/UrlImageConverter.java | Refactors URL image fetching to enforce policy checks, redirect limits, and maximum read size; validates image type. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/url/CidrBlock.java | Adds CIDR parsing and matching used for private-network allowlisting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
LGTM |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose of the pull request
What's changed?
Checklist