Skip to content

Commit b0f5245

Browse files
authored
Dependencies update (#4412)
- Update to go 1.26 - Update all dependancies (expect Gin) - Replace all `ptr.Of()` usage by `new()`
1 parent 7b295be commit b0f5245

98 files changed

Lines changed: 6564 additions & 6600 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ stages:
2121
- task: GoTool@0
2222
displayName: "Install Go"
2323
inputs:
24-
version: '1.25.1'
24+
version: '1.26.1'
2525

2626
- pwsh: |
2727
choco install -y make

build/docker/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/golang:1.25-alpine3.21 AS build
1+
FROM docker.io/golang:1.26-alpine3.23 AS build
22

33
ARG BUILD_VERSION
44

@@ -28,11 +28,11 @@ RUN make clean release DOCKER_BUILD=1 BUILD_STATIC=1 CGO_CFLAGS="-D_LARGEFILE64_
2828
cscli parsers install crowdsecurity/whitelists && \
2929
echo '{"source": "file", "filename": "/does/not/exist", "labels": {"type": "syslog"}}' > /etc/crowdsec/acquis.yaml
3030

31-
# we create a useless acquis.yaml, which will be overridden by a mounted volume
32-
# in most cases, but is still required for the container to start during tests
31+
# we create a useless acquis.yaml, which will be overridden by a mounted volume
32+
# in most cases, but is still required for the container to start during tests
3333

34-
# In case we need to remove agents here..
35-
# cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete
34+
# In case we need to remove agents here..
35+
# cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete
3636

3737
FROM docker.io/alpine:3.21 AS slim
3838

build/docker/Dockerfile.debian

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/golang:1.25-bookworm AS build
1+
FROM docker.io/golang:1.26-trixie AS build
22

33
ARG BUILD_VERSION
44

@@ -33,12 +33,12 @@ RUN make clean release DOCKER_BUILD=1 BUILD_STATIC=1 && \
3333
cscli parsers install crowdsecurity/whitelists && \
3434
echo '{"source": "file", "filename": "/does/not/exist", "labels": {"type": "syslog"}}' > /etc/crowdsec/acquis.yaml
3535

36-
# we create a useless acquis.yaml, which will be overridden by a mounted volume
37-
# in most cases, but is still required for the container to start during tests
36+
# we create a useless acquis.yaml, which will be overridden by a mounted volume
37+
# in most cases, but is still required for the container to start during tests
3838

3939

40-
# In case we need to remove agents here..
41-
# cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete
40+
# In case we need to remove agents here..
41+
# cscli machines list -o json | yq '.[].machineId' | xargs -r cscli machines delete
4242

4343
FROM docker.io/debian:bookworm-slim AS slim
4444

cmd/crowdsec-cli/cliconsole/console.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/spf13/cobra"
2020
"gopkg.in/yaml.v3"
2121

22-
"github.com/crowdsecurity/go-cs-lib/ptr"
2322
"github.com/crowdsecurity/go-cs-lib/slicetools"
2423

2524
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/core/args"
@@ -399,7 +398,7 @@ func (cli *cliConsole) setConsoleOpts(args []string, wanted bool) error {
399398
log.Debugf("%s already set to %t", csconfig.CONSOLE_MANAGEMENT, wanted)
400399
} else {
401400
log.Infof("%s set to %t", csconfig.CONSOLE_MANAGEMENT, wanted)
402-
consoleCfg.ConsoleManagement = ptr.Of(wanted)
401+
consoleCfg.ConsoleManagement = new(wanted)
403402
}
404403

405404
if cfg.API.Server.OnlineClient.Credentials != nil {
@@ -432,31 +431,31 @@ func (cli *cliConsole) setConsoleOpts(args []string, wanted bool) error {
432431
log.Debugf("%s already set to %t", csconfig.SEND_CUSTOM_SCENARIOS, wanted)
433432
} else {
434433
log.Infof("%s set to %t", csconfig.SEND_CUSTOM_SCENARIOS, wanted)
435-
consoleCfg.ShareCustomScenarios = ptr.Of(wanted)
434+
consoleCfg.ShareCustomScenarios = new(wanted)
436435
}
437436
case csconfig.SEND_TAINTED_SCENARIOS:
438437
// for each flag check if it's already set before setting it
439438
if consoleCfg.ShareTaintedScenarios != nil && *consoleCfg.ShareTaintedScenarios == wanted {
440439
log.Debugf("%s already set to %t", csconfig.SEND_TAINTED_SCENARIOS, wanted)
441440
} else {
442441
log.Infof("%s set to %t", csconfig.SEND_TAINTED_SCENARIOS, wanted)
443-
consoleCfg.ShareTaintedScenarios = ptr.Of(wanted)
442+
consoleCfg.ShareTaintedScenarios = new(wanted)
444443
}
445444
case csconfig.SEND_MANUAL_SCENARIOS:
446445
// for each flag check if it's already set before setting it
447446
if consoleCfg.ShareManualDecisions != nil && *consoleCfg.ShareManualDecisions == wanted {
448447
log.Debugf("%s already set to %t", csconfig.SEND_MANUAL_SCENARIOS, wanted)
449448
} else {
450449
log.Infof("%s set to %t", csconfig.SEND_MANUAL_SCENARIOS, wanted)
451-
consoleCfg.ShareManualDecisions = ptr.Of(wanted)
450+
consoleCfg.ShareManualDecisions = new(wanted)
452451
}
453452
case csconfig.SEND_CONTEXT:
454453
// for each flag check if it's already set before setting it
455454
if consoleCfg.ShareContext != nil && *consoleCfg.ShareContext == wanted {
456455
log.Debugf("%s already set to %t", csconfig.SEND_CONTEXT, wanted)
457456
} else {
458457
log.Infof("%s set to %t", csconfig.SEND_CONTEXT, wanted)
459-
consoleCfg.ShareContext = ptr.Of(wanted)
458+
consoleCfg.ShareContext = new(wanted)
460459
}
461460
default:
462461
return fmt.Errorf("unknown flag %s", arg)

cmd/crowdsec-cli/clidecision/import.go

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
log "github.com/sirupsen/logrus"
1919
"github.com/spf13/cobra"
2020

21-
"github.com/crowdsecurity/go-cs-lib/ptr"
22-
2321
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/core/args"
2422
"github.com/crowdsecurity/crowdsec/pkg/models"
2523
"github.com/crowdsecurity/crowdsec/pkg/types"
@@ -171,13 +169,13 @@ func (cli *cliDecisions) import_(ctx context.Context, input string, duration str
171169
}
172170

173171
decisions[i] = &models.Decision{
174-
Value: ptr.Of(d.Value),
175-
Duration: ptr.Of(d.Duration),
176-
Origin: ptr.Of(types.CscliImportOrigin),
177-
Scenario: ptr.Of(d.Scenario),
178-
Type: ptr.Of(d.Type),
179-
Scope: ptr.Of(d.Scope),
180-
Simulated: ptr.Of(false),
172+
Value: new(d.Value),
173+
Duration: new(d.Duration),
174+
Origin: new(types.CscliImportOrigin),
175+
Scenario: new(d.Scenario),
176+
Type: new(d.Type),
177+
Scope: new(d.Scope),
178+
Simulated: new(false),
181179
}
182180
}
183181

@@ -227,22 +225,22 @@ func (cli *cliDecisions) import_(ctx context.Context, input string, duration str
227225
for chunk := range slices.Chunk(actualDecisions, batch) {
228226
importAlert := models.Alert{
229227
CreatedAt: time.Now().UTC().Format(time.RFC3339),
230-
Scenario: ptr.Of(fmt.Sprintf("import %s: %d IPs", input, len(chunk))),
228+
Scenario: new(fmt.Sprintf("import %s: %d IPs", input, len(chunk))),
231229

232-
Message: ptr.Of(""),
230+
Message: new(""),
233231
Events: []*models.Event{},
234232
Source: &models.Source{
235-
Scope: ptr.Of(""),
236-
Value: ptr.Of(""),
233+
Scope: new(""),
234+
Value: new(""),
237235
},
238-
StartAt: ptr.Of(time.Now().UTC().Format(time.RFC3339)),
239-
StopAt: ptr.Of(time.Now().UTC().Format(time.RFC3339)),
240-
Capacity: ptr.Of(int32(0)),
241-
Simulated: ptr.Of(false),
242-
EventsCount: ptr.Of(int32(len(chunk))),
243-
Leakspeed: ptr.Of(""),
244-
ScenarioHash: ptr.Of(""),
245-
ScenarioVersion: ptr.Of(""),
236+
StartAt: new(time.Now().UTC().Format(time.RFC3339)),
237+
StopAt: new(time.Now().UTC().Format(time.RFC3339)),
238+
Capacity: new(int32(0)),
239+
Simulated: new(false),
240+
EventsCount: new(int32(len(chunk))),
241+
Leakspeed: new(""),
242+
ScenarioHash: new(""),
243+
ScenarioVersion: new(""),
246244
Decisions: chunk,
247245
Kind: types.CscliAlertKind.String(),
248246
}

cmd/crowdsec-cli/clinotifications/notifications.go

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
"gopkg.in/tomb.v2"
2323
"gopkg.in/yaml.v3"
2424

25-
"github.com/crowdsecurity/go-cs-lib/ptr"
26-
2725
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/core/args"
2826
"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/core/require"
2927
"github.com/crowdsecurity/crowdsec/pkg/apiclient"
@@ -321,34 +319,34 @@ func (cli *cliNotifications) newTestCmd() *cobra.Command {
321319
return nil
322320
})
323321
alert := &models.Alert{
324-
Capacity: ptr.Of(int32(0)),
322+
Capacity: new(int32(0)),
325323
Decisions: []*models.Decision{{
326-
Duration: ptr.Of("4h"),
327-
Scope: ptr.Of("Ip"),
328-
Value: ptr.Of("10.10.10.10"),
329-
Type: ptr.Of("ban"),
330-
Scenario: ptr.Of("test alert"),
331-
Origin: ptr.Of(types.CscliOrigin),
324+
Duration: new("4h"),
325+
Scope: new("Ip"),
326+
Value: new("10.10.10.10"),
327+
Type: new("ban"),
328+
Scenario: new("test alert"),
329+
Origin: new(types.CscliOrigin),
332330
}},
333331
Events: []*models.Event{},
334-
EventsCount: ptr.Of(int32(1)),
335-
Leakspeed: ptr.Of("0"),
336-
Message: ptr.Of("test alert"),
337-
ScenarioHash: ptr.Of(""),
338-
Scenario: ptr.Of("test alert"),
339-
ScenarioVersion: ptr.Of(""),
340-
Simulated: ptr.Of(false),
332+
EventsCount: new(int32(1)),
333+
Leakspeed: new("0"),
334+
Message: new("test alert"),
335+
ScenarioHash: new(""),
336+
Scenario: new("test alert"),
337+
ScenarioVersion: new(""),
338+
Simulated: new(false),
341339
Source: &models.Source{
342340
AsName: "",
343341
AsNumber: "",
344342
Cn: "",
345343
IP: "10.10.10.10",
346344
Range: "",
347-
Scope: ptr.Of("Ip"),
348-
Value: ptr.Of("10.10.10.10"),
345+
Scope: new("Ip"),
346+
Value: new("10.10.10.10"),
349347
},
350-
StartAt: ptr.Of(time.Now().UTC().Format(time.RFC3339)),
351-
StopAt: ptr.Of(time.Now().UTC().Format(time.RFC3339)),
348+
StartAt: new(time.Now().UTC().Format(time.RFC3339)),
349+
StopAt: new(time.Now().UTC().Format(time.RFC3339)),
352350
CreatedAt: time.Now().UTC().Format(time.RFC3339),
353351
}
354352
if err := yaml.Unmarshal([]byte(alertOverride), alert); err != nil {
@@ -368,8 +366,8 @@ func (cli *cliNotifications) newTestCmd() *cobra.Command {
368366
},
369367
}
370368
cmd.Flags().StringVarP(&alertOverride, "alert", "a", "",
371-
"JSON string used to override alert fields in the generic alert " +
372-
"(see crowdsec/pkg/models/alert.go in the source tree for the full definition of the object)")
369+
"JSON string used to override alert fields in the generic alert "+
370+
"(see crowdsec/pkg/models/alert.go in the source tree for the full definition of the object)")
373371

374372
return cmd
375373
}
@@ -489,8 +487,8 @@ cscli notifications reinject <alert_id> -a '{"remediation": true,"scenario":"not
489487
},
490488
}
491489
cmd.Flags().StringVarP(&alertOverride, "alert", "a", "",
492-
"JSON string used to override alert fields in the reinjected alert " +
493-
"(see crowdsec/pkg/models/alert.go in the source tree for the full definition of the object)")
490+
"JSON string used to override alert fields in the reinjected alert "+
491+
"(see crowdsec/pkg/models/alert.go in the source tree for the full definition of the object)")
494492

