-
Notifications
You must be signed in to change notification settings - Fork 0
/
le.go
38 lines (29 loc) · 806 Bytes
/
le.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
// Copyright 2022 Juan Pablo Tosso and the OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0
//go:build !coraza.disabled_operators.le
package operators
import (
"strconv"
"github.com/nguyentin2068/waf/experimental/plugins/macro"
"github.com/nguyentin2068/waf/experimental/plugins/plugintypes"
)
type le struct {
data macro.Macro
}
var _ plugintypes.Operator = (*le)(nil)
func newLE(options plugintypes.OperatorOptions) (plugintypes.Operator, error) {
data := options.Arguments
m, err := macro.NewMacro(data)
if err != nil {
return nil, err
}
return &le{data: m}, nil
}
func (o *le) Evaluate(tx plugintypes.TransactionState, value string) bool {
d, _ := strconv.Atoi(o.data.Expand(tx))
v, _ := strconv.Atoi(value)
return v <= d
}
func init() {
Register("le", newLE)
}