-
Notifications
You must be signed in to change notification settings - Fork 80
Fix Int cast flagged by copilot #416
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
Merged
Merged
Changes from all commits
Commits
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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.
this doesn't really make sense. iirc valid values for debug are like 0, 1, or 2 and valid values for timeout are... some reasonable number of seconds. would it make more sense to bounds check? i'm not sure limiting the range to int32 is doing much for us
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.
also negative numbers make no sense since this is... an enum and a number of seconds so if we're trying to make the parser validate the input why parse it as signed?
Uh oh!
There was an error while loading. Please reload this page.
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.
My take is, the report doesn't make sense in the first place: If we parse an in64 > INT32_MAX, we'll end up passing an invalid integer to pprof that will either ignore it or fail. The pprof API takes negative integers (and supposedly fails when given that input).
This is meant to quiet down automated reports with the lowest amount of work while not impacting functionality, security or maintainability.
The automated report is a compliance blocker impacting sales.
Alternatively, we may be able to close the report by explaining why we believe this is not an issue, but we should expect scrutiny doing that. Would you rather we go that route?
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 intent of the flag makes sense - we're missing input validation. it's fair to argue that the library does validation on its own and so this is wasted effort. but if we were compelled to add it it seemed like we might as well actually validate the input. if the goal is just checking a box idc
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.
Valid values for "debug" depend on the profiler used. What does maintaining validation logic for tool name -> valid debug values get us? I can buy that adding an upper limit for the timeout may somewhat mitigate some DOS attempts if anybody ever got access to the pprof endpoint. However, we'd need to make the limit at least 5 min and that's plenty of time to create about as many goroutines as you want.
This validation would however likely make most sense in https://github.com/livekit/protocol/blob/2504a42c8d96f69d22e49462e9b130222a9143b9/pprof/pprof.go#L35. So we would still need to deal with the casting check.
I can make all parameters to all these functions int64 instead, but this feels about as ridiculous.
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.
if parsing as int32 silences the warning let's ship it...