Skip to content

Commit

Permalink
bug: fix integer type conversion (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
dduzgun-security authored Aug 7, 2024
1 parent 41718d4 commit c541171
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
IMPROVEMENTS:
* build: Updated to Go 1.22.6 and alpine to 3.20 [[GH-943](https://github.com/hashicorp/nomad-autoscaler/pull/943)]

BUG FIXES:
* security: Fix incorrect conversion between integer types [[GH-946](https://github.com/hashicorp/nomad-autoscaler/pull/946)]

## 0.4.4 (June 4, 2024)

IMPROVEMENTS:
Expand Down
6 changes: 3 additions & 3 deletions policy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,16 @@ func (h *Handler) handleTick(ctx context.Context, policy *sdk.ScalingPolicy) (*s
// Convert the last event string. If an error occurs, just log and
// continue with the evaluation. A malformed timestamp shouldn't mean
// we skip scaling.
lastTS, err := strconv.ParseUint(ts, 10, 64)
lastTS, err := strconv.ParseInt(ts, 10, 64)
if err != nil {
h.log.Error("failed to parse last event timestamp as uint64", "error", err)
h.log.Error("failed to parse last event timestamp as int64", "error", err)
return eval, nil
}

// Calculate the remaining time period left on the cooldown. If this is
// cooldownIgnoreTime or below, we do not need to enter cooldown. Reasoning
// on ignoring small variations can be seen within GH-138.
cdPeriod := h.calculateRemainingCooldown(policy.Cooldown, curTime, int64(lastTS))
cdPeriod := h.calculateRemainingCooldown(policy.Cooldown, curTime, lastTS)
if cdPeriod <= cooldownIgnoreTime {
return eval, nil
}
Expand Down

0 comments on commit c541171

Please sign in to comment.