1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-06-25 19:55:22 +00:00

🚨 More linter fixes

Source: https://github.com/makeworld-the-better-one/amfora/actions/runs/224580926
This commit is contained in:
makeworld 2020-08-25 21:18:57 -04:00
parent 01fa5709f5
commit e4279de417
3 changed files with 10 additions and 9 deletions

View File

@ -39,19 +39,20 @@ func expiryKey(domain string, port string) string {
func loadTofuEntry(domain string, port string) (string, time.Time, error) { func loadTofuEntry(domain string, port string) (string, time.Time, error) {
id := tofuStore.GetString(idKey(domain, port)) // Fingerprint id := tofuStore.GetString(idKey(domain, port)) // Fingerprint
if len(id) != 64 { if len(id) != sha256.Size*2 {
// Not set, or invalid // Not set, or invalid
return "", time.Time{}, errors.New("not found") return "", time.Time{}, errors.New("not found") //nolint:goerr113
} }
expiry := tofuStore.GetTime(expiryKey(domain, port)) expiry := tofuStore.GetTime(expiryKey(domain, port))
if expiry.IsZero() { if expiry.IsZero() {
// Not set // Not set
return id, time.Time{}, errors.New("not found") return id, time.Time{}, errors.New("not found") //nolint:goerr113
} }
return id, expiry, nil return id, expiry, nil
} }
//nolint:errcheck
// certID returns a generic string representing a cert or domain. // certID returns a generic string representing a cert or domain.
func certID(cert *x509.Certificate) string { func certID(cert *x509.Certificate) string {
h := sha256.New() h := sha256.New()
@ -62,14 +63,14 @@ func certID(cert *x509.Certificate) string {
// origCertID uses cert.Raw, which was used in v1.0.0 of the app. // origCertID uses cert.Raw, which was used in v1.0.0 of the app.
func origCertID(cert *x509.Certificate) string { func origCertID(cert *x509.Certificate) string {
h := sha256.New() h := sha256.New()
h.Write(cert.Raw) h.Write(cert.Raw) //nolint:errcheck
return fmt.Sprintf("%X", h.Sum(nil)) return fmt.Sprintf("%X", h.Sum(nil))
} }
func saveTofuEntry(domain, port string, cert *x509.Certificate) { func saveTofuEntry(domain, port string, cert *x509.Certificate) {
tofuStore.Set(idKey(domain, port), certID(cert)) tofuStore.Set(idKey(domain, port), certID(cert))
tofuStore.Set(expiryKey(domain, port), cert.NotAfter.UTC()) tofuStore.Set(expiryKey(domain, port), cert.NotAfter.UTC())
tofuStore.WriteConfig() tofuStore.WriteConfig() //nolint:errcheck // Not an issue if it's not saved, only cached data
} }
// handleTofu is the abstracted interface for taking care of TOFU. // handleTofu is the abstracted interface for taking care of TOFU.
@ -90,7 +91,7 @@ func handleTofu(domain, port string, cert *x509.Certificate) bool {
// Store expiry again in case it changed // Store expiry again in case it changed
tofuStore.Set(expiryKey(domain, port), cert.NotAfter.UTC()) tofuStore.Set(expiryKey(domain, port), cert.NotAfter.UTC())
tofuStore.WriteConfig() tofuStore.WriteConfig() //nolint:errcheck
return true return true
} }

View File

@ -114,13 +114,13 @@ func Init() error {
if err != nil { if err != nil {
return err return err
} }
os.OpenFile(tofuDBPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) os.OpenFile(tofuDBPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) //nolint:errcheck
// Bookmarks // Bookmarks
err = os.MkdirAll(bkmkDir, 0755) err = os.MkdirAll(bkmkDir, 0755)
if err != nil { if err != nil {
return err return err
} }
os.OpenFile(bkmkPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) os.OpenFile(bkmkPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) //nolint:errcheck
// Setup vipers // Setup vipers

View File

@ -1,5 +1,5 @@
// +build linux freebsd netbsd openbsd // +build linux freebsd netbsd openbsd
//nolint:goerr113
package webbrowser package webbrowser
import ( import (