Skip to content

Commit b02320a

Browse files
committed
Add maxItems:10 for SearchLogQuery
Signed-off-by: Priya Wadhwa <priya@chainguard.dev>
1 parent 36dfbda commit b02320a

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

openapi.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,21 +519,24 @@ definitions:
519519
properties:
520520
entryUUIDs:
521521
type: array
522+
minItems: 1
523+
maxItems: 10
522524
items:
523525
type: string
524-
minItems: 1
525526
pattern: '^([0-9a-fA-F]{64}|[0-9a-fA-F]{80})$'
526527
logIndexes:
527528
type: array
528529
minItems: 1
530+
maxItems: 10
529531
items:
530532
type: integer
531533
minimum: 0
532534
entries:
533535
type: array
536+
minItems: 1
537+
maxItems: 10
534538
items:
535539
$ref: '#/definitions/ProposedEntry'
536-
minItems: 1
537540

538541
LogInfo:
539542
type: object

pkg/api/entries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func SearchLogQueryHandler(params entries.SearchLogQueryParams) middleware.Respo
322322

323323
totalQueries := len(params.Entry.EntryUUIDs) + len(params.Entry.Entries()) + len(params.Entry.LogIndexes)
324324
if totalQueries > maxSearchQueries {
325-
return handleRekorAPIError(params, http.StatusBadRequest, fmt.Errorf(maxSearchQueryLimit, maxSearchQueries), maxSearchQueryLimit, maxSearchQueries)
325+
return handleRekorAPIError(params, http.StatusUnprocessableEntity, fmt.Errorf(maxSearchQueryLimit, maxSearchQueries), fmt.Sprintf(maxSearchQueryLimit, maxSearchQueries))
326326
}
327327

328328
if len(params.Entry.EntryUUIDs) > 0 || len(params.Entry.Entries()) > 0 {

pkg/generated/models/search_log_query.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/generated/restapi/embedded_spec.go

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,10 +954,10 @@ func TestSearchQueryLimit(t *testing.T) {
954954
if resp.StatusCode != 200 && !test.shouldErr {
955955
t.Fatalf("expected test to pass but it failed")
956956
}
957-
if resp.StatusCode != 400 && test.shouldErr {
957+
if resp.StatusCode != 422 && test.shouldErr {
958958
t.Fatal("expected test to fail but it passed")
959959
}
960-
if test.shouldErr && !strings.Contains(string(c), "more than max allowed") {
960+
if test.shouldErr && !strings.Contains(string(c), "logIndexes in body should have at most 10 items") {
961961
t.Fatal("expected max limit error but didn't get it")
962962
}
963963
})

0 commit comments

Comments
 (0)