Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add serial number and revision number to svid minting log entries #3699

Merged
merged 4 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/server/api/svid/v1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ func (s *Service) MintX509SVID(ctx context.Context, req *svidv1.MintX509SVIDRequ
}

rpccontext.AddRPCAuditFields(ctx, logrus.Fields{
telemetry.ExpiresAt: x509SVID[0].NotAfter.Unix(),
telemetry.ExpiresAt: x509SVID[0].NotAfter.Format(time.RFC3339),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change intentional? I don't have a strong opinion on the formatting here, the concern from my end is more around backward compatibility for folks using this field today

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just a couple of lines below on line 122 the Expiration is logged in time.RFC3339 format so changed it for consistency's sake after discussing with Ryan. I don't have a strong opinion though, I can easily revert it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha ... alrighty then.

})

rpccontext.AuditRPCWithFields(ctx, commonX509SVIDLogFields)
log.WithField(telemetry.Expiration, x509SVID[0].NotAfter.Format(time.RFC3339)).
WithField(telemetry.SerialNumber, x509SVID[0].SerialNumber.String()).
WithFields(commonX509SVIDLogFields).
Debug("Signed X509 SVID")

Expand Down Expand Up @@ -263,6 +264,8 @@ func (s *Service) newX509SVID(ctx context.Context, param *svidv1.NewX509SVIDPara
}

log.WithField(telemetry.Expiration, x509Svid[0].NotAfter.Format(time.RFC3339)).
WithField(telemetry.SerialNumber, x509Svid[0].SerialNumber.String()).
WithField(telemetry.RevisionNumber, entry.RevisionNumber).
Debug("Signed X509 SVID")

return &svidv1.BatchNewX509SVIDResponse_Result{
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/api/svid/v1/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ func TestServiceMintX509SVID(t *testing.T) {
x509CA := test.ca.X509CA()
now := test.ca.Clock().Now().UTC()
expiredAt := now.Add(test.ca.X509SVIDTTL())
expiresAtStr := strconv.FormatInt(expiredAt.Unix(), 10)
expiresAtStr := expiredAt.Format(time.RFC3339)
customExpiresAt := now.Add(10 * time.Second)
expiresAtCustomStr := strconv.FormatInt(customExpiresAt.Unix(), 10)
expiresAtCustomStr := customExpiresAt.Format(time.RFC3339)

for _, tt := range []struct {
name string
Expand Down