Skip to content

Commit 9297274

Browse files
authored
Merge pull request #82 from joemiller/joem/lint-fixes
chore: go and goreleaser lint fixes
2 parents d84ec2c + 4030357 commit 9297274

File tree

8 files changed

+60
-52
lines changed

8 files changed

+60
-52
lines changed

.goreleaser.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: 2
2+
13
project_name: yk-attest-verify
24

35
builds:
@@ -30,7 +32,7 @@ builds:
3032
archives:
3133
# binary-only releases - all platforms
3234
- id: binaries
33-
format: binary
35+
formats: [binary]
3436
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
3537
# archive releases containing: binary, readme, and license. tarballs (macos, linux), zip (windows)
3638
- id: archives
@@ -42,7 +44,7 @@ archives:
4244
{{- else }}{{ .Arch }}{{ end }}
4345
format_overrides:
4446
- goos: windows
45-
format: zip
47+
formats: [zip]
4648

4749
checksum:
4850
name_template: "checksums.txt"
@@ -74,6 +76,8 @@ brews:
7476
homepage: "https://github.com/joemiller/yk-attest-verify"
7577
description: "Validate and enforce policy on YubiKey PIV and OpenPGP attestation certificates"
7678

79+
# dockers section temporarily kept - dockers_v2 migration pending
80+
# TODO: migrate to dockers_v2 once structure is confirmed
7781
dockers:
7882
# primary docker image for amd64 arch
7983
- dockerfile: Dockerfile

cmd/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ func (o *result) PrintResultJSON(attestation interface{}) error {
7878
if err != nil {
7979
return err
8080
}
81-
fmt.Fprintf(o.Cmd.OutOrStdout(), "%s\n", data)
81+
fmt.Fprintf(o.Cmd.OutOrStdout(), "%s\n", data) //nolint:errcheck
8282
return nil
8383
}

