mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-02 08:58:52 +00:00
Merge commit from fork
* 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`
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user