Repository navigation
Improve /search validation consistency and missing-ID warnings - #187
Open
afoote-mitre wants to merge 5 commits into
Open
afoote-mitre wants to merge 5 commits into
afoote-mitre wants to merge 5 commits into
Conversation
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.
Summary
Address the first five items in #180 for
POST /search, with one commit per item. These changes make errors, boolean inputs, date boundaries, and missing-ID reporting more predictable.Partially addresses #180. Items 6 and 7 remain deferred for team discussion.
Why These Changes Were Needed
/searchnow consistently uses{ "error": "CODE", "message": "Description" }, returning the first error when multiple validations fail. Equivalent trailing-slash and case-insensitive route variants receive the same shape. Clients that previously parsed router errors as arrays must use the documented object shape./webSearcherror handling is unchanged.routes/index.js,routes/index.test.js,api-docs/openapi.test.js,README.md,test/postman/buildCollection.js"abc"and1.5previously received a misleading maximum-limit error. Invalid types, fractional values, and nonpositive values now returnRESULTS_PER_PAGE_INT; positive integers above 500 returnMAX_RESULTS_LIMIT. Valid integer strings remain accepted. Arrays and booleans are rejected before coercion.routes/index.js,routes/index.test.js,README.md,test/postman/buildCollection.jsknownExploitedanddisputedpreviously rejected string booleans accepted by the other three boolean filters. All five now accept JSON booleans and lowercase"true"/"false"strings, normalizing strings before downstream checks. Numbers, null, arrays, and other strings remain invalid. Omitted filters retain their existing behavior.routes/index.js,routes/index.test.js,routes/swagger.js,api-docs/openapi.test.js,README.md,test/postman/buildCollection.jsYYYY-MM-DDand timestamps with seconds, an explicit timezone, and up to three fractional-second digits. Date-only starts become midnight UTC; date-only ends include the full day through23:59:59.999Z. Explicit timestamps retain their exact instant. Range ordering is checked after normalization; impossible dates, timezone-less timestamps, leap seconds, and finer precision remain invalid. This applies to publication, modification, SSVC, and KEV boundaries.utils/searchDates.js,utils/searchDates.test.js,routes/index.js,controllers/middleware.js,utils/errors.js,utils/errors.test.js, route and middleware tests,routes/swagger.js,README.mdutils/searchCveIdWarnings.js,utils/searchCveIdWarnings.test.js,utils/searchQueryBuilder.js,utils/searchQueryBuilder.test.js,controllers/searchController.js,routes/search.integration.test.js,routes/swagger.js,README.md, Postman source and collectionMissing-ID Warning Behavior
CVE_IDS_NOT_RETURNEDwarning and are not included in the additional lookup.CVE_IDS_NOT_FOUNDmeans an ID was absent from the searchable configured index at lookup time, not that it does not exist globally. Existing IDs excluded by filters or pagination do not receive this warning.CVE_ID_AVAILABILITY_UNVERIFIEDidentifies IDs whose verification failed while preserving an otherwise successful search. Incomplete or prematurely terminated lookups are not interpreted as absence. The overall deadline and client cancellation still apply.Date Input Examples
{ "pubStartDate": "2024-01-01", "pubEndDate": "2024-12-31", "lastModStartDate": "2024-01-01T01:00:00+01:00" }The publication boundaries normalize to
2024-01-01T00:00:00.000Zand2024-12-31T23:59:59.999Z. The modification boundary normalizes to2024-01-01T00:00:00.000Z. All boundaries are inclusive.Deferred Items
X-Powered-By, and operational use of User-Agent information remain under discussion.