Skip to content

Commit

Permalink
Add error messages for failures (#267)
Browse files Browse the repository at this point in the history
Signed-off-by: Hayden Blauzvern <hblauzvern@google.com>
  • Loading branch information
haydentherapper authored Sep 7, 2023
1 parent af8bb3a commit 8320a17
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/rekor/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ func MatchedIndices(logEntries []models.LogEntry, mvs MonitoredValues) ([]Identi

verifiers, err := extractVerifiers(&entry)
if err != nil {
return nil, err
return nil, fmt.Errorf("error extracting verifiers for UUID %s at index %d: %w", uuid, *entry.LogIndex, err)
}
subjects, certs, fps, err := extractAllIdentities(verifiers)
if err != nil {
return nil, err
return nil, fmt.Errorf("error extracting identities for UUID %s at index %d: %w", uuid, *entry.LogIndex, err)
}

for _, monitoredFp := range mvs.Fingerprints {
Expand All @@ -130,7 +130,7 @@ func MatchedIndices(logEntries []models.LogEntry, mvs MonitoredValues) ([]Identi
for _, cert := range certs {
match, sub, iss, err := certMatchesPolicy(cert, monitoredCertID.CertSubject, monitoredCertID.Issuers)
if err != nil {
return nil, err
return nil, fmt.Errorf("error with policy matching for UUID %s at index %d: %w", uuid, *entry.LogIndex, err)
} else if match {
matchedEntries = append(matchedEntries, IdentityEntry{
CertSubject: sub,
Expand All @@ -145,7 +145,7 @@ func MatchedIndices(logEntries []models.LogEntry, mvs MonitoredValues) ([]Identi
for _, monitoredSub := range mvs.Subjects {
regex, err := regexp.Compile(monitoredSub)
if err != nil {
return nil, err
return nil, fmt.Errorf("error compiling regex for UUID %s at index %d: %w", uuid, *entry.LogIndex, err)
}
for _, sub := range subjects {
if regex.MatchString(sub) {
Expand Down

0 comments on commit 8320a17

Please sign in to comment.