Skip to content

Commit 9910c6a

Browse files
Merge pull request #107 from interlynk-io/fix/asm-dt-integration
Improve sbomasm DT integration. Generated CDX 1.6 compliant sboms.
2 parents 1fa8f14 + b0faf14 commit 9910c6a

File tree

12 files changed

+465
-455
lines changed

12 files changed

+465
-455
lines changed

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ docker run -v .:/app/sboms/ ghcr.io/interlynk-io/sbomasm:v0.1.3 assemble -n "ass
6464
sbomasm assemble -n "mega cdx app" -v "1.0.0" -t "application" -e 1.4 -o final-product.cdx.json sbom1.json sbom2.json sbom3.json
6565
```
6666

67+
#### Dependency Track Integration
68+
69+
Assemble 2 projects from DT into a flat merged assembled sbom, and save the file to local disk.
70+
```sh
71+
sbomasm assemble dt -d -u "http://localhost:8081/" -k "odt_EpqhWc1Meuc50VeD0w5fuyKELt5dbCUb" -n "mega-app" -v "1.0.0
72+
" -t "application" -f -o merged_sbom.json 08c2777b-bc4f-4b98-be54-e3f901736d71 9d94d566-a20c-4b65-b1b8-18dc4e238a55
73+
```
74+
75+
Assemble 2 projects from DT using flat merge and push the assembled sbom to another project
76+
```sh
77+
./build/sbomasm assemble dt -d -u "http://localhost:8081/" -k "odt_EpqhWc1Meuc50VeD0w5fuyKELt5dbCUb" -n "mega-app" -v "1.0.0
78+
" -t "application" -f -o 1379d800-abb0-498b-a6e5-533318670e40 08c2777b-bc4f-4b98-be54-e3f901736d71 9d94d566-a20c-4b65-b1b8-18dc4e238a55
79+
```
80+
6781
### Edit SBOMs
6882
Change the name and version of the primary component.
6983
```sh
@@ -160,14 +174,14 @@ for input and output formats
160174
## Merge Algorithm
161175
The default merge algorithm is `Hierarchical` merge.
162176
163-
| Algo | SBOM Spec | Notes |
164-
|----------|----------|----------|
165-
| Hierarchical | CycloneDX | For each input SBOM, we associate the dependent components with its primary component. This primary component is then included as a dependent of the newly created primary component for the assembled SBOM. |
166-
| Flat | CycloneDX | Provides a flat list of components, duplicates are not removed. |
167-
| Assembly | CycloneDX | Similar to Hierarchical merge, but treats each sbom as not dependent, so no relationships are created with primary. |
168-
| Hierarchical | SPDX | It maintains relationships among all the merged documents. Contains relationship is using to express dependencies. No duplicate components are removed.|
169-
| Flat | SPDX | It creates a flat list of all packages and files. It removes all relationships except the describes relationship|
170-
| Assembly | SPDX | Similar to Hierarchical, except the contains relationship is omitted |
177+
| Algo | SBOM Spec| Duplicates | Notes |
178+
|----------|----------|------|----------|
179+
| Hierarchical | CycloneDX | Not Removed | For each input SBOM, we associate the dependent components with its primary component. This primary component is then included as a dependent of the newly created primary component for the assembled SBOM|
180+
| Flat | CycloneDX | Removed | Provides a flat list of components |
181+
| Assembly | CycloneDX | Removed | Similar to Hierarchical merge, but treats each sbom as not dependent, so no relationships are created with primary. |
182+
| Hierarchical | SPDX | Not Removed | It maintains relationships among all the merged documents. Contains relationship is using to express dependencies. No duplicate components are removed.|
183+
| Flat | SPDX | Not Removed | It creates a flat list of all packages and files. It removes all relationships except the describes relationship|
184+
| Assembly | SPDX | Not Removed | Similar to Hierarchical, except the contains relationship is omitted |
171185
172186
# A complete example/use-case
173187
Interlynk produces a variety of closed-source tools that it offers to its customers. One of its security-conscious customers recognizes the importance of being diligent about the tools running on its network and has asked Interlynk to provide SBOMs for each tool. Interlynk has complied with this request by providing individual SBOMs for each tool it ships to the customer. However, the customer soon realizes that keeping track of so many SBOMs, which they receive at regular intervals, is challenging. To address this issue, the customer automates the process by combining all the SBOMs provided by Interlynk into a single SBOM, which they can monitor more easily using their preferred tool.

