Skip to content

Commit e53e207

Browse files
authored
Merge pull request #1070 from CVEProject/prod-staging
Updating to v2.1.4
2 parents 12d439c + b53f7a7 commit e53e207

File tree

8 files changed

+339
-314
lines changed

8 files changed

+339
-314
lines changed

api-docs/openapi.json

Lines changed: 155 additions & 155 deletions
Large diffs are not rendered by default.

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.1.3",
4+
"version": "2.1.4",
55
"license": "(CC0)",
66
"devDependencies": {
77
"apidoc": "^0.53.1",

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

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,47 @@ router.get('/cve-id',
3939
description: 'A filtered list of information about CVE IDs owned by the organization, along with pagination fields if results span multiple pages of data',
4040
content: {
4141
"application/json": {
42-
schema: { $ref: '/schemas/cve-id/list-cve-ids-response.json' }
42+
schema: { $ref: '../schemas/cve-id/list-cve-ids-response.json' }
4343
}
4444
}
4545
}
4646
#swagger.responses[400] = {
4747
description: 'Bad Request',
4848
content: {
4949
"application/json": {
50-
schema: { $ref: '/schemas/errors/bad-request.json' }
50+
schema: { $ref: '../schemas/errors/bad-request.json' }
5151
}
5252
}
5353
}
5454
#swagger.responses[401] = {
5555
description: 'Not Authenticated',
5656
content: {
5757
"application/json": {
58-
schema: { $ref: '/schemas/errors/generic.json' }
58+
schema: { $ref: '../schemas/errors/generic.json' }
5959
}
6060
}
6161
}
6262
#swagger.responses[403] = {
6363
description: 'Forbidden',
6464
content: {
6565
"application/json": {
66-
schema: { $ref: '/schemas/errors/generic.json' }
66+
schema: { $ref: '../schemas/errors/generic.json' }
6767
}
6868
}
6969
}
7070
#swagger.responses[404] = {
7171
description: 'Not Found',
7272
content: {
7373
"application/json": {
74-
schema: { $ref: '/schemas/errors/generic.json' }
74+
schema: { $ref: '../schemas/errors/generic.json' }
7575
}
7676
}
7777
}
7878
#swagger.responses[500] = {
7979
description: 'Internal Server Error',
8080
content: {
8181
"application/json": {
82-
schema: { $ref: '/schemas/errors/generic.json' }
82+
schema: { $ref: '../schemas/errors/generic.json' }
8383
}
8484
}
8585
}
@@ -121,55 +121,55 @@ router.post('/cve-id',
121121
description: 'A list of the newly reserved CVE IDs',
122122
content: {
123123
'application/json': {
124-
schema: { $ref: '/schemas/cve-id/create-cve-ids-response.json' }
124+
schema: { $ref: '../schemas/cve-id/create-cve-ids-response.json' }
125125
}
126126
}
127127
}
128128
#swagger.responses[206] = {
129129
description: 'A partial list of the CVE IDs the IDR service managed to reserve before encountering a case where no more CVE IDs could be reserved',
130130
content: {
131131
'application/json': {
132-
schema: { $ref: '/schemas/cve-id/create-cve-ids-partial-response.json' }
132+
schema: { $ref: '../schemas/cve-id/create-cve-ids-partial-response.json' }
133133
}
134134
}
135135
}
136136
#swagger.responses[400] = {
137137
description: 'Bad Request',
138138
content: {
139139
"application/json": {
140-
schema: { $ref: '/schemas/errors/bad-request.json' }
140+
schema: { $ref: '../schemas/errors/bad-request.json' }
141141
}
142142
}
143143
}
144144
#swagger.responses[401] = {
145145
description: 'Not Authenticated',
146146
content: {
147147
"application/json": {
148-
schema: { $ref: '/schemas/errors/generic.json' }
148+
schema: { $ref: '../schemas/errors/generic.json' }
149149
}
150150
}
151151
}
152152
#swagger.responses[403] = {
153153
description: 'Forbidden',
154154
content: {
155155
"application/json": {
156-
schema: { $ref: '/schemas/errors/generic.json' }
156+
schema: { $ref: '../schemas/errors/generic.json' }
157157
}
158158
}
159159
}
160160
#swagger.responses[404] = {
161161
description: 'Not Found',
162162
content: {
163163
"application/json": {
164-
schema: { $ref: '/schemas/errors/generic.json' }
164+
schema: { $ref: '../schemas/errors/generic.json' }
165165
}
166166
}
167167
}
168168
#swagger.responses[500] = {
169169
description: 'Internal Server Error',
170170
content: {
171171
"application/json": {
172-
schema: { $ref: '/schemas/errors/generic.json' }
172+
schema: { $ref: '../schemas/errors/generic.json' }
173173
}
174174
}
175175
}
@@ -208,55 +208,55 @@ router.get('/cve-id/:id',
208208
description: 'The requested CVE ID information is returned',
209209
content: {
210210
"application/json": {
211-
schema: { $ref: '/schemas/cve-id/get-cve-id-response.json' }
211+
schema: { $ref: '../schemas/cve-id/get-cve-id-response.json' }
212212
}
213213
}
214214
}
215215
#swagger.responses[400] = {
216216
description: 'Bad Request',
217217
content: {
218218
"application/json": {
219-
schema: { $ref: '/schemas/errors/bad-request.json' }
219+
schema: { $ref: '../schemas/errors/bad-request.json' }
220220
}
221221
}
222222
}
223223
#swagger.responses[401] = {
224224
description: 'Not Authenticated',
225225
content: {
226226
"application/json": {
227-
schema: { $ref: '/schemas/errors/generic.json' }
227+
schema: { $ref: '../schemas/errors/generic.json' }
228228
}
229229
}
230230
}
231231
#swagger.responses[403] = {
232232
description: 'Forbidden',
233233
content: {
234234
"application/json": {
235-
schema: { $ref: '/schemas/errors/generic.json' }
235+
schema: { $ref: '../schemas/errors/generic.json' }
236236
}
237237
}
238238
}
239239
#swagger.responses[404] = {
240240
description: 'Not Found',
241241
content: {
242242
"application/json": {
243-
schema: { $ref: '/schemas/errors/generic.json' }
243+
schema: { $ref: '../schemas/errors/generic.json' }
244244
}
245245
}
246246
}
247247
#swagger.responses[429] = {
248248
description: 'Too Many Requests',
249249
content: {
250250
"application/json": {
251-
schema: { $ref: '/schemas/errors/generic.json' }
251+
schema: { $ref: '../schemas/errors/generic.json' }
252252
}
253253
}
254254
}
255255
#swagger.responses[500] = {
256256
description: 'Internal Server Error',
257257
content: {
258258
"application/json": {
259-
schema: { $ref: '/schemas/errors/generic.json' }
259+
schema: { $ref: '../schemas/errors/generic.json' }
260260
}
261261
}
262262
}
@@ -291,47 +291,47 @@ router.put('/cve-id/:id',
291291
description: 'The updated CVE ID information is returned',
292292
content: {
293293
"application/json": {
294-
schema: { $ref: '/schemas/cve-id/update-cve-id-response.json' }
294+
schema: { $ref: '../schemas/cve-id/update-cve-id-response.json' }
295295
}
296296
}
297297
}
298298
#swagger.responses[400] = {
299299
description: 'Bad Request',
300300
content: {
301301
"application/json": {
302-
schema: { $ref: '/schemas/errors/bad-request.json' }
302+
schema: { $ref: '../schemas/errors/bad-request.json' }
303303
}
304304
}
305305
}
306306
#swagger.responses[401] = {
307307
description: 'Not Authenticated',
308308
content: {
309309
"application/json": {
310-
schema: { $ref: '/schemas/errors/generic.json' }
310+
schema: { $ref: '../schemas/errors/generic.json' }
311311
}
312312
}
313313
}
314314
#swagger.responses[403] = {
315315
description: 'Forbidden',
316316
content: {
317317
"application/json": {
318-
schema: { $ref: '/schemas/errors/generic.json' }
318+
schema: { $ref: '../schemas/errors/generic.json' }
319319
}
320320
}
321321
}
322322
#swagger.responses[404] = {
323323
description: 'Not Found',
324324
content: {
325325
"application/json": {
326-
schema: { $ref: '/schemas/errors/generic.json' }
326+
schema: { $ref: '../schemas/errors/generic.json' }
327327
}
328328
}
329329
}
330330
#swagger.responses[500] = {
331331
description: 'Internal Server Error',
332332
content: {
333333
"application/json": {
334-
schema: { $ref: '/schemas/errors/generic.json' }
334+
schema: { $ref: '../schemas/errors/generic.json' }
335335
}
336336
}
337337
}
@@ -375,39 +375,39 @@ router.post('/cve-id-range/:year',
375375
description: 'Bad Request',
376376
content: {
377377
"application/json": {
378-
schema: { $ref: '/schemas/errors/bad-request.json' }
378+
schema: { $ref: '../schemas/errors/bad-request.json' }
379379
}
380380
}
381381
}
382382
#swagger.responses[401] = {
383383
description: 'Not Authenticated',
384384
content: {
385385
"application/json": {
386-
schema: { $ref: '/schemas/errors/generic.json' }
386+
schema: { $ref: '../schemas/errors/generic.json' }
387387
}
388388
}
389389
}
390390
#swagger.responses[403] = {
391391
description: 'Forbidden',
392392
content: {
393393
"application/json": {
394-
schema: { $ref: '/schemas/errors/generic.json' }
394+
schema: { $ref: '../schemas/errors/generic.json' }
395395
}
396396
}
397397
}
398398
#swagger.responses[404] = {
399399
description: 'Not Found',
400400
content: {
401401
"application/json": {
402-
schema: { $ref: '/schemas/errors/generic.json' }
402+
schema: { $ref: '../schemas/errors/generic.json' }
403403
}
404404
}
405405
}
406406
#swagger.responses[500] = {
407407
description: 'Internal Server Error',
408408
content: {
409409
"application/json": {
410-
schema: { $ref: '/schemas/errors/generic.json' }
410+
schema: { $ref: '../schemas/errors/generic.json' }
411411
}
412412
}
413413
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@ function hasSingleEnglishEntry (langsArr) {
9494
return true
9595
}
9696

97+
/**
98+
* Temporary description validator that ensures description fields have at least 1 non-whitespace character
99+
*
100+
* @param {String} descIndex
101+
* @returns true
102+
* @throws Error
103+
*/
104+
function validateDescription (descIndex) {
105+
// For each index, check if it exists, then apply custom validator
106+
return body(descIndex).optional({ nullable: true }).isArray().custom((descriptions, { req, path }) => {
107+
// For each array of descriptions, check if at least one non-whitespace character
108+
for (const desc of descriptions) {
109+
// Some descriptions use 'value' for field name, problemTypes uses 'description'
110+
return (!!desc.value?.trim().length || !!desc.description?.trim().length)
111+
}
112+
})
113+
}
114+
97115
function validateRejectBody (req, res, next) {
98116
const rejectBody = req.body
99117
const result = validateRejected(rejectBody) // validate function is based on custom schema
@@ -136,5 +154,6 @@ module.exports = {
136154
validateCveCnaContainerJsonSchema,
137155
validateUniqueEnglishEntry,
138156
hasSingleEnglishEntry,
157+
validateDescription,
139158
validateRejectBody
140159
}

0 commit comments

Comments
 (0)