Skip to content

Commit f7870f7

Browse files
fix: broken authz login found in test
Signed-off-by: Andrew Lilley Brinker <abrinker@mitre.org>
1 parent bbc3d15 commit f7870f7

15 files changed

Lines changed: 444 additions & 205 deletions

File tree

package-lock.json

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

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"standard": "^16.0.3"
2929
},
3030
"dependencies": {
31+
"@types/express": "^5.0.6",
3132
"ajv": "^8.6.2",
3233
"ajv-formats": "^2.1.1",
3334
"argon2": "^0.41.1",
@@ -78,21 +79,20 @@
7879
},
7980
"scripts": {
8081
"action:test": "node node_modules/mocha/bin/mocha test/unit-tests --recursive --exit",
81-
"action:coverage": "NODE_ENV=test node node_modules/nyc/bin/nyc.js --lines=80 node_modules/mocha/bin/mocha.js src/* --recursive --exit",
82-
"action:lint-src": "node node_modules/eslint/bin/eslint.js src/",
82+
"action:coverage": "NODE_ENV=test MONGO_CONN_STRING=mongodb://localhost:27017 MONGO_DB_NAME=cve_test node node_modules/nyc/bin/nyc.js --lines=80 npm run test", "action:lint-src": "node node_modules/eslint/bin/eslint.js src/",
8383
"action:lint-test": "node node_modules/eslint/bin/eslint.js test/",
8484
"action:lint-test-utils": "node node_modules/eslint/bin/eslint.js test-utils/",
8585
"clean": "node node_modules/depcheck/bin/depcheck.js",
8686
"lint:src": "node node_modules/eslint/bin/eslint.js src/ --fix",
8787
"lint:test": "node node_modules/eslint/bin/eslint.js test/ --fix",
8888
"lint:test-utils": "node node_modules/eslint/bin/eslint.js test-utils/ --fix",
89-
"populate:dev": "NODE_ENV=development node-dev src/scripts/populate.js",
89+
"populate:dev": "NODE_ENV=development node-dev src/scripts/populate.mjs",
9090
"migrate:dev": "NODE_ENV=development MONGO_CONN_STRING=mongodb://localhost:27017 MONGO_DB_NAME=cve_dev node-dev src/scripts/migrate.js",
9191
"migrate:test-black-box": "NODE_ENV=development MONGO_CONN_STRING=mongodb://docdb:27017 MONGO_DB_NAME=cve_dev node-dev src/scripts/migrate.js",
9292
"migrate:test": "NODE_ENV=test MONGO_CONN_STRING=mongodb://localhost:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js",
93-
"populate:stage": "NODE_ENV=staging node src/scripts/populate.js",
94-
"populate:int": "NODE_ENV=integration node src/scripts/populate.js",
95-
"populate:prd": "NODE_ENV=production node src/scripts/populate.js",
93+
"populate:stage": "NODE_ENV=staging node src/scripts/populate.mjs",
94+
"populate:int": "NODE_ENV=integration node src/scripts/populate.mjs",
95+
"populate:prd": "NODE_ENV=production node src/scripts/populate.mjs",
9696
"populate-cve:dev": "NODE_ENV=development node-dev src/scripts/populate-cve.js",
9797
"populate-cve:stage": "NODE_ENV=staging node src/scripts/populate-cve.js",
9898
"populate-cve:int": "NODE_ENV=integration node src/scripts/populate-cve.js",
@@ -105,8 +105,8 @@
105105
"start:prd": "node src/swagger.js && NODE_ENV=production node src/scripts/updateOpenapiHost.js && NODE_ENV=production node src/index.js",
106106
"swagger-autogen": "node src/swagger.js",
107107
"test": "NODE_ENV=test mocha --recursive --exit || true",
108-
"test:integration": "NODE_ENV=test node-dev src/scripts/populate.js y; NODE_ENV=test MONGO_CONN_STRING=mongodb://docdb:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js; NODE_ENV=test mocha test/integration-tests --recursive --exit",
109-
"test:integration-local": "NODE_ENV=test node-dev src/scripts/populate.js y; NODE_ENV=test MONGO_CONN_STRING=mongodb://localhost:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js; NODE_ENV=test mocha test/integration-tests --recursive --exit",
108+
"test:integration": "NODE_ENV=test node-dev src/scripts/populate.mjs y; NODE_ENV=test MONGO_CONN_STRING=mongodb://docdb:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js; NODE_ENV=test mocha test/integration-tests --recursive --exit",
109+
"test:integration-local": "NODE_ENV=test node-dev src/scripts/populate.mjs y; NODE_ENV=test MONGO_CONN_STRING=mongodb://localhost:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js; NODE_ENV=test mocha test/integration-tests --recursive --exit",
110110
"test:unit-tests": "NODE_ENV=test mocha test/unit-tests --recursive --exit || true",
111111
"test:coverage": "NODE_ENV=test nyc --reporter=text mocha src/* --recursive --exit || true",
112112
"test:coverage-html": "NODE_ENV=test nyc --reporter=html mocha src/* --recursive --exit || true",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,9 @@ async function sequentialReservation (year, amount, shortName, orgShortName, req
582582
isFull = true
583583

584584
if (isPriority) {
585-
logger.error(JSON.stringify({ message: 'The cve id priority and sequential blocks are full for year ' + year + '. No more priority or sequential ids can be reserved at this time.' }))
585+
logger.error({ message: 'The cve id priority and sequential blocks are full for year ' + year + '. No more priority or sequential ids can be reserved at this time.' })
586586
} else {
587-
logger.error(JSON.stringify({ message: 'The cve id sequential block is full for year ' + year + '. No more sequential ids can be reserved at this time.' }))
587+
logger.error({ message: 'The cve id sequential block is full for year ' + year + '. No more sequential ids can be reserved at this time.' })
588588
}
589589

590590
res.header(CONSTANTS.QUOTA_HEADER, availableIds)
@@ -692,7 +692,7 @@ async function nonSequentialReservation (year, amount, shortName, orgShortName,
692692
isFull = result.isFull
693693

694694
if (isFull) {
695-
logger.error(JSON.stringify({ message: 'The cve id non-sequential block is full for year ' + year + '. No more sequential ids can be reserved at this time.' }))
695+
logger.error({ message: 'The cve id non-sequential block is full for year ' + year + '. No more sequential ids can be reserved at this time.' })
696696
res.header(CONSTANTS.QUOTA_HEADER, availableIds)
697697
return res.status(403).json(error.yearRangeFull(year))
698698
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ async function submitCna (req, res, next) {
556556
result = Cve.validateCveRecord(cveModel.cve)
557557

558558
if (!result.isValid) {
559-
logger.error(JSON.stringify({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' }))
559+
logger.error({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' })
560560
return res.status(400).json(error.invalidCnaContainerJsonSchema(result.errors))
561561
}
562562

@@ -662,7 +662,7 @@ async function updateCna (req, res, next) {
662662
result = Cve.validateCveRecord(cveModel.cve)
663663

664664
if (!result.isValid) {
665-
logger.error(JSON.stringify({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' }))
665+
logger.error({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' })
666666
return res.status(400).json(error.invalidCnaContainerJsonSchema(result.errors))
667667
}
668668

@@ -734,7 +734,7 @@ async function rejectCVE (req, res, next) {
734734

735735
result = Cve.validateCveRecord(newCveObj.cve)
736736
if (!result.isValid) {
737-
logger.error(JSON.stringify({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' }))
737+
logger.error({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' })
738738
return res.status(400).json(error.invalidCnaContainerJsonSchema(result.errors))
739739
}
740740

@@ -809,7 +809,7 @@ async function rejectExistingCve (req, res, next) {
809809

810810
result = Cve.validateCveRecord(updatedCve.cve)
811811
if (!result.isValid) {
812-
logger.error(JSON.stringify({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' }))
812+
logger.error({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' })
813813
return res.status(400).json(error.invalidCnaContainerJsonSchema(result.errors))
814814
}
815815
result = await cveRepo.updateByCveId(id, updatedCve)
@@ -920,7 +920,7 @@ async function insertAdp (req, res, next) {
920920
const cveModel = new Cve({ cve: convertDatesToISO(cveRecord, CONSTANTS.DATE_FIELDS) })
921921
result = Cve.validateCveRecord(cveModel.cve)
922922
if (!result.isValid) {
923-
logger.error(JSON.stringify({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' }))
923+
logger.error({ uuid: req.ctx.uuid, message: 'CVE JSON schema validation FAILED.' })
924924
return res.status(400).json(error.badAdpJson(result.errors))
925925
}
926926

0 commit comments

Comments
 (0)