Skip to content

Commit fad9573

Browse files
committed
Discrimate Vulnerability.bomRefs
Signed-off-by: Xavier Maso <[email protected]>
1 parent ab6809f commit fad9573

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/serialize/baseSerializer.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
import type { Bom, BomRef, Component } from '../models'
20+
import type { Bom, BomRef, Component, Vulnerability } from '../models'
2121
import { BomRefDiscriminator } from './bomRefDiscriminator'
2222
import type { NormalizerOptions, Serializer, SerializerOptions } from './types'
2323

@@ -30,13 +30,22 @@ export abstract class BaseSerializer<NormalizedBom> implements Serializer {
3030
iterComponents(components)
3131
}
3232
}
33+
function iterVulnerabilities (vs: Iterable<Vulnerability.Vulnerability>): void {
34+
for (const { bomRef } of vs) {
35+
bomRefs.add(bomRef)
36+
}
37+
}
3338

3439
if (bom.metadata.component !== undefined) {
3540
bomRefs.add(bom.metadata.component.bomRef)
3641
iterComponents(bom.metadata.component.components)
3742
}
3843
iterComponents(bom.components)
3944

45+
if (bom.vulnerabilities !== undefined) {
46+
iterVulnerabilities(bom.vulnerabilities)
47+
}
48+
4049
return bomRefs.values()
4150
}
4251

0 commit comments

Comments
 (0)