From 25f33b830f89d6fe387f128cbfa81c044c4a966a Mon Sep 17 00:00:00 2001 From: shankar0123 Date: Sun, 5 Apr 2026 19:16:34 -0400 Subject: [PATCH] fix: resolve golangci-lint issues in wincertstore connector Remove unnecessary fmt.Sprintf wrapping a string literal (staticcheck S1039), remove unused tempFileForPFX function, and clean up unused os import. Co-Authored-By: Claude Opus 4.6 --- .../target/wincertstore/wincertstore.go | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/internal/connector/target/wincertstore/wincertstore.go b/internal/connector/target/wincertstore/wincertstore.go index f6e150e..c4203a9 100644 --- a/internal/connector/target/wincertstore/wincertstore.go +++ b/internal/connector/target/wincertstore/wincertstore.go @@ -14,7 +14,6 @@ import ( "encoding/json" "fmt" "log/slog" - "os" "os/exec" "regexp" "strings" @@ -242,7 +241,7 @@ func (c *Connector) buildImportScript(pfxB64, pfxPassword, thumbprint string) st // Remove expired certs with same subject (optional) if c.config.RemoveExpired { - sb.WriteString(fmt.Sprintf(" $subject = $cert.Subject\n")) + sb.WriteString(" $subject = $cert.Subject\n") sb.WriteString(fmt.Sprintf(" Get-ChildItem 'Cert:\\%s\\%s' | Where-Object { $_.Subject -eq $subject -and $_.NotAfter -lt (Get-Date) -and $_.Thumbprint -ne '%s' } | Remove-Item -Force\n", c.config.StoreLocation, c.config.StoreName, thumbprint)) } @@ -312,20 +311,3 @@ func (c *Connector) ValidateDeployment(ctx context.Context, request target.Valid // Ensure Connector implements target.Connector. var _ target.Connector = (*Connector)(nil) -// tempFileForPFX is a helper used only in WinRM mode — writes PFX to temp file. -// In WinRM mode, the PFX is base64-encoded and transferred in the PowerShell script -// (same pattern as IIS WinRM deployment). -func tempFileForPFX(pfxData []byte) (string, func(), error) { - f, err := os.CreateTemp("", "certctl-pfx-*.pfx") - if err != nil { - return "", nil, fmt.Errorf("create temp PFX file: %w", err) - } - if _, err := f.Write(pfxData); err != nil { - f.Close() - os.Remove(f.Name()) - return "", nil, fmt.Errorf("write temp PFX file: %w", err) - } - f.Close() - cleanup := func() { os.Remove(f.Name()) } - return f.Name(), cleanup, nil -}