Common.Sbom.Lib 1.0.0

dotnet add package Common.Sbom.Lib --version 1.0.0
                    
NuGet\Install-Package Common.Sbom.Lib -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Common.Sbom.Lib" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Common.Sbom.Lib" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Common.Sbom.Lib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Common.Sbom.Lib --version 1.0.0
                    
#r "nuget: Common.Sbom.Lib, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Common.Sbom.Lib@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Common.Sbom.Lib&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Common.Sbom.Lib&version=1.0.0
                    
Install as a Cake Tool

Common SBOM Library - Controller Usage

Overview

The Common SBOM Library now includes a ready-to-use controller that can be easily integrated into any microservice with minimal configuration. This eliminates the need to implement SBOM endpoints in each service individually.

Features

  • Automatic SBOM Generation: GET /api/sbom - Generate SBOM for the current service
  • File Downloads: GET /api/sbom/download - Download SBOM as file
  • Validation: POST /api/sbom/validate - Validate SBOM documents
  • Health Checks: GET /api/sbom/health - Service health status
  • Metadata: GET /api/sbom/metadata - Service and configuration info
  • Aggregation: GET /api/sbom/aggregate - Aggregate multiple service SBOMs (optional)

Quick Start

1. Basic Setup (Minimal Configuration)

// Program.cs
using Common.Sbom.Lib.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Add SBOM services with controller
builder.Services.AddSbomServicesWithController();

var app = builder.Build();

// Your other middleware...
app.MapControllers();
app.Run();

Result: SBOM endpoints available at /api/sbom/*

2. Custom Configuration

// Program.cs
builder.Services.AddSbomServicesWithController(
    configuration: builder.Configuration,
    configureControllerOptions: options =>
    {
        options.RoutePrefix = "api/v1/compliance/sbom";
        options.RequireAuthentication = true;
        options.EnableDownload = true;
        options.EnableValidation = false;
        options.EnableAggregation = false; // Individual service mode
        options.CacheDuration = TimeSpan.FromMinutes(10);
        options.ServiceName = "UserService";
        options.ServiceVersion = "2.1.0";
        options.AdditionalMetadata = new Dictionary<string, object>
        {
            ["Environment"] = "Production",
            ["Owner"] = "Platform Team"
        };
    });

3. Advanced Setup (Separate Registration)

// Program.cs
// Add core services first
builder.Services.AddSbomServices(builder.Configuration);

// Add controller with specific configuration
builder.Services.AddSbomController(options =>
{
    options.RoutePrefix = "compliance/sbom";
    options.RequireAuthentication = true;
    options.SupportedFormats = new List<SbomFormat> 
    { 
        SbomFormat.CycloneDx, 
        SbomFormat.Spdx 
    };
});

// Add health checks
builder.Services.AddSbomHealthChecks();

Available Endpoints

Core Endpoints (Always Available)

Method Endpoint Description
GET /api/sbom Get SBOM for current service
GET /api/sbom/metadata Get service metadata and configuration
GET /api/sbom/health Health check for SBOM service

Optional Endpoints (Configurable)

Method Endpoint Description Option
GET /api/sbom/download Download SBOM as file EnableDownload = true
POST /api/sbom/validate Validate SBOM document EnableValidation = true
GET /api/sbom/aggregate Get aggregated SBOM EnableAggregation = true

Configuration Options

public class SbomControllerOptions
{
    public string RoutePrefix { get; set; } = "api/sbom";
    public bool EnableController { get; set; } = true;
    public bool EnableDownload { get; set; } = true;
    public bool EnableValidation { get; set; } = true;
    public bool EnableAggregation { get; set; } = false;
    public bool RequireAuthentication { get; set; } = false;
    public bool EnableSwagger { get; set; } = true;
    public TimeSpan CacheDuration { get; set; } = TimeSpan.FromMinutes(5);
    public List<SbomFormat> SupportedFormats { get; set; } = [CycloneDx, Spdx, Json];
    public string ServiceName { get; set; } = ""; // Auto-detected from assembly
    public string ServiceVersion { get; set; } = ""; // Auto-detected from assembly
    public Dictionary<string, object> AdditionalMetadata { get; set; } = new();
}

Authentication Integration

If you enable RequireAuthentication = true, the controller will check User.Identity.IsAuthenticated. Ensure your authentication middleware is configured:

// Add your authentication
builder.Services.AddAuthentication("Bearer")
    .AddJwtBearer("Bearer", options => { /* your config */ });

// Add SBOM with authentication
builder.Services.AddSbomServicesWithController(
    configureControllerOptions: options => 
    {
        options.RequireAuthentication = true;
    });

var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();

Microservices Architecture Benefits

  1. Consistency: All services have identical SBOM endpoints
  2. Zero Code Duplication: One-line setup across all services
  3. Centralized Maintenance: Updates happen in one place
  4. Flexible Configuration: Each service can customize as needed
  5. Security: Centralized authentication and authorization
  6. Compliance: Standardized SBOM generation across the organization

Example Service Integration

// UserService/Program.cs
using Common.Sbom.Lib.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddAuthentication(/* your auth setup */);

// One line to add SBOM functionality!
builder.Services.AddSbomServicesWithController(
    builder.Configuration,
    options => options.RequireAuthentication = true);

var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();
app.MapControllers(); // SBOM controller is automatically included

app.Run();

Testing Your Integration

After integration, test these endpoints:

# Get service SBOM
curl https://your-service/api/sbom

# Get service metadata
curl https://your-service/api/sbom/metadata

# Health check
curl https://your-service/api/sbom/health

# Download SBOM file
curl https://your-service/api/sbom/download?format=CycloneDx

Swagger/OpenAPI Integration

The controller includes Swagger annotations. Your service's Swagger UI will automatically show the SBOM endpoints with full documentation.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 1,074 6/25/2025