Files
captureimg/.github/scripts/vulnerability-gate.ps1
poli0981andClaude Opus 5.5 c649442a3a chore!: .NET 10 foundation, required CI quality gates, hardened release pipeline (#21)
* chore(build)!: move to .NET 10 LTS, refresh dependencies, enforce LF + SPDX headers

.NET 9 reaches end of support on 2026-11-10 and this machine only has .NET 10
SDKs, so the repo no longer built locally.

- global.json: SDK 10.0.401 (latestFeature) + Microsoft.Testing.Platform runner
- all projects retargeted to net10.0 / net10.0-windows10.0.22621.0
- Directory.Build.props: single version source (App no longer overrides it),
  TreatWarningsAsErrors everywhere, lock files + locked restore in CI,
  NuGetAudit (all, low), EnableWindowsTargeting (Dependabot evaluated every
  Windows-TFM project as "not compatible" without it), XML docs on so IDE0005
  runs in build
- packages: Microsoft.Extensions 10.0.13, Serilog 4.4.0 (+ sinks/extensions),
  CommunityToolkit.Mvvm 8.4.2, Stateless 5.20.1, Vortice 3.8.3, SkiaSharp
  4.153.1, Velopack 1.2.161 (DownloadUpdatesAsync lost ignoreDeltas;
  CheckForUpdatesAsync now honours cancellation via WaitAsync), WinAppSDK last
  1.8 patch
- security: drop SixLabors.ImageSharp 3.1.12 (GHSA-j3p4-wp97-rph4,
  GHSA-j9gm-c75j-xc9q, GHSA-jjfr-hcj7-qf5w high; GHSA-gwg2-r3hj-4w44,
  GHSA-wmxv-xphr-5c9g moderate) — TIFF now goes through the built-in WIC
  encoder (opaque, LZW)
- removed unused references: M.E.Hosting/Localization/Options/DI.Abstractions
  where unused, Serilog sinks in Infrastructure, SkiaSharp.NativeAssets.Win32
  (transitive), CsWinRT, Microsoft.Win32.Registry, H.NotifyIcon,
  Hosting.Abstractions
- tests: xunit 2 -> xunit.v3 4.0.2 (MTP v2), FluentAssertions 6 ->
  AwesomeAssertions 9 (FA >= 8 is commercially licensed), NSubstitute 6,
  coverlet -> Microsoft.Testing.Extensions.CodeCoverage; tests pass the xunit
  cancellation token
- .gitattributes: eol=lf everywhere (matches .editorconfig); .gitignore now
  ignores .idea/ and .claude/
- .editorconfig: SPDX header template (IDE0073) and IDE0161/0065/0005/0051/
  0052/0059/0060 enforced in build; headers added to every C# file, whitespace
  normalised; dead IID field and unused parameter/field removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: required quality gates, hardened release pipeline, working Dependabot

New required checks (one job each, no path filters so they always report):
- build: locked restore, Release build with warnings as errors, tests on
  Microsoft.Testing.Platform with Cobertura coverage summarised in the job summary
- format: `dotnet format whitespace` + style subset (SPDX header, file-scoped
  namespaces, using placement, unnecessary usings)
- deadcode: JetBrains InspectCode gated on file-local dead/redundant-code rules
  (WinUI projects excluded until they are replaced)
- audit: `dotnet list package --vulnerable --include-transitive` parsed by a gate
  script (the command itself always exits 0)
- license: nuget-license allowlist for the shipped app's dependency closure
- publish-smoke: publishes the app and verifies the payload (.pri/.xbf, legal docs)
- pr-title (Conventional Commits), dependency-review (vulnerabilities of any
  severity + non-free licenses), workflow-lint (actionlint + zizmor), docs
  (markdownlint + offline lychee); weekly external link check and OpenSSF
  Scorecard are informational

Release workflow:
- version taken from the tag through env + SemVer regex (removes the
  `${{ github.event.inputs.version }}` script injection) and checked against
  Directory.Build.props; prerelease derived from the version
- vpk pinned through the tool manifest (was unpinned while the library was
  0.0.1053); full packages only, so the previous release's 100 MB package is no
  longer re-uploaded; release notes come from CHANGELOG (the in-app update page
  showed none); identical packId/title/shortcuts/mainExe
- CycloneDX SBOM, SHA256SUMS of this version's assets, build-provenance
  attestations; release is created as a draft via gh (no third-party action with
  a write token); workflow_dispatch can rebuild an existing tag or dry-run

Other workflows: every action pinned to a commit SHA; least-privilege
permissions per job; notify-ci-failure ignores fork pull requests (they could post
their commit message to Discord) and all callers pass only the secrets they need
instead of `secrets: inherit`; announce-release now fires because releases are
published with a user token; discussion-welcome pinned and lists security@.
Removed .github/scripts/discord_notify.py (unused; the reusable workflows carry
their own copy).

Dependabot: EnableWindowsTargeting fixes the "not compatible" evaluation;
dead avalonia group removed; ecosystems grouped (incl. Velopack + vpk), 3-day
cooldown, tool manifest covered; version-update PRs paused (limit 0) until the
2.0.0 release.

Repo tooling: .config/dotnet-tools.json (vpk, InspectCode, nuget-license,
ReportGenerator, CycloneDX), markdownlint + lychee configs, RuntimeIdentifiers
win-x64 for stable lock files, CLAUDE.md for AI assistants, markdown lint fixes,
and the remaining InspectCode findings in Core/Infrastructure/ViewModels fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: fix first-run findings of the new gates

- dependency-review: drop Commons-Clause from deny-licenses (not an SPDX id)
- docs: disable markdownlint MD060 (table pipe alignment) introduced in
  markdownlint 0.41, which the CI action ships
- Dependabot cooldown 3 -> 7 days (zizmor dependabot-cooldown audit)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: quote InspectCode arguments, force HTTPS for actionlint download

- PowerShell splits a dash-prefixed native argument at its first period, so
  -o=inspectcode.sarif reached InspectCode as two arguments ('Specify only one
  solution file'); arguments are now quoted
- curl in workflow-lint refuses non-HTTPS protocols and redirects (SonarCloud
  githubactions:S6506)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:02:41 +07:00

47 lines
1.9 KiB
PowerShell

# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) CaptureImage Contributors
#
# `dotnet list package --vulnerable` exits 0 even when it finds vulnerable packages,
# so the CI `audit` job feeds its JSON output to this script, which fails on any
# finding (direct or transitive, any severity) and lists them in the job summary.
[CmdletBinding()]
param([Parameter(Mandatory)] [string] $Report)
$ErrorActionPreference = 'Stop'
$doc = Get-Content -Raw -LiteralPath $Report | ConvertFrom-Json
$rows = @()
foreach ($project in @($doc.projects)) {
foreach ($framework in @($project.frameworks)) {
foreach ($kind in 'topLevelPackages', 'transitivePackages') {
foreach ($package in @($framework.$kind)) {
foreach ($vuln in @($package.vulnerabilities)) {
if (-not $vuln) { continue }
$rows += [pscustomobject]@{
Project = [IO.Path]::GetFileNameWithoutExtension($project.path)
Package = $package.id
Version = $package.resolvedVersion
Severity = $vuln.severity
Advisory = $vuln.advisoryurl
}
}
}
}
}
}
$rows = @($rows | Sort-Object Package, Version, Advisory -Unique)
$summary = @('## NuGet vulnerability audit', '', "Vulnerable packages: **$($rows.Count)**", '')
if ($rows.Count -gt 0) {
$summary += '| Package | Version | Severity | Advisory | Project |', '|---|---|---|---|---|'
foreach ($r in $rows) {
$summary += "| $($r.Package) | $($r.Version) | $($r.Severity) | $($r.Advisory) | $($r.Project) |"
Write-Output "::error title=Vulnerable package::$($r.Package) $($r.Version) ($($r.Severity)) $($r.Advisory)"
}
}
if ($env:GITHUB_STEP_SUMMARY) { $summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8 }
else { $summary | Write-Output }
if ($rows.Count -gt 0) { exit 1 }