Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit 4a71cf1

Browse files
author
Julio Guerra
committed
v0.12.1
Fixes: - (d81222d) Add missing request parameters when both JSON values and form values were present - only the form values were taken into account. - (ee22b77) Upgrade to libsqreen v0.7.0: - Fix false positives in libinjection SQL heuristics. - Fix a false positive in libinjection XSS heuristics. - Add support for boolean values. - Add support for float values. - Fix memory deallocator of scalar values. - (c425760) Fix data bindings with null values. Internal Changes: - (eeb1dca) Avoid copying the metadata returned by the In-App WAF.
2 parents 231d66f + e1e5230 commit 4a71cf1

File tree

11 files changed

+64
-12
lines changed

11 files changed

+64
-12
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# v0.12.1
2+
3+
## Fixes
4+
5+
- (d81222d) Add missing request parameters when both JSON values and form values
6+
were present - only the form values were taken into account.
7+
8+
- (ee22b77) Upgrade to libsqreen v0.7.0:
9+
- Fix false positives in libinjection SQL heuristics.
10+
- Fix a false positive in libinjection XSS heuristics.
11+
- Add support for boolean values.
12+
- Add support for float values.
13+
- Fix memory deallocator of scalar values.
14+
15+
- (c425760) Fix data bindings with null values.
16+
17+
## Internal Changes
18+
19+
- (eeb1dca) Avoid copying the metadata returned by the In-App WAF.
20+
21+
122
# v0.12.0
223

324
## New Features

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/spf13/cast v1.3.1 // indirect
2929
github.com/spf13/pflag v1.0.5 // indirect
3030
github.com/spf13/viper v1.3.2
31-
github.com/sqreen/go-libsqreen v0.6.1
31+
github.com/sqreen/go-libsqreen v0.7.0
3232
github.com/sqreen/go-sdk/signal v1.0.0
3333
github.com/stretchr/testify v1.5.1
3434
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
103103
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
104104
github.com/sqreen/go-libsqreen v0.6.1 h1:+SHH3h8qHhINEzgRVqTZ40YxqwDjSVxU5r4isUeg+C8=
105105
github.com/sqreen/go-libsqreen v0.6.1/go.mod h1:D324eoKlZGfW+TF3WGg+2fUtpdrI+cEK5UYwpxfaeUc=
106+
github.com/sqreen/go-libsqreen v0.7.0 h1:MRX/KB5lX3O6ucvmTUap6iSDt27bM+76MQpuDNjL+1o=
107+
github.com/sqreen/go-libsqreen v0.7.0/go.mod h1:D324eoKlZGfW+TF3WGg+2fUtpdrI+cEK5UYwpxfaeUc=
106108
github.com/sqreen/go-sdk/signal v1.0.0 h1:WNjufvcjKYOgSZHPCwqG0Od5eVAD8wxwmiIe6ZCqoNE=
107109
github.com/sqreen/go-sdk/signal v1.0.0/go.mod h1:UksuO4mxxDMFw3el+R9mW9tmCgdc94WiDcGuCXU/pwU=
108110
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

internal/backend/api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ type RequestRecord_Observed_Attack struct {
400400
}
401401

402402
type WAFAttackInfo struct {
403-
WAFData string `json:"waf_data"`
403+
WAFData json.RawMessage `json:"waf_data"`
404404
}
405405

406406
type WAFInfoFilter struct {
@@ -456,7 +456,7 @@ func (i *WAFAttackInfo) Scrub(scrubber *sqsanitize.Scrubber, info sqsanitize.Inf
456456
if err != nil {
457457
return false, err
458458
}
459-
i.WAFData = string(buf)
459+
i.WAFData = buf
460460
return scrubbed, nil
461461
}
462462

internal/backend/api/json_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestCustomScrubber(t *testing.T) {
162162
}
163163
buf, err := json.Marshal(&winfo)
164164
require.NoError(t, err)
165-
winfoJSONStr := string(buf)
165+
winfoJSON := buf
166166

167167
rr := &api.RequestRecord{
168168
Request: api.RequestRecord_Request{
@@ -176,7 +176,7 @@ func TestCustomScrubber(t *testing.T) {
176176
Observed: api.RequestRecord_Observed{
177177
Attacks: []*api.RequestRecord_Observed_Attack{
178178
{
179-
Info: api.WAFAttackInfo{WAFData: winfoJSONStr},
179+
Info: api.WAFAttackInfo{WAFData: winfoJSON},
180180
},
181181
},
182182
},

internal/binding-accessor/binding-accessor_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,17 @@ func TestBindingAccessor(t *testing.T) {
286286
},
287287
ExpectedValue: "Sqreen",
288288
},
289+
{
290+
Title: "flat values transformation",
291+
Expression: "# | flat_values",
292+
Context: []interface{}{
293+
map[string]interface{}{
294+
"k1": "hello",
295+
},
296+
nil,
297+
},
298+
ExpectedValue: FlattenedResult{"hello"},
299+
},
289300
{
290301
Title: "flat values transformation",
291302
Expression: "# | flat_values",
@@ -336,6 +347,18 @@ func TestBindingAccessor(t *testing.T) {
336347
},
337348
ExpectedValue: FlattenedResult{"A", "B", "C", "D", "E", "One", 2, "Three"},
338349
},
350+
{
351+
Title: "flat keys transformation",
352+
Expression: "# | flat_keys",
353+
Context: []interface{}{
354+
map[*string]interface{}{
355+
new(string): "hello",
356+
nil: "hello nil",
357+
},
358+
nil,
359+
},
360+
ExpectedValue: FlattenedResult{new(string), (*string)(nil)},
361+
},
339362
{
340363
Title: "field value transformation",
341364
Expression: "#.B | flat_values",

internal/binding-accessor/exec.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ func flatValues(v reflect.Value, depth int, elements *int) (values []interface{}
208208
return flatValues(v.Elem(), depth, elements)
209209

210210
default:
211+
if !v.IsValid() || !v.CanInterface() {
212+
break
213+
}
211214
*elements -= 1
212215
values = []interface{}{v.Interface()}
213216
}

internal/protection/http/bindingaccessor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (r *RequestBindingAccessorContext) FilteredParams() RequestParamMap {
6565
return params
6666
}
6767

68-
res := make(types.RequestParamMap, len(form)+len(params))
68+
res := make(types.RequestParamMap, 1+len(params))
6969
res.Add("Form", form)
7070
for k, v := range params {
7171
res.Add(k, v)

internal/protection/http/http.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,19 @@ func (r *requestReader) Params() types.RequestParamMap {
9393
params := r.RequestReader.Params()
9494
if len(params) == 0 {
9595
return r.requestParams
96-
} else if len(r.requestParams) == 0 {
96+
}
97+
98+
if len(r.requestParams) == 0 {
9799
return params
98100
}
99101

100102
res := make(types.RequestParamMap, len(params)+len(r.requestParams))
101103
for n, v := range params {
102104
res[n] = v
103105
}
106+
for n, v := range r.requestParams {
107+
res[n] = v
108+
}
104109
return res
105110
}
106111

internal/rule/callback/waf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func runWAF(ctx *httpprotection.RequestContext, bindingAccessors map[string]bind
140140
return false, nil
141141
}
142142

143-
attackInfo := api.WAFAttackInfo{WAFData: string(info)}
143+
attackInfo := api.WAFAttackInfo{WAFData: info}
144144
blocked = false
145145

146146
if blockingMode && action == waftypes.BlockAction {

0 commit comments

Comments
 (0)