Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Callaway <bcallaway@google.com>
  • Loading branch information
bobcallaway committed Apr 13, 2022
2 parents a416a7f + faca7f7 commit 630a20b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
23 changes: 19 additions & 4 deletions pkg/api/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,15 @@ func logEntryFromLeaf(ctx context.Context, signer signature.Signer, tc TrillianC
if err != nil {
log.Logger.Errorf("error fetching attestation by key, trying by UUID: %s %s", attKey, err)
// the original attestation implementation stored this by uuid instead of by digest
att, err = storageClient.FetchAttestation(ctx, uuid)
activeTree := fmt.Sprintf("%x", tc.logID)
entryIDstruct, err := sharding.CreateEntryIDFromParts(activeTree, uuid)
if err != nil {
log.Logger.Errorf("error fetching attestation by uuid: %s %s", uuid, err)
err := fmt.Errorf("error creating EntryID from active treeID %v and uuid %v: %w", activeTree, uuid, err)
return nil, err
}
att, err = storageClient.FetchAttestation(ctx, entryIDstruct.UUID)
if err != nil {
log.Logger.Errorf("error fetching attestation by uuid: %s %s", entryIDstruct.UUID, err)
}
}
if err == nil {
Expand Down Expand Up @@ -205,7 +211,15 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl
metricNewEntries.Inc()

queuedLeaf := resp.getAddResult.QueuedLeaf.Leaf

uuid := hex.EncodeToString(queuedLeaf.GetMerkleLeafHash())
activeTree := fmt.Sprintf("%x", tc.logID)
entryIDstruct, err := sharding.CreateEntryIDFromParts(activeTree, uuid)
if err != nil {
err := fmt.Errorf("error creating EntryID from active treeID %v and uuid %v: %w", activeTree, uuid, err)
return nil, handleRekorAPIError(params, http.StatusInternalServerError, err, fmt.Sprintf(validationError, err))
}
entryID := entryIDstruct.ReturnEntryIDString()

// The log index should be the virtual log index across all shards
virtualIndex := sharding.VirtualLogIndex(queuedLeaf.LeafIndex, api.logRanges.ActiveTreeID(), api.logRanges)
Expand All @@ -224,7 +238,7 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl
return
}
for _, key := range keys {
if err := addToIndex(context.Background(), key, uuid); err != nil {
if err := addToIndex(context.Background(), key, entryID); err != nil {
log.RequestIDLogger(params.HTTPRequest).Error(err)
}
}
Expand All @@ -240,9 +254,10 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl
return
}
if err := storeAttestation(context.Background(), attKey, attVal); err != nil {
// entryIDstruct.UUID
log.RequestIDLogger(params.HTTPRequest).Errorf("error storing attestation: %s", err)
} else {
log.RequestIDLogger(params.HTTPRequest).Infof("stored attestation for uuid %s with filename %s", uuid, attKey)
log.RequestIDLogger(params.HTTPRequest).Infof("stored attestation for uuid %s with filename %s", entryIDstruct.UUID, attKey)
}
}()
}
Expand Down
2 changes: 1 addition & 1 deletion release/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ steps:
- '-c'
- |
echo $$GITHUB_TOKEN | docker login ghcr.io -u $$GITHUB_USER --password-stdin \
&& make copy-signed-release-to-ghcr
&& make copy-signed-release-to-ghcr || true
availableSecrets:
secretManager:
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ func TestGet(t *testing.T) {
out := runCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath, "--public-key", pubPath)
outputContains(t, out, "Created entry at")

uuid := getUUIDFromUploadOutput(t, out)
uuid, err := sharding.GetUUIDFromIDString(getUUIDFromUploadOutput(t, out))
if err != nil {
t.Error(err)
}

// since we at least have 1 valid entry, check the log at index 0
runCli(t, "get", "--log-index", "0")
Expand Down

0 comments on commit 630a20b

Please sign in to comment.