Skip to content

Commit 3851c14

Browse files
feat(CSAF2.1): #287 add mandatory test 6.1.42 - start error messages with a lower case letter, use an array of type number
1 parent 0af6f00 commit 3851c14

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

csaf_2_1/mandatoryTests/mandatoryTest_6_1_42.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,13 @@ function onlyDifferInQualifiers(firstPurl, secondPurl) {
9999
* differ only in qualifiers to the first URL
100100
*
101101
* @param {Array<string> | undefined} purls PURLs to check
102-
* @return {Array<string>} indexes of the PURLs that differ
102+
* @return {Array<number>} indexes of the PURLs that differ
103103
*/
104104
export function checkPurls(purls) {
105+
/** @type {Array<number>}*/
105106
const invalidPurls = []
106107
if (purls) {
107-
/**
108-
* @type {Array<PackageURL | null>}
109-
*/
108+
/** @type {Array<PackageURL | null>} */
110109
const packageUrls = purls.map((purl) => {
111110
try {
112111
return PackageURL.fromString(purl)
@@ -124,7 +123,7 @@ export function checkPurls(purls) {
124123
for (let i = 1; i < packageUrls.length; i++) {
125124
const packageUrl = packageUrls[i]
126125
if (!packageUrl || !onlyDifferInQualifiers(firstPurls, packageUrl)) {
127-
invalidPurls.push('' + i)
126+
invalidPurls.push(i)
128127
}
129128
}
130129
}
@@ -191,7 +190,7 @@ export function mandatoryTest_6_1_42(doc) {
191190
ctx.isValid = false
192191
ctx.errors.push({
193192
instancePath: `${prefix}/product_identification_helper/purls/${invalidPurlIndex}`,
194-
message: `The PURL differs to the first PURL not only in qualifiers`,
193+
message: 'the PURL differs to the first PURL not only in qualifiers',
195194
})
196195
})
197196
}
@@ -212,7 +211,7 @@ export function mandatoryTest_6_1_42(doc) {
212211
ctx.isValid = false
213212
ctx.errors.push({
214213
instancePath: `${prefix}/product/product_identification_helper/purls/${invalidPurlIndex}`,
215-
message: `The PURL differs to the first PURL not only in qualifiers`,
214+
message: 'the PURL differs to the first PURL not only in qualifiers',
216215
})
217216
})
218217
branch.branches?.forEach((branch, index) => {

tests/csaf_2_1/mandatoryTest_6_1_42.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('mandatoryTest_6_1_42', function () {
3434
'pkg:golang/google.golang.com/genproto#googleapis/api/annotations',
3535
]),
3636
'change in namespace'
37-
).to.eql(['1'])
37+
).to.eql([1])
3838
expect(
3939
checkPurls([
4040
'pkg:npm/%40angular/[email protected]',
@@ -43,6 +43,6 @@ describe('mandatoryTest_6_1_42', function () {
4343
'pkg:npm/%40angular/[email protected]',
4444
]),
4545
'change in version and invalid PURL'
46-
).to.eql(['1', '2', '3'])
46+
).to.eql([1, 2, 3])
4747
})
4848
})

0 commit comments

Comments
 (0)