@@ -5,7 +5,7 @@ const errorMsgs = require('../../middleware/errorMessages')
55const { body, param, query } = require ( 'express-validator' )
66const controller = require ( './registry-org.controller' )
77const { parseGetParams, parsePostParams, parseDeleteParams, parseError, isOrgRole } = require ( './registry-org.middleware' )
8- const { toUpperCaseArray, isFlatStringArray } = require ( '../../middleware/middleware' )
8+ const { toUpperCaseArray, toLowerCaseArray , isFlatStringArray } = require ( '../../middleware/middleware' )
99const getConstants = require ( '../../constants' ) . getConstants
1010const CONSTANTS = getConstants ( )
1111
@@ -71,7 +71,7 @@ router.get('/registryOrg',
7171 query ( ) . custom ( ( query ) => { return mw . validateQueryParameterNames ( query , [ 'page' ] ) } ) ,
7272 query ( [ 'page' ] ) . custom ( ( val ) => { return mw . containsNoInvalidCharacters ( val ) } ) ,
7373 query ( [ 'page' ] ) . optional ( ) . isInt ( { min : CONSTANTS . PAGINATOR_PAGE } ) ,
74- // parseError,
74+ parseError ,
7575 parseGetParams ,
7676 controller . ALL_ORGS
7777)
@@ -141,7 +141,7 @@ router.get('/registryOrg/:identifier',
141141 mw . validateUser ,
142142 mw . onlySecretariat ,
143143 param ( [ 'identifier' ] ) . isString ( ) . trim ( ) ,
144- // parseError,
144+ parseError ,
145145 parseGetParams ,
146146 controller . SINGLE_ORG
147147)
@@ -214,14 +214,38 @@ router.post('/registryOrg',
214214 mw . onlySecretariat ,
215215 body ( [ 'short_name' ] ) . isString ( ) . trim ( ) . notEmpty ( ) . isLength ( { min : CONSTANTS . MIN_SHORTNAME_LENGTH , max : CONSTANTS . MAX_SHORTNAME_LENGTH } ) ,
216216 body ( [ 'long_name' ] ) . isString ( ) . trim ( ) . notEmpty ( ) ,
217+ body ( [ 'cve_program_org_function' ] ) . isString ( ) . trim ( ) . default ( 'CNA' ) ,
218+ body ( [ 'root_or_tlr' ] ) . default ( false ) . isBoolean ( ) ,
219+ body ( [ 'oversees' ] ) . default ( [ ] ) . isArray ( ) ,
220+ body (
221+ [
222+ 'charter_or_scope' ,
223+ 'disclosure_policy' ,
224+ 'product_list' ,
225+ 'reports_to' ,
226+ 'contact_info.poc' ,
227+ 'contact_info.poc_email' ,
228+ 'contact_info.poc_phone' ,
229+ 'contact_info.org_email' ,
230+ 'contact_info.website'
231+ ] )
232+ . default ( '' )
233+ . isString ( ) ,
217234 body ( [ 'authority.active_roles' ] ) . optional ( )
218235 . custom ( isFlatStringArray )
219236 . customSanitizer ( toUpperCaseArray )
220237 . custom ( isOrgRole ) ,
221238 body ( [ 'soft_quota' ] ) . optional ( ) . not ( ) . isArray ( ) . isInt ( { min : CONSTANTS . MONGOOSE_VALIDATION . Org_policies_id_quota_min , max : CONSTANTS . MONGOOSE_VALIDATION . Org_policies_id_quota_max } ) . withMessage ( errorMsgs . ID_QUOTA ) ,
222239 body ( [ 'hard_quota' ] ) . optional ( ) . not ( ) . isArray ( ) . isInt ( { min : CONSTANTS . MONGOOSE_VALIDATION . Org_policies_id_quota_min , max : CONSTANTS . MONGOOSE_VALIDATION . Org_policies_id_quota_max } ) . withMessage ( errorMsgs . ID_QUOTA ) ,
223- // TODO: more validation needed?
224- // parseError,
240+ body ( [ 'contact_info.additional_contact_users' ] ) . optional ( )
241+ . custom ( isFlatStringArray ) ,
242+ body ( [ 'contact_info.admins' ] ) . optional ( )
243+ . custom ( isFlatStringArray ) ,
244+ body ( [ 'aliases' ] ) . optional ( )
245+ . custom ( isFlatStringArray )
246+ . customSanitizer ( toLowerCaseArray ) ,
247+ // TO-DO: validate users here once implemented
248+ parseError ,
225249 parsePostParams ,
226250 controller . CREATE_ORG
227251)
@@ -307,8 +331,40 @@ router.put('/registryOrg/:shortname',
307331 mw . validateUser ,
308332 mw . onlySecretariat ,
309333 param ( [ 'shortname' ] ) . isString ( ) . trim ( ) ,
310- // TODO: do more validation here
311- // parseError,
334+ body ( [ 'short_name' ] ) . isString ( ) . trim ( ) . notEmpty ( ) . isLength ( { min : CONSTANTS . MIN_SHORTNAME_LENGTH , max : CONSTANTS . MAX_SHORTNAME_LENGTH } ) ,
335+ body ( [ 'long_name' ] ) . isString ( ) . trim ( ) . notEmpty ( ) ,
336+ body ( [ 'cve_program_org_function' ] ) . isString ( ) . trim ( ) . default ( 'CNA' ) ,
337+ body ( [ 'root_or_tlr' ] ) . default ( false ) . isBoolean ( ) ,
338+ body ( [ 'oversees' ] ) . default ( [ ] ) . isArray ( ) ,
339+ body (
340+ [
341+ 'charter_or_scope' ,
342+ 'disclosure_policy' ,
343+ 'product_list' ,
344+ 'reports_to' ,
345+ 'contact_info.poc' ,
346+ 'contact_info.poc_email' ,
347+ 'contact_info.poc_phone' ,
348+ 'contact_info.org_email' ,
349+ 'contact_info.website'
350+ ] )
351+ . default ( '' )
352+ . isString ( ) ,
353+ body ( [ 'authority.active_roles' ] ) . optional ( )
354+ . custom ( isFlatStringArray )
355+ . customSanitizer ( toUpperCaseArray )
356+ . custom ( isOrgRole ) ,
357+ body ( [ 'soft_quota' ] ) . optional ( ) . not ( ) . isArray ( ) . isInt ( { min : CONSTANTS . MONGOOSE_VALIDATION . Org_policies_id_quota_min , max : CONSTANTS . MONGOOSE_VALIDATION . Org_policies_id_quota_max } ) . withMessage ( errorMsgs . ID_QUOTA ) ,
358+ body ( [ 'hard_quota' ] ) . optional ( ) . not ( ) . isArray ( ) . isInt ( { min : CONSTANTS . MONGOOSE_VALIDATION . Org_policies_id_quota_min , max : CONSTANTS . MONGOOSE_VALIDATION . Org_policies_id_quota_max } ) . withMessage ( errorMsgs . ID_QUOTA ) ,
359+ body ( [ 'contact_info.additional_contact_users' ] ) . optional ( )
360+ . custom ( isFlatStringArray ) ,
361+ body ( [ 'contact_info.admins' ] ) . optional ( )
362+ . custom ( isFlatStringArray ) ,
363+ body ( [ 'aliases' ] ) . optional ( )
364+ . custom ( isFlatStringArray )
365+ . customSanitizer ( toLowerCaseArray ) ,
366+ // TO-DO: validate users here once implemented
367+ parseError ,
312368 parsePostParams ,
313369 parseGetParams ,
314370 controller . UPDATE_ORG
@@ -380,7 +436,7 @@ router.delete('/registryOrg/:identifier',
380436 // TODO: permissions
381437 mw . onlySecretariat ,
382438 param ( [ 'identifier' ] ) . isString ( ) . trim ( ) ,
383- // parseError,
439+ parseError ,
384440 parseDeleteParams ,
385441 controller . DELETE_ORG
386442)
0 commit comments