Skip to content
Snippets Groups Projects
Unverified Commit 0c1ff4d2 authored by dlorenc's avatar dlorenc Committed by GitHub
Browse files

Merge pull request #203 from bobcallaway/last_size

Return 400 error if requested tree size > reality
parents ccf05989 5366584c
No related branches found
No related tags found
No related merge requests found
...@@ -34,12 +34,13 @@ const ( ...@@ -34,12 +34,13 @@ const (
trillianUnexpectedResult = "Unexpected result from transparency log" trillianUnexpectedResult = "Unexpected result from transparency log"
failedToGenerateCanonicalEntry = "Error generating canonicalized entry" failedToGenerateCanonicalEntry = "Error generating canonicalized entry"
entryAlreadyExists = "An equivalent entry already exists in the transparency log" entryAlreadyExists = "An equivalent entry already exists in the transparency log"
firstSizeLessThanLastSize = "firstSize(%v) must be less than lastSize(%v)" firstSizeLessThanLastSize = "firstSize(%d) must be less than lastSize(%d)"
malformedUUID = "UUID must be a 64-character hexadecimal string" malformedUUID = "UUID must be a 64-character hexadecimal string"
malformedHash = "Hash must be a 64-character hexadecimal string created from SHA256 algorithm" malformedHash = "Hash must be a 64-character hexadecimal string created from SHA256 algorithm"
malformedPublicKey = "Public key provided could not be parsed" malformedPublicKey = "Public key provided could not be parsed"
failedToGenerateCanonicalKey = "Error generating canonicalized public key" failedToGenerateCanonicalKey = "Error generating canonicalized public key"
redisUnexpectedResult = "Unexpected result from searching index" redisUnexpectedResult = "Unexpected result from searching index"
lastSizeGreaterThanKnown = "The tree size requested(%d) was greater than what is currently observable(%d)"
) )
func errorMsg(message string, code int) *models.Error { func errorMsg(message string, code int) *models.Error {
......
...@@ -21,7 +21,6 @@ import ( ...@@ -21,7 +21,6 @@ import (
"crypto/x509" "crypto/x509"
"encoding/hex" "encoding/hex"
"encoding/pem" "encoding/pem"
"errors"
"fmt" "fmt"
"net/http" "net/http"
...@@ -107,7 +106,10 @@ func GetLogProofHandler(params tlog.GetLogProofParams) middleware.Responder { ...@@ -107,7 +106,10 @@ func GetLogProofHandler(params tlog.GetLogProofParams) middleware.Responder {
proofHashes = append(proofHashes, hex.EncodeToString(hash)) proofHashes = append(proofHashes, hex.EncodeToString(hash))
} }
} else { } else {
return handleRekorAPIError(params, http.StatusInternalServerError, errors.New("grpc call succeeded but no proof returned"), trillianUnexpectedResult) // The proof field may be empty if the requested tree_size was larger than that available at the server
// (e.g. because there is skew between server instances, and an earlier client request was processed by
// a more up-to-date instance). root.TreeSize is the maximum size currently observed
return handleRekorAPIError(params, http.StatusBadRequest, nil, fmt.Sprintf(lastSizeGreaterThanKnown, params.LastSize, root.TreeSize))
} }
consistencyProof := models.ConsistencyProof{ consistencyProof := models.ConsistencyProof{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment