feat: allow downloads only from trusted origins and with approved file types#40
Closed
feat: allow downloads only from trusted origins and with approved file types#40
Conversation
7daf573 to
07c0027
Compare
Author
|
@633kh4ck kindly review 🙏 |
633kh4ck
reviewed
Apr 10, 2025
src/WebViewShared.tsx
Outdated
| } | ||
|
|
||
| const matchingRule = downloadWhitelist.find(rule => { | ||
| const ruleOriginRegex = stringWhitelistToRegex(rule.origin); |
There was a problem hiding this comment.
I just took over this issue. What's the requirements here?
There was a problem hiding this comment.
There was a problem hiding this comment.
We can compare origins instead of doing the regexp 04a38c7
633kh4ck
reviewed
Apr 10, 2025
src/WebViewShared.tsx
Outdated
| const matchingRule = downloadWhitelist.find(rule => { | ||
| const ruleOriginRegex = stringWhitelistToRegex(rule.origin); | ||
|
|
||
| return ruleOriginRegex.test(origin) && rule.allowedFileExtensions.includes(fileExtension); |
There was a problem hiding this comment.
Subject to 'type confusion'-like issue 12. Type-check allowedFileExtensions:
const fileExtension = 'js'
const downloadWhitelist = [{
origin: 'https://example.com',
allowedFileExtensions: 'json'
}]
const result = downloadWhitelist.find(rule => {
return rule.allowedFileExtensions.includes(fileExtension)
})
!!result // oopsFootnotes
There was a problem hiding this comment.
Solved by forcing it to be always array a02e114
07c0027 to
c2ad41d
Compare
490514d to
a02e114
Compare
sergii-bo
approved these changes
Aug 13, 2025
sergii-bo
left a comment
There was a problem hiding this comment.
tACK
- Can download card statement if url is whitelisted
- Cannot download card statement if url is not whitelisted
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.
This adds origin-based validation to download requests, ensuring only requests from explicitly allowed origins and approved file types are processed. Enhances security by preventing unauthorised download triggers.
Closes #42