From 20af933e5420cce07447b4296240d95c0c1d05f6 Mon Sep 17 00:00:00 2001 From: Yujian Zhao Date: Fri, 1 Nov 2024 18:27:51 +0000 Subject: [PATCH] Fix lint and style errors --- metadata/decode.go | 2 +- protocol/attestation_androidkey_test.go | 8 +++++--- protocol/attestation_apple.go | 2 +- protocol/client.go | 2 +- protocol/options.go | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/metadata/decode.go b/metadata/decode.go index 24291f2e..7d4b3517 100644 --- a/metadata/decode.go +++ b/metadata/decode.go @@ -109,7 +109,7 @@ func (d *Decoder) DecodeBytes(bytes []byte) (payload *PayloadJSON, err error) { if x5c, ok = token.Header[HeaderX509Certificate].([]any); !ok { // If that attribute is missing as well, Metadata TOC signing trust anchor is considered the TOC signing certificate chain. - chain[0] = d.root + chain = []any{d.root} } else { chain = x5c } diff --git a/protocol/attestation_androidkey_test.go b/protocol/attestation_androidkey_test.go index e6fd426c..bdec9bcd 100644 --- a/protocol/attestation_androidkey_test.go +++ b/protocol/attestation_androidkey_test.go @@ -57,9 +57,11 @@ func TestVerifyAndroidKeyFormat(t *testing.T) { if got != tt.want { t.Errorf("verifyAndroidKeyFormat() got = %v, want %v", got, tt.want) } - //if !reflect.DeepEqual(got1, tt.want1) { - // t.Errorf("verifySafetyNetFormat() got1 = %v, want %v", got1, tt.want1) - //} + /* + if !reflect.DeepEqual(got1, tt.want1) { + t.Errorf("verifySafetyNetFormat() got1 = %v, want %v", got1, tt.want1) + } + */ }) } } diff --git a/protocol/attestation_apple.go b/protocol/attestation_apple.go index c828e7b1..9b80b288 100644 --- a/protocol/attestation_apple.go +++ b/protocol/attestation_apple.go @@ -77,7 +77,7 @@ func verifyAppleFormat(att AttestationObject, clientDataHash []byte, _ metadata. return "", nil, ErrAttestationFormat.WithDetails("Unable to parse apple attestation certificate extensions") } - if !bytes.Equal(decoded.Nonce, nonce[:]) || err != nil { + if !bytes.Equal(decoded.Nonce, nonce[:]) { return "", nil, ErrInvalidAttestation.WithDetails("Attestation certificate does not contain expected nonce") } diff --git a/protocol/client.go b/protocol/client.go index ab9b6ab2..7e8356a3 100644 --- a/protocol/client.go +++ b/protocol/client.go @@ -16,7 +16,7 @@ type CollectedClientData struct { // Type the string "webauthn.create" when creating new credentials, // and "webauthn.get" when getting an assertion from an existing credential. The // purpose of this member is to prevent certain types of signature confusion attacks - //(where an attacker substitutes one legitimate signature for another). + // (where an attacker substitutes one legitimate signature for another). Type CeremonyType `json:"type"` Challenge string `json:"challenge"` Origin string `json:"origin"` diff --git a/protocol/options.go b/protocol/options.go index 9085fcdc..178cf466 100644 --- a/protocol/options.go +++ b/protocol/options.go @@ -194,7 +194,7 @@ type AttestationFormat string const ( // AttestationFormatPacked is the "packed" attestation statement format is a WebAuthn-optimized format for // attestation. It uses a very compact but still extensible encoding method. This format is implementable by - //authenticators with limited resources (e.g., secure elements). + // authenticators with limited resources (e.g., secure elements). AttestationFormatPacked AttestationFormat = "packed" // AttestationFormatTPM is the TPM attestation statement format returns an attestation statement in the same format