Skip to content

Commit

Permalink
Merge pull request #193 from siemens/catooltest7.0
Browse files Browse the repository at this point in the history
Bug fix for metadata
  • Loading branch information
Vijayalakshmi027 committed Aug 6, 2024
2 parents 554eb9f + ff12c08 commit 86cef13
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 62 deletions.
4 changes: 2 additions & 2 deletions src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public void SetMetadataInComparisonBOM_GivenBOMWithMetadata_AddsNewMetadataInfoI
Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases, caToolInformation);

//Assert
Assert.That(tools.Name, Is.EqualTo(files.Metadata.Tools[1].Name), "Returns bom with metadata tools");
Assert.That(SiemensSBOM.Name, Is.EqualTo(files.Metadata.Tools[2].Name), "Returns bom with metadata tools");
Assert.That(tools.Name, Is.EqualTo(files.Metadata.Tools[0].Name), "Returns bom with metadata tools");
Assert.That(SiemensSBOM.Name, Is.EqualTo(files.Metadata.Tools[1].Name), "Returns bom with metadata tools");
Assert.That(component.Name, Is.EqualTo(files.Metadata.Component.Name), "Returns bom with metadata component ");
Assert.That(component.Version, Is.EqualTo(files.Metadata.Component.Version), "Returns bom with metadata component ");
Assert.That(component.Type, Is.EqualTo(files.Metadata.Component.Type), "Returns bom with metadata component ");
Expand Down
69 changes: 31 additions & 38 deletions src/LCT.PackageIdentifier/CycloneBomProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,53 @@ public static Bom SetMetadataInComparisonBOM(Bom bom,
CatoolInfo caToolInformation)
{
Logger.Debug("Starting to add metadata info into the BOM");
List<Tool> tools = new List<Tool>();
List<Component> components = new List<Component>();
List<Property> properties = new();
Tool tool = new Tool
Metadata metadata = new Metadata
{
Name = "Clearing Automation Tool",
Version = caToolInformation.CatoolVersion,
Vendor = "Siemens AG",
ExternalReferences = new List<ExternalReference>() { new ExternalReference { Url = "https://github.com/siemens/continuous-clearing", Type = ExternalReference.ExternalReferenceType.Website } }

Tools = new List<Tool>(),
Properties = new List<Property>()
};
tools.Add(tool);
Tool SiemensSBOM = new Tool
{
Name = "Siemens SBOM",
Version = "2.0.0",
Vendor = "Siemens AG",
ExternalReferences = new List<ExternalReference>() { new ExternalReference { Url = "https://sbom.siemens.io/", Type = ExternalReference.ExternalReferenceType.Website } }
};
tools.Add(SiemensSBOM);

SetMetaDataToolsValues(metadata, caToolInformation);

Component component = new Component
{
Name = appSettings.SW360ProjectName,
Version = projectReleases.Version,
Type = Component.Classification.Application
};
components.Add(component);
metadata.Component = component;

if (bom.Metadata != null)
{
bom.Metadata.Tools.AddRange(tools);
bom.Metadata.Component = bom.Metadata.Component ?? new Component();
bom.Metadata.Component.Name = component.Name;
bom.Metadata.Component.Version = component.Version;
bom.Metadata.Component.Type = component.Type;
}
else
{
bom.Metadata = new Metadata
{
Tools = tools,
Component = component,
};
}
Property projectType = new()
Property projectType = new Property
{
Name = "siemens:profile",
Value = "clearing"
};
bom.Metadata.Properties = properties;
bom.Metadata.Properties.Add(projectType);
metadata.Properties.Add(projectType);

bom.Metadata = metadata;
return bom;
}

public static void SetMetaDataToolsValues(Metadata metadata, CatoolInfo caToolInformation)
{
Tool tool = new Tool
{
Name = "Clearing Automation Tool",
Version = caToolInformation.CatoolVersion,
Vendor = "Siemens AG",
ExternalReferences = new List<ExternalReference>() { new ExternalReference { Url = "https://github.com/siemens/continuous-clearing", Type = ExternalReference.ExternalReferenceType.Website } }
};
metadata.Tools.Add(tool);

Tool SiemensSBOM = new Tool
{
Name = "Siemens SBOM",
Version = "2.0.0",
Vendor = "Siemens AG",
ExternalReferences = new List<ExternalReference>() { new ExternalReference { Url = "https://sbom.siemens.io/", Type = ExternalReference.ExternalReferenceType.Website } }
};
metadata.Tools.Add(SiemensSBOM);
}
public static void SetProperties(CommonAppSettings appSettings, Component component, ref List<Component> componentForBOM, string repo = "Not Found in JFrogRepo")
{
List<Property> propList = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@
"metadata": {
"timestamp": "2024-07-06T14:57:50Z",
"tools": [
{
"vendor": "Siemens AG",
"name": "Clearing Automation Tool",
"version": "6.1.0",
"externalReferences": [
{
"url": "https://github.com/siemens/continuous-clearing",
"type": "website"
}
]
},
{
"vendor": "Siemens AG",
"name": "Siemens SBOM",
"version": "2.0.0",
"externalReferences": [
{
"url": "https://sbom.siemens.io/",
"type": "website"
}
]
},
{
"vendor": "Siemens AG",
"name": "Clearing Automation Tool",
Expand Down

0 comments on commit 86cef13

Please sign in to comment.