Skip to content

Commit 04c0425

Browse files
committed
#1557 added check for encoded ':'s
1 parent 59b1dec commit 04c0425

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,20 @@ function purlValidateHelper (affected) {
218218
if (purlObj.version !== undefined) {
219219
throw new Error('The PURL version component is currently not supported by the CVE schema: ' + purlStr)
220220
}
221+
222+
// Check for versions within qualifiers
221223
if (purlObj.qualifiers !== undefined) {
222224
if (Object.keys(purlObj.qualifiers).includes('vers')) {
223225
throw new Error('PURL versions are currently not supported by the CVE schema: ' + purlStr)
224226
}
225227
}
226228

229+
// PackageURL does not properly prevent encoded ':', so check for that here
230+
const encColon = /%3a/i
231+
if (encColon.test(purlStr)) {
232+
throw new Error('Percent-encoded colons are not allowed in a PURL: ' + purlStr)
233+
}
234+
227235
// PackageURL does not properly account for certain Subpath situations
228236
// so adding additional validation to account for them
229237
// Handles PURLs that include a # but no subpath

0 commit comments

Comments
 (0)