mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-04 14:12:14 -04:00
PromQL duration expr: Add a check for durations our of range
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This commit is contained in:
parent
7370d62acf
commit
9cfd6f7df8
2 changed files with 20 additions and 0 deletions
|
|
@ -1115,6 +1115,11 @@ func (p *parser) evalDurationExprBinOp(lhs, rhs Node, op Item) *NumberLiteral {
|
|||
return &NumberLiteral{Val: 0}
|
||||
}
|
||||
|
||||
if val > 1<<63/1e9 || val < -(1<<63)/1e9 {
|
||||
p.addParseErrf(op.PositionRange(), "duration out of range")
|
||||
return &NumberLiteral{Val: 0}
|
||||
}
|
||||
|
||||
return &NumberLiteral{
|
||||
Val: val,
|
||||
PosRange: posrange.PositionRange{
|
||||
|
|
|
|||
|
|
@ -4060,6 +4060,21 @@ var testExpr = []struct {
|
|||
fail: true,
|
||||
errMsg: `modulo by zero`,
|
||||
},
|
||||
{
|
||||
input: `foo[150y+150y]`,
|
||||
fail: true,
|
||||
errMsg: `duration out of range`,
|
||||
},
|
||||
{
|
||||
input: `foo offset (150y+150y)`,
|
||||
fail: true,
|
||||
errMsg: `duration out of range`,
|
||||
},
|
||||
{
|
||||
input: `foo offset (-2*150y)`,
|
||||
fail: true,
|
||||
errMsg: `duration out of range`,
|
||||
},
|
||||
}
|
||||
|
||||
func makeInt64Pointer(val int64) *int64 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue