refactor: go fix ftw
This commit is contained in:
@@ -90,7 +90,7 @@ func TestEmailService_Performance(t *testing.T) {
|
||||
|
||||
start := time.Now()
|
||||
iterations := 1000
|
||||
for i := 0; i < iterations; i++ {
|
||||
for range iterations {
|
||||
service.GenerateVerificationEmailBody(user.Username, "https://example.com/confirm?token=test")
|
||||
}
|
||||
duration := time.Since(start)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -339,10 +340,8 @@ func (s *URLMetadataService) validateURLForSSRF(u *url.URL) error {
|
||||
if err != nil {
|
||||
return ErrSSRFBlocked
|
||||
}
|
||||
for _, ip := range ips {
|
||||
if isPrivateOrReservedIP(ip) {
|
||||
return ErrSSRFBlocked
|
||||
}
|
||||
if slices.ContainsFunc(ips, isPrivateOrReservedIP) {
|
||||
return ErrSSRFBlocked
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -359,13 +358,7 @@ func isLocalhost(hostname string) bool {
|
||||
"0:0:0:0:0:0:0:0",
|
||||
}
|
||||
|
||||
for _, name := range localhostNames {
|
||||
if hostname == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return slices.Contains(localhostNames, hostname)
|
||||
}
|
||||
|
||||
func isPrivateOrReservedIP(ip net.IP) bool {
|
||||
|
||||
Reference in New Issue
Block a user