Merge pull request #5560 from mohamedawnallah/fixNullPointerDereferenceInAltNamesMutators

operator/pkg/certs: mitigate potential null pointer dereference in AltNames Mutators for both the `APIServer` and `EtcdServer`
This commit is contained in:
karmada-bot 2024-10-17 09:28:28 +08:00 committed by GitHub
commit c230b14827
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -455,7 +455,7 @@ func etcdServerAltNamesMutator(cfg *AltNamesMutatorConfig) (*certutil.AltNames,
IPs: []net.IP{net.IPv4(127, 0, 0, 1)},
}
if cfg.Components.Etcd.Local != nil {
if cfg.Components != nil && cfg.Components.Etcd != nil && cfg.Components.Etcd.Local != nil {
appendSANsToAltNames(altNames, cfg.Components.Etcd.Local.ServerCertSANs)
}
@ -488,7 +488,7 @@ func apiServerAltNamesMutator(cfg *AltNamesMutatorConfig) (*certutil.AltNames, e
fmt.Sprintf("*.%s.svc", cfg.Namespace)})
}
if len(cfg.Components.KarmadaAPIServer.CertSANs) > 0 {
if cfg.Components != nil && cfg.Components.KarmadaAPIServer != nil && len(cfg.Components.KarmadaAPIServer.CertSANs) > 0 {
appendSANsToAltNames(altNames, cfg.Components.KarmadaAPIServer.CertSANs)
}
if len(cfg.ControlplaneAddress) > 0 {