Skip to content

Commit defd2b9

Browse files
committed
#1204 removes ajv precision, adds specific enums for CVSS scores in schema
1 parent 70b3ddf commit defd2b9

File tree

4 files changed

+422
-32
lines changed

4 files changed

+422
-32
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const cnaContainerSchema = JSON.parse(fs.readFileSync('src/middleware/schemas/5.
88
const logger = require('../../middleware/logger')
99
const Ajv = require('ajv')
1010
const addFormats = require('ajv-formats')
11-
const ajv = new Ajv({ allErrors: false, multipleOfPrecision: 6 })
11+
const ajv = new Ajv({ allErrors: false })
1212
addFormats(ajv)
1313
const validateRejected = ajv.compile(RejectedSchema)
1414
const validateCnaContainer = ajv.compile(cnaContainerSchema)

src/middleware/schemas/5.1_published_cna_container.json

Lines changed: 210 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -915,9 +915,108 @@
915915
},
916916
"scoreType": {
917917
"type": "number",
918-
"minimum": 0,
919-
"maximum": 10,
920-
"multipleOf": 0.1
918+
"enum": [
919+
0.1,
920+
0.2,
921+
0.3,
922+
0.4,
923+
0.5,
924+
0.6,
925+
0.7,
926+
0.8,
927+
0.9,
928+
1.0,
929+
1.1,
930+
1.2,
931+
1.3,
932+
1.4,
933+
1.5,
934+
1.6,
935+
1.7,
936+
1.8,
937+
1.9,
938+
2.0,
939+
2.1,
940+
2.2,
941+
2.3,
942+
2.4,
943+
2.5,
944+
2.6,
945+
2.7,
946+
2.8,
947+
2.9,
948+
3.0,
949+
3.1,
950+
3.2,
951+
3.3,
952+
3.4,
953+
3.5,
954+
3.6,
955+
3.7,
956+
3.8,
957+
3.9,
958+
4.0,
959+
4.1,
960+
4.2,
961+
4.3,
962+
4.4,
963+
4.5,
964+
4.6,
965+
4.7,
966+
4.8,
967+
4.9,
968+
5.0,
969+
5.1,
970+
5.2,
971+
5.3,
972+
5.4,
973+
5.5,
974+
5.6,
975+
5.7,
976+
5.8,
977+
5.9,
978+
6.0,
979+
6.1,
980+
6.2,
981+
6.3,
982+
6.4,
983+
6.5,
984+
6.6,
985+
6.7,
986+
6.8,
987+
6.9,
988+
7.0,
989+
7.1,
990+
7.2,
991+
7.3,
992+
7.4,
993+
7.5,
994+
7.6,
995+
7.7,
996+
7.8,
997+
7.9,
998+
8.0,
999+
8.1,
1000+
8.2,
1001+
8.3,
1002+
8.4,
1003+
8.5,
1004+
8.6,
1005+
8.7,
1006+
8.8,
1007+
8.9,
1008+
9.0,
1009+
9.1,
1010+
9.2,
1011+
9.3,
1012+
9.4,
1013+
9.5,
1014+
9.6,
1015+
9.7,
1016+
9.8,
1017+
9.9,
1018+
10.0
1019+
]
9211020
},
9221021
"noneScoreType": {
9231022
"type": "number",
@@ -926,27 +1025,123 @@
9261025
},
9271026
"lowScoreType": {
9281027
"type": "number",
929-
"minimum": 0.1,
930-
"maximum": 3.9,
931-
"multipleOf": 0.1
1028+
"enum": [
1029+
0.1,
1030+
0.2,
1031+
0.3,
1032+
0.4,
1033+
0.5,
1034+
0.6,
1035+
0.7,
1036+
0.8,
1037+
0.9,
1038+
1.0,
1039+
1.1,
1040+
1.2,
1041+
1.3,
1042+
1.4,
1043+
1.5,
1044+
1.6,
1045+
1.7,
1046+
1.8,
1047+
1.9,
1048+
2.0,
1049+
2.1,
1050+
2.2,
1051+
2.3,
1052+
2.4,
1053+
2.5,
1054+
2.6,
1055+
2.7,
1056+
2.8,
1057+
2.9,
1058+
3.0,
1059+
3.1,
1060+
3.2,
1061+
3.3,
1062+
3.4,
1063+
3.5,
1064+
3.6,
1065+
3.7,
1066+
3.8,
1067+
3.9
1068+
]
9321069
},
9331070
"mediumScoreType": {
9341071
"type": "number",
935-
"minimum": 4,
936-
"maximum": 6.9,
937-
"multipleOf": 0.1
1072+
"enum": [
1073+
4.0,
1074+
4.1,
1075+
4.2,
1076+
4.3,
1077+
4.4,
1078+
4.5,
1079+
4.6,
1080+
4.7,
1081+
4.8,
1082+
4.9,
1083+
5.0,
1084+
5.1,
1085+
5.2,
1086+
5.3,
1087+
5.4,
1088+
5.5,
1089+
5.6,
1090+
5.7,
1091+
5.8,
1092+
5.9,
1093+
6.0,
1094+
6.1,
1095+
6.2,
1096+
6.3,
1097+
6.4,
1098+
6.5,
1099+
6.6,
1100+
6.7,
1101+
6.8,
1102+
6.9
1103+
]
9381104
},
9391105
"highScoreType": {
9401106
"type": "number",
941-
"minimum": 7,
942-
"maximum": 8.9,
943-
"multipleOf": 0.1
1107+
"enum": [
1108+
7.0,
1109+
7.1,
1110+
7.2,
1111+
7.3,
1112+
7.4,
1113+
7.5,
1114+
7.6,
1115+
7.7,
1116+
7.8,
1117+
7.9,
1118+
8.0,
1119+
8.1,
1120+
8.2,
1121+
8.3,
1122+
8.4,
1123+
8.5,
1124+
8.6,
1125+
8.7,
1126+
8.8,
1127+
8.9
1128+
]
9441129
},
9451130
"criticalScoreType": {
9461131
"type": "number",
947-
"minimum": 9,
948-
"maximum": 10,
949-
"multipleOf": 0.1
1132+
"enum": [
1133+
9.0,
1134+
9.1,
1135+
9.2,
1136+
9.3,
1137+
9.4,
1138+
9.5,
1139+
9.6,
1140+
9.7,
1141+
9.8,
1142+
9.9,
1143+
10.0
1144+
]
9501145
},
9511146
"severityType": {
9521147
"type": "string",

0 commit comments

Comments
 (0)