Skip to content

Commit 5fbf21e

Browse files
authored
Update release notes and Readme (#236)
1 parent f323a74 commit 5fbf21e

File tree

2 files changed

+79
-12
lines changed

2 files changed

+79
-12
lines changed

.github/workflows/BuildAndPack.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,26 +121,24 @@ jobs:
121121
with:
122122
fail_on_unmatched_files: true
123123
files: |
124-
artifacts/packages/*.nupkg
125124
artifacts/sboms/netescapades-aspnetcore-securityheaders.bom.json
126125
artifacts/sboms/netescapades-aspnetcore-securityheaders-taghelpers.bom.json
127126
body: |
128127
${{steps.release_notes.outputs.content}}
129128
130129
---
131130
132-
All NuGet packages are available on https://www.nuget.org.
133-
You can view the provenance attestation for [the NuGet packages here](${{ steps.artifact-attestation.outputs.attestation-url }}).
134-
135-
To verify the provenance for a given downloaded NuGet package, you can use the GitHub CLI:
136-
137-
```bash
138-
gh attestation verify --owner andrewlock <filename-or-url>
139-
```
131+
All NuGet packages are available on https://www.nuget.org. You can view the build provenance attestation
132+
for [the NuGet packages here](${{ steps.artifact-attestation.outputs.attestation-url }}).
140133
141-
The Software Bill of Materials (SBOM) is available for each package in CycloneDX format, and is attached to the relase.
142-
View the provenance attestation for [the NetEscapades.AspNetCore.SecurityHeaders SBOM here](${{ steps.nupkg-sbom.outputs.attestation-url }}).
143-
and for [the NetEscapades.AspNetCore.SecurityHeaders.TagHelpers SBOM here](${{ steps.taghelpers-sbom.outputs.attestation-url }}).
134+
The Software Bill of Materials (SBOM) is available for each package in CycloneDX format. View the provenance
135+
attestations for the SBOMs here:
136+
- [NetEscapades.AspNetCore.SecurityHeaders SBOM](${{ steps.nupkg-sbom.outputs.attestation-url }})
137+
- [NetEscapades.AspNetCore.SecurityHeaders.TagHelpers SBOM](${{ steps.taghelpers-sbom.outputs.attestation-url }})
138+
139+
> [!NOTE]
140+
> You cannot assert the provenance of the _.nupkg_ packages downloaded from nuget.org directly. First, you
141+
> must remove the `.signature.p7s` file, [as described here](https://github.com/andrewlock/NetEscapades.AspNetCore.SecurityHeaders#verifying-nuget-provenance-attestations).
144142
145143
publish-test-results:
146144
name: "Publish Tests Results"

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,75 @@ If you aren't using Razor, or don't want to use the TagHelpers library, you can
688688
string nonce = HttpContext.GetNonce();
689689
```
690690

691+
# Verifying NuGet provenance attestations
692+
693+
All releases of the NuGet packages in this repository include provenance attestations, a Software Bill of Materials (SBOM),
694+
and attestations for the SBOMs. These attestations are generated based on the NuGet packages created in the pipeline.
695+
However, [nuget.org modifies any uploaded packages]((https://andrewlock.net/creating-provenance-attestations-for-nuget-packages-in-github-actions/#and-now-for-the-bad-news))
696+
to include a signature file, which changes the SHA of the packages.
697+
698+
To verify the provenance for a given downloaded NuGet package from nuget.org, you must first reverse the signature file
699+
modification, to reconstruct the package for which the attestation was made. You can then use the GitHub CLI to verify
700+
the provenance of the package and the associated SBOMs.
701+
702+
To remove the signature file on Linux or macOS, you can use the `zip` utility:
703+
704+
```bash
705+
file="path/to/NetEscapades.AspNetCore.SecurityHeaders.1.0.0.nupkg"
706+
zip -d $file .signature.p7s
707+
```
708+
709+
alternatively, use PowerShell and .NET to remove the `.signature.p7s` file:
710+
711+
```powershell
712+
$file="path/to/NetEscapades.AspNetCore.SecurityHeaders.1.0.0.nupkg"
713+
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression')
714+
$stream = New-Object IO.FileStream($file, [IO.FileMode]::Open)
715+
$zip = New-Object IO.Compression.ZipArchive($stream, [IO.Compression.ZipArchiveMode]::Update)
716+
$zip.Entries | ? { $_.Name -eq ".signature.p7s" } | % { $_.Delete() }
717+
$zip.Dispose();
718+
```
719+
720+
You can then verify the provenance of the package using [the GitHub CLI](https://cli.github.com/):
721+
722+
```bash
723+
gh attestation verify --owner andrewlock "NetEscapades.AspNetCore.SecurityHeaders.1.0.0.nupkg"
724+
gh attestation verify --owner andrewlock "NetEscapades.AspNetCore.SecurityHeaders.TagHelpers.1.0.0.nupkg"
725+
```
726+
727+
on success, this displays output similar to the following:
728+
729+
```bash
730+
Loaded digest sha256:bf809ff0ed6a8a31131df4391b169e35ded44d4dfd97cc797123441683a95c9f for file://NetEscapades.AspNetCore.SecurityHeaders.1.0.0.nupkg
731+
Loaded 2 attestations from GitHub API
732+
733+
The following policy criteria will be enforced:
734+
- Predicate type must match:................ https://slsa.dev/provenance/v1
735+
- Source Repository Owner URI must match:... https://github.com/andrewlock
736+
- Subject Alternative Name must match regex: (?i)^https://github.com/andrewlock/
737+
- OIDC Issuer must match:................... https://token.actions.githubusercontent.com
738+
739+
Verification succeeded!
740+
741+
The following 1 attestation matched the policy criteria
742+
743+
- Attestation #1
744+
- Build repo:..... andrewlock/NetEscapades.AspNetCore.SecurityHeaders
745+
- Build workflow:. .github/workflows/BuildAndPack.yml@refs/tags/v1.0.0
746+
- Signer repo:.... andrewlock/NetEscapades.AspNetCore.SecurityHeaders
747+
- Signer workflow: .github/workflows/BuildAndPack.yml@refs/tags/v1.0.0
748+
```
749+
750+
SBOMs are provided in the GitHub release for the packages using the [CycloneDX standard](https://cyclonedx.org/).
751+
As for build provenance, attestations for the SBOMs must be verified against the _.nupkg_ files
752+
with the `.signature.p7s` file removed. Assuming you have modified the _.nupkg_ files to remove the signature file, as described above,
753+
you can verify the SBOM attestations by specifying the `--predicate-type`:
754+
755+
```bash
756+
gh attestation verify --owner andrewlock --predicate-type https://cyclonedx.org/bom "NetEscapades.AspNetCore.SecurityHeaders.1.0.0nupkg"
757+
gh attestation verify --owner andrewlock --predicate-type https://cyclonedx.org/bom "NetEscapades.AspNetCore.SecurityHeaders.TagHelpers.1.0.0.nupkg"
758+
```
759+
691760
## Additional Resources
692761

693762
* [ASP.NET Core Middleware Docs](https://docs.asp.net/en/latest/fundamentals/middleware.html)

0 commit comments

Comments
 (0)