Skip to content

Commit

Permalink
Add-support-for-conan-to-spdx-file (#549)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Oslund <[email protected]>
  • Loading branch information
tarun06 and sfoslund authored Sep 18, 2024
1 parent 3c6bb73 commit ae8c3c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class ScannedComponentExtensions
return component.Component switch
{
CargoComponent cargoComponent => cargoComponent.ToSbomPackage(component),
ConanComponent conanComponent => conanComponent.ToSbomPackage(),
CondaComponent condaComponent => condaComponent.ToSbomPackage(),
DockerImageComponent dockerImageComponent => dockerImageComponent.ToSbomPackage(),
GitComponent gitComponent => gitComponent.ToSbomPackage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ public void CargoComponent_ToSbomPackage()
Assert.AreEqual(cargoComponent.Version, sbomPackage.PackageVersion);
}

[TestMethod]
public void ConanComponent_ToSbomPackage()
{
var md5 = Guid.NewGuid().ToString();
var sha1Hash = Guid.NewGuid().ToString();

var conanComponent = new ConanComponent("name", "version", md5, sha1Hash);
var scannedComponent = new ExtendedScannedComponent() { Component = conanComponent };

var sbomPackage = scannedComponent.ToSbomPackage(new AdapterReport());

Assert.IsNotNull(sbomPackage.Id);
Assert.IsNotNull(sbomPackage.PackageUrl);
Assert.AreEqual(conanComponent.Name, sbomPackage.PackageName);
Assert.AreEqual(conanComponent.Version, sbomPackage.PackageVersion);
Assert.IsNotNull(sbomPackage.Checksum.First(x => x.ChecksumValue == conanComponent.Md5Hash));
Assert.IsNotNull(sbomPackage.Checksum.First(x => x.ChecksumValue == conanComponent.Sha1Hash));
Assert.AreEqual(conanComponent.PackageSourceURL, sbomPackage.PackageSource);
}

[TestMethod]
public void CondaComponent_ToSbomPackage()
{
Expand Down

0 comments on commit ae8c3c3

Please sign in to comment.