cmd/dt.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ Basic Example:
6262
dtParams.PopulateInputField(ctx)
6363

6464
assembleParams, err := extractArgsFromDTtoAssemble(dtParams)
65-
fmt.Println("assemble.Input: ", assembleParams.Input)
6665
if err != nil {
6766
return err
6867
}
@@ -165,12 +164,10 @@ func extractDtArgs(cmd *cobra.Command, args []string) (*dt.Params, error) {
165164
if _, err := uuid.Parse(output); err == nil {
166165
aParams.Upload = true
167166
aParams.UploadProjectID = uuid.MustParse(output)
168-
fmt.Printf("Upload: %v and SBOM to Project ID: %v \n", aParams.Upload, aParams.UploadProjectID)
169167
} else {
170168
// Assume it's a file path
171169
aParams.Output = output
172170
aParams.Upload = false
173-
fmt.Printf("Upload: %v and SBOM to Project ID: %v \n", aParams.Upload, aParams.Output)
174171
}
175172

176173
for _, arg := range args {

go.mod

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require (
1111
github.com/google/go-github/v52 v52.0.0
1212
github.com/google/uuid v1.6.0
1313
github.com/mitchellh/copystructure v1.2.0
14-
github.com/mitchellh/hashstructure/v2 v2.0.2
1514
github.com/pingcap/log v1.1.0
1615
github.com/samber/lo v1.47.0
1716
github.com/spdx/tools-golang v0.5.5
@@ -27,21 +26,17 @@ require (
2726
github.com/anchore/go-struct-converter v0.0.0-20230627203149-c72ef8859ca9 // indirect
2827
github.com/cloudflare/circl v1.3.9 // indirect
2928
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
30-
github.com/davecgh/go-spew v1.1.1 // indirect
3129
github.com/google/go-querystring v1.1.0 // indirect
3230
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3331
github.com/mitchellh/reflectwalk v1.0.2 // indirect
34-
github.com/pmezard/go-difflib v1.0.0 // indirect
3532
github.com/rogpeppe/go-internal v1.12.0 // indirect
3633
github.com/spdx/gordf v0.0.0-20221230105357-b735bd5aac89 // indirect
3734
github.com/spf13/pflag v1.0.5 // indirect
38-
github.com/stretchr/testify v1.9.0
3935
go.uber.org/multierr v1.11.0 // indirect
4036
golang.org/x/crypto v0.26.0 // indirect
4137
golang.org/x/oauth2 v0.22.0 // indirect
4238
golang.org/x/sys v0.24.0 // indirect
4339
golang.org/x/text v0.17.0 // indirect
4440
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
45-
gopkg.in/yaml.v3 v3.0.1 // indirect
4641
sigs.k8s.io/yaml v1.4.0 // indirect
4742
)

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
4848
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
4949
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
5050
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
51-
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
52-
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
5351
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
5452
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
5553
github.com/pingcap/errors v0.11.0 h1:DCJQB8jrHbQ1VVlMFIrbj2ApScNNotVmkSNplu2yUt4=

pkg/assemble/cdx/comp_service.go

Lines changed: 0 additions & 95 deletions
This file was deleted.

pkg/assemble/cdx/interface.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ type MergeSettings struct {
131131
}
132132

133133
func Merge(ms *MergeSettings) error {
134-
merger := newMerge(ms)
135-
136-
merger.loadBoms()
137-
merger.initOutBom()
138-
139134
if len(ms.Output.Spec) > 0 && ms.Output.Spec != "cyclonedx" {
140135
return errors.New("invalid output spec")
141136
}
@@ -144,13 +139,6 @@ func Merge(ms *MergeSettings) error {
144139
return errors.New("invalid CycloneDX spec version")
145140
}
146141

147-
if ms.Assemble.FlatMerge {
148-
return merger.flatMerge()
149-
} else if ms.Assemble.HierarchicalMerge {
150-
return merger.hierarchicalMerge()
151-
} else if ms.Assemble.AssemblyMerge {
152-
return merger.assemblyMerge()
153-
}
154-
155-
return merger.hierarchicalMerge()
142+
merger := newMerge(ms)
143+
return merger.combinedMerge()
156144
}

0 commit comments

Comments
 (0)