-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Issue 1426 - Source validation on the claim form #1428
Open
lucaslobatob
wants to merge
9
commits into
stage
Choose a base branch
from
issue1426-InvalidSourceCreation
base: stage
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−18
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c22fb24
API: Added checkSource method to validate URLs before redirection by …
lucaslobatob 3cf4be9
Added checkSource method to validate URLs before redirection bymaking…
lucaslobatob 1ba2275
Created new route /api/source/check-source to handle URL validation a…
lucaslobatob d0b7ede
Updated ClaimSource ListItem component to call API for link verificat…
lucaslobatob 4211940
Created message feedback for user
lucaslobatob 8d1459e
Creating source validation on the claim form
lucaslobatob f7ee409
Implemented @UseGuards with AbilitiesGuard and @CheckAbilities with R…
lucaslobatob 2771679
Added the checkSource method that performs a GET request to validate …
lucaslobatob 5188f1d
Maintained the checkLink method that uses the Source Api.check Source…
lucaslobatob 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 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 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 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 |
---|---|---|
|
@@ -103,6 +103,23 @@ | |
); | ||
} | ||
|
||
@ApiTags("source") | ||
@Get("/check-source") | ||
async checkSpurce(@Query() query) { | ||
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. nitpick: typo |
||
try { | ||
const result = await fetch(query.source, { | ||
method: "GET", | ||
}); | ||
|
||
if (result.ok) { | ||
return { status: 200, message: "Link válido"}; | ||
} else { | ||
return { status: 404, message: "Link inválido"}; | ||
} | ||
} catch (error) { | ||
return { status: 500, message: "Erro interno ao verificar o link"}; | ||
} | ||
} | ||
|
||
@IsPublic() | ||
@ApiTags("source") | ||
@Get("api/source") | ||
|
This file contains 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 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 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
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.
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.
issue(blocking): now that I'm thinking, this is a DDOS vector and we should not continue. We can consider a few options like putting this behind RBAC for logged-in users.
But why aren't we just requesting from the client-side? Why we need to create a new endpoint for this?
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.
The endpoint was needed because of CORS restrictions, many sources block client-side requests. After, I can look with @lucaslobatob at some ways to make it more secure.
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.
I'm still not satisfied with the current solution, there are still too many vulnerabilities. Let's sync and create an epic documentation before proceeding.