Conversation
This adds pagination and filtering for rrtype and sensorid to the REST API.
There was a problem hiding this comment.
Pull Request Overview
This PR extends the REST API to fully mirror GraphQL–style filtering (limit/offset pagination, rrtype and sensor ID filters) and updates tests, helper functions, and module settings to support these features.
- Added URL parameter parsing and pagination logic in
query/query_rest.go - Extended test suite in
query/query_rest_test.gofor rrtype, sensor ID, and pagination - Updated module Go version and cleaned up dependencies
- Enhanced dummy DB search to honor rrtype and sensor ID filters
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/mkjson.py | Switched to python3 shebang and fixed missing .encode() on text before hashing |
| query/query_rest_test.go | Expanded makeRESTQuery signature; added tests for pagination, sensor IDs, and RR types; replaced ioutil with io |
| query/query_rest.go | Introduced parseParams, limitSlice, and updated ServeHTTP to apply new filters and pagination |
| go.mod | Bumped Go toolchain to 1.23; reorganized and expanded require blocks |
| db/db_dummy.go | Improved MockDB.Search to filter by sensor ID and RR type |
| return | ||
| offParams, ok := r.URL.Query()["next"] | ||
| if ok && len(offParams[0]) > 0 { | ||
| offVal, err := strconv.ParseUint(offParams[0], 10, 32) |
There was a problem hiding this comment.
Similarly, parse the offset with 64-bit size (ParseUint(..., 10, 64)) to avoid silently truncating larger values.
Suggested change
| offVal, err := strconv.ParseUint(offParams[0], 10, 32) | |
| offVal, err := strconv.ParseUint(offParams[0], 10, 64) |
Contributor
|
Accepting merge request.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces changes to extend the functionality of the REST API to match the filtering capabilities of the GraphQL API beyond the original CIRCL API.
The PR also introduces simple offset/limit pagination. The pagination is not optimized as in actually changing the backend-facing protocol to have the server optimize the query according to a given cursor (which is probably not too difficult to do but would change the protocol).
Instead, the scope of the queries towards the backend is adjusted.