mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-12-06 01:53:42 +01:00
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package lure
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestIsCandidate(t *testing.T) {
|
|
cases := []struct {
|
|
in string
|
|
want bool
|
|
}{
|
|
{"4H7K9QM2XR3T", true},
|
|
{"zQ8fRt2mKp9x", true},
|
|
// an operator written code may be any text, so no alphabet is applied
|
|
{"special-42", true},
|
|
{"Special_42", true},
|
|
{"hello", true},
|
|
// a single dot is allowed so a lure can end in invoice.pdf
|
|
{"invoice.pdf", true},
|
|
{"main.4f3a2b1c.js", true},
|
|
// values that could not sit in a single path segment unescaped
|
|
{"hello world", false},
|
|
{"a/b", false},
|
|
{"%2Fetc", false},
|
|
{"a\\b", false},
|
|
{"a%2Fb", false},
|
|
{"a?b", false},
|
|
{"a#b", false},
|
|
{"", false},
|
|
// a browser resolves a lone dot away before sending, and the resolver
|
|
// refuses a whole path carrying a doubled dot rather than cleaning it
|
|
{".", false},
|
|
{"..", false},
|
|
{"...", false},
|
|
{"invoice..pdf", false},
|
|
{"v1..2", false},
|
|
// a single dot elsewhere in the segment is still fine
|
|
{".hidden", true},
|
|
{strings.Repeat("a", MaxCustomLength), true},
|
|
{strings.Repeat("a", MaxCustomLength+1), false},
|
|
}
|
|
for _, c := range cases {
|
|
if got := IsCandidate(c.in); got != c.want {
|
|
t.Errorf("IsCandidate(%q) = %v, want %v", c.in, got, c.want)
|
|
}
|
|
}
|
|
}
|