Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert changes to sort order for /cve and /cve-id endpoints #990

Merged
merged 2 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/controller/cve-id.controller/cve-id.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ async function getFilteredCveId (req, res, next) {
}

const options = CONSTANTS.PAGINATOR_OPTIONS
options.sort = {
'time.created': 1
}
options.sort = { owning_cna: 'asc', cve_id: 'asc' }

try {
const orgShortName = req.ctx.org
Expand Down
8 changes: 7 additions & 1 deletion src/controller/cve.controller/cve.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ async function getFilteredCves (req, res, next) {
// so need to explicitly specify it here and remove it from the options
{
$sort: {
'time.created': 1
'cve.cveMetadata.cveId': 1
}
},
{
$project: {
_id: false,
time: false
}
}
]
Expand Down
16 changes: 16 additions & 0 deletions test-http/src/test/cve_tests/cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,19 @@ def test_cve_get_bad_page():
response_contains_json(res, 'error', 'BAD_INPUT')
response_contains_json(res, 'details', utils.BAD_PAGE_ERROR_DETAILS)



def test_get_cve_ensure_sorted():
""" Should be ordered by CVE ID asc. """
res = requests.get(
f'{env.AWG_BASE_URL}{CVE_URL}/',
headers=utils.BASE_HEADERS,
)

assert res.status_code == 200
records = json.loads(res.content.decode())['cveRecords']

prev_id = "CVE-1900-0000"
for record in records:
assert record['cveMetadata']['cveId'] > prev_id
prev_id = record['cveMetadata']['cveId']