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

Resolves #894 Cve database updates must succeed before Cve-Id database updates #937

Merged
merged 2 commits into from
Dec 1, 2022
Merged
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
13 changes: 7 additions & 6 deletions src/controller/cve.controller/cve.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ async function submitCve (req, res, next) {
return res.status(400).json(error.cveRecordExists())
}

await cveIdRepo.updateByCveId(cveId, { state: state })
await cveRepo.updateByCveId(cveId, newCve, { upsert: true })
await cveIdRepo.updateByCveId(cveId, { state: state })

const responseMessage = {
message: cveId + ' record was successfully created.',
Expand Down Expand Up @@ -382,14 +382,14 @@ async function updateCna (req, res, next) {
return res.status(500).json(error.serverError())
}

await cveRepo.updateByCveId(id, cveModel)
// change cve id state to publish
if (cveId.state === CONSTANTS.CVE_STATES.REJECTED) {
result = await cveIdRepo.updateByCveId(id, { state: CONSTANTS.CVE_STATES.PUBLISHED })
if (!result) {
return res.status(500).json(error.serverError())
}
}
await cveRepo.updateByCveId(id, cveModel)

const responseMessage = {
message: id + ' record was successfully updated.',
Expand Down Expand Up @@ -447,14 +447,15 @@ async function rejectCVE (req, res, next) {
if (!result) {
return res.status(500).json(error.serverError())
}
// Update state of CVE ID
result = await cveIdRepo.updateByCveId(id, { state: CONSTANTS.CVE_STATES.REJECTED })

// Save rejected CVE record object
result = await cveRepo.updateByCveId(id, newCveObj, { upsert: true })
if (!result) {
return res.status(500).json(error.serverError())
}

// Save rejected CVE record object
result = await cveRepo.updateByCveId(id, newCveObj, { upsert: true })
// Update state of CVE ID
result = await cveIdRepo.updateByCveId(id, { state: CONSTANTS.CVE_STATES.REJECTED })
if (!result) {
return res.status(500).json(error.serverError())
}
Expand Down