From b377208ededa964893dedd5660734e9616f998f7 Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Wed, 23 Aug 2023 20:47:54 -0600 Subject: [PATCH] chore: Appease gosec linter (#5777) These happen to be harmless memory aliasing but I guess the linter can't know that and we can't really prove it in general. --- modules/caddyhttp/reverseproxy/httptransport.go | 3 ++- modules/caddytls/certselection.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/caddyhttp/reverseproxy/httptransport.go b/modules/caddyhttp/reverseproxy/httptransport.go index bcce67b4..9290f7ec 100644 --- a/modules/caddyhttp/reverseproxy/httptransport.go +++ b/modules/caddyhttp/reverseproxy/httptransport.go @@ -529,7 +529,8 @@ func (t TLSConfig) MakeTLSClientConfig(ctx caddy.Context) (*tls.Config, error) { certs := caddytls.AllMatchingCertificates(t.ClientCertificateAutomate) var err error for _, cert := range certs { - err = cri.SupportsCertificate(&cert.Certificate) + certCertificate := cert.Certificate // avoid taking address of iteration variable (gosec warning) + err = cri.SupportsCertificate(&certCertificate) if err == nil { return &cert.Certificate, nil } diff --git a/modules/caddytls/certselection.go b/modules/caddytls/certselection.go index 0311f116..1bef890a 100644 --- a/modules/caddytls/certselection.go +++ b/modules/caddytls/certselection.go @@ -58,7 +58,8 @@ nextChoice: if len(p.SerialNumber) > 0 { var found bool for _, sn := range p.SerialNumber { - if cert.Leaf.SerialNumber.Cmp(&sn.Int) == 0 { + snInt := sn.Int // avoid taking address of iteration variable (gosec warning) + if cert.Leaf.SerialNumber.Cmp(&snInt) == 0 { found = true break }