Skip to content

Commit 51b4e03

Browse files
authored
Merge pull request #1803 from CVEProject/jd-update-db-string
Hotfix to adjust database interactions prod - v2.6.4
2 parents fcd5556 + 2c6d5cd commit 51b4e03

7 files changed

Lines changed: 11 additions & 8 deletions

File tree

api-docs/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"openapi": "3.0.2",
33
"info": {
4-
"version": "2.6.3",
4+
"version": "2.6.4",
55
"title": "CVE Services API",
66
"description": "The CVE Services API supports automation tooling for the CVE Program. Credentials are required for most service endpoints. Representatives of <a href='https://www.cve.org/ProgramOrganization/CNAs'>CVE Numbering Authorities (CNAs)</a> should use one of the methods below to obtain credentials: <ul><li>If your organization already has an Organizational Administrator (OA) account for the CVE Services, ask your admin for credentials</li> <li>Contact your Root (<a href='https://www.cve.org/PartnerInformation/ListofPartners/partner/Google'>Google</a>, <a href='https://www.cve.org/PartnerInformation/ListofPartners/partner/INCIBE'>INCIBE</a>, <a href='https://www.cve.org/PartnerInformation/ListofPartners/partner/jpcert'>JPCERT/CC</a>, or <a href='https://www.cve.org/PartnerInformation/ListofPartners/partner/redhat'>Red Hat</a>) or Top-Level Root (<a href='https://www.cve.org/PartnerInformation/ListofPartners/partner/icscert'>CISA ICS</a> or <a href='https://www.cve.org/PartnerInformation/ListofPartners/partner/mitre'>MITRE</a>) to request credentials </ul> <p>CVE data is to be in the JSON 5.2 CVE Record format. Details of the JSON 5.2 schema are located <a href='https://github.com/CVEProject/cve-schema/releases/tag/v5.2.0' target='_blank'>here</a>.</p> <a href='https://cveform.mitre.org/' class='link' target='_blank'>Contact the CVE Services team</a>",
77
"contact": {

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cve-services",
33
"author": "Automation Working Group",
4-
"version": "2.6.3",
4+
"version": "2.6.4",
55
"license": "(CC0)",
66
"devDependencies": {
77
"@faker-js/faker": "^7.6.0",

src/controller/cve-id.controller/cve-id.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async function getFilteredCveId (req, res, next) {
118118
}
119119
}
120120
}
121-
121+
options.readPreference = 'primary'
122122
const agt = setMinAggregateObj(query)
123123
const pg = await cveIdRepo.aggregatePaginate(agt, options)
124124
const payload = {

src/controller/cve.controller/cve.controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ async function getFilteredCves (req, res, next) {
113113
for (let i = 0; i < timeModified.timeStamp.length; i++) {
114114
if (timeModified.dateOperator[i] === 'lt') {
115115
if (cnaModified) {
116+
options.hint = { 'cve.containers.cna.providerMetadata.dateUpdated': 1 }
116117
query['cve.containers.cna.providerMetadata.dateUpdated'] = {}
117118
// Due to this not being the mongo created date object, we need to actually check the "ISO String" version of this _NOT_ the date object that is being created in the middleware
118119
query['cve.containers.cna.providerMetadata.dateUpdated'].$lt = timeModifiedLtDateObject.toISOString()
@@ -121,6 +122,7 @@ async function getFilteredCves (req, res, next) {
121122
}
122123
} else {
123124
if (cnaModified) {
125+
options.hint = { 'cve.containers.cna.providerMetadata.dateUpdated': 1 }
124126
query['cve.containers.cna.providerMetadata.dateUpdated'] = {}
125127
// Due to this not being the mongo created date object, we need to actually check the "ISO String" version of this _NOT_ the date object that is being created in the middleware
126128
query['cve.containers.cna.providerMetadata.dateUpdated'].$gt = timeModifiedGtDateObject.toISOString()
@@ -177,7 +179,7 @@ async function getFilteredCves (req, res, next) {
177179
logger.info({ uuid: req.ctx.uuid, message: 'The cve records count was sent to the user.' })
178180
return res.status(200).json(payload) // only return count number, not the records
179181
}
180-
182+
options.readPreference = 'primary'
181183
const pg = await cveRepo.aggregatePaginate(agt, options)
182184
const payload = {
183185
cveRecords: pg.itemsList.map(val => { return val.cve })

src/repositories/baseRepository.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class BaseRepository {
1616
}
1717

1818
async aggregatePaginate (aggregation, options) {
19-
const arg = this.collection.aggregate(aggregation)
19+
const readPref = options.readPreference ? options.readPreference : ''
20+
const arg = this.collection.aggregate(aggregation).read(readPref)
2021
return this.collection.aggregatePaginate(arg, options)
2122
}
2223

src/swagger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const fullCnaContainerRequest = require('../schemas/cve/create-cve-record-cna-re
1818
/* eslint-disable no-multi-str */
1919
const doc = {
2020
info: {
21-
version: '2.6.3',
21+
version: '2.6.4',
2222
title: 'CVE Services API',
2323
description: "The CVE Services API supports automation tooling for the CVE Program. Credentials are \
2424
required for most service endpoints. Representatives of \

0 commit comments

Comments
 (0)