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

#842 Add additional properties to SBOM #846

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
79 changes: 79 additions & 0 deletions CycloneDX/Services/NugetV3Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Diagnostics.Contracts;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -289,6 +290,7 @@ private static Component SetupComponentProperties(Component component, NuspecMod
var title = nuspecModel.nuspecReader.GetTitle();
var summary = nuspecModel.nuspecReader.GetSummary();
var description = nuspecModel.nuspecReader.GetDescription();
var owner = nuspecModel.nuspecReader.GetOwners();
if (!string.IsNullOrEmpty(summary))
{
component.Description = summary;
Expand All @@ -301,7 +303,84 @@ private static Component SetupComponentProperties(Component component, NuspecMod
{
component.Description = title;
}
if (!string.IsNullOrEmpty(owner))
{
component.Publisher = owner;
}
else
{
component.Publisher = component.Author;
}

var releaseNoteType = "internal";
var version = nuspecModel.nuspecReader.GetVersion();
if (version.IsPrerelease)
{
releaseNoteType = "pre-release";
}
else if (version.Minor == 0 && version.Patch == 0)
{
releaseNoteType = "major";
}
else if (version.Minor != 0 && version.Patch == 0)
{
releaseNoteType = "minor";
}
else if (version.Patch != 0)
{
releaseNoteType = "patch";
}
component.ReleaseNotes = new ReleaseNotes
{
Type = releaseNoteType,
Title = version.ToString(),
Tags = nuspecModel.nuspecReader.GetTags().Split(",").ToList(),
Notes = new List<Note>
{
new Note
{
Text = new AttachedText{
Content = nuspecModel.nuspecReader.GetReleaseNotes()
}
}
}
};

var properties = new List<Property>
{
new Property
{
Name = "language",
Value = nuspecModel.nuspecReader.GetLanguage()
},
new Property
{
Name = "minclientVersion",
Value = nuspecModel.nuspecReader.GetMinClientVersion().Version.ToString(),
},
new Property
{
Name = "gitBranch",
Value = nuspecModel.nuspecReader.GetRepositoryMetadata().Branch
},
new Property
{
Name = "gitCommit",
Value = nuspecModel.nuspecReader.GetRepositoryMetadata().Commit
},
new Property
{
Name = "gitRepositoryType",
Value = nuspecModel.nuspecReader.GetRepositoryMetadata().Type
},
new Property
{
Name = "licenceAcceptanceRequired",
Value = nuspecModel.nuspecReader.GetRequireLicenseAcceptance().ToString()
}

};
component.Properties = properties;
return component;
}

Expand Down
Loading