github-advanced-security[bot] commented on code in PR #3860:
URL: https://github.com/apache/dubbo-go/pull/3860#discussion_r4656604083


##########
metrics/api.go:
##########
@@ -38,6 +38,55 @@
        DefaultTimeWindowSeconds = 120
 )
 
+// Window is the sliding window used by aggregate metrics: TimeWindowSeconds
+// split into BucketNum buckets.
+type Window struct {
+       BucketNum         int
+       TimeWindowSeconds int64
+}
+
+// DefaultWindow returns the window used when none is configured.
+func DefaultWindow() Window {
+       return Window{BucketNum: DefaultBucketNum, TimeWindowSeconds: 
DefaultTimeWindowSeconds}
+}
+
+// WindowOption sets the sliding window of an aggregate metric vector.
+type WindowOption func(*Window)
+
+// OrDefault returns w with each non-positive field replaced by the default,
+// and with BucketNum capped at TimeWindowSeconds so that each bucket covers at
+// least one second.
+func (w Window) OrDefault() Window {
+       if w.BucketNum <= 0 {
+               w.BucketNum = DefaultBucketNum
+       }
+       if w.TimeWindowSeconds <= 0 {
+               w.TimeWindowSeconds = DefaultTimeWindowSeconds
+       }
+       if int64(w.BucketNum) > w.TimeWindowSeconds {
+               w.BucketNum = int(w.TimeWindowSeconds)

Review Comment:
   ## CodeQL / Incorrect conversion between integer types
   
   Incorrect conversion of a signed 64-bit integer from [strconv.ParseInt](1) 
to a lower bit size type int without an upper bound check.
   
   [Show more 
details](https://github.com/apache/dubbo-go/security/code-scanning/81)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

  • [PR] fix(metr... AsperforMias (via GitHub) via notifications
    • Re: [PR]... sonarqubecloud[bot] (via GitHub) via notifications
    • Re: [PR]... github-advanced-security[bot] (via GitHub) via notifications
    • Re: [PR]... codecov-commenter (via GitHub) via notifications
    • Re: [PR]... sonarqubecloud[bot] (via GitHub) via notifications
    • Re: [PR]... sonarqubecloud[bot] (via GitHub) via notifications

Reply via email to