Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
with:
language: java
repo-url: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}
17 changes: 10 additions & 7 deletions src/main/java/io/github/guacsec/trustifyda/sbom/CycloneDXSbom.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public Sbom addRoot(PackageURL rootRef, String license) {
}
}
bom.getMetadata().setComponent(rootComponent);
bom.getComponents().add(rootComponent);
bom.getDependencies().add(newDependency(rootRef));
return this;
}
Expand Down Expand Up @@ -266,13 +265,12 @@ public Sbom addDependency(PackageURL sourceRef, PackageURL targetRef, String s)
if (s != null) {
scope = Component.Scope.valueOf(s.toUpperCase());
}
String rootCoordinates = root != null ? root.getCoordinates() : null;
Component srcComp = newComponent(sourceRef, scope);
boolean isRootSource = srcComp.getBomRef().equals(rootCoordinates);
Dependency srcDep;
if (bom.getComponents().stream().noneMatch(c -> c.getBomRef().equals(srcComp.getBomRef()))) {
bom.addComponent(srcComp);
srcDep = newDependency(sourceRef);
bom.addDependency(srcDep);
} else {
if (isRootSource
|| bom.getComponents().stream().anyMatch(c -> c.getBomRef().equals(srcComp.getBomRef()))) {
Optional<Dependency> existingDep =
bom.getDependencies().stream()
.filter(d -> d.getRef().equals(srcComp.getBomRef()))
Expand All @@ -283,13 +281,18 @@ public Sbom addDependency(PackageURL sourceRef, PackageURL targetRef, String s)
srcDep = newDependency(sourceRef);
bom.addDependency(srcDep);
}
} else {
bom.addComponent(srcComp);
srcDep = newDependency(sourceRef);
bom.addDependency(srcDep);
}
Dependency targetDep = newDependency(targetRef);
srcDep.addDependency(targetDep);
if (bom.getDependencies().stream().noneMatch(d -> d.getRef().equals(targetDep.getRef()))) {
bom.addDependency(targetDep);
}
if (bom.getComponents().stream().noneMatch(c -> c.getBomRef().equals(targetDep.getRef()))) {
if (!targetDep.getRef().equals(rootCoordinates)
&& bom.getComponents().stream().noneMatch(c -> c.getBomRef().equals(targetDep.getRef()))) {
bom.addComponent(newComponent(targetRef, scope));
}
return this;
Expand Down
8 changes: 0 additions & 8 deletions src/test/resources/msc/golang/expected_sbom_ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:golang/github.com/sample/demo-app@v0.0.0",
"group" : "github.com/sample",
"name" : "demo-app",
"version" : "v0.0.0",
"purl" : "pkg:golang/github.com/sample/demo-app@v0.0.0"
},
{
"type" : "library",
"bom-ref" : "pkg:golang/github.com/gin-gonic/gin@v1.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components": [
{
"type": "application",
"bom-ref": "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0",
"group": "github.com/rhecosystemappeng/saasi",
"name": "deployer",
"version": "v0.0.0",
"purl": "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0"
},
{
"type": "library",
"bom-ref": "pkg:golang/cloud.google.com/go@v0.52.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:golang/golang.org/x/example@v0.0.0",
"group" : "golang.org/x",
"name" : "example",
"version" : "v0.0.0",
"purl" : "pkg:golang/golang.org/x/example@v0.0.0"
},
{
"type" : "library",
"bom-ref" : "pkg:golang/github.com/spf13/cobra@v0.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components": [
{
"type": "application",
"bom-ref": "pkg:golang/golang.org/x/example@v0.0.0",
"group": "golang.org/x",
"name": "example",
"version": "v0.0.0",
"purl": "pkg:golang/golang.org/x/example@v0.0.0"
},
{
"type": "library",
"bom-ref": "pkg:golang/github.com/spf13/viper@v1.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0",
"group" : "github.com/rhecosystemappeng/saasi",
"name" : "deployer",
"version" : "v0.0.0",
"purl" : "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0"
},
{
"type" : "library",
"bom-ref" : "pkg:golang/github.com/davecgh/go-spew@v1.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components": [
{
"type": "application",
"bom-ref": "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0",
"group": "github.com/rhecosystemappeng/saasi",
"name": "deployer",
"version": "v0.0.0",
"purl": "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0"
},
{
"type": "library",
"bom-ref": "pkg:golang/github.com/stretchr/testify@v1.8.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:golang/rhda-test@v0.0.0",
"name" : "rhda-test",
"version" : "v0.0.0",
"purl" : "pkg:golang/rhda-test@v0.0.0"
},
{
"type" : "library",
"bom-ref" : "pkg:golang/github.com/emicklei/go-restful/v3@v3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
}
},
"components": [
{
"type": "application",
"bom-ref": "pkg:golang/rhda-test@v0.0.0",
"name": "rhda-test",
"version": "v0.0.0",
"purl": "pkg:golang/rhda-test@v0.0.0"
},
{
"type": "library",
"bom-ref": "pkg:golang/github.com/json-iterator/go@v1.1.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components": [
{
"type": "application",
"bom-ref": "pkg:golang/github.com/devfile-samples/devfile-sample-go-basic@v0.0.0",
"group": "github.com/devfile-samples",
"name": "devfile-sample-go-basic",
"version": "v0.0.0",
"purl": "pkg:golang/github.com/devfile-samples/devfile-sample-go-basic@v0.0.0"
},
{
"type": "library",
"bom-ref": "pkg:golang/github.com/miekg/dns@v1.1.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components": [
{
"type": "application",
"bom-ref": "pkg:golang/github.com/devfile-samples/devfile-sample-go-basic@v0.0.0",
"group": "github.com/devfile-samples",
"name": "devfile-sample-go-basic",
"version": "v0.0.0",
"purl": "pkg:golang/github.com/devfile-samples/devfile-sample-go-basic@v0.0.0"
},
{
"type": "library",
"bom-ref": "pkg:golang/github.com/ipfs/go-verifcid@v0.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0",
"group" : "github.com/rhecosystemappeng/saasi",
"name" : "deployer",
"version" : "v0.0.0",
"purl" : "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0"
},
{
"type" : "library",
"bom-ref" : "pkg:golang/github.com/davecgh/go-spew@v1.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components": [
{
"type": "application",
"bom-ref": "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0",
"group": "github.com/rhecosystemappeng/saasi",
"name": "deployer",
"version": "v0.0.0",
"purl": "pkg:golang/github.com/rhecosystemappeng/saasi/deployer@v0.0.0"
},
{
"type": "library",
"bom-ref": "pkg:golang/github.com/stretchr/testify@v1.8.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:golang/github.com/devfile-samples/devfile-sample-go-basic@v0.0.0",
"group" : "github.com/devfile-samples",
"name" : "devfile-sample-go-basic",
"version" : "v0.0.0",
"purl" : "pkg:golang/github.com/devfile-samples/devfile-sample-go-basic@v0.0.0"
},
{
"type" : "library",
"bom-ref" : "pkg:golang/github.com/gin-gonic/gin@v1.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components": [
{
"type": "application",
"bom-ref": "pkg:golang/github.com/devfile-samples/devfile-sample-go-basic@v0.0.0",
"group": "github.com/devfile-samples",
"name": "devfile-sample-go-basic",
"version": "v0.0.0",
"purl": "pkg:golang/github.com/devfile-samples/devfile-sample-go-basic@v0.0.0"
},
{
"type": "library",
"bom-ref": "pkg:golang/github.com/ipfs/go-verifcid@v0.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/log4j/log4j@1.2.17",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/log4j/log4j@1.2.17",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/log4j/log4j@1.2.17",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/log4j/log4j@1.2.17",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/io.quarkus/quarkus-hibernate-orm@2.13.5.Final",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/io.quarkus/quarkus-hibernate-orm@2.13.5.Final",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/io.quarkus/quarkus-hibernate-orm@2.13.5.Final",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/io.quarkus/quarkus-hibernate-orm@2.13.5.Final",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
}
},
"components" : [
{
"type" : "application",
"bom-ref" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT",
"group" : "org.acme.dbaas",
"name" : "postgresql-orm-quarkus",
"version" : "1.0.0-SNAPSHOT",
"purl" : "pkg:maven/org.acme.dbaas/postgresql-orm-quarkus@1.0.0-SNAPSHOT"
},
{
"type" : "library",
"bom-ref" : "pkg:maven/io.quarkus/quarkus-hibernate-orm@2.13.5.Final",
Expand Down
Loading
Loading