Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rekor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SafSec
rekor
Commits
6093a339
Unverified
Commit
6093a339
authored
2 years ago
by
priyawadhwa
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Return 404 if entry isn't found in log (#915)
Signed-off-by:
Priya Wadhwa
<
priya@chainguard.dev
>
parent
c962a689
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/api/entries.go
+7
-3
7 additions, 3 deletions
pkg/api/entries.go
tests/e2e_test.go
+1
-1
1 addition, 1 deletion
tests/e2e_test.go
with
8 additions
and
4 deletions
pkg/api/entries.go
+
7
−
3
View file @
6093a339
...
...
@@ -299,8 +299,11 @@ func getEntryURL(locationURL url.URL, uuid string) strfmt.URI {
func
GetLogEntryByUUIDHandler
(
params
entries
.
GetLogEntryByUUIDParams
)
middleware
.
Responder
{
logEntry
,
err
:=
retrieveLogEntry
(
params
.
HTTPRequest
.
Context
(),
params
.
EntryUUID
)
if
err
!=
nil
{
if
errors
.
Is
(
err
,
ErrNotFound
)
{
return
handleRekorAPIError
(
params
,
http
.
StatusNotFound
,
err
,
""
)
}
if
_
,
ok
:=
(
err
)
.
(
types
.
ValidationError
);
ok
{
return
handleRekorAPIError
(
params
,
http
.
StatusBadRequest
,
err
,
"incorrectly formatted uuid %s"
,
params
.
EntryUUID
)
return
handleRekorAPIError
(
params
,
http
.
StatusBadRequest
,
err
,
fmt
.
Sprintf
(
"incorrectly formatted uuid %s"
,
params
.
EntryUUID
)
,
params
.
EntryUUID
)
}
return
handleRekorAPIError
(
params
,
http
.
StatusInternalServerError
,
err
,
"ID %s not found in any known trees"
,
params
.
EntryUUID
)
}
...
...
@@ -448,7 +451,7 @@ func retrieveLogEntryByIndex(ctx context.Context, logIndex int) (models.LogEntry
func
retrieveLogEntry
(
ctx
context
.
Context
,
entryUUID
string
)
(
models
.
LogEntry
,
error
)
{
uuid
,
err
:=
sharding
.
GetUUIDFromIDString
(
entryUUID
)
if
err
!=
nil
{
return
models
.
LogEntry
{}
,
sharding
.
ErrPlainUUID
return
nil
,
sharding
.
ErrPlainUUID
}
// Get the tree ID and check that shard for the entry
...
...
@@ -469,9 +472,10 @@ func retrieveLogEntry(ctx context.Context, entryUUID string) (models.LogEntry, e
}
return
logEntry
,
nil
}
return
nil
,
ErrNotFound
}
return
models
.
LogEntry
{}
,
err
return
nil
,
err
}
func
retrieveUUIDFromTree
(
ctx
context
.
Context
,
uuid
string
,
tid
int64
)
(
models
.
LogEntry
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/e2e_test.go
+
1
−
1
View file @
6093a339
...
...
@@ -691,7 +691,7 @@ func TestGetNonExistantIndex(t *testing.T) {
func
TestGetNonExistantUUID
(
t
*
testing
.
T
)
{
// this uuid is extremely likely to not exist
out
:=
runCliErr
(
t
,
"get"
,
"--uuid"
,
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
)
outputContains
(
t
,
out
,
"40
0
"
)
outputContains
(
t
,
out
,
"40
4
"
)
}
func
TestEntryUpload
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment