chore: fix lint issues in onboarding handler and ca CLI
- commit
- dddcd1ae394fa7ffbded57e210892d16abadf3a4
- author
- brice · · 2026-03-29 17:09 UTC
- parent
- 000e12a
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +5 -5
M internal/adapters/in/cli/ca.go +2 -2
| @@ -91,10 +91,10 @@ func runCAExport(out io.Writer, outPath string) error { | |||
| 91 | 91 | rootPEM := ca.RootCertificate() | |
| 92 | 92 | ||
| 93 | 93 | if outPath != "" { | |
| 94 | - | if err := os.MkdirAll(filepath.Dir(outPath), 0755); err != nil { | |
| 94 | + | if err := os.MkdirAll(filepath.Dir(outPath), 0750); err != nil { | |
| 95 | 95 | return err | |
| 96 | 96 | } | |
| 97 | - | if err := os.WriteFile(outPath, rootPEM, 0644); err != nil { | |
| 97 | + | if err := os.WriteFile(outPath, rootPEM, 0600); err != nil { | |
| 98 | 98 | return err | |
| 99 | 99 | } | |
| 100 | 100 | return cliWriteLine(out, cliRenderSuccess(fmt.Sprintf("Root CA certificate written to %s", outPath))) | |
| @@ -91,10 +91,10 @@ func runCAExport(out io.Writer, outPath string) error { | |||||
| 91 | rootPEM := ca.RootCertificate() | 91 | rootPEM := ca.RootCertificate() | ||
| 92 | 92 | ||||
| 93 | if outPath != "" { | 93 | if outPath != "" { | ||
| 94 | - | if err := os.MkdirAll(filepath.Dir(outPath), 0755); err != nil { | 94 | + | if err := os.MkdirAll(filepath.Dir(outPath), 0750); err != nil { |
| 95 | return err | 95 | return err | ||
| 96 | } | 96 | } | ||
| 97 | - | if err := os.WriteFile(outPath, rootPEM, 0644); err != nil { | 97 | + | if err := os.WriteFile(outPath, rootPEM, 0600); err != nil { |
| 98 | return err | 98 | return err | ||
| 99 | } | 99 | } | ||
| 100 | return cliWriteLine(out, cliRenderSuccess(fmt.Sprintf("Root CA certificate written to %s", outPath))) | 100 | return cliWriteLine(out, cliRenderSuccess(fmt.Sprintf("Root CA certificate written to %s", outPath))) | ||
M internal/adapters/in/http/onboarding/handler.go +3 -3
| @@ -30,7 +30,7 @@ func NewHandler(rootPEM, rootDER []byte, rootCN string, cloudflareCIDRs []*net.I | |||
| 30 | 30 | func (h *Handler) ServeCACert(w http.ResponseWriter, _ *http.Request) { | |
| 31 | 31 | w.Header().Set("Content-Type", "application/x-x509-ca-cert") | |
| 32 | 32 | w.Header().Set("Content-Disposition", "attachment; filename=gordon-ca.crt") | |
| 33 | - | w.Write(h.rootPEM) | |
| 33 | + | _, _ = w.Write(h.rootPEM) | |
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | 36 | // ServeMobileconfig serves an iOS configuration profile with the root CA. | |
| @@ -38,7 +38,7 @@ func (h *Handler) ServeMobileconfig(w http.ResponseWriter, _ *http.Request) { | |||
| 38 | 38 | mc := pkiadapter.GenerateMobileconfig(h.rootDER, h.rootCN) | |
| 39 | 39 | w.Header().Set("Content-Type", "application/x-apple-aspen-config") | |
| 40 | 40 | w.Header().Set("Content-Disposition", "attachment; filename=gordon-ca.mobileconfig") | |
| 41 | - | w.Write(mc) | |
| 41 | + | _, _ = w.Write(mc) | |
| 42 | 42 | } | |
| 43 | 43 | ||
| 44 | 44 | // ServeOnboardingPage serves the CA trust onboarding HTML page. | |
| @@ -49,7 +49,7 @@ func (h *Handler) ServeOnboardingPage(w http.ResponseWriter, r *http.Request) { | |||
| 49 | 49 | host := r.Host | |
| 50 | 50 | redirectURL := fmt.Sprintf("%s://%s/", scheme, host) | |
| 51 | 51 | ||
| 52 | - | fmt.Fprintf(w, `<!DOCTYPE html> | |
| 52 | + | _, _ = fmt.Fprintf(w, `<!DOCTYPE html> | |
| 53 | 53 | <html lang="en"> | |
| 54 | 54 | <head> | |
| 55 | 55 | <meta charset="utf-8"> | |
| @@ -30,7 +30,7 @@ func NewHandler(rootPEM, rootDER []byte, rootCN string, cloudflareCIDRs []*net.I | |||||
| 30 | func (h *Handler) ServeCACert(w http.ResponseWriter, _ *http.Request) { | 30 | func (h *Handler) ServeCACert(w http.ResponseWriter, _ *http.Request) { | ||
| 31 | w.Header().Set("Content-Type", "application/x-x509-ca-cert") | 31 | w.Header().Set("Content-Type", "application/x-x509-ca-cert") | ||
| 32 | w.Header().Set("Content-Disposition", "attachment; filename=gordon-ca.crt") | 32 | w.Header().Set("Content-Disposition", "attachment; filename=gordon-ca.crt") | ||
| 33 | - | w.Write(h.rootPEM) | 33 | + | _, _ = w.Write(h.rootPEM) |
| 34 | } | 34 | } | ||
| 35 | 35 | ||||
| 36 | // ServeMobileconfig serves an iOS configuration profile with the root CA. | 36 | // ServeMobileconfig serves an iOS configuration profile with the root CA. | ||
| @@ -38,7 +38,7 @@ func (h *Handler) ServeMobileconfig(w http.ResponseWriter, _ *http.Request) { | |||||
| 38 | mc := pkiadapter.GenerateMobileconfig(h.rootDER, h.rootCN) | 38 | mc := pkiadapter.GenerateMobileconfig(h.rootDER, h.rootCN) | ||
| 39 | w.Header().Set("Content-Type", "application/x-apple-aspen-config") | 39 | w.Header().Set("Content-Type", "application/x-apple-aspen-config") | ||
| 40 | w.Header().Set("Content-Disposition", "attachment; filename=gordon-ca.mobileconfig") | 40 | w.Header().Set("Content-Disposition", "attachment; filename=gordon-ca.mobileconfig") | ||
| 41 | - | w.Write(mc) | 41 | + | _, _ = w.Write(mc) |
| 42 | } | 42 | } | ||
| 43 | 43 | ||||
| 44 | // ServeOnboardingPage serves the CA trust onboarding HTML page. | 44 | // ServeOnboardingPage serves the CA trust onboarding HTML page. | ||
| @@ -49,7 +49,7 @@ func (h *Handler) ServeOnboardingPage(w http.ResponseWriter, r *http.Request) { | |||||
| 49 | host := r.Host | 49 | host := r.Host | ||
| 50 | redirectURL := fmt.Sprintf("%s://%s/", scheme, host) | 50 | redirectURL := fmt.Sprintf("%s://%s/", scheme, host) | ||
| 51 | 51 | ||||
| 52 | - | fmt.Fprintf(w, `<!DOCTYPE html> | 52 | + | _, _ = fmt.Fprintf(w, `<!DOCTYPE html> |
| 53 | <html lang="en"> | 53 | <html lang="en"> | ||
| 54 | <head> | 54 | <head> | ||
| 55 | <meta charset="utf-8"> | 55 | <meta charset="utf-8"> | ||