From 114bdd8308b62204779fb2c3e976ca6f82a1d5a7 Mon Sep 17 00:00:00 2001 From: BEN ABT Date: Tue, 24 Nov 2026 22:55:53 +0100 Subject: [PATCH 1/3] chore(package): deterministic CI builds and accurate package metadata - Set ContinuousIntegrationBuild in GitHub Actions. The embedded PDBs of the published packages contained paths of the build agent (/home/runner/work/...); they are now mapped to /_/. - Fix the product name of the core package ("HTTP Client Agents") and the descriptions of both packages. Client Hints do not identify bots. - Use single-word tags: NuGet split "User Agent" into "User" and "Agent". - Add Copyright and PackageReleaseNotes. --- Directory.Build.props | 10 +++++++++- .../HttpClientHints.AspNetCore.csproj | 4 ++-- src/HttpClientHints/HttpClientHints.csproj | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 7c259d3..4f3979f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -52,13 +52,21 @@ true HTTP Client Hints for .NET + Copyright (c) 2024-2026 MyCSharp https://github.com/mycsharp/HttpClientHints https://github.com/mycsharp/HttpClientHints MIT - UserAgent, User Agent, Client Hints, Browser, Client, Detector, Detection, Console, ASP, Desktop, Mobile + https://github.com/mycsharp/HttpClientHints/releases + + client-hints;user-agent-client-hints;user-agent;sec-ch-ua;accept-ch;aspnetcore;http;browser;platform;mobile httpclienthints-logo.png + + + true + + diff --git a/src/HttpClientHints.AspNetCore/HttpClientHints.AspNetCore.csproj b/src/HttpClientHints.AspNetCore/HttpClientHints.AspNetCore.csproj index 1034749..a5a8db9 100644 --- a/src/HttpClientHints.AspNetCore/HttpClientHints.AspNetCore.csproj +++ b/src/HttpClientHints.AspNetCore/HttpClientHints.AspNetCore.csproj @@ -1,8 +1,8 @@ - HTTP Client Hints Extensions for ASP.NET Core - HTTP Client Hints Extensions for ASP.NET Core + HTTP Client Hints for ASP.NET Core + Requests HTTP Client Hints with Accept-CH and reads them from the HttpContext in ASP.NET Core. diff --git a/src/HttpClientHints/HttpClientHints.csproj b/src/HttpClientHints/HttpClientHints.csproj index 18eed80..20e4e47 100644 --- a/src/HttpClientHints/HttpClientHints.csproj +++ b/src/HttpClientHints/HttpClientHints.csproj @@ -1,8 +1,8 @@ - HTTP Client Agents - Reads HTTP Client Hints to identify Browsers, Platforms and Bots. + HTTP Client Hints + Reads HTTP Client Hints such as Sec-CH-UA, Sec-CH-UA-Platform and Sec-CH-UA-Mobile and decodes their structured values. From 7e1bc8b33650b4d3ccbe0d0c88cc9de0ec750fe6 Mon Sep 17 00:00:00 2001 From: BEN ABT Date: Tue, 24 Nov 2026 22:55:54 +0100 Subject: [PATCH 2/3] ci: check formatting, pin nbgv and add Dependabot - Run dotnet format --verify-no-changes in every build. - Pin dotnet/nbgv to v0.5.2 instead of the master branch. - Update actions/download-artifact from v4 to v8, which runs on Node.js 24. The packages are downloaded by name, which v5 to v8 did not change. - Add Dependabot for NuGet and GitHub Actions with grouped updates. Microsoft.Extensions.Primitives stays at the lowest version for .NET 8. --- .github/dependabot.yml | 40 ++++++++++++++++++++++++++++ .github/workflows/build-and-test.yml | 5 +++- .github/workflows/main-build.yml | 2 +- readme.md | 2 ++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..cc128c1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,40 @@ +# Dependabot version updates +# https://docs.github.com/code-security/dependabot/working-with-dependabot/dependabot-options-reference + +version: 2 +updates: + - package-ecosystem: nuget + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + commit-message: + prefix: chore + include: scope + ignore: + # The packages reference the lowest version that supports .NET 8. A newer version would raise + # the minimum version for every consumer. NuGetAudit reports vulnerable versions in the build. + - dependency-name: Microsoft.Extensions.Primitives + groups: + analyzers: + patterns: + - Roslynator.* + - Meziantou.Analyzer + tests: + patterns: + - Microsoft.Testing.* + - xunit.* + benchmarks: + patterns: + - BenchmarkDotNet* + + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + commit-message: + prefix: ci + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 850e45e..d3bb4b3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -52,7 +52,7 @@ jobs: global-json-file: ./global.json - name: Calculate Version with NBGV - uses: dotnet/nbgv@master + uses: dotnet/nbgv@v0.5.2 id: nbgv with: setAllVars: true @@ -64,6 +64,9 @@ jobs: - name: Restore dependencies run: dotnet restore + - name: Check formatting + run: dotnet format --verify-no-changes --no-restore --verbosity minimal + - name: Build run: dotnet build --configuration ${{ inputs.configuration }} --no-restore /p:Version=${{ steps.nbgv.outputs.SemVer2 }} diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index 4c810f0..b85cb13 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v6 - name: Download NuGet packages - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: nuget-packages path: ./artifacts diff --git a/readme.md b/readme.md index 9657ff8..8fe5ff4 100644 --- a/readme.md +++ b/readme.md @@ -218,6 +218,8 @@ dotnet test -c Release --no-build Line and branch coverage of both packages must stay at 100 %. CI collects coverage on every build and fails below this threshold. Run the same check locally with `just test-cov`, or call `./eng/Assert-CodeCoverage.ps1` after a test run with `--coverage --coverage-output-format cobertura`. +CI also checks the formatting with `dotnet format --verify-no-changes`. Run the same check locally with `just format-check`. + ## Release Every push to `main` builds and tests the solution and creates a draft GitHub release with the NuGet packages. Publishing that release runs `.github/workflows/release-publish.yml`, which pushes the packages to NuGet.org with [Trusted Publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing). The workflow exchanges a GitHub OIDC token for a NuGet API key that is valid for one hour, so the repository stores no NuGet API key. From a333e16b5d38060026fe4c6b37ec468c3e010ddc Mon Sep 17 00:00:00 2001 From: BEN ABT Date: Tue, 24 Nov 2026 22:55:54 +0100 Subject: [PATCH 3/3] docs: private vulnerability reporting and project instructions - SECURITY.md asked to report vulnerabilities in public issues. It now points to GitHub private vulnerability reporting. - Replace the unrelated Azure rule in copilot-instructions.md with the build, test, code and documentation rules of this repository. - Replace the solution item for the missing ci.yml with the existing workflow files and dependabot.yml. --- .github/copilot-instructions.md | 34 ++++++++++++++++++++++++++++++++- MyCSharp.HttpClientHints.sln | 6 +++++- SECURITY.md | 12 +++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 17c77c3..67a4a77 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1 +1,33 @@ -- @azure Rule - Use Azure Best Practices: When generating code for Azure, running terminal commands for Azure, or performing operations related to Azure, invoke your `get_azure_best_practices` tool if available. \ No newline at end of file +# Instructions for MyCSharp.HttpClientHints + +## Projects + +- `src/HttpClientHints`: package `MyCSharp.HttpClientHints` with the `HttpClientHints` record and `HttpClientHintsInterpreter`. +- `src/HttpClientHints.AspNetCore`: package `MyCSharp.HttpClientHints.AspNetCore` with the `Accept-CH` middleware, the `HttpContext` and `IHeaderDictionary` extensions and `IHttpClientHintsFeature`. +- `tests/*.UnitTests`: xUnit v3 tests on Microsoft.Testing.Platform. FluentAssertions is blocked; use `Assert`. +- `tests/HttpClientHints.NativeAot.Smoke`: Native AOT smoke test that roots both packages. +- `perf/HttpClientHints.Benchmarks`: BenchmarkDotNet benchmarks. + +## Build and test + +- The packages target .NET 8, 9, 10 and 11. Build with the .NET 11 SDK. +- `dotnet build -c Release` must not produce warnings: `TreatWarningsAsErrors` is enabled, with Roslynator, Meziantou and the trimming and AOT analyzers. +- Line and branch coverage of both packages must stay at 100 %: `just test-cov`. +- CI checks the formatting: `just format-check`. +- Native AOT: `dotnet publish tests/HttpClientHints.NativeAot.Smoke -c Release -f net11.0 -r ` must publish without warnings, and the executable must exit with 0. + +## Code + +- Every C# file starts with `// Copyright © https://myCSharp.de - all rights reserved`. +- Do not use reflection or dynamic code generation; both packages are `IsAotCompatible`. +- Reading Client Hints is on the request path: avoid allocations, measure changes with the benchmarks. +- Public API is part of the NuGet packages: removing or changing members is a breaking change and needs a major version. + +## Documentation + +- `readme.md` and the package readmes in `src/*/readme.md` describe the current behavior only. Do not add version history such as "Since 3.2". +- Link NuGet packages to `https://nubrowse.com/packages/`. + +## Commits + +Use Conventional Commits, for example `feat:`, `fix:`, `perf:`, `docs:`, `test:`, `ci:` and `chore:`. diff --git a/MyCSharp.HttpClientHints.sln b/MyCSharp.HttpClientHints.sln index fa8ff4a..d03f5e8 100644 --- a/MyCSharp.HttpClientHints.sln +++ b/MyCSharp.HttpClientHints.sln @@ -11,7 +11,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{E23F6AE5-FF68-4E ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore - .github\workflows\ci.yml = .github\workflows\ci.yml + .github\dependabot.yml = .github\dependabot.yml + .github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml + .github\workflows\main-build.yml = .github\workflows\main-build.yml + .github\workflows\pr-validation.yml = .github\workflows\pr-validation.yml + .github\workflows\release-publish.yml = .github\workflows\release-publish.yml Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props global.json = global.json diff --git a/SECURITY.md b/SECURITY.md index dacde8b..6ec0330 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,3 +1,13 @@ # Security Policy -Please use the GitHub Issues functionality to report bugs. +## Reporting a vulnerability + +Do not report security vulnerabilities in public GitHub issues. + +Report them privately through [GitHub private vulnerability reporting](https://github.com/mycsharp/HttpClientHints/security/advisories/new). Only the maintainers can see the report. Please include the affected package and version, a description of the issue and, if possible, steps to reproduce it. + +Fixes are released as new versions of the NuGet packages `MyCSharp.HttpClientHints` and `MyCSharp.HttpClientHints.AspNetCore`. + +## Other bugs + +Report bugs that are not security vulnerabilities in [GitHub issues](https://github.com/mycsharp/HttpClientHints/issues).