From b367efb8cfb3881bf19027f49b99508227f0b504 Mon Sep 17 00:00:00 2001 From: Stephen Walsh <868017+stphnwlsh@users.noreply.github.com> Date: Mon, 26 Oct 2026 21:41:07 +0000 Subject: [PATCH 1/4] Align Codecov and add security scanning - Shared codecov.yml enforcing 95% project and patch coverage; codecov-action v7 - Replace the monthly dotnet-outdated workflow with Dependabot (monthly, one grouped PR for NuGet and GitHub Actions) - Move CodeQL to its own workflow on v4 with build-mode none, security-and-quality queries and a weekly run - Scan the built Docker image with Trivy and upload results to code scanning - Add OpenSSF Scorecard workflow and badge - Add SECURITY.md pointing to private vulnerability reporting --- .github/dependabot.yml | 17 ++++++++ .github/workflows/build-pipeline.yml | 52 ++++++++++--------------- .github/workflows/codeql.yml | 43 ++++++++++++++++++++ .github/workflows/dependecy-updates.yml | 49 ----------------------- .github/workflows/scorecard.yml | 40 +++++++++++++++++++ Dockerfile | 2 +- README.md | 1 + SECURITY.md | 13 +++++++ codecov.yml | 6 ++- global.json | 2 +- 10 files changed, 140 insertions(+), 85 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/dependecy-updates.yml create mode 100644 .github/workflows/scorecard.yml create mode 100644 SECURITY.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3258ab7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 + +multi-ecosystem-groups: + monthly-dependencies: + schedule: + interval: "monthly" + +updates: + - package-ecosystem: "nuget" + directory: "/" + patterns: ["*"] + multi-ecosystem-group: "monthly-dependencies" + + - package-ecosystem: "github-actions" + directory: "/" + patterns: ["*"] + multi-ecosystem-group: "monthly-dependencies" diff --git a/.github/workflows/build-pipeline.yml b/.github/workflows/build-pipeline.yml index 3a57971..b685bfd 100644 --- a/.github/workflows/build-pipeline.yml +++ b/.github/workflows/build-pipeline.yml @@ -8,42 +8,13 @@ on: workflow_dispatch: jobs: - analyse: - name: Static Analysis + pipeline: + name: Build, Test and Publish runs-on: ubuntu-latest permissions: - actions: read contents: read security-events: write - strategy: - fail-fast: true - matrix: - language: ["csharp"] - - steps: - - name: Checkout - id: checkout - uses: actions/checkout@v4 - - - name: Initialize - id: initialize - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: Build - id: build - uses: github/codeql-action/autobuild@v2 - - - name: Analysis - id: analysis - uses: github/codeql-action/analyze@v2 - - pipeline: - name: Build, Test and Publish - runs-on: ubuntu-latest - strategy: fail-fast: true matrix: @@ -103,7 +74,7 @@ jobs: - name: Analysis id: analysis - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v7 with: files: ./out/coverage.opencover.xml token: ${{ secrets.CODECOV_TOKEN }} @@ -123,6 +94,23 @@ jobs: VERSION_SUFFIX: ${{ steps.initialize.outputs.version_suffix }} DOCKER_TAG: ${{ steps.initialize.outputs.docker_tag }} + - name: Scan + id: scan + uses: aquasecurity/trivy-action@v0.36.0 + with: + image-ref: ${{ steps.initialize.outputs.name }}:${{ steps.initialize.outputs.docker_tag }} + format: sarif + output: trivy-results.sarif + severity: CRITICAL,HIGH + ignore-unfixed: true + + - name: Upload Scan + id: upload-scan + uses: github/codeql-action/upload-sarif@v4 + with: + sarif_file: trivy-results.sarif + category: trivy + - name: Docker Login id: login if: ${{ github.ref == 'refs/heads/main' }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..a002aa4 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,43 @@ +name: CodeQL + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: "0 3 * * 1" + workflow_dispatch: + +jobs: + analyse: + name: Static Analysis + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: true + matrix: + language: ["csharp"] + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + + - name: Initialize + id: initialize + uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + build-mode: none + queries: security-and-quality + + - name: Analysis + id: analysis + uses: github/codeql-action/analyze@v4 + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/dependecy-updates.yml b/.github/workflows/dependecy-updates.yml deleted file mode 100644 index 8da63de..0000000 --- a/.github/workflows/dependecy-updates.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Automated Dependency Updates - -on: - schedule: - - cron: "0 0 1 * *" - workflow_dispatch: - -jobs: - dependencies: - name: Update Dependencies - runs-on: ubuntu-latest - - strategy: - fail-fast: true - matrix: - language: ["csharp"] - - steps: - - name: Checkout - id: checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.AUTOMATED_DEPENDENCY_UPDATES_TOKEN }} - - - name: Setup - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 10.0.x - - - name: Update - id: update - uses: stphnwlsh/dotnet-outdated-action@v2 - with: - excludes: visualstudio - - - name: Test - id: test - if: ${{ steps.update.outputs.updated == 'true' }} - run: dotnet test -c Release -v minimal - - - name: Push - id: push - if: ${{ steps.update.outputs.updated == 'true' }} - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> - commit_user_name: github-actions[bot] - commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com - commit_message: Automated Dependency Updates diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml new file mode 100644 index 0000000..fb66ed4 --- /dev/null +++ b/.github/workflows/scorecard.yml @@ -0,0 +1,40 @@ +name: OpenSSF Scorecard + +on: + branch_protection_rule: + push: + branches: [main] + schedule: + - cron: "0 4 * * 1" + workflow_dispatch: + +permissions: read-all + +jobs: + analysis: + name: Scorecard Analysis + runs-on: ubuntu-latest + permissions: + security-events: write + id-token: write + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Analysis + id: analysis + uses: ossf/scorecard-action@v2.5.0 + with: + results_file: results.sarif + results_format: sarif + publish_results: true + + - name: Upload + id: upload + uses: github/codeql-action/upload-sarif@v4 + with: + sarif_file: results.sarif diff --git a/Dockerfile b/Dockerfile index a2b755a..7b2fef5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,7 @@ RUN dotnet build --no-restore -c Release -v minimal -p:VersionPrefix=${VERSION_P # Dotnet Test FROM build AS test -RUN dotnet test --no-restore --no-build -c Release -v minimal -p:CollectCoverage=true -p:CoverletOutput=../results/ -p:MergeWith="../results/coverage.json" -p:CoverletOutputFormat=opencover%2cjson -m:1 -p:ExcludeByFile="**/program.cs" +RUN dotnet test --no-restore --no-build -c Release -v minimal -p:CollectCoverage=true -p:CoverletOutput=../results/ -p:MergeWith="../results/coverage.json" -p:CoverletOutputFormat=opencover%2cjson -m:1 -p:ExcludeByFile="**/Program.cs" FROM scratch AS coverage COPY --from=test /sln/tests/results/*.xml . diff --git a/README.md b/README.md index 7f26e6e..4491a43 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/stphnwlsh/cleanmodelcontextprotocol/build-pipeline.yml?label=Build%20Pipeline%20&logo=github&style=for-the-badge)](https://github.com/stphnwlsh/CleanModelContextProtocol/actions/workflows/build-pipeline.yml) [![Codecov](https://img.shields.io/codecov/c/github/stphnwlsh/CleanModelContextProtocol?label=Code%20Coverage&logo=codecov&logoColor=white&style=for-the-badge)](https://codecov.io/gh/stphnwlsh/CleanModelContextProtocol) +[![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/stphnwlsh/CleanModelContextProtocol?label=OpenSSF%20Scorecard&style=for-the-badge)](https://scorecard.dev/viewer/?uri=github.com/stphnwlsh/CleanModelContextProtocol) [![Nuget](https://img.shields.io/nuget/v/CleanModelContextProtocol.Template?label=nuget%20template&logo=nuget&logoColor=white&style=for-the-badge)](https://www.nuget.org/packages/CleanModelContextProtocol.Template/) [![GitHub Sponsors](https://img.shields.io/static/v1?label=GitHub%20Sponsors&message=$1&logo=githubsponsors&logoColor=white&color=ea4aaa&style=for-the-badge)](https://github.com/sponsors/stphnwlsh/sponsorships?sponsor=stphnwlsh&tier_id=333950) [![Buy Me A Coffee](https://img.shields.io/static/v1?label=Buy%20Me%20A%20Coffee&message=$1&logo=buymeacoffee&logoColor=white&color=ffdd00&style=for-the-badge)](https://www.buymeacoffee.com/stphnwlsh) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..91c241f --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +Security fixes are made on the `main` branch and released in the latest version of the template on NuGet. + +## Reporting a Vulnerability + +Please don't report security vulnerabilities through public GitHub issues. + +Report them privately through GitHub's [private vulnerability reporting](https://github.com/stphnwlsh/CleanModelContextProtocol/security/advisories/new) instead. Include as much detail as you can: what's affected, how to reproduce it, and the impact you expect. + +You'll get a response within 7 days. Once the issue is confirmed, a fix will be released as soon as possible, and you'll be credited in the advisory unless you'd prefer not to be. diff --git a/codecov.yml b/codecov.yml index 0edb813..3c1d530 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,5 +2,7 @@ coverage: status: project: default: - target: 100% - threshold: 2% + target: 95% + patch: + default: + target: 95% diff --git a/global.json b/global.json index 12a3749..7ca72cb 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.1", + "version": "10.0.100", "allowPrerelease": false, "rollForward": "latestFeature" } From 3a3ba87c5893a7358bed543ef50323cf521d372c Mon Sep 17 00:00:00 2001 From: Stephen Walsh <868017+stphnwlsh@users.noreply.github.com> Date: Mon, 26 Oct 2026 22:14:15 +0000 Subject: [PATCH 2/4] Remove unused endpoint validation filter --- .../Filters/ValidationAttribute.cs | 6 -- .../Filters/ValidationDescriptor.cs | 10 ---- src/Presentation/Filters/ValidationFilter.cs | 60 ------------------- 3 files changed, 76 deletions(-) delete mode 100644 src/Presentation/Filters/ValidationAttribute.cs delete mode 100644 src/Presentation/Filters/ValidationDescriptor.cs delete mode 100644 src/Presentation/Filters/ValidationFilter.cs diff --git a/src/Presentation/Filters/ValidationAttribute.cs b/src/Presentation/Filters/ValidationAttribute.cs deleted file mode 100644 index 7e144c4..0000000 --- a/src/Presentation/Filters/ValidationAttribute.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CleanModelContextProtocol.Presentation.Filters; - -[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] -public class ValidateAttribute : Attribute -{ -} diff --git a/src/Presentation/Filters/ValidationDescriptor.cs b/src/Presentation/Filters/ValidationDescriptor.cs deleted file mode 100644 index bfa0c6d..0000000 --- a/src/Presentation/Filters/ValidationDescriptor.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CleanModelContextProtocol.Presentation.Filters; - -using FluentValidation; - -public class ValidationDescriptor -{ - public required int ArgumentIndex { get; init; } - public required Type ArgumentType { get; init; } - public required IValidator Validator { get; init; } -} diff --git a/src/Presentation/Filters/ValidationFilter.cs b/src/Presentation/Filters/ValidationFilter.cs deleted file mode 100644 index 550a69d..0000000 --- a/src/Presentation/Filters/ValidationFilter.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace CleanModelContextProtocol.Presentation.Filters; - -using System.Reflection; -using FluentValidation; -using Microsoft.AspNetCore.Http; - -public static class ValidationFilter -{ - public static EndpointFilterDelegate ValidationFilterFactory(EndpointFilterFactoryContext context, EndpointFilterDelegate next) - { - var validationDescriptors = GetValidators(context.MethodInfo, context.ApplicationServices); - - if (validationDescriptors.Any()) - { - return invocationContext => Validate(validationDescriptors, invocationContext, next); - } - - // pass-thru - return invocationContext => next(invocationContext); - } - - private static async ValueTask Validate(IEnumerable validationDescriptors, EndpointFilterInvocationContext invocationContext, EndpointFilterDelegate next) - { - foreach (var descriptor in validationDescriptors) - { - var argument = invocationContext.Arguments[descriptor.ArgumentIndex]; - - if (argument is not null) - { - var validationResult = await descriptor.Validator.ValidateAsync( - new ValidationContext(argument) - ); - - if (!validationResult.IsValid) - { - return TypedResults.ValidationProblem(validationResult.ToDictionary()); - } - } - } - - return await next.Invoke(invocationContext); - } - - private static IEnumerable GetValidators(MethodInfo methodInfo, IServiceProvider serviceProvider) - { - foreach (var item in methodInfo.GetParameters().Select((parameter, index) => new { parameter, index })) - { - if (item.parameter.GetCustomAttribute() is not null) - { - var validatorType = typeof(IValidator<>).MakeGenericType(item.parameter.ParameterType); - var validator = serviceProvider.GetService(validatorType) as IValidator; - - if (validator is not null) - { - yield return new ValidationDescriptor { ArgumentIndex = item.index, ArgumentType = item.parameter.ParameterType, Validator = validator }; - } - } - } - } -} From 4869ccce445d252f221fbfc3a5eacae665fba7fa Mon Sep 17 00:00:00 2001 From: Stephen Walsh <868017+stphnwlsh@users.noreply.github.com> Date: Mon, 26 Oct 2026 22:16:02 +0000 Subject: [PATCH 3/4] Scan GitHub Actions workflows with CodeQL --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a002aa4..3582457 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: true matrix: - language: ["csharp"] + language: ["actions", "csharp"] steps: - name: Checkout From 480c01a760153a4788ead39b7e9ca43d23837a4e Mon Sep 17 00:00:00 2001 From: Stephen Walsh <868017+stphnwlsh@users.noreply.github.com> Date: Mon, 26 Oct 2026 22:17:39 +0000 Subject: [PATCH 4/4] Pin third-party actions to commit hashes --- .github/workflows/build-pipeline.yml | 4 ++-- .github/workflows/scorecard.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-pipeline.yml b/.github/workflows/build-pipeline.yml index b685bfd..b61b259 100644 --- a/.github/workflows/build-pipeline.yml +++ b/.github/workflows/build-pipeline.yml @@ -74,7 +74,7 @@ jobs: - name: Analysis id: analysis - uses: codecov/codecov-action@v7 + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7 with: files: ./out/coverage.opencover.xml token: ${{ secrets.CODECOV_TOKEN }} @@ -96,7 +96,7 @@ jobs: - name: Scan id: scan - uses: aquasecurity/trivy-action@v0.36.0 + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 with: image-ref: ${{ steps.initialize.outputs.name }}:${{ steps.initialize.outputs.docker_tag }} format: sarif diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index fb66ed4..98c5c33 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -27,7 +27,7 @@ jobs: - name: Analysis id: analysis - uses: ossf/scorecard-action@v2.5.0 + uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0 with: results_file: results.sarif results_format: sarif