Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…t-library into cdx1.6
  • Loading branch information
mtsfoni committed Sep 8, 2024
2 parents 2100346 + 78a1f74 commit 30455bb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/CycloneDX.Core/BomUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ internal static Bom CopyBomAndDowngrade(Bom bom)

EnumerateAllComponents(bomCopy, (component) =>
{
#pragma warning disable 618
component.Author = null;
#pragma warning restore 618
component.MimeType = null;
component.Supplier = null;
component.Swid = null;
Expand Down Expand Up @@ -481,7 +483,12 @@ public static void EnumerateAllLicenseChoices(Bom bom, Action<LicenseChoice> cal

public static void EnumerateAllOrganizationalEntity(Bom bom, Action<OrganizationalEntity> callback)
{
if (bom.Metadata?.Manufacture != null) callback(bom.Metadata.Manufacture);
#pragma warning disable 618
if (bom.Metadata?.Manufacture != null)
{
callback(bom.Metadata.Manufacture);
}
#pragma warning restore 618
if (bom.Metadata?.Supplier != null) callback(bom.Metadata.Supplier);

if (bom.Annotations != null)
Expand Down
12 changes: 11 additions & 1 deletion src/CycloneDX.Core/Models/Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,20 @@ public enum ComponentScope
public List<OrganizationalContact> Authors { get; set; }
public bool ShouldSerializeAuthors() { return Authors?.Count > 0; }

[XmlElement("author")]
[Obsolete("This will be removed in a future version. Use @.authors or @.manufacturer instead.")]
[XmlIgnore]
[ProtoMember(5)]
public string Author { get; set; }

#pragma warning disable 618
[EditorBrowsable(EditorBrowsableState.Never)]
[XmlElement("author")]
[JsonIgnore]
public string Author_Xml { get { return Author; } set { Author = value; } }
public bool ShouldSerializeAuthor_Xml() { return Author != null; }
#pragma warning restore 618


[XmlElement("publisher")]
[ProtoMember(6)]
public string Publisher { get; set; }
Expand Down
12 changes: 11 additions & 1 deletion src/CycloneDX.Core/Models/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,20 @@ public List<ProtobufTools> ProtobufTools
public OrganizationalEntity Manufacturer { get; set; }
public bool ShouldSerializeManufacturer() { return Manufacturer != null; }

[XmlElement("manufacture")]
[Obsolete("This will be removed in a future version.Use the @.component.manufacturer instead.")]
[XmlIgnore]
[ProtoMember(5)]
public OrganizationalEntity Manufacture { get; set; }

#pragma warning disable 618
[EditorBrowsable(EditorBrowsableState.Never)]
[XmlElement("manufacture")]
[JsonIgnore]
public OrganizationalEntity Manufacture_Xml { get { return Manufacture; } set { Manufacture = value; } }
public bool ShouldSerializeManufacture_Xml() { return Manufacture != null; }
#pragma warning restore 618


[XmlElement("supplier")]
[ProtoMember(6)]
public OrganizationalEntity Supplier { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ public static void AddSpdxPackages(this Bom bom, SpdxDocument doc)
var originatorMatch = originatorRegex.Match(package.Originator);
if (originatorMatch.Success)
{
#pragma warning disable 618
component.Author = originatorMatch.Groups["name"].ToString();
#pragma warning restore 618
if (package.Originator.ToLowerInvariant().StartsWith("organization:"))
{
#pragma warning disable 618
component.Properties.AddSpdxElement(PropertyTaxonomy.PACKAGE_ORIGINATOR_ORGANIZATION, component.Author);
#pragma warning restore 618
}
component.Properties.AddSpdxElement(PropertyTaxonomy.PACKAGE_ORIGINATOR_EMAIL, originatorMatch.Groups["email"].ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static void AddCycloneDXComponents(this SpdxDocument doc, Bom bom)

// Package Originator
package.Originator = component.Properties?.GetSpdxElement(PropertyTaxonomy.PACKAGE_ORIGINATOR) ?? "NOASSERTION";
#pragma warning disable 618
if (component.Author != null)
{
if (component.Author == component.Properties?.GetSpdxElement(PropertyTaxonomy.PACKAGE_ORIGINATOR_ORGANIZATION))
Expand All @@ -147,7 +148,7 @@ public static void AddCycloneDXComponents(this SpdxDocument doc, Bom bom)
package.Originator = $"Person: {component.Author} ({component.Properties?.GetSpdxElement(PropertyTaxonomy.PACKAGE_ORIGINATOR_EMAIL) ?? ""})";
}
}

#pragma warning restore 618
package.Supplier = component.Properties?.GetSpdxElement(PropertyTaxonomy.PACKAGE_SUPPLIER) ?? "NOASSERTION";
if (component.Supplier != null)
{
Expand Down

0 comments on commit 30455bb

Please sign in to comment.