Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maraino committed Mar 8, 2025
1 parent fb0d140 commit a9b37a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
10 changes: 5 additions & 5 deletions kms/cloudkms/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,24 +436,24 @@ func parse(data []byte) ([]AttestationAttribute, error) {
// attestation file.
func parseAttestationV1(data []byte, isSymmetricKey bool) ([]AttestationAttribute, []AttestationAttribute, error) {
// Asymmetric key attestation objects start after 984 bytes.
const CaviumAttestationAsymOffset = 984
const caviumAttestationAsymOffset = 984
// Symmetric key attestation objects start after 24 bytes.
const CaviumAttestationSymOffset = 24
const caviumAttestationSymOffset = 24

if isSymmetricKey {
attributes, _, err := parseV1(data[CaviumAttestationSymOffset:])
attributes, _, err := parseV1(data[caviumAttestationSymOffset:])
if err != nil {
return nil, nil, err
}

Check warning on line 447 in kms/cloudkms/attestation.go

View check run for this annotation

Codecov / codecov/patch

kms/cloudkms/attestation.go#L446-L447

Added lines #L446 - L447 were not covered by tests
return attributes, nil, nil
}

pubAttributes, offset, err := parseV1(data[CaviumAttestationAsymOffset:])
pubAttributes, offset, err := parseV1(data[caviumAttestationAsymOffset:])
if err != nil {
return nil, nil, err
}

Check warning on line 454 in kms/cloudkms/attestation.go

View check run for this annotation

Codecov / codecov/patch

kms/cloudkms/attestation.go#L453-L454

Added lines #L453 - L454 were not covered by tests

privAttributes, _, err := parseV1(data[CaviumAttestationAsymOffset+offset:])
privAttributes, _, err := parseV1(data[caviumAttestationAsymOffset+offset:])
if err != nil {
return nil, nil, err
}

Check warning on line 459 in kms/cloudkms/attestation.go

View check run for this annotation

Codecov / codecov/patch

kms/cloudkms/attestation.go#L458-L459

Added lines #L458 - L459 were not covered by tests
Expand Down
29 changes: 15 additions & 14 deletions kms/cloudkms/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,21 +722,22 @@ func TestValidateCaviumRoot(t *testing.T) {
require.NoError(t, err)

for _, f := range r.File {
if f.Name == "liquid_security_certificate.crt" {
rc, err := f.Open()
require.NoError(t, err)
t.Cleanup(func() {
assert.NoError(t, rc.Close())
})
b, err = io.ReadAll(rc)
require.NoError(t, err)

cert, err := pemutil.ParseCertificate(b)
require.NoError(t, err)

assert.Equal(t, root, cert)
return
if f.Name != "liquid_security_certificate.crt" {
continue
}
rc, err := f.Open()
require.NoError(t, err)
t.Cleanup(func() {
assert.NoError(t, rc.Close())
})
b, err = io.ReadAll(rc)
require.NoError(t, err)

cert, err := pemutil.ParseCertificate(b)
require.NoError(t, err)

assert.Equal(t, root, cert)
return
}

t.Error("certificate not found")
Expand Down

0 comments on commit a9b37a0

Please sign in to comment.