mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
35 lines
672 B
Go
35 lines
672 B
Go
package rules
|
|
|
|
import (
|
|
"regexp"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"github.com/zricethezav/gitleaks/v8/config"
|
|
"github.com/zricethezav/gitleaks/v8/detect"
|
|
)
|
|
|
|
func Twilio() *config.Rule {
|
|
// define rule
|
|
r := config.Rule{
|
|
Description: "Twilio API Key",
|
|
RuleID: "twilio-api-key",
|
|
Regex: regexp.MustCompile(`SK[0-9a-fA-F]{32}`),
|
|
Keywords: []string{"twilio"},
|
|
}
|
|
|
|
// validate
|
|
tps := []string{
|
|
"twilioAPIKey := \"SK" + sampleHex32Token + "\"",
|
|
}
|
|
d := detect.NewDetector(config.Config{
|
|
Rules: []*config.Rule{&r},
|
|
})
|
|
for _, tp := range tps {
|
|
if len(d.DetectString(tp)) != 1 {
|
|
log.Fatal().Msg("Failed to validate twilio")
|
|
}
|
|
}
|
|
return &r
|
|
}
|