@@ -17,25 +17,32 @@ SPDX-License-Identifier: Apache-2.0
17
17
Copyright (c) OWASP Foundation. All Rights Reserved.
18
18
*/
19
19
20
- import type { Bom , BomRef , Component } from '../models'
20
+ import { treeIteratorSymbol } from '../_helpers/tree'
21
+ import type { Bom , BomRef } from '../models'
21
22
import { BomRefDiscriminator } from './bomRefDiscriminator'
22
23
import type { NormalizerOptions , Serializer , SerializerOptions } from './types'
23
24
24
25
export abstract class BaseSerializer < NormalizedBom > implements Serializer {
25
26
#getAllBomRefs ( bom : Bom ) : Iterable < BomRef > {
26
27
const bomRefs = new Set < BomRef > ( )
27
- function iterComponents ( cs : Iterable < Component > ) : void {
28
- for ( const { bomRef, components } of cs ) {
28
+
29
+ // region from components
30
+ if ( bom . metadata . component !== undefined ) {
31
+ bomRefs . add ( bom . metadata . component . bomRef )
32
+ for ( const { bomRef } of bom . metadata . component . components [ treeIteratorSymbol ] ( ) ) {
29
33
bomRefs . add ( bomRef )
30
- iterComponents ( components )
31
34
}
32
35
}
36
+ for ( const { bomRef } of bom . components [ treeIteratorSymbol ] ( ) ) {
37
+ bomRefs . add ( bomRef )
38
+ }
39
+ // endregion from components
33
40
34
- if ( bom . metadata . component !== undefined ) {
35
- bomRefs . add ( bom . metadata . component . bomRef )
36
- iterComponents ( bom . metadata . component . components )
41
+ // region from vulnerabilities
42
+ for ( const { bomRef } of bom . vulnerabilities ) {
43
+ bomRefs . add ( bomRef )
37
44
}
38
- iterComponents ( bom . components )
45
+ // endregion from vulnerabilities
39
46
40
47
return bomRefs . values ( )
41
48
}
0 commit comments