Skip to content

Commit

Permalink
(chore): move to v3 (#94)
Browse files Browse the repository at this point in the history
JIRA: APPSEC-52726

### Changes

Update go.mod and module references to go-libbdwaf v3 version.

---------

Signed-off-by: Eliott Bouhana <[email protected]>
Co-authored-by: Eliott Bouhana <[email protected]>
  • Loading branch information
Hellzy and eliottness authored May 6, 2024
1 parent dc08fd2 commit 639e12b
Show file tree
Hide file tree
Showing 28 changed files with 65 additions and 62 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {
Persistent: map[string]any{
"server.request.path_params": "/rfiinc.txt",
},
}, time.Minute)
})
}
```

Expand Down
4 changes: 2 additions & 2 deletions alignement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ package waf
import (
"testing"

"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"

"github.com/ebitengine/purego"
"github.com/stretchr/testify/require"
Expand Down
4 changes: 2 additions & 2 deletions cgo_ref_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ package waf
import (
"strconv"

"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
)

// cgoRefPool is a way to make sure we can safely send go allocated data on the C side of the WAF
Expand Down
8 changes: 4 additions & 4 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"sync"
"time"

"github.com/DataDog/go-libddwaf/v2/errors"
"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v2/timer"
"github.com/DataDog/go-libddwaf/v3/errors"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/timer"

"sync/atomic"
)
Expand Down
6 changes: 3 additions & 3 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
package waf

import (
"github.com/DataDog/go-libddwaf/v2/errors"
"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/errors"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
)

// decodeErrors transforms the wafObject received by the wafRulesetInfo after the call to wafDl.wafInit to a map where
Expand Down
8 changes: 4 additions & 4 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ package waf
import (
"context"
"fmt"
"github.com/DataDog/go-libddwaf/v2/timer"
"math"
"reflect"
"strings"
"time"
"unicode"

"github.com/DataDog/go-libddwaf/v2/errors"
"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/errors"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/timer"
)

// Encode Go values into wafObjects. Only the subset of Go types representable into wafObjects
Expand Down
8 changes: 4 additions & 4 deletions encoder_decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ package waf
import (
"context"
"encoding/json"
"github.com/DataDog/go-libddwaf/v2/timer"
"reflect"
"sort"
"testing"
"time"

"github.com/DataDog/go-libddwaf/v2/errors"
"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/errors"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/timer"

"github.com/stretchr/testify/require"
)
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/DataDog/go-libddwaf/v2
module github.com/DataDog/go-libddwaf/v3

go 1.20

Expand All @@ -16,6 +16,3 @@ require (
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// Version where import paths were not changed to go-libddwaf/v2
retract v2.0.0
8 changes: 4 additions & 4 deletions handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"fmt"
"time"

wafErrors "github.com/DataDog/go-libddwaf/v2/errors"
"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v2/timer"
wafErrors "github.com/DataDog/go-libddwaf/v3/errors"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/timer"

"sync/atomic"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/bindings/safe.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package bindings

import (
wafErrors "github.com/DataDog/go-libddwaf/v2/errors"
wafErrors "github.com/DataDog/go-libddwaf/v3/errors"

"fmt"
"reflect"
Expand Down
2 changes: 1 addition & 1 deletion internal/bindings/safe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package bindings

import (
"errors"
wafErrors "github.com/DataDog/go-libddwaf/v2/errors"
wafErrors "github.com/DataDog/go-libddwaf/v3/errors"
"strconv"
"testing"

Expand Down
6 changes: 3 additions & 3 deletions internal/bindings/waf_dl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"fmt"
"os"

"github.com/DataDog/go-libddwaf/v2/internal/lib"
"github.com/DataDog/go-libddwaf/v2/internal/log"
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/internal/lib"
"github.com/DataDog/go-libddwaf/v3/internal/log"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
"github.com/ebitengine/purego"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/bindings/waf_dl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"runtime"
"testing"

"github.com/DataDog/go-libddwaf/v2/internal/lib"
"github.com/DataDog/go-libddwaf/v3/internal/lib"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/log/log_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package log
// uint64_t message_len
// );
import "C"
import "github.com/DataDog/go-libddwaf/v2/internal/unsafe"
import "github.com/DataDog/go-libddwaf/v3/internal/unsafe"

// CallbackFunctionPointer returns a pointer to the log callback function which
// can be used with libddwaf.
Expand Down
2 changes: 1 addition & 1 deletion internal/log/log_purego.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package log

import (
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
"sync"

"github.com/ebitengine/purego"
Expand Down
2 changes: 1 addition & 1 deletion internal/support/waf_cgo_disabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package support

import "github.com/DataDog/go-libddwaf/v2/errors"
import "github.com/DataDog/go-libddwaf/v3/errors"

func init() {
wafSupportErrors = append(wafSupportErrors, errors.CgoDisabledError{})
Expand Down
4 changes: 2 additions & 2 deletions internal/support/waf_cgo_disabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ package support_test
import (
"testing"

waf "github.com/DataDog/go-libddwaf/v2"
"github.com/DataDog/go-libddwaf/v2/errors"
waf "github.com/DataDog/go-libddwaf/v3"
"github.com/DataDog/go-libddwaf/v3/errors"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/support/waf_manually_disabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package support

import "github.com/DataDog/go-libddwaf/v2/errors"
import "github.com/DataDog/go-libddwaf/v3/errors"

func init() {
wafManuallyDisabledErr = errors.ManuallyDisabledError{}
Expand Down
5 changes: 3 additions & 2 deletions internal/support/waf_manually_disabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
package support_test

import (
"github.com/DataDog/go-libddwaf/v2/errors"
"testing"

waf "github.com/DataDog/go-libddwaf/v2"
waf "github.com/DataDog/go-libddwaf/v3"
"github.com/DataDog/go-libddwaf/v3/errors"

"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/support/waf_unsupported_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package support

import "github.com/DataDog/go-libddwaf/v2/errors"
import "github.com/DataDog/go-libddwaf/v3/errors"

func init() {
wafSupportErrors = append(wafSupportErrors, errors.UnsupportedGoVersionError{})
Expand Down
4 changes: 2 additions & 2 deletions internal/support/waf_unsupported_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"runtime"
"testing"

waf "github.com/DataDog/go-libddwaf/v2"
"github.com/DataDog/go-libddwaf/v2/errors"
waf "github.com/DataDog/go-libddwaf/v3"
"github.com/DataDog/go-libddwaf/v3/errors"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/support/waf_unsupported_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package support
import (
"runtime"

"github.com/DataDog/go-libddwaf/v2/errors"
"github.com/DataDog/go-libddwaf/v3/errors"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions internal/support/waf_unsupported_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"runtime"
"testing"

waf "github.com/DataDog/go-libddwaf/v2"
"github.com/DataDog/go-libddwaf/v2/errors"
waf "github.com/DataDog/go-libddwaf/v3"
"github.com/DataDog/go-libddwaf/v3/errors"
"github.com/stretchr/testify/require"
)

Expand Down
3 changes: 2 additions & 1 deletion timer/clock_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package timer

import (
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"testing"
"time"

"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
)

func BenchmarkMostUsedFunctions(b *testing.B) {
Expand Down
8 changes: 5 additions & 3 deletions timer/timer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
package timer_test

import (
"github.com/DataDog/go-libddwaf/v2/internal/unsafe"
"github.com/DataDog/go-libddwaf/v2/timer"
"github.com/stretchr/testify/require"
"strconv"
"testing"
"time"

"github.com/DataDog/go-libddwaf/v3/internal/unsafe"
"github.com/DataDog/go-libddwaf/v3/timer"

"github.com/stretchr/testify/require"
)

func hasExpired(t *testing.T, timer timer.Timer, duration time.Duration) {
Expand Down
6 changes: 3 additions & 3 deletions waf.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ package waf
import (
"errors"
"fmt"
wafErrors "github.com/DataDog/go-libddwaf/v2/errors"
"sync"
"time"

"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/support"
wafErrors "github.com/DataDog/go-libddwaf/v3/errors"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/support"
)

// ErrTimeout is the error returned when the WAF times out while processing a request.
Expand Down
8 changes: 5 additions & 3 deletions waf_support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ package waf

import (
"flag"
wafErrors "github.com/DataDog/go-libddwaf/v2/errors"
"github.com/DataDog/go-libddwaf/v2/internal/support"
"github.com/stretchr/testify/require"
"testing"

wafErrors "github.com/DataDog/go-libddwaf/v3/errors"
"github.com/DataDog/go-libddwaf/v3/internal/support"

"github.com/stretchr/testify/require"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions waf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
_ "embed"
"encoding/json"
"fmt"
"github.com/DataDog/go-libddwaf/v2/timer"
"math/rand"
"sort"
"strconv"
Expand All @@ -22,10 +21,11 @@ import (
"text/template"
"time"

"github.com/DataDog/go-libddwaf/v2/errors"
"github.com/DataDog/go-libddwaf/v3/errors"
"github.com/DataDog/go-libddwaf/v3/internal/bindings"
"github.com/DataDog/go-libddwaf/v3/internal/lib"
"github.com/DataDog/go-libddwaf/v3/timer"

"github.com/DataDog/go-libddwaf/v2/internal/bindings"
"github.com/DataDog/go-libddwaf/v2/internal/lib"
"github.com/stretchr/testify/require"
)

Expand Down

0 comments on commit 639e12b

Please sign in to comment.