mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 13:52:51 +00:00
* Inject DenyList from config to `StartCommands()` * Implementation draft * Move address checker to separate package * Migrate usages of actions.AddressChecker to denylist.AddressChecker * Rename denylist package files * Pass []denylist.AddressChecker to StartCommand * Add DenyList to defaults.yaml and add custom config parser * net: add HostnameToIPList function * denylist: Add IsHostBlocked() * actions: use denylist.IsHostBlocked() * command: Inject ip lookup function + extend add target validationt test * command: Unexport ChangeTarget.IsValid() * command: Add denyList check on ChangeTarget validation * command: Export ActionsV2DenyList and IPLookupFunction params * Lint fix * Check denylist during action execution * Fix integration tests * Apply suggestions * Add `mapstructure.StringToSliceHookFunc()` to decode `HTTPConfigDecodeHook`
31 lines
884 B
Go
31 lines
884 B
Go
package net
|
|
|
|
import (
|
|
builtin_net "net"
|
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
type IPLookupFunc func(string) ([]builtin_net.IP, error)
|
|
|
|
// HostnameToIPList converts the input URL to a list [net.IP].
|
|
//
|
|
// Returns an internal error if the lookup fails.
|
|
// Returns an invalid argument if the lookup function is nil
|
|
func HostnameToIPList(hostname string, lookupFunc IPLookupFunc) ([]builtin_net.IP, error) {
|
|
ip := builtin_net.ParseIP(hostname)
|
|
ips := []builtin_net.IP{ip}
|
|
if ip != nil {
|
|
return ips, nil
|
|
}
|
|
// if the hostname is a domain, we need to check resolve the ip(s), since it might be denied
|
|
if lookupFunc == nil {
|
|
return nil, zerrors.ThrowInvalidArgument(nil, "NET-naSn77", "lookup function must not be nil")
|
|
}
|
|
ips, err := lookupFunc(hostname)
|
|
if err != nil {
|
|
return nil, zerrors.ThrowInternal(err, "NET-4m9s2", "lookup failed")
|
|
}
|
|
return ips, nil
|
|
}
|