mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 19:01:34 +00:00
fix(scep-probe): satisfy staticcheck QF1008 in describeCertAlgorithm
CI flagged QF1008 on the chained selector pub.Curve.Params() — the linter wants the promoted-method form pub.Params() (Curve is embedded in ecdsa.PublicKey, so Params is reachable via promotion). Restructure the nil check so the embedded interface still gets validated before the promoted call, then invoke pub.Params() once and reuse the result. Verification: * gofmt clean * staticcheck on internal/service/...: clean * 6/6 TestProbeSCEP_* tests still pass
This commit is contained in:
@@ -322,8 +322,15 @@ func describeCertAlgorithm(c *x509.Certificate) string {
|
||||
case *rsa.PublicKey:
|
||||
return fmt.Sprintf("RSA-%d", pub.N.BitLen())
|
||||
case *ecdsa.PublicKey:
|
||||
if pub.Curve != nil && pub.Curve.Params() != nil {
|
||||
return "ECDSA-" + pub.Curve.Params().Name
|
||||
// Curve is embedded in ecdsa.PublicKey; check the interface
|
||||
// itself for nil before calling Params() via promotion (QF1008
|
||||
// — staticcheck wants the promoted-method form, not the
|
||||
// chained selector). Still need the nil check because
|
||||
// calling Params() on a nil embedded interface would panic.
|
||||
if pub.Curve != nil {
|
||||
if params := pub.Params(); params != nil {
|
||||
return "ECDSA-" + params.Name
|
||||
}
|
||||
}
|
||||
return "ECDSA"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user