Skip to content

Commit 3cc4dfa

Browse files
committed
fix: value setting
1 parent 0a6cd42 commit 3cc4dfa

File tree

9 files changed

+15
-19
lines changed

9 files changed

+15
-19
lines changed

examples/http-server/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/tidwall/match v1.1.1 // indirect
1414
github.com/tidwall/pretty v1.2.1 // indirect
1515
github.com/valllabh/ocsf-schema-golang v1.0.3 // indirect
16-
golang.org/x/net v0.50.0 // indirect
16+
golang.org/x/net v0.51.0 // indirect
1717
golang.org/x/sync v0.19.0 // indirect
1818
golang.org/x/tools v0.41.0 // indirect
1919
google.golang.org/protobuf v1.35.1 // indirect

examples/http-server/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ github.com/valllabh/ocsf-schema-golang v1.0.3 h1:eR8k/3jP/OOqB8LRCtdJ4U+vlgd/gk5
2727
github.com/valllabh/ocsf-schema-golang v1.0.3/go.mod h1:sZ3as9xqm1SSK5feFWIR2CuGeGRhsM7TR1MbpBctzPk=
2828
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
2929
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
30-
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
31-
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
30+
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
31+
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
3232
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
3333
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
3434
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
6767
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
6868
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
6969
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
70-
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
71-
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
7270
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
7371
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
7472
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

internal/bodyprocessors/json.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func (js *jsonBodyProcessor) ProcessRequest(reader io.Reader, v plugintypes.Tran
2727
return err
2828
}
2929
ss := s.String()
30-
3130
// Process with recursion limit
3231
col := v.ArgsPost()
3332
data, err := readJSON(ss, bpo.RequestBodyRecursionLimit)
@@ -48,17 +47,18 @@ func (js *jsonBodyProcessor) ProcessRequest(reader io.Reader, v plugintypes.Tran
4847
return nil
4948
}
5049

51-
func (js *jsonBodyProcessor) ProcessResponse(reader io.Reader, v plugintypes.TransactionVariables, bpo plugintypes.BodyProcessorOptions) error {
50+
const ignoreJSONRecursionLimit = -1
51+
52+
func (js *jsonBodyProcessor) ProcessResponse(reader io.Reader, v plugintypes.TransactionVariables, _ plugintypes.BodyProcessorOptions) error {
5253
// Read the entire body to store it and process it
5354
s := strings.Builder{}
5455
if _, err := io.Copy(&s, reader); err != nil {
5556
return err
5657
}
5758
ss := s.String()
58-
59-
// Process with recursion limit
59+
// Process with no recursion limit as we don't have a directive for response body
6060
col := v.ResponseArgs()
61-
data, err := readJSON(ss, bpo.RequestBodyRecursionLimit)
61+
data, err := readJSON(ss, ignoreJSONRecursionLimit)
6262
if err != nil {
6363
return err
6464
}

internal/corazawaf/transaction.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ type Transaction struct {
7171
ForceRequestBodyVariable bool
7272
RequestBodyAccess bool
7373
RequestBodyLimit int64
74-
RequestBodyJsonDepthLimit int
7574
ForceResponseBodyVariable bool
7675
ResponseBodyAccess bool
7776
ResponseBodyLimit int64

internal/corazawaf/waf.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ func (w *WAF) newTransaction(opts Options) *Transaction {
190190
tx.ForceRequestBodyVariable = false
191191
tx.RequestBodyAccess = w.RequestBodyAccess
192192
tx.RequestBodyLimit = w.RequestBodyLimit
193-
tx.RequestBodyJsonDepthLimit = w.RequestBodyJsonDepthLimit
194193
tx.ResponseBodyAccess = w.ResponseBodyAccess
195194
tx.ResponseBodyLimit = w.ResponseBodyLimit
196195
tx.RuleEngine = w.RuleEngine

internal/seclang/directives.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ func directiveSecRequestBodyJsonDepthLimit(options *DirectiveOptions) error {
297297
if err != nil {
298298
return err
299299
}
300+
301+
if limit <= 0 {
302+
return errors.New("limit must be a positive integer")
303+
}
304+
300305
options.WAF.RequestBodyJsonDepthLimit = limit
301306
return nil
302307
}

testing/coraza_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ func TestEngine(t *testing.T) {
2424
t.Run(p.Meta.Name, func(t *testing.T) {
2525
tt, err := testList(t, &p)
2626
if err != nil {
27-
t.Error(err)
27+
t.Fatal(err)
2828
}
29+
2930
for _, test := range tt {
3031
t.Run(test.Name, func(t *testing.T) {
3132
if err := test.RunPhases(); err != nil {

testing/coreruleset/go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/
88
github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
99
github.com/corazawaf/coraza-coreruleset v0.0.0-20240226094324-415b1017abdc h1:OlJhrgI3I+FLUCTI3JJW8MoqyM78WbqJjecqMnqG+wc=
1010
github.com/corazawaf/coraza-coreruleset v0.0.0-20240226094324-415b1017abdc/go.mod h1:7rsocqNDkTCira5T0M7buoKR2ehh7YZiPkzxRuAgvVU=
11-
github.com/corazawaf/coraza-coreruleset/v4 v4.22.0 h1:rQhJ1+2+TZsoVBXlRWn+AVteECot3pIF8tSVDjjhkUc=
12-
github.com/corazawaf/coraza-coreruleset/v4 v4.22.0/go.mod h1:tRjsdtj39+at47dLCpE8ChoDa2FK2IAwTWIpDT8Z62g=
13-
github.com/corazawaf/coraza-coreruleset/v4 v4.23.0 h1:e7f2tRhOBFN8YtL72wqy2cMPS6o64XyMgS81dRbw2/c=
14-
github.com/corazawaf/coraza-coreruleset/v4 v4.23.0/go.mod h1:tRjsdtj39+at47dLCpE8ChoDa2FK2IAwTWIpDT8Z62g=
1511
github.com/corazawaf/coraza-coreruleset/v4 v4.24.0 h1:7Ys2vZegaDIwDeDcRuCQNjMzNaDLklqXogJsucoE1tk=
1612
github.com/corazawaf/coraza-coreruleset/v4 v4.24.0/go.mod h1:tRjsdtj39+at47dLCpE8ChoDa2FK2IAwTWIpDT8Z62g=
1713
github.com/corazawaf/libinjection-go v0.3.2 h1:9rrKt0lpg4WvUXt+lwS06GywfqRXXsa/7JcOw5cQLwI=
@@ -119,8 +115,6 @@ golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
119115
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
120116
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
121117
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
122-
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
123-
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
124118
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
125119
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
126120
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=

0 commit comments

Comments
 (0)