-
Notifications
You must be signed in to change notification settings - Fork 136
feat: init dynamic modules work #1564
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
base: main
Are you sure you want to change the base?
Conversation
58ae337 to
f6966e9
Compare
f6966e9 to
18a2b96
Compare
18a2b96 to
150c142
Compare
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
150c142 to
6ae4e4a
Compare
Signed-off-by: Takeshi Yoneda <[email protected]>
| e.SendLocalReply(500, nil, []byte(fmt.Sprintf("invalid router filter pointer: %v", err))) | ||
| return sdk.RequestHeadersStatusStopIteration | ||
| } | ||
| rf := (*routerFilter)(unsafe.Pointer(uintptr(rfPtr))) // nolint:govet |
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types High
strconv.ParseInt
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix this problem:
- Before converting the int64 value from
strconv.ParseIntinto auintptr, check that it's within the representable (non-negative, and <= math.MaxUintptr) range of typeuintptr. - The lower bound should ensure the parsed value isn't negative (
>= 0), since uintptr is unsigned. - The upper bound can use
math.MaxUintptrfrom themathpackage for the maximum allowed uintptr value. - If the check fails, send a local reply error and bail out as with other failure cases.
- Add an import for
"math"if it isn't already present in this snippet.
The edits are limited to the code shown in internal/dynamicmodule/upstream_filter.go, specifically in the block covering lines 64-138 (the RequestHeaders function), as well as potentially adding the required import.
-
Copy modified line R13 -
Copy modified lines R77-R80
| @@ -10,6 +10,7 @@ | ||
| "fmt" | ||
| "strconv" | ||
| "unsafe" | ||
| "math" | ||
|
|
||
| "github.com/envoyproxy/ai-gateway/internal/apischema/anthropic" | ||
| cohereschema "github.com/envoyproxy/ai-gateway/internal/apischema/cohere" | ||
| @@ -73,6 +74,10 @@ | ||
| e.SendLocalReply(500, nil, []byte(fmt.Sprintf("invalid router filter pointer: %v", err))) | ||
| return sdk.RequestHeadersStatusStopIteration | ||
| } | ||
| if rfPtr < 0 || uint64(rfPtr) > math.MaxUintptr { | ||
| e.SendLocalReply(500, nil, []byte(fmt.Sprintf("router filter pointer out of uintptr range: %v", rfPtr))) | ||
| return sdk.RequestHeadersStatusStopIteration | ||
| } | ||
| rf := (*routerFilter)(unsafe.Pointer(uintptr(rfPtr))) // nolint:govet | ||
| rf.attemptCount++ | ||
| onRetry := rf.attemptCount > 1 |
Description
wip -- aiming to pass all tests in tests/extproc, without control plane impl
Related Issues/PRs (if applicable)
#90