cmd/pgp.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ func pgpVerify(cmd *cobra.Command, args []string) error {
100100
if sshPubKeyFile != "" {
101101
pubkeyraw, err := os.ReadFile(sshPubKeyFile)
102102
if err != nil {
103-
return fmt.Errorf("Error reading SSH pub key %s: %w", sshPubKeyFile, err)
103+
return fmt.Errorf("error reading SSH pub key %s: %w", sshPubKeyFile, err)
104104
}
105105
sshPubKey, _, _, _, err = ssh.ParseAuthorizedKey(pubkeyraw)
106106
if err != nil {
107-
return fmt.Errorf("Error parsing SSH pub key %s: %w", sshPubKeyFile, err)
107+
return fmt.Errorf("error parsing SSH pub key %s: %w", sshPubKeyFile, err)
108108
}
109109
}
110110

@@ -226,14 +226,14 @@ func pgpVerify(cmd *cobra.Command, args []string) error {
226226
}
227227

228228
func printPGPAttestation(w io.Writer, attestation *pgp.Attestation) {
229-
fmt.Fprintln(w, "YubiKey OPGP Attestation:")
230-
fmt.Fprintf(w, " - Generation Date: %s\n", attestation.GenerationDate)
231-
fmt.Fprintf(w, " - Cardholder : %s\n", attestation.Cardholder)
232-
fmt.Fprintf(w, " - Key slot : %s\n", attestation.Slot)
233-
fmt.Fprintf(w, " - Key source : %s\n", attestation.Keysource)
234-
fmt.Fprintf(w, " - Key fingerprint: %s\n", attestation.Fingerprint)
235-
fmt.Fprintf(w, " - YubiKey Version: v%d.%d.%d\n", attestation.Version.Major, attestation.Version.Minor, attestation.Version.Patch)
236-
fmt.Fprintf(w, " - Serial # : %d\n", attestation.Serial)
237-
fmt.Fprintf(w, " - Formfactor : %s\n", attestation.Formfactor)
238-
fmt.Fprintf(w, " - Touch Policy : %s\n", attestation.TouchPolicy)
229+
fmt.Fprintln(w, "YubiKey OPGP Attestation:") //nolint:errcheck
230+
fmt.Fprintf(w, " - Generation Date: %s\n", attestation.GenerationDate) //nolint:errcheck
231+
fmt.Fprintf(w, " - Cardholder : %s\n", attestation.Cardholder) //nolint:errcheck
232+
fmt.Fprintf(w, " - Key slot : %s\n", attestation.Slot) //nolint:errcheck
233+
fmt.Fprintf(w, " - Key source : %s\n", attestation.Keysource) //nolint:errcheck
234+
fmt.Fprintf(w, " - Key fingerprint: %s\n", attestation.Fingerprint) //nolint:errcheck
235+
fmt.Fprintf(w, " - YubiKey Version: v%d.%d.%d\n", attestation.Version.Major, attestation.Version.Minor, attestation.Version.Patch) //nolint:errcheck
236+
fmt.Fprintf(w, " - Serial # : %d\n", attestation.Serial) //nolint:errcheck
237+
fmt.Fprintf(w, " - Formfactor : %s\n", attestation.Formfactor) //nolint:errcheck
238+
fmt.Fprintf(w, " - Touch Policy : %s\n", attestation.TouchPolicy) //nolint:errcheck
239239
}

cmd/piv.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ func pivVerify(cmd *cobra.Command, args []string) error {
9494
if sshPubKeyFile != "" {
9595
pubkeyraw, err := os.ReadFile(sshPubKeyFile)
9696
if err != nil {
97-
return fmt.Errorf("Error reading SSH pub key %s: %w", sshPubKeyFile, err)
97+
return fmt.Errorf("error reading SSH pub key %s: %w", sshPubKeyFile, err)
9898
}
9999
sshPubKey, _, _, _, err = ssh.ParseAuthorizedKey(pubkeyraw)
100100
if err != nil {
101-
return fmt.Errorf("Error parsing SSH pub key %s: %w", sshPubKeyFile, err)
101+
return fmt.Errorf("error parsing SSH pub key %s: %w", sshPubKeyFile, err)
102102
}
103103
}
104104

@@ -212,11 +212,11 @@ func pivVerify(cmd *cobra.Command, args []string) error {
212212
}
213213

214214
func printPIVAttestation(w io.Writer, attestation *piv.Attestation) {
215-
fmt.Fprintln(w, "YubiKey PIV Attestation:")
216-
fmt.Fprintf(w, " - Key slot : %s\n", attestation.Slot)
217-
fmt.Fprintf(w, " - YubiKey Version: v%d.%d.%d\n", attestation.Version.Major, attestation.Version.Minor, attestation.Version.Patch)
218-
fmt.Fprintf(w, " - Serial # : %d\n", attestation.Serial)
219-
fmt.Fprintf(w, " - Formfactor : %s\n", attestation.Formfactor)
220-
fmt.Fprintf(w, " - PIN Policy : %s\n", attestation.PINPolicy)
221-
fmt.Fprintf(w, " - Touch Policy : %s\n", attestation.TouchPolicy)
215+
fmt.Fprintln(w, "YubiKey PIV Attestation:") //nolint:errcheck
216+
fmt.Fprintf(w, " - Key slot : %s\n", attestation.Slot) //nolint:errcheck
217+
fmt.Fprintf(w, " - YubiKey Version: v%d.%d.%d\n", attestation.Version.Major, attestation.Version.Minor, attestation.Version.Patch) //nolint:errcheck
218+
fmt.Fprintf(w, " - Serial # : %d\n", attestation.Serial) //nolint:errcheck
219+
fmt.Fprintf(w, " - Formfactor : %s\n", attestation.Formfactor) //nolint:errcheck
220+
fmt.Fprintf(w, " - PIN Policy : %s\n", attestation.PINPolicy) //nolint:errcheck
221+
fmt.Fprintf(w, " - Touch Policy : %s\n", attestation.TouchPolicy) //nolint:errcheck
222222
}

pkg/pgp/attestation.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ func (f Formfactor) MarshalJSON() ([]byte, error) {
106106
type TouchPolicy int
107107

108108
// Touch policies supported by this package.
109-
// $ ykman openpgp set-touch
109+
//
110+
// $ ykman openpgp set-touch
110111
const (
111112
TouchPolicyDisabled TouchPolicy = iota // No touch required
112113
TouchPolicyEnabled // Touch required
@@ -302,8 +303,9 @@ func (a *Attestation) addExt(e pkix.Extension) error {
302303

303304
// parseSlot parses the common-name from the attestation cert's subject. The format
304305
// is described in: https://developers.yubico.com/PGP/Attestation.html -
305-
// Subject will be the string "YubiKey OPGP Attestation " with the
306-
// attested slot appended ("SIG", "DEC", or "AUT")
306+
//
307+
// Subject will be the string "YubiKey OPGP Attestation " with the
308+
// attested slot appended ("SIG", "DEC", or "AUT")
307309
func parseSlot(subject string) (Slot, error) {
308310
if len(subject) < 3 {
309311
return Slot(""), fmt.Errorf("subject less than 3 chars, unable to determine slot")
@@ -318,5 +320,5 @@ func parseSlot(subject string) (Slot, error) {
318320
case "AUT":
319321
return SlotAuthenticate, nil
320322
}
321-
return Slot(""), fmt.Errorf("Unknown slot '%v'", slot)
323+
return Slot(""), fmt.Errorf("unknown slot '%v'", slot)
322324
}

pkg/pgp/verify.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ type Policy struct {
2222
// `ykman openpgp attest` command. The AttestSignerCert used to sign the attestation cert (signer)
2323
// can be exported from the Yubikey using the `ykman openpgp export-certificate ATT`:
2424
//
25-
// # create an attestation cert covering the key in the authentication (AUT) key slot
26-
// ykman openpgp attest AUT attest.pem
27-
//
28-
// # export the attestation (ATT) singer cert used to sign the cert above.
29-
// ykman openpgp attest AUT signer.pem
25+
// # create an attestation cert covering the key in the authentication (AUT) key slot
26+
// ykman openpgp attest AUT attest.pem
3027
//
28+
// # export the attestation (ATT) singer cert used to sign the cert above.
29+
// ykman openpgp attest AUT signer.pem
3130
type VerificationRequest struct {
3231
AttestCert *x509.Certificate
3332
AttestSignerCert *x509.Certificate
@@ -40,7 +39,8 @@ type VerificationErrors []error
4039
// Error implements the error interface for VerificationErrors and returns a
4140
// summary of the error messages. To inspect the list of errors individually you
4241
// would cast the err to VerificationError and inspect the list.
43-
// errs := err.(VerificationErrors)
42+
//
43+
// errs := err.(VerificationErrors)
4444
func (ve VerificationErrors) Error() string {
4545
if len(ve) == 0 {
4646
return ""
@@ -108,7 +108,7 @@ verifyCert:
108108

109109
attestation, err := ParseAttestation(req.AttestCert)
110110
if err != nil {
111-
errs = append(errs, fmt.Errorf("Unable to parse attestation cert: %v", err))
111+
errs = append(errs, fmt.Errorf("unable to parse attestation cert: %v", err))
112112
return nil, errs
113113
}
114114

pkg/piv/attestation.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ var (
4040
type Slot string
4141

4242
// Slot represents the YubiKey card slot that is covered by the attestation.
43-
// $ yubico-piv-tool -h
44-
// 9a is for PIV Authentication
45-
// 9c is for Digital Signature (PIN always checked)
46-
// 9d is for Key Management
47-
// 9e is for Card Authentication (PIN never checked)
48-
// 82-95 is for Retired Key Management
49-
// f9 is for Attestation
43+
//
44+
// $ yubico-piv-tool -h
45+
// 9a is for PIV Authentication
46+
// 9c is for Digital Signature (PIN always checked)
47+
// 9d is for Key Management
48+
// 9e is for Card Authentication (PIN never checked)
49+
// 82-95 is for Retired Key Management
50+
// f9 is for Attestation
5051
const (
5152
SlotAuthenticate = Slot("9a")
5253
SlotSignature = Slot("9c")
@@ -282,8 +283,9 @@ func (a *Attestation) addExt(e pkix.Extension) error {
282283

283284
// parseSlot parses the common-name from the attestation cert's subject. The format
284285
// is described in: https://developers.yubico.com/PIV/Introduction/PIV_attestation.html
285-
// Subject will be the string "YubiKey PIV Attestation " with the
286-
// attested slot appended.
286+
//
287+
// Subject will be the string "YubiKey PIV Attestation " with the
288+
// attested slot appended.
287289
func parseSlot(subject string) (Slot, error) {
288290
if len(subject) < 2 {
289291
return Slot(""), fmt.Errorf("subject less than 2 chars, unable to determine slot")
@@ -300,5 +302,5 @@ func parseSlot(subject string) (Slot, error) {
300302
case "9e":
301303
return SlotKeyCardAuth, nil
302304
}
303-
return Slot(""), fmt.Errorf("Unknown slot '%v'", slot)
305+
return Slot(""), fmt.Errorf("unknown slot '%v'", slot)
304306
}

pkg/piv/verify.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ type Policy struct {
4141
//
4242
// Attestation (AttestCert) certs can be generated with the `yubico-piv-tool` utility
4343
//
44-
// # generate an attestation cert against the 9a slot:
45-
// yubico-piv-tool --action=attest --slot=9a >piv-attest.pem
46-
//
47-
// # export the signer cert:
48-
// yubico-piv-tool --action=read-certificate --slot=f9 >piv-attestation-signer.pem
44+
// # generate an attestation cert against the 9a slot:
45+
// yubico-piv-tool --action=attest --slot=9a >piv-attest.pem
4946
//
47+
// # export the signer cert:
48+
// yubico-piv-tool --action=read-certificate --slot=f9 >piv-attestation-signer.pem
5049
type VerificationRequest struct {
5150
AttestCert *x509.Certificate
5251
AttestSignerCert *x509.Certificate
@@ -59,7 +58,8 @@ type VerificationErrors []error
5958
// Error implements the error interface for VerificationErrors and returns a
6059
// summary of the error messages. To inspect the list of errors individually you
6160
// would cast the err to VerificationError and inspect the list.
62-
// errs := err.(VerificationErrors)
61+
//
62+
// errs := err.(VerificationErrors)
6363
func (ve VerificationErrors) Error() string {
6464
if len(ve) == 0 {
6565
return ""
@@ -126,7 +126,7 @@ verifyCert:
126126

127127
attestation, err := ParseAttestation(req.AttestCert)
128128
if err != nil {
129-
errs = append(errs, fmt.Errorf("Unable to parse attestation cert: %v", err))
129+
errs = append(errs, fmt.Errorf("unable to parse attestation cert: %v", err))
130130
return nil, errs
131131
}
132132

0 commit comments

Comments
 (0)