replace std library regex engine with go-re2 (#1669)

This commit is contained in:
ahrav authored and GitHub committed 2024-12-20 09:53:01 -06:00
1 parent 906085fba6
commit a91c6717a0
44 files changed
+59 -44

No files matched your search

+1 -1
View File
@@ -2,9 +2,9 @@ package base
import ( import (
"fmt" "fmt"
"regexp"
"strings" "strings"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
) )
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+2 -1
View File
@@ -2,7 +2,8 @@ package rules
import ( import (
"fmt" "fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -2,7 +2,7 @@ package rules
import ( import (
"fmt" "fmt"
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+2 -1
View File
@@ -2,7 +2,8 @@ package rules
import ( import (
"fmt" "fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -3,8 +3,8 @@ package rules
import ( import (
b64 "encoding/base64" b64 "encoding/base64"
"fmt" "fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+2 -1
View File
@@ -2,7 +2,8 @@ package rules
import ( import (
"fmt" "fmt"
"regexp"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -2,7 +2,7 @@ package rules
import ( import (
"encoding/base64" "encoding/base64"
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+1 -1
View File
@@ -2,7 +2,7 @@ package rules
import ( import (
"fmt" "fmt"
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+1 -1
View File
@@ -1,7 +1,7 @@
package rules package rules
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils" "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
+2 -1
View File
@@ -6,8 +6,9 @@ package utils
import ( import (
"fmt" "fmt"
"regexp"
"strings" "strings"
regexp "github.com/wasilibs/go-re2"
) )
const ( const (
+1 -1
View File
@@ -2,9 +2,9 @@ package config
import ( import (
"fmt" "fmt"
"regexp"
"strings" "strings"
regexp "github.com/wasilibs/go-re2"
"golang.org/x/exp/maps" "golang.org/x/exp/maps"
) )
+1 -1
View File
@@ -2,12 +2,12 @@ package config
import ( import (
"errors" "errors"
"regexp"
"testing" "testing"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
regexp "github.com/wasilibs/go-re2"
) )
func TestCommitAllowed(t *testing.T) { func TestCommitAllowed(t *testing.T) {
+1 -1
View File
@@ -3,12 +3,12 @@ package config
import ( import (
_ "embed" _ "embed"
"fmt" "fmt"
"regexp"
"sort" "sort"
"strings" "strings"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/spf13/viper" "github.com/spf13/viper"
regexp "github.com/wasilibs/go-re2"
) )
//go:embed gitleaks.toml //go:embed gitleaks.toml
+1 -1
View File
@@ -2,10 +2,10 @@ package config
import ( import (
"fmt" "fmt"
"regexp"
"testing" "testing"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
regexp "github.com/wasilibs/go-re2"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
+2 -1
View File
@@ -2,8 +2,9 @@ package config
import ( import (
"fmt" "fmt"
"regexp"
"strings" "strings"
regexp "github.com/wasilibs/go-re2"
) )
// Rules contain information that define details on how to detect secrets // Rules contain information that define details on how to detect secrets
+1 -1
View File
@@ -1,7 +1,7 @@
package config package config
import ( import (
"regexp" regexp "github.com/wasilibs/go-re2"
) )
func anyRegexMatch(f string, res []*regexp.Regexp) bool { func anyRegexMatch(f string, res []*regexp.Regexp) bool {
+1 -1
View File
@@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"testing" "testing"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
@@ -12,6 +11,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
regexp "github.com/wasilibs/go-re2"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/report" "github.com/zricethezav/gitleaks/v8/report"
+4 -1
View File
@@ -13,7 +13,7 @@ require (
github.com/rs/zerolog v1.26.1 github.com/rs/zerolog v1.26.1
github.com/spf13/cobra v1.2.1 github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.8.1 github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
) )
@@ -32,6 +32,8 @@ require (
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 // indirect github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 // indirect
github.com/muesli/termenv v0.15.1 // indirect github.com/muesli/termenv v0.15.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect
github.com/tetratelabs/wazero v1.8.2 // indirect
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
golang.org/x/crypto v0.29.0 // indirect golang.org/x/crypto v0.29.0 // indirect
) )
@@ -50,6 +52,7 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect github.com/subosito/gotenv v1.2.0 // indirect
github.com/wasilibs/go-re2 v1.8.0
golang.org/x/sync v0.9.0 // indirect golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect golang.org/x/text v0.20.0 // indirect
+8 -1
View File
@@ -284,10 +284,17 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4=
github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
github.com/wasilibs/go-re2 v1.8.0 h1:6wpqZ31vdoJRSOM41bWEd1AbSmRe161yQkTzoihqwEg=
github.com/wasilibs/go-re2 v1.8.0/go.mod h1:RjA3Y/yW6xFL8Iyz8f5sVhttLq5b5DRF8baZ7Sh+elk=
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 h1:OvLBa8SqJnZ6P+mjlzc2K7PM22rRUPE1x32G9DTPrC4=
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52/go.mod h1:jMeV4Vpbi8osrE/pKUxRZkVaA0EX7NZN0A9/oRzgpgY=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=