fix(discordwebhook): Update Discord webhook detector to support 19-digit IDs (#4133)
* fix(discordwebhook): update regex to support new 19-digit webhook IDs * test(discordwebhook): add test case for 19-digit webhook IDs --------- Co-authored-by: Kashif Khan <[email protected]>
This commit is contained in:
co-authored by
Kashif Khan
parent
3f9d9c345e
commit
6f42e37a82
@@ -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.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user