diff --git a/pkg/apiclient/decisions_service.go b/pkg/apiclient/decisions_service.go index ae92fb189..054c51a9c 100644 --- a/pkg/apiclient/decisions_service.go +++ b/pkg/apiclient/decisions_service.go @@ -6,6 +6,8 @@ import ( "fmt" "net/http" + "github.com/crowdsecurity/go-cs-lib/pkg/ptr" + "github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/modelscapi" "github.com/crowdsecurity/crowdsec/pkg/types" @@ -102,10 +104,10 @@ func (s *DecisionsService) GetDecisionsFromGroups(decisionsGroups []*modelscapi. partialDecisions[idx] = &models.Decision{ Scenario: decisionsGroup.Scenario, Scope: decisionsGroup.Scope, - Type: types.StrPtr(types.DecisionTypeBan), + Type: ptr.Of(types.DecisionTypeBan), Value: decision.Value, Duration: decision.Duration, - Origin: types.StrPtr(types.CAPIOrigin), + Origin: ptr.Of(types.CAPIOrigin), } } decisions = append(decisions, partialDecisions...) @@ -138,10 +140,10 @@ func (s *DecisionsService) FetchV3Decisions(ctx context.Context, url string) (*m partialDecisions[idx] = &models.Decision{ Scenario: &scenarioDeleted, Scope: decisionsGroup.Scope, - Type: types.StrPtr(types.DecisionTypeBan), + Type: ptr.Of(types.DecisionTypeBan), Value: &decision, Duration: &durationDeleted, - Origin: types.StrPtr(types.CAPIOrigin), + Origin: ptr.Of(types.CAPIOrigin), } } v2Decisions.Deleted = append(v2Decisions.Deleted, partialDecisions...) @@ -210,7 +212,7 @@ func (s *DecisionsService) GetDecisionsFromBlocklist(ctx context.Context, blockl Type: blocklist.Remediation, Value: &decision, Duration: blocklist.Duration, - Origin: types.StrPtr(types.ListOrigin), + Origin: ptr.Of(types.ListOrigin), }) } diff --git a/pkg/apiclient/decisions_service_test.go b/pkg/apiclient/decisions_service_test.go index 7af2bf81f..935ddcea5 100644 --- a/pkg/apiclient/decisions_service_test.go +++ b/pkg/apiclient/decisions_service_test.go @@ -8,11 +8,11 @@ import ( "reflect" "testing" + "github.com/crowdsecurity/go-cs-lib/pkg/ptr" "github.com/crowdsecurity/go-cs-lib/pkg/version" "github.com/crowdsecurity/crowdsec/pkg/models" "github.com/crowdsecurity/crowdsec/pkg/modelscapi" - "github.com/crowdsecurity/crowdsec/pkg/types" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -461,7 +461,7 @@ func TestDecisionsFromBlocklist(t *testing.T) { Remediation: &tremediationBlocklist, Name: &tnameBlocklist, Duration: &tdurationBlocklist, - }, types.StrPtr("Sun, 01 Jan 2023 01:01:01 GMT")) + }, ptr.Of("Sun, 01 Jan 2023 01:01:01 GMT")) require.NoError(t, err) assert.False(t, isModified) _, isModified, err = newcli.Decisions.GetDecisionsFromBlocklist(context.Background(), &modelscapi.BlocklistLink{ @@ -470,7 +470,7 @@ func TestDecisionsFromBlocklist(t *testing.T) { Remediation: &tremediationBlocklist, Name: &tnameBlocklist, Duration: &tdurationBlocklist, - }, types.StrPtr("Mon, 02 Jan 2023 01:01:01 GMT")) + }, ptr.Of("Mon, 02 Jan 2023 01:01:01 GMT")) require.NoError(t, err) assert.True(t, isModified) }