-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lt.go
40 lines (30 loc) · 832 Bytes
/
lt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2022 Juan Pablo Tosso and the OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0
//go:build !coraza.disabled_operators.lt
package operators
import (
"strconv"
"github.com/appsentinels/coraza/v3/experimental/plugins/macro"
"github.com/appsentinels/coraza/v3/experimental/plugins/plugintypes"
)
type lt struct {
data macro.Macro
}
var _ plugintypes.Operator = (*lt)(nil)
func newLT(options plugintypes.OperatorOptions) (plugintypes.Operator, error) {
data := options.Arguments
m, err := macro.NewMacro(data)
if err != nil {
return nil, err
}
return <{data: m}, nil
}
func (o *lt) Evaluate(tx plugintypes.TransactionState, value string) bool {
vv := o.data.Expand(tx)
data, _ := strconv.Atoi(vv)
v, _ := strconv.Atoi(value)
return v < data
}
func init() {
Register("lt", newLT)
}