Просмотр исходного кода

build: support either stdlib or 3rd-party regexp (#1706)

Richard Gomez 1 год назад
Родитель
Сommit
3f4d91fc22
47 измененных файлов с 102 добавлено и 123 удалено
  1. 1 2
      cmd/generate/config/base/config.go
  2. 1 2
      cmd/generate/config/rules/1password.go
  3. 1 2
      cmd/generate/config/rules/age.go
  4. 1 2
      cmd/generate/config/rules/aws.go
  5. 2 4
      cmd/generate/config/rules/azure.go
  6. 2 4
      cmd/generate/config/rules/clojars.go
  7. 1 1
      cmd/generate/config/rules/curl.go
  8. 2 4
      cmd/generate/config/rules/doppler.go
  9. 2 4
      cmd/generate/config/rules/duffel.go
  10. 2 4
      cmd/generate/config/rules/dynatrace.go
  11. 2 4
      cmd/generate/config/rules/easypost.go
  12. 2 4
      cmd/generate/config/rules/flutterwave.go
  13. 2 4
      cmd/generate/config/rules/frameio.go
  14. 1 2
      cmd/generate/config/rules/freemius.go
  15. 2 4
      cmd/generate/config/rules/gcp.go
  16. 1 2
      cmd/generate/config/rules/generic.go
  17. 2 4
      cmd/generate/config/rules/github.go
  18. 2 4
      cmd/generate/config/rules/gitlab.go
  19. 2 5
      cmd/generate/config/rules/harness.go
  20. 2 4
      cmd/generate/config/rules/hashicorp.go
  21. 2 4
      cmd/generate/config/rules/hashicorp_vault.go
  22. 1 1
      cmd/generate/config/rules/jwt.go
  23. 2 4
      cmd/generate/config/rules/kubernetes.go
  24. 2 4
      cmd/generate/config/rules/linear.go
  25. 2 4
      cmd/generate/config/rules/nuget.go
  26. 2 4
      cmd/generate/config/rules/openshift.go
  27. 1 2
      cmd/generate/config/rules/privatekey.go
  28. 2 4
      cmd/generate/config/rules/pypi.go
  29. 1 1
      cmd/generate/config/rules/sentry.go
  30. 2 4
      cmd/generate/config/rules/shopify.go
  31. 1 2
      cmd/generate/config/rules/sidekiq.go
  32. 2 3
      cmd/generate/config/rules/slack.go
  33. 2 4
      cmd/generate/config/rules/teams.go
  34. 2 4
      cmd/generate/config/rules/twilio.go
  35. 1 1
      cmd/generate/config/utils/generate.go
  36. 3 0
      cmd/root.go
  37. 2 1
      config/allowlist.go
  38. 2 1
      config/allowlist_test.go
  39. 1 1
      config/config.go
  40. 2 2
      config/config_test.go
  41. 1 1
      config/rule.go
  42. 1 1
      config/utils.go
  43. 1 1
      detect/detect.go
  44. 1 1
      detect/detect_test.go
  45. 0 2
      logging/log.go
  46. 15 0
      regexp/stdlib_regex.go
  47. 15 0
      regexp/wasilibs_regex.go

+ 1 - 2
cmd/generate/config/base/config.go

@@ -4,9 +4,8 @@ import (
 	"fmt"
 	"strings"
 
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func CreateGlobalConfig() config.Config {

+ 1 - 2
cmd/generate/config/rules/1password.go

@@ -1,11 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // https://developer.1password.com/docs/service-accounts/security/?token-example=encoded

+ 1 - 2
cmd/generate/config/rules/age.go

@@ -1,10 +1,9 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func AgeSecretKey() *config.Rule {

+ 1 - 2
cmd/generate/config/rules/aws.go

@@ -1,11 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func AWS() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/azure.go

@@ -3,12 +3,10 @@ package rules
 import (
 	"fmt"
 
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // References:

+ 2 - 4
cmd/generate/config/rules/clojars.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func Clojars() *config.Rule {

+ 1 - 1
cmd/generate/config/rules/curl.go

@@ -2,10 +2,10 @@ package rules
 
 import (
 	"fmt"
-	regexp "github.com/wasilibs/go-re2"
 
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // https://curl.se/docs/manpage.html#-u

+ 2 - 4
cmd/generate/config/rules/doppler.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func Doppler() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/duffel.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func Duffel() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/dynatrace.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func Dynatrace() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/easypost.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func EasyPost() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/flutterwave.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func FlutterwavePublicKey() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/frameio.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func FrameIO() *config.Rule {

+ 1 - 2
cmd/generate/config/rules/freemius.go

@@ -1,10 +1,9 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func Freemius() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/gcp.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // TODO this one could probably use some work

+ 1 - 2
cmd/generate/config/rules/generic.go

@@ -1,11 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func GenericCredential() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/github.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 var githubAllowlist = []config.Allowlist{

+ 2 - 4
cmd/generate/config/rules/gitlab.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // overview with all GitLab tokens:

+ 2 - 5
cmd/generate/config/rules/harness.go

@@ -1,13 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func HarnessApiKey() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/hashicorp.go

@@ -3,12 +3,10 @@ package rules
 import (
 	"fmt"
 
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func HashiCorpTerraform() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/hashicorp_vault.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func VaultServiceToken() *config.Rule {

+ 1 - 1
cmd/generate/config/rules/jwt.go

@@ -4,10 +4,10 @@ import (
 	b64 "encoding/base64"
 	"fmt"
 
-	regexp "github.com/wasilibs/go-re2"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func JWT() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/kubernetes.go

@@ -3,11 +3,9 @@ package rules
 import (
 	"fmt"
 
-	regexp "github.com/wasilibs/go-re2"
-
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // KubernetesSecret validates if we detected a kubernetes secret which contains data!

+ 2 - 4
cmd/generate/config/rules/linear.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func LinearAPIToken() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/nuget.go

@@ -1,11 +1,9 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func NugetConfigPassword() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/openshift.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // OpenShift 4 user tokens are prefixed with `sha256~`.

+ 1 - 2
cmd/generate/config/rules/privatekey.go

@@ -1,10 +1,9 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func PrivateKey() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/pypi.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func PyPiUploadToken() *config.Rule {

+ 1 - 1
cmd/generate/config/rules/sentry.go

@@ -2,11 +2,11 @@ package rules
 
 import (
 	"encoding/base64"
-	regexp "github.com/wasilibs/go-re2"
 
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func SentryAccessToken() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/shopify.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func ShopifySharedSecret() *config.Rule {

+ 1 - 2
cmd/generate/config/rules/sidekiq.go

@@ -1,11 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func SidekiqSecret() *config.Rule {

+ 2 - 3
cmd/generate/config/rules/slack.go

@@ -2,12 +2,11 @@ package rules
 
 import (
 	"fmt"
-	regexp "github.com/wasilibs/go-re2"
 
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // https://api.slack.com/authentication/token-types#bot

+ 2 - 4
cmd/generate/config/rules/teams.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func TeamsWebhook() *config.Rule {

+ 2 - 4
cmd/generate/config/rules/twilio.go

@@ -1,12 +1,10 @@
 package rules
 
 import (
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
-	"github.com/zricethezav/gitleaks/v8/config"
-
 	"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
+	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func Twilio() *config.Rule {

+ 1 - 1
cmd/generate/config/utils/generate.go

@@ -8,7 +8,7 @@ import (
 	"fmt"
 	"strings"
 
-	regexp "github.com/wasilibs/go-re2"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 const (

+ 3 - 0
cmd/root.go

@@ -16,6 +16,7 @@ import (
 	"github.com/zricethezav/gitleaks/v8/config"
 	"github.com/zricethezav/gitleaks/v8/detect"
 	"github.com/zricethezav/gitleaks/v8/logging"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 	"github.com/zricethezav/gitleaks/v8/report"
 )
 
@@ -110,6 +111,8 @@ func initConfig(source string) {
 		_, _ = fmt.Fprint(os.Stderr, banner)
 	}
 
+	logging.Debug().Msgf("using %s regex engine", regexp.Version)
+
 	cfgPath, err := rootCmd.Flags().GetString("config")
 	if err != nil {
 		logging.Fatal().Msg(err.Error())

+ 2 - 1
config/allowlist.go

@@ -4,8 +4,9 @@ import (
 	"fmt"
 	"strings"
 
-	regexp "github.com/wasilibs/go-re2"
 	"golang.org/x/exp/maps"
+
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 type AllowlistMatchCondition int

+ 2 - 1
config/allowlist_test.go

@@ -7,7 +7,8 @@ import (
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
 	"github.com/stretchr/testify/assert"
-	regexp "github.com/wasilibs/go-re2"
+
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func TestCommitAllowed(t *testing.T) {

+ 1 - 1
config/config.go

@@ -7,9 +7,9 @@ import (
 	"strings"
 
 	"github.com/spf13/viper"
-	regexp "github.com/wasilibs/go-re2"
 
 	"github.com/zricethezav/gitleaks/v8/logging"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 //go:embed gitleaks.toml

+ 2 - 2
config/config_test.go

@@ -5,11 +5,11 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-	regexp "github.com/wasilibs/go-re2"
-
 	"github.com/spf13/viper"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
+
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 const configPath = "../testdata/config/"

+ 1 - 1
config/rule.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"strings"
 
-	regexp "github.com/wasilibs/go-re2"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 // Rules contain information that define details on how to detect secrets

+ 1 - 1
config/utils.go

@@ -1,7 +1,7 @@
 package config
 
 import (
-	regexp "github.com/wasilibs/go-re2"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 )
 
 func anyRegexMatch(f string, res []*regexp.Regexp) bool {

+ 1 - 1
detect/detect.go

@@ -5,13 +5,13 @@ import (
 	"context"
 	"fmt"
 	"os"
-	"regexp"
 	"strings"
 	"sync"
 	"sync/atomic"
 
 	"github.com/zricethezav/gitleaks/v8/config"
 	"github.com/zricethezav/gitleaks/v8/logging"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 	"github.com/zricethezav/gitleaks/v8/report"
 
 	ahocorasick "github.com/BobuSumisu/aho-corasick"

+ 1 - 1
detect/detect_test.go

@@ -12,10 +12,10 @@ import (
 	"github.com/spf13/viper"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
-	regexp "github.com/wasilibs/go-re2"
 
 	"github.com/zricethezav/gitleaks/v8/cmd/scm"
 	"github.com/zricethezav/gitleaks/v8/config"
+	"github.com/zricethezav/gitleaks/v8/regexp"
 	"github.com/zricethezav/gitleaks/v8/report"
 	"github.com/zricethezav/gitleaks/v8/sources"
 )

+ 0 - 2
logging/log.go

@@ -6,8 +6,6 @@ import (
 	"github.com/rs/zerolog"
 )
 
-// TODO: Should this be a pointer?
-// https://github.com/rs/zerolog/issues/1
 var Logger zerolog.Logger
 
 func init() {

+ 15 - 0
regexp/stdlib_regex.go

@@ -0,0 +1,15 @@
+//go:build stdregex
+
+package regexp
+
+import (
+	re "regexp"
+)
+
+const Version = "stdlib"
+
+type Regexp = re.Regexp
+
+func MustCompile(str string) *re.Regexp {
+	return re.MustCompile(str)
+}

+ 15 - 0
regexp/wasilibs_regex.go

@@ -0,0 +1,15 @@
+//go:build !stdregex
+
+package regexp
+
+import (
+	re "github.com/wasilibs/go-re2"
+)
+
+const Version = "github.com/wasilibs/go-re2"
+
+type Regexp = re.Regexp
+
+func MustCompile(str string) *re.Regexp {
+	return re.MustCompile(str)
+}