@@ -17,27 +17,30 @@ 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
- #getAllBomRefs ( bom : Bom ) : Iterable < BomRef > {
26
- const bomRefs = new Set < BomRef > ( )
27
- function iterComponents ( cs : Iterable < Component > ) : void {
28
- for ( const { bomRef, components } of cs ) {
29
- bomRefs . add ( bomRef )
30
- iterComponents ( components )
26
+ * #getAllBomRefs ( bom : Bom ) : Generator < BomRef > {
27
+ // region from components
28
+ if ( bom . metadata . component !== undefined ) {
29
+ yield bom . metadata . component . bomRef
30
+ for ( const { bomRef } of bom . metadata . component . components [ treeIteratorSymbol ] ( ) ) {
31
+ yield bomRef
31
32
}
32
33
}
33
-
34
- if ( bom . metadata . component !== undefined ) {
35
- bomRefs . add ( bom . metadata . component . bomRef )
36
- iterComponents ( bom . metadata . component . components )
34
+ for ( const { bomRef } of bom . components [ treeIteratorSymbol ] ( ) ) {
35
+ yield bomRef
37
36
}
38
- iterComponents ( bom . components )
37
+ // endregion from components
39
38
40
- return bomRefs . values ( )
39
+ // region from vulnerabilities
40
+ for ( const { bomRef } of bom . vulnerabilities ) {
41
+ yield bomRef
42
+ }
43
+ // endregion from vulnerabilities
41
44
}
42
45
43
46
/**
0 commit comments