Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
fix(discordwebhook): Update Discord webhook detector to support 19-digit IDs (#4133)
Matin Rahmanian6f42e37a8208
diff --git a/pkg/detectors/discordwebhook/discordwebhook.go b/pkg/detectors/discordwebhook/discordwebhook.goindex 8355c4a24..d06739f14 100644--- a/pkg/detectors/discordwebhook/discordwebhook.go+++ b/pkg/detectors/discordwebhook/discordwebhook.go@@ -20,7 +20,7 @@ var (client = detectors.DetectorHttpClientWithNoLocalAddresses// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.- keyPat = regexp.MustCompile(`(https:\/\/discord\.com\/api\/webhooks\/[0-9]{18}\/[0-9a-zA-Z-]{68})`)+ keyPat = regexp.MustCompile(`(https:\/\/discord\.com\/api\/webhooks\/[0-9]{18,19}\/[0-9a-zA-Z-]{68})`))// Keywords are used for efficiently pre-filtering chunks.diff --git a/pkg/detectors/discordwebhook/discordwebhook_test.go b/pkg/detectors/discordwebhook/discordwebhook_test.goindex 67ac8f618..7fec8c0bd 100644--- a/pkg/detectors/discordwebhook/discordwebhook_test.go+++ b/pkg/detectors/discordwebhook/discordwebhook_test.go@@ -31,6 +31,27 @@ var (# - The above credentials should only be used in a secure environment.`secret = "https://discord.com/api/webhooks/144147826297622273/Rz9B09dB7cXxtldzXXfmJY0opIzgeANtGJw08vx5PXrP8BpbOeE5lZ7wx8vVcyacYkEl"++ validPattern19Digits = `+ # Configuration File: config.yaml+ database:+ host: $DB_HOST+ port: $DB_PORT+ username: $DB_USERNAME+ password: $DB_PASS # IMPORTANT: Do not share this password publicly++ api:+ auth_type: ""+ in: ""+ discord_hook: "https://discord.com/api/webhooks/1369248176954937405/Q7bFGgbEMoZ-tRHuA4QHk3xTNC7nrrSmTm8IPjFvkp-ChRj4gi2C9lzvJiUcVlnE48X2"+ base_url: ""+ response_code: 200++ # Notes:+ # - Remember to rotate the secret every 90 days.+ # - The above credentials should only be used in a secure environment.+ `+ secret19Digits = "https://discord.com/api/webhooks/1369248176954937405/Q7bFGgbEMoZ-tRHuA4QHk3xTNC7nrrSmTm8IPjFvkp-ChRj4gi2C9lzvJiUcVlnE48X2")func TestDiscordWebHook_Pattern(t *testing.T) {@@ -47,6 +68,11 @@ func TestDiscordWebHook_Pattern(t *testing.T) {input: validPattern,want: []string{secret},},+ {+ name: "valid pattern with 19-digit ID",+ input: validPattern19Digits,+ want: []string{secret19Digits},+ },}for _, test := range tests {