Skip to content

Commit 694e153

Browse files
committed
Added PURL validation to prevent qualifiers with keys and no value
1 parent 240f193 commit 694e153

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,17 @@ function purlValidateHelper (affected) {
219219
throw new Error('The PURL version component is currently not supported by the CVE schema: ' + purlStr)
220220
}
221221

222-
// Check for versions within qualifiers
222+
// Handle qualifier cases
223223
if (purlObj.qualifiers !== undefined) {
224+
// Check for versions within qualifiers
224225
if (Object.keys(purlObj.qualifiers).includes('vers')) {
225226
throw new Error('PURL versions are currently not supported by the CVE schema: ' + purlStr)
226227
}
228+
229+
// Check for qualifier with key but no value
230+
if ((Array.from(parsedPurlArray[4].values()).includes(''))) {
231+
throw new Error('Qualifier keys must have a value: ' + purlStr)
232+
}
227233
}
228234

229235
// PackageURL does not properly prevent encoded ':', so check for that here

0 commit comments

Comments
 (0)