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.
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
refactor(torii-server): server proxy handlers #2708
refactor(torii-server): server proxy handlers #2708
Changes from all commits
aa3c5ac
ff49502
7d12dba
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Check warning on line 19 in crates/torii/server/src/handlers/graphql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/graphql.rs#L17-L19
Check warning on line 26 in crates/torii/server/src/handlers/graphql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/graphql.rs#L24-L26
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.
Handle Response builder error case, sensei!
The
unwrap()
call on the Response builder could panic. Consider usingunwrap_or_else
for safer error handling.📝 Committable suggestion
Check warning on line 45 in crates/torii/server/src/handlers/graphql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/graphql.rs#L28-L45
Check warning on line 19 in crates/torii/server/src/handlers/grpc.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/grpc.rs#L17-L19
Check warning on line 30 in crates/torii/server/src/handlers/grpc.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/grpc.rs#L24-L30
Check warning on line 48 in crates/torii/server/src/handlers/grpc.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/grpc.rs#L32-L48
Check warning on line 18 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L16-L18
Check warning on line 53 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L20-L53
Check warning on line 55 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L55
Check warning on line 59 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L57-L59
Check warning on line 67 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L61-L67
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.
Ohayo sensei! Handle serialization errors more gracefully
The current error handling exposes internal error details and uses
unwrap()
. This could leak sensitive information and potentially crash the server.Consider this safer approach:
📝 Committable suggestion
Check warning on line 75 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L71-L75
Check warning on line 80 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L77-L80
Check warning on line 82 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L82
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.
Ohayo sensei! Add query validation and sanitization
The
execute_query
method executes queries without validation or sanitization, which could lead to SQL injection or harmful operations.Consider:
Would you like assistance implementing these security measures?
Check warning on line 85 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L84-L85
Check warning on line 97 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L88-L97
Check warning on line 112 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L101-L112
Check warning on line 117 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L114-L117
Check warning on line 119 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L119
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.
🛠️ Refactor suggestion
Ohayo sensei! Add request size limits and improve error handling
The query extraction lacks request size limits and uses
unwrap()
in error paths.Consider these improvements:
unwrap()
withunwrap_or_else
:Check warning on line 126 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L124-L126
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.
🛠️ Refactor suggestion
Ohayo sensei! Enhance request validation
The
should_handle
method only checks the path prefix. Consider adding more validation:Check warning on line 133 in crates/torii/server/src/handlers/sql.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/sql.rs#L128-L133
Check warning on line 18 in crates/torii/server/src/handlers/static_files.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/static_files.rs#L16-L18
Check warning on line 25 in crates/torii/server/src/handlers/static_files.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/static_files.rs#L23-L25
Check warning on line 46 in crates/torii/server/src/handlers/static_files.rs
Codecov / codecov/patch
crates/torii/server/src/handlers/static_files.rs#L27-L46