Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for metadata #193

Merged
merged 1 commit into from
Aug 6, 2024
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
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
Loading