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

always increment counter for rekor prober #811

Merged
merged 1 commit into from
Nov 1, 2023
Merged
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
10 changes: 6 additions & 4 deletions cmd/prober/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ func fulcioWriteEndpoint(ctx context.Context, priv *ecdsa.PrivateKey) (*x509.Cer
// if a certificate is provided, the Rekor entry will contain that certificate,
// otherwise the provided key is used
func rekorWriteEndpoint(ctx context.Context, cert *x509.Certificate, priv *ecdsa.PrivateKey) error {
verified := "false"
endpoint := rekorEndpoint
hostPath := rekorURL + endpoint
defer func() {
verificationCounter.With(prometheus.Labels{verifiedLabel: verified}).Inc()
}()

body, err := rekorEntryRequest(cert, priv)
if err != nil {
Expand Down Expand Up @@ -170,15 +174,13 @@ func rekorWriteEndpoint(ctx context.Context, cert *x509.Certificate, priv *ecdsa
logEntryAnon = e
break
}
verified := "true"
rekorPubKeys, err := cosign.GetRekorPubs(ctx)
if err != nil {
return fmt.Errorf("getting rekor public keys: %w", err)
}
if err = cosign.VerifyTLogEntryOffline(ctx, &logEntryAnon, rekorPubKeys); err != nil {
verified = "false"
if err = cosign.VerifyTLogEntryOffline(ctx, &logEntryAnon, rekorPubKeys); err == nil {
verified = "true"
}
verificationCounter.With(prometheus.Labels{verifiedLabel: verified}).Inc()
return err
}

Expand Down
Loading