495493
return cmd
496494
}

cmd/crowdsec/lpmetrics.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
"github.com/sirupsen/logrus"
1616

17-
"github.com/crowdsecurity/go-cs-lib/ptr"
1817
"github.com/crowdsecurity/go-cs-lib/version"
1918

2019
acquisitionTypes "github.com/crowdsecurity/crowdsec/pkg/acquisition/types"
@@ -213,10 +212,10 @@ func (m *MetricsProvider) gatherPromMetrics(metricsName []string, labelsMap labe
213212
}
214213

215214
item := &models.MetricsDetailItem{
216-
Name: ptr.Of(metricName),
217-
Unit: ptr.Of(unitType),
215+
Name: new(metricName),
216+
Unit: new(unitType),
218217
Labels: metricsLabels,
219-
Value: ptr.Of(value),
218+
Value: new(value),
220219
}
221220
m.logger.Debugf("Gathered metric: %s, item: %+v", metricFamily.GetName(), item)
222221
items = append(items, item)
@@ -301,14 +300,14 @@ func (m *MetricsProvider) getAppsecBlockedMetrics() []*models.MetricsDetailItem
301300

302301
func (m *MetricsProvider) metricsPayload() *models.AllMetrics {
303302
os := &models.OSversion{
304-
Name: ptr.Of(m.static.osName),
305-
Version: ptr.Of(m.static.osVersion),
303+
Name: new(m.static.osName),
304+
Version: new(m.static.osVersion),
306305
}
307306

308307
base := models.BaseMetrics{
309-
UtcStartupTimestamp: ptr.Of(m.static.startupTS),
308+
UtcStartupTimestamp: new(m.static.startupTS),
310309
Os: os,
311-
Version: ptr.Of(version.String()),
310+
Version: new(version.String()),
312311
FeatureFlags: m.static.featureFlags,
313312
Metrics: make([]*models.DetailedMetrics, 0),
314313
}
@@ -321,8 +320,8 @@ func (m *MetricsProvider) metricsPayload() *models.AllMetrics {
321320

322321
met.Metrics = append(met.Metrics, &models.DetailedMetrics{
323322
Meta: &models.MetricsMeta{
324-
UtcNowTimestamp: ptr.Of(time.Now().Unix()),
325-
WindowSizeSeconds: ptr.Of(int64(m.interval.Seconds())),
323+
UtcNowTimestamp: new(time.Now().Unix()),
324+
WindowSizeSeconds: new(int64(m.interval.Seconds())),
326325
},
327326
Items: make([]*models.MetricsDetailItem, 0),
328327
})

0 commit comments

Comments
 (0)