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

Commit b3b89ec

Browse files
author
Julio Guerra
committed
New Feature:
- (#137) RASP: add noSQL Injection protection support for the Go MongoDB driver `go.mongodb.org/mongo-driver/mongo`. This protection can be configured at <https://my.sqreen.com/application/goto/modules/rasp/details/nosql_injection>. Internal Changes: - (#138) Health-check the HTTPS connectivity to the new backend API `ingestion.sqreen.com` before using it. Fallback to the usual `back.sqreen.com` in case of a connection issue. Therefore, the agent can take up to 30 seconds to connect to Sqreen if the health-check timeouts. Please make sure to add this new firewall and proxy configurations. - (#136) Add support to attach multiple security protections per hook point. Fixes: - (#140) Fix the In-App WAF metadata PII scrubbing to also match substrings.
2 parents 4a71cf1 + 53e2d05 commit b3b89ec

33 files changed

+1532
-679
lines changed

CHANGELOG.md

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
# v0.12.1
1+
# v0.13.0 - 24 July 2020
2+
3+
## New Feature
4+
5+
- (#137) RASP: add noSQL Injection protection support for the Go MongoDB driver
6+
`go.mongodb.org/mongo-driver/mongo`. This protection can be configured at
7+
<https://my.sqreen.com/application/goto/modules/rasp/details/nosql_injection>.
8+
9+
## Internal Changes
10+
11+
- (#138) Health-check the HTTPS connectivity to the new backend API
12+
`ingestion.sqreen.com` before using it. Fallback to the usual
13+
`back.sqreen.com` in case of a connection issue. Therefore, the agent can take
14+
up to 30 seconds to connect to Sqreen if the health-check timeouts. Please
15+
make sure to add this new firewall and proxy configurations.
16+
17+
- (#136) Add support to attach multiple security protections per hook point.
18+
19+
## Fixes
20+
21+
- (#140) Fix the In-App WAF metadata PII scrubbing to also match substrings.
22+
23+
24+
# v0.12.1 - 13 July 2020
225

326
## Fixes
427

@@ -19,7 +42,7 @@
1942
- (eeb1dca) Avoid copying the metadata returned by the In-App WAF.
2043

2144

22-
# v0.12.0
45+
# v0.12.0 - 6 July 2020
2346

2447
## New Features
2548

@@ -53,7 +76,7 @@
5376
- (794d6e2) Allow port numbers in the `X-Forwarded-For` header.
5477

5578

56-
# v0.11.0
79+
# v0.11.0 - 19 June 2020
5780

5881
## New Features
5982

@@ -90,14 +113,14 @@
90113
- (#114) Add Goroutine Local Storage (GLS) support through static instrumentation of the Go runtime.
91114

92115

93-
# v0.10.1
116+
# v0.10.1 - 5 June 2020
94117

95118
## Fix
96119

97120
- (#116) Fix the instrumentation tool ignoring vendored packages, leading to
98121
missing hook points in the agent.
99122

100-
# v0.10.0
123+
# v0.10.0 - 20 May 2020
101124

102125
## New Features
103126

@@ -136,7 +159,7 @@
136159

137160
- Document PII scrubbing configuration at <https://docs.sqreen.com/go/configuration/#personally-identifiable-information-scrubbing>.
138161

139-
# v0.9.1
162+
# v0.9.1 - 31 March 2020
140163

141164
## Fixes
142165

@@ -150,7 +173,7 @@
150173
- (#101) Prevent starting the agent when the instrumentation tool and agent
151174
versions are not the same.
152175

153-
# v0.9.0
176+
# v0.9.0 - 19 February 2020
154177

155178
This new major version says farewell to the `beta` and adds SQL-injection
156179
run time protection thanks the first building blocks of [RASP][RASP-Wikipedia]
@@ -233,7 +256,7 @@ Because we now want a stable public API, find below the breaking changes:
233256
compiled as a Go module. This is also shown by the dashboard when the list
234257
of dependencies is empty.
235258

236-
# v0.1.0-beta.10
259+
# v0.1.0-beta.10 - 24 January 2020
237260

238261
## Breaking Change
239262

@@ -264,7 +287,7 @@ Because we now want a stable public API, find below the breaking changes:
264287
- (#92) Vendoring using `go mod vendor` could lead to compilation errors due to
265288
missing files.
266289

267-
# v0.1.0-beta.9
290+
# v0.1.0-beta.9 - 19 December 2019
268291

269292
## New Features
270293

@@ -283,7 +306,7 @@ Because we now want a stable public API, find below the breaking changes:
283306
- The In-App WAF has been intensively optimized so that large requests can no longer impact
284307
its execution time. (#83)
285308

286-
# v0.1.0-beta.8
309+
# v0.1.0-beta.8 - 15 October 2019
287310

288311
## Internal Changes
289312

@@ -292,7 +315,7 @@ Because we now want a stable public API, find below the breaking changes:
292315
- Ignore WAF timeout errors and add more context when reporting an error (#80).
293316
- Update the libsqreen to v0.4.0 to add support for the `@pm` operator.
294317

295-
# v0.1.0-beta.7
318+
# v0.1.0-beta.7 - 26 September 2019
296319

297320
## Breaking Changes
298321

@@ -319,7 +342,7 @@ Because we now want a stable public API, find below the breaking changes:
319342
- Fix a compilation error on 32-bit target architectures.
320343

321344

322-
# v0.1.0-beta.6
345+
# v0.1.0-beta.6 - 25 July 2019
323346

324347
## New Features
325348

@@ -354,7 +377,7 @@ Because we now want a stable public API, find below the breaking changes:
354377
log-level.
355378

356379

357-
# v0.1.0-beta.5
380+
# v0.1.0-beta.5 - 23 May 2019
358381

359382
## New Features
360383

@@ -380,7 +403,7 @@ Because we now want a stable public API, find below the breaking changes:
380403
processing loop.
381404

382405

383-
# v0.1.0-beta.4
406+
# v0.1.0-beta.4 - 16 April 2019
384407

385408
This release adds the ability to block IP addresses or users into your Go web
386409
services by adding support for [Security Automation] according to your
@@ -440,7 +463,7 @@ Note that redirecting users or IP addresses is not supported yet.
440463
- Avoid performing multiple times commands within the same command batch. (51)
441464

442465

443-
# v0.1.0-beta.3
466+
# v0.1.0-beta.3 - 22 March 2019
444467

445468
## New Features
446469

@@ -477,15 +500,15 @@ Note that redirecting users or IP addresses is not supported yet.
477500
self-managing the initializations. (#28)
478501

479502

480-
# v0.1.0-beta.2
503+
# v0.1.0-beta.2 - 14 February 2019
481504

482505
## New feature
483506

484507
- Add a new `Identify()` method allowing to explicitly associate a user to the
485508
current request. As soon as we add the support for the security reponses, it
486509
will allow to block users (#26).
487510

488-
# v0.1.0-beta.1
511+
# v0.1.0-beta.1 - 7 February 2019
489512

490513
This version is a new major version towards the v0.1.0 as it proposes a new and
491514
stable SDK API, that now will only be updated upon user feedback. So please,

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
[![GoDoc](https://godoc.org/github.com/sqreen/go-agent?status.svg)](https://godoc.org/github.com/sqreen/go-agent)
99
[![Go Report Card](https://goreportcard.com/badge/github.com/sqreen/go-agent)](https://goreportcard.com/report/github.com/sqreen/go-agent)
1010
[![Build Status](https://dev.azure.com/sqreenci/Go%20Agent/_apis/build/status/sqreen.go-agent?branchName=master)](https://dev.azure.com/sqreenci/Go%20Agent/_build/latest?definitionId=8&branchName=master)
11-
[![Sourcegraph](https://sourcegraph.com/github.com/sqreen/go-agent/-/badge.svg)](https://sourcegraph.com/github.com/sqreen/go-agent?badge)
1211

1312
After performance monitoring (APM), error and log monitoring it’s time to add a
1413
security component into your app. Sqreen’s microagent automatically monitors

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ require (
2929
github.com/spf13/pflag v1.0.5 // indirect
3030
github.com/spf13/viper v1.3.2
3131
github.com/sqreen/go-libsqreen v0.7.0
32-
github.com/sqreen/go-sdk/signal v1.0.0
33-
github.com/stretchr/testify v1.5.1
32+
github.com/sqreen/go-sdk/signal v1.1.0
33+
github.com/stretchr/testify v1.6.1
3434
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect
3535
golang.org/x/net v0.0.0-20200513185701-a91f0712d120
3636
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 // indirect
@@ -40,4 +40,5 @@ require (
4040
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
4141
gopkg.in/go-playground/assert.v1 v1.2.1
4242
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
43+
gopkg.in/yaml.v2 v2.3.0 // indirect
4344
)

go.sum

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
101101
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
102102
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=
104-
github.com/sqreen/go-libsqreen v0.6.1 h1:+SHH3h8qHhINEzgRVqTZ40YxqwDjSVxU5r4isUeg+C8=
105-
github.com/sqreen/go-libsqreen v0.6.1/go.mod h1:D324eoKlZGfW+TF3WGg+2fUtpdrI+cEK5UYwpxfaeUc=
106104
github.com/sqreen/go-libsqreen v0.7.0 h1:MRX/KB5lX3O6ucvmTUap6iSDt27bM+76MQpuDNjL+1o=
107105
github.com/sqreen/go-libsqreen v0.7.0/go.mod h1:D324eoKlZGfW+TF3WGg+2fUtpdrI+cEK5UYwpxfaeUc=
108-
github.com/sqreen/go-sdk/signal v1.0.0 h1:WNjufvcjKYOgSZHPCwqG0Od5eVAD8wxwmiIe6ZCqoNE=
109-
github.com/sqreen/go-sdk/signal v1.0.0/go.mod h1:UksuO4mxxDMFw3el+R9mW9tmCgdc94WiDcGuCXU/pwU=
106+
github.com/sqreen/go-sdk/signal v1.1.0 h1:l22lqlUNDlEaqsNjpgVelGteBCwGodZqUDPUMBOLzhE=
107+
github.com/sqreen/go-sdk/signal v1.1.0/go.mod h1:XWJV0TzuoN6PotzRn4YSe6fhTxyw67yRpVYr9NJTzto=
110108
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
111109
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
112110
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
@@ -115,8 +113,8 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
115113
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
116114
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
117115
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
118-
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
119-
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
116+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
117+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
120118
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 h1:3SVOIvH7Ae1KRYyQWRjXWJEA9sS/c/pjvH++55Gr648=
121119
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
122120
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
@@ -190,3 +188,6 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
190188
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
191189
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
192190
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
191+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
192+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
193+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/adapter.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,15 @@ func newMetricsAPIAdapter(logger plog.ErrorLogger, expiredMetrics map[string]*me
334334
return metricsArray
335335
}
336336

337+
type variousInfoAPIAdapter struct {
338+
*appInfoAPIAdapter
339+
sqreenDomains api.SqreenDomainStatusMap
340+
}
341+
342+
func (v variousInfoAPIAdapter) GetSqreenDomains() api.SqreenDomainStatusMap {
343+
return v.sqreenDomains
344+
}
345+
337346
type appInfoAPIAdapter app.Info
338347

339348
func (a *appInfoAPIAdapter) unwrap() *app.Info { return (*app.Info)(a) }

internal/agent.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ func New(cfg *config.Config) *AgentType {
228228
logger.Info(message)
229229
return nil
230230
}
231-
// TODO: agent.Health() + waf.Health()
231+
232232
if waf.Version() == nil {
233-
message := fmt.Sprintf("in-app waf disabled: cgo was disabled during the program compilation while required by the in-app waf")
233+
message := "in-app waf disabled: cgo was disabled during the program compilation while required by the in-app waf"
234234
backend.SendAgentMessage(logger, cfg, message)
235235
logger.Info("agent: ", message)
236236
}
@@ -240,9 +240,11 @@ func New(cfg *config.Config) *AgentType {
240240
sdkMetricsPeriod := time.Duration(cfg.SDKMetricsPeriod()) * time.Second
241241
logger.Debugf("agent: using sdk metrics store time period of %s", sdkMetricsPeriod)
242242

243-
piiScrubber, err := sqsanitize.NewScrubber(cfg.StripSensitiveKeyRegexp(), cfg.StripSensitiveValueRegexp(), config.ScrubberRedactedString)
243+
piiScrubber := sqsanitize.NewScrubber(cfg.StripSensitiveKeyRegexp(), cfg.StripSensitiveValueRegexp(), config.ScrubberRedactedString)
244+
245+
client, err := backend.NewClient(cfg.BackendHTTPAPIBaseURL(), cfg.BackendHTTPAPIProxy(), logger)
244246
if err != nil {
245-
logger.Error(sqerrors.Wrap(err, "ecdsa public key"))
247+
logger.Error(sqerrors.Wrap(err, "agent: could not create the backend client"))
246248
return nil
247249
}
248250

@@ -264,7 +266,7 @@ func New(cfg *config.Config) *AgentType {
264266
cancel: cancel,
265267
config: cfg,
266268
appInfo: app.NewInfo(logger),
267-
client: backend.NewClient(cfg.BackendHTTPAPIBaseURL(), cfg.BackendHTTPAPIProxy(), logger),
269+
client: client,
268270
actors: actor.NewStore(logger),
269271
rules: rulesEngine,
270272
piiScrubber: piiScrubber,
@@ -341,7 +343,7 @@ func (a *AgentType) Serve() error {
341343

342344
token := a.config.BackendHTTPAPIToken()
343345
appName := a.config.AppName()
344-
appLoginRes, err := appLogin(a.ctx, a.logger, a.client, token, appName, a.appInfo, a.config.UseSignalBackend())
346+
appLoginRes, err := appLogin(a.ctx, a.logger, a.client, token, appName, a.appInfo, a.config.DisableSignalBackend())
345347
if err != nil {
346348
if xerrors.Is(err, context.Canceled) {
347349
a.logger.Debug(err)
@@ -586,11 +588,14 @@ func stopTimer(t *time.Timer) {
586588

587589
func (m *eventManager) Loop(ctx context.Context, client *backend.Client) {
588590
var (
589-
stalenessTimer = time.NewTimer(m.maxStaleness)
591+
// We can't create a stopped timer so we initializae it with a large value
592+
// of 24 hours and stop it immediately. Calls to Reset() will correctly
593+
// set the configured timer value.
594+
stalenessTimer = time.NewTimer(24 * time.Hour)
590595
stalenessChan <-chan time.Time
591596
)
592-
defer stopTimer(stalenessTimer)
593597
stopTimer(stalenessTimer)
598+
defer stopTimer(stalenessTimer)
594599

595600
batch := make([]Event, 0, m.count)
596601
for {
@@ -647,7 +652,7 @@ func (m *eventManager) sendBatch(ctx context.Context, client *backend.Client, ba
647652
if _, err := m.agent.piiScrubber.Scrub(event, nil); err != nil {
648653
// Only log this unexpected error and keep the event that may have been
649654
// partially scrubbed.
650-
m.agent.logger.Error(errors.Wrap(err, "could not send the event batch"))
655+
m.agent.logger.Error(errors.Wrap(err, "could not scrub the event"))
651656
}
652657
req.Batch = append(req.Batch, *api.NewBatchRequest_EventFromFace(event))
653658
}

0 commit comments

Comments
 (0)