Skip to content

Generate a CycloneDX SBOM for the shipped NuGet package#7

Open
grokys wants to merge 2 commits into
mainfrom
sbom
Open

Generate a CycloneDX SBOM for the shipped NuGet package#7
grokys wants to merge 2 commits into
mainfrom
sbom

Conversation

@grokys

@grokys grokys commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary

Adds a CreateSbom nuke target that produces a CycloneDX SBOM for the shipped Avalonia.BuildServices package, as EU Cyber Resilience Act technical-documentation evidence. Uses the shared generator merged in AvaloniaUI/build-common#4; see AvaloniaUI/Avalonia.Controls.TreeDataGrid-Accelerate#169 for the pilot.

  • CreateSbom is .TriggeredBy(CreatePackage), so the existing default target generates and embeds the SBOM with no build-command changes. It runs after RefAssemblyGenerator, so the recorded SHA-512 hashes are those of the binaries actually shipped. The standalone copy lands in artifacts/sbom/ and CI uploads it as an sbom workflow artifact; an identical copy is embedded into the .nupkg at _manifest/cyclonedx/bom.cdx.json.
  • Both constituent projects are scanned: Avalonia.BuildServices and Avalonia.BuildServices.Collector, whose output is bundled into the package''s tools/ folder.
  • Submodule pin: the new build-common submodule points at the head of Support repository layouts beyond src/packages in SBOM generation build-common#5 (2272ff9) rather than main, because this repository keeps its package project under BuildTask/ and needs that PR''s projectSearchDirs parameter (same pin as the Xpf companion PR). Bump to the merge commit once Add copilot GDPR review instructions. #5 lands.
  • AvaloniaUI.Licensing: IL-merged into the shipped assembly and referenced with PrivateAssets="All", so all three of the shared generator''s detection paths miss it — cyclonedx-dotnet excludes it as a dev dependency, it''s absent from the shipped nuspec (the cross-check that rescues it in the other component repos, which use partial PrivateAssets), and the merged bytes live inside the primary assembly the package-content scan deliberately skips. Its code ships regardless, so Build.cs adds it to the SBOM explicitly, reading the version from the csproj''s PackageReference so it can''t drift, and rewrites both the standalone file and the embedded copy.
  • The two shipped binaries appear in the SBOM under names like Avalonia.BuildServices.<guid>@0.0.0.0 — accurate, since RefAssemblyGenerator deliberately randomizes the shipped assemblies'' identities per build; each component carries an avalonia:packagePath property identifying the real file, plus a SHA-512 of the shipped bytes.

Test plan

  • Ran the full nuke build locally: both constituent projects located and scanned, SBOM generated with correct root metadata (MIT licence, supplier, repository URL), 21 resolved NuGet dependencies, both shipped DLLs recorded with SHA-512 hashes in a complete composition, and AvaloniaUI.Licensing@3.0.0-rc2 present with a dependency edge from the root
  • Verified the embedded _manifest/cyclonedx/bom.cdx.json is byte-identical to the standalone copy and json is registered in [Content_Types].xml
  • Verified the CycloneDX tool runs on the same .NET 9 runtime as the rest of the build (no extra SDK needed in CI)

🤖 Generated with Claude Code

Adds a CreateSbom nuke target that produces a CycloneDX SBOM for
Avalonia.BuildServices as EU Cyber Resilience Act evidence, using the
shared generator from AvaloniaUI/build-common#4. The SBOM is written to
artifacts/sbom and embedded into the .nupkg at
_manifest/cyclonedx/bom.cdx.json.

The build-common submodule is pinned to the head of
AvaloniaUI/build-common#5 for its projectSearchDirs parameter, since
this repository keeps its package project under BuildTask/ rather than
the src/ layout the merged generator expects.

AvaloniaUI.Licensing is IL-merged into the shipped assembly and
referenced with PrivateAssets="All", so it is invisible to the shared
generator (excluded as a dev dependency, absent from the nuspec, and
merged into the primary assembly the content scan skips); it is added
to the SBOM explicitly, with the version read from the csproj.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 13:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an automated CycloneDX SBOM generation step to the NUKE build so that each shipped Avalonia.BuildServices NuGet package includes an embedded SBOM (and CI also publishes the standalone SBOM) as technical-documentation evidence.

Changes:

  • Introduces a CreateSbom NUKE target that runs after packaging to generate and embed a CycloneDX SBOM.
  • Adds build-time integration for the CycloneDX tool and shared SBOM generator extensions (via build-common submodule).
  • Updates CI to checkout submodules and upload the generated SBOM as a workflow artifact.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
build/Build.cs Adds CreateSbom target, invokes shared SBOM generator, and post-processes SBOM + embedded copy to include IL-merged AvaloniaUI.Licensing.
build/_build.csproj Downloads CycloneDX tool package and references shared NUKE extensions from build-common.
.nuke/build.schema.json Registers CreateSbom as an executable NUKE target.
.gitmodules Adds build-common as a git submodule.
.github/workflows/ci.yml Enables submodule checkout and uploads standalone SBOM files as CI artifacts.

Comment thread build/Build.cs
If the shared generator ever starts emitting the component itself (e.g.
the reference moves off PrivateAssets="All" and licensing lands back in
the shipped nuspec), skip the manual addition instead of emitting a
duplicate bom-ref, and warn that the step is obsolete.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants