diff --git a/.editorconfig b/.editorconfig
index db13261..4c2c47a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -32,3 +32,73 @@ indent_size = 2
# Generated files: relax style enforcement
[*.{g,g.i,Designer}.cs]
generated_code = true
+
+# --- ReSharper inspections: what Qodana reads (qodana.yaml, .github/workflows/qodana.yml) ---
+# Qodana for .NET runs ReSharper's engine, and the engine reads these keys; so does Rider or ReSharper in the editor,
+# which is why they are here and not in qodana.yaml: the same list everywhere. An inspection is off only where it
+# argues with a choice this project made; each line says which. Everything else it reports is fixed. (What is NOT
+# ReSharper's - a whole severity, the IntelliJ platform's inspections, JetBrains' security rules, a file the engine
+# itself misreads - is in qodana.yaml.)
+[*.{cs,xaml}]
+# A code-behind class names its base so that the type reads whole without the half XAML generates.
+resharper_redundant_extends_list_entry_highlighting = none
+# An argument that repeats a default says which value the call relies on (updateAccent: true, Mica, Hide(None)).
+resharper_redundant_argument_default_value_highlighting = none
+# `partial void OnXChanged(T value)`: the signature is CommunityToolkit.Mvvm's generator's, used or not.
+resharper_unused_parameter_in_partial_method_highlighting = none
+# WPF UI's implicit styles (BasedOn {x:Type ui:Button}, ui:Card) arrive with ui:ControlsDictionary at run time, from
+# a package's compiled resources the inspection does not read. A key that does not exist fails as the page loads.
+resharper_xaml_static_resource_not_resolved_highlighting = none
+# Pages get their DataContext in code (ShellPageProvider) and item templates bind to view-models the XAML does not
+# declare, so the engine cannot resolve those bindings; it would ask for design-time types on every page. The
+# accessibility tests check what the bindings must provide (names for every control and list item).
+resharper_xaml_binding_with_context_not_resolved_highlighting = none
+# Proposals, not findings - ReSharper's suggestions for a style this project did not take. Its style is this file,
+# `dotnet format` and the analyzers the build treats as errors (SonarAnalyzer included).
+resharper_convert_to_primary_constructor_highlighting = none
+resharper_merge_into_pattern_highlighting = none
+resharper_use_utf8_string_literal_highlighting = none
+resharper_arrange_object_creation_when_type_evident_highlighting = none
+resharper_convert_closure_to_method_group_highlighting = none
+resharper_use_collection_expression_highlighting = none
+resharper_convert_to_auto_property_highlighting = none
+# The streams and pipes these name are closed synchronously on purpose; `await using` would add a ConfigureAwait to
+# every one without closing them any sooner.
+resharper_use_await_using_highlighting = none
+# A member's accessibility is what its type offers, not a count of today's callers.
+resharper_member_can_be_private_global_highlighting = none
+resharper_property_can_be_made_init_only_global_highlighting = none
+resharper_auto_property_can_be_made_get_only_global_highlighting = none
+# "Never used" across the solution is not what decides for a member other code can reach: a view-model's properties
+# and commands are read by XAML bindings the engine cannot resolve (above), the product links by x:Static, and a
+# model's members by System.Text.Json. The private kind (.Local) stays on.
+resharper_unused_member_global_highlighting = none
+resharper_unused_auto_property_accessor_global_highlighting = none
+resharper_unused_method_return_value_global_highlighting = none
+resharper_unused_parameter_global_highlighting = none
+resharper_class_never_instantiated_global_highlighting = none
+resharper_event_never_subscribed_to_global_highlighting = none
+resharper_collection_never_queried_global_highlighting = none
+# The compiler's nullable analysis is the gate (warnings are errors). These three go further and call a guard
+# redundant because an annotation promises non-null - where a JSON file read from disk, a dependency property or a
+# WPF event hands over null all the same (the corrupt-file tests rely on those guards).
+resharper_null_coalescing_condition_is_always_not_null_according_to_api_contract_highlighting = none
+resharper_conditional_access_qualifier_is_non_nullable_according_to_api_contract_highlighting = none
+resharper_condition_is_always_true_or_false_according_to_nullable_api_contract_highlighting = none
+# A record's positional property is part of its equality and of what it prints, and XAML binds to it by name.
+resharper_not_accessed_positional_property_global_highlighting = none
+resharper_not_accessed_positional_property_local_highlighting = none
+# `default: break;` is how a switch says the rest is left alone on purpose (and Sonar S131 asks for the default).
+resharper_redundant_empty_switch_section_highlighting = none
+# Async void only for event handlers (CLAUDE.md), which is what these are.
+resharper_async_void_event_handler_method_highlighting = none
+
+[*.resx]
+# A vi, ja, zh-Hans or es value that equals the English one is deliberate: product, tool and command names (winget,
+# DISM, SFC), units and format strings are not translated.
+resharper_overridden_with_same_value_highlighting = none
+
+[tests/**/*.cs]
+# A test's lambda runs inside the `using` scope it captures from, and reads a variable the test changes on purpose.
+resharper_access_to_disposed_closure_highlighting = none
+resharper_access_to_modified_closure_highlighting = none
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 84d68ff..03ebbdf 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -38,8 +38,9 @@ See [BUILD.md](../BUILD.md) for packaging and CI.
messages follow [Conventional Commits](https://www.conventionalcommits.org/)
(`fix(catalog): …`, `feat(ui): …`).
- PRs need the required checks to pass: `build`, `package`, CodeQL (`Analyze (csharp)`,
- `Analyze (actions)`) and `dependency-review`. The SonarCloud quality gate is reported on PRs from
- this repository too (fork PRs don't get the analysis token).
+ `Analyze (actions)`) and `dependency-review`. The SonarCloud quality gate and the Qodana report
+ (zero problems expected) are shown on PRs from this repository too (fork PRs don't get the
+ analysis tokens).
- **Dependencies:** package versions live in each `.csproj` (GitHub's dependency graph doesn't read
`Directory.Packages.props`). Discuss a new package before adding it; runtime dependencies must be
GPLv3-compatible (dependency review enforces a license allow-list).
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
index 9245e00..7e68719 100644
--- a/.github/SECURITY.md
+++ b/.github/SECURITY.md
@@ -93,7 +93,8 @@ and some antivirus engines may show false positives (common for admin tools). In
- The code is **not obfuscated** (obfuscation is a leading cause of false positives), and the
source is public under the GPLv3.
- CI runs **CodeQL** (C# and GitHub Actions), **dependency review**, **OpenSSF Scorecard**,
- **SonarCloud** and **Snyk**; every restore audits direct and transitive NuGet packages;
+ **SonarCloud**, **Qodana** (JetBrains' inspections and security rules) and **Snyk**; every
+ restore audits direct and transitive NuGet packages;
Dependabot keeps dependencies and the SHA-pinned actions current; `main` only accepts pull
requests that pass the required checks.
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index a863cd1..278fafa 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -8,10 +8,16 @@ updates:
open-pull-requests-limit: 5
commit-message:
prefix: "deps"
- labels: ["dependencies", "nuget"]
+ # Labels that exist in the repository (a missing label is silently dropped).
+ labels: ["dependencies", ".NET"]
cooldown:
default-days: 3
semver-major-days: 14
+ # The app stays on the .NET 10 LTS line: Microsoft.Extensions.* majors follow .NET majors, and
+ # moving to a new .NET major is a deliberate migration done by hand, not a Dependabot bump.
+ ignore:
+ - dependency-name: "Microsoft.Extensions.*"
+ update-types: ["version-update:semver-major"]
groups:
microsoft-extensions:
patterns: ["Microsoft.Extensions.*"]
@@ -33,7 +39,11 @@ updates:
day: monday
commit-message:
prefix: "build"
- labels: ["dependencies", "dotnet-sdk"]
+ labels: ["dependencies", ".NET"]
+ # Patch and feature-band SDKs only; a new .NET major (11, 12…) is moved to by hand.
+ ignore:
+ - dependency-name: "*"
+ update-types: ["version-update:semver-major"]
- package-ecosystem: github-actions
directory: "/"
@@ -43,7 +53,7 @@ updates:
open-pull-requests-limit: 5
commit-message:
prefix: "ci"
- labels: ["dependencies", "github-actions"]
+ labels: ["dependencies", "github_actions"]
cooldown:
default-days: 3
groups:
diff --git a/.github/workflows/notify-ci-failure.yml b/.github/workflows/notify-ci-failure.yml
index 0462954..761cb0c 100644
--- a/.github/workflows/notify-ci-failure.yml
+++ b/.github/workflows/notify-ci-failure.yml
@@ -1,11 +1,11 @@
name: Notify CI Failure
-# Posts a Discord alert when the Build or SonarCloud workflow fails on main (reuses the shared
-# workflow in poli0981/.github). Requires repo secret DISCORD_CI_WEBHOOK.
+# Posts a Discord alert when the Build, SonarCloud or Qodana workflow fails on main (reuses the
+# shared workflow in poli0981/.github). Requires repo secret DISCORD_CI_WEBHOOK.
on:
workflow_run:
- workflows: ["Build", "SonarCloud"]
+ workflows: ["Build", "SonarCloud", "Qodana"]
types: [completed]
# The reusable workflow requests actions: read; without granting it here every run was a
@@ -16,7 +16,7 @@ permissions:
jobs:
notify:
- # Both workflows only run on `push` for main, so this limits alerts to main without trusting
+ # The three workflows only run on `push` for main, so this limits alerts to main without trusting
# forgeable values (branch names, actor logins) — and skips pull-request runs (including
# Dependabot's), which have no access to the webhook secret anyway.
if: >-
diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml
new file mode 100644
index 0000000..b9a728d
--- /dev/null
+++ b/.github/workflows/qodana.yml
@@ -0,0 +1,112 @@
+name: Qodana
+
+# JetBrains Qodana for .NET (`qodana-dotnet`, Rider's engine, on the Ultimate licence of the Qodana
+# Cloud project): ReSharper's C#, XAML and .resx inspections, the IntelliJ platform's Markdown and XML
+# inspections and JetBrains' security rules, over the whole solution. Results go to Qodana Cloud, to
+# annotations and a summary comment on the pull request, and to the run's `qodana-report` artifact
+# (SARIF and the linter's logs, for a reader without a Qodana Cloud account).
+#
+# - Native mode on a Windows runner (qodana.yaml: `withinDocker: false`): WPF (net10.0-windows) only
+# loads on Windows, and the linter reads the projects with the SDK this job installs from
+# global.json. Every setting is in qodana.yaml; nothing is an action argument.
+# - The solution is built first, so a build that fails is one red step with the compiler's own
+# message rather than a report of unresolved symbols.
+# - `pr-mode: false`: the whole solution every time, so a pull request and `main` are judged by the
+# same list. The gate (qodana.yaml) is zero problems.
+# - Advisory: not a required check of the `main` ruleset, so a finding, a Qodana Cloud outage or a
+# lapsed licence is a red job beside a green build, never a blocked merge.
+# - No `contents: write`: the job never pushes quick-fixes.
+# Requires the repository secret QODANA_TOKEN.
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ branches: [main]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+env:
+ DOTNET_NOLOGO: true
+ DOTNET_CLI_TELEMETRY_OPTOUT: true
+
+jobs:
+ token:
+ # Pull requests from forks and from Dependabot get no repository secrets. Checking for the token
+ # skips those runs without trusting actor or repository names from the event.
+ name: Check for QODANA_TOKEN
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions: {}
+ outputs:
+ available: ${{ steps.check.outputs.available }}
+ steps:
+ - name: Check for QODANA_TOKEN
+ id: check
+ env:
+ QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
+ run: |
+ if [ -n "$QODANA_TOKEN" ]; then
+ echo "available=true" >> "$GITHUB_OUTPUT"
+ else
+ echo "available=false" >> "$GITHUB_OUTPUT"
+ echo "::notice::QODANA_TOKEN is not available to this run (fork or Dependabot pull request); skipping the analysis."
+ fi
+
+ qodana:
+ name: Qodana
+ needs: token
+ if: needs.token.outputs.available == 'true'
+ # WPF (net10.0-windows) only builds on Windows, and the linter runs natively beside the SDK.
+ runs-on: windows-latest
+ timeout-minutes: 60
+ permissions:
+ contents: read
+ checks: write # the annotations
+ pull-requests: write # the summary comment
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ # The pull request's own commit, not its merge commit (empty on a push or a dispatch, which
+ # then check out the commit that started them).
+ ref: ${{ github.event.pull_request.head.sha }}
+ fetch-depth: 0 # full history: Qodana's reports are VCS-aware
+ persist-credentials: false
+
+ - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
+ with:
+ global-json-file: global.json
+
+ # Outside the workspace: the linter reads every file under the repository root.
+ - name: Cache NuGet packages
+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ~/.nuget/packages
+ key: nuget-qodana-${{ runner.os }}-${{ hashFiles('global.json', 'Directory.Build.props', '**/*.csproj') }}
+ restore-keys: nuget-qodana-${{ runner.os }}-
+
+ - name: Restore
+ run: dotnet restore CommandForge.slnx
+
+ - name: Build what the linter loads
+ run: dotnet build CommandForge.slnx -c Release --no-restore
+
+ # Caches are saved from `main` only (a pull request reads them), under keys of this job's own.
+ - name: Qodana Scan
+ uses: JetBrains/qodana-action@3e8d76ff0e0241618abd808682f426afe84bab3f # v2026.2.2
+ with:
+ pr-mode: false
+ upload-result: true
+ artifact-name: qodana-report
+ cache-default-branch-only: true
+ primary-cache-key: qodana-${{ github.ref_name }}-${{ github.sha }}
+ additional-cache-key: qodana-main
+ env:
+ QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
+ QODANA_ENDPOINT: https://qodana.cloud
diff --git a/BUILD.md b/BUILD.md
index 99950dd..26864ce 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -54,7 +54,9 @@ dotnet test CommandForge.slnx --collect "XPlat Code Coverage;Format=opencover"
`Directory.Packages.props`.
- Every restore runs a **NuGet audit** of direct and transitive packages; moderate or higher
advisories fail the build.
-- Dependabot groups updates (Velopack and the `vpk` tool move together) with a cooldown.
+- Dependabot groups updates (Velopack and the `vpk` tool move together) with a cooldown. It skips
+ new major versions of the .NET SDK and of `Microsoft.Extensions.*`: moving to a new .NET major is
+ a deliberate migration, done by hand.
## Publish (self-contained) + package
@@ -98,10 +100,11 @@ All workflows pin actions to full commit SHAs and use least-privilege permission
| `build.yml` | `build`: restore, `dotnet format --verify-no-changes`, Release build, tests (results and coverage uploaded). `package`: publish and `vpk pack` exactly like a release. |
| `codeql.yml` | CodeQL for C# (Windows, manual build) and for the workflows themselves (`actions`). |
| `sonarcloud.yml` | SonarCloud analysis with test coverage: the SonarScanner for .NET (pinned in `.config/dotnet-tools.json`) wraps a Release build and an OpenCover test run, and the SonarCloud app reports the quality gate on the PR. Needs the `SONAR_TOKEN` secret, so PRs from forks and Dependabot are skipped. |
+| `qodana.yml` | JetBrains Qodana for .NET (Rider's inspections, native mode on Windows) over the whole solution, after a Release build; settings in `qodana.yaml`, and the gate is zero problems. Results go to Qodana Cloud, to annotations and a comment on the PR, and to the `qodana-report` artifact. Advisory (not a required check). Needs the `QODANA_TOKEN` secret, so PRs from forks and Dependabot are skipped. |
| `dependency-review.yml` | Fails a PR that adds a dependency with a moderate+ vulnerability or a license outside the GPLv3-compatible allow-list. |
| `scorecard.yml` | OpenSSF Scorecard, reported to code scanning. |
| `release.yml` | Tag-triggered release — see [RELEASING.md](RELEASING.md). |
-| `notify-ci-failure.yml` | Posts a Discord alert when the Build or SonarCloud workflow fails on `main` (needs the `DISCORD_CI_WEBHOOK` secret). |
+| `notify-ci-failure.yml` | Posts a Discord alert when the Build, SonarCloud or Qodana workflow fails on `main` (needs the `DISCORD_CI_WEBHOOK` secret). |
The SonarCloud quality gate ("Sonar way") expects new code to be at least 80% covered by tests,
with no new issues. XAML code-behind and the two entry points (`Program.cs` of the app and of the
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70a0fb3..db76c65 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Changed
+- Code quality: JetBrains Qodana for .NET now inspects `main` and every pull request from CI, next
+ to SonarCloud: Rider's C#, XAML and resource inspections and JetBrains' security rules, run
+ natively on Windows. The gate is zero problems. Its first report also fixed a process object that
+ could be left undisposed when a command's program could not be found, and the command history
+ being read outside the lock it is written under.
+- Dependencies: Microsoft.Extensions.DependencyInjection 10.0.15, CsWin32 0.3.371, SonarAnalyzer
+ 10.36, SonarScanner for .NET 12.1.0, xUnit v3 4.0.3, Microsoft.NET.Test.Sdk 18.12.0, coverlet
+ 10.1.1; in CI, setup-dotnet 6.1.0 and CodeQL action 4.39.3.
+- Dependabot no longer proposes new major versions of .NET or Microsoft.Extensions: moving to a
+ new .NET major is a deliberate migration, done by hand.
+
+### Security
+- Built with the .NET 10.0.404 SDK, so the app ships the .NET 10.0.15 runtime (the November 2026
+ security update).
+- Links and folders are opened only when they are `https:` or `mailto:` addresses or existing
+ folders: Windows runs whatever the shell is handed, so a `file:` address or an unknown protocol is
+ refused.
+
## [2.1.0] — 2026-10-26
Three new categories and 37 new commands (the catalog grows from 261 to 298), the October 2026
diff --git a/Directory.Build.props b/Directory.Build.props
index 48616f5..7286a1b 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -60,7 +60,7 @@
live in each .csproj: GitHub's dependency graph (Dependabot alerts, dependency review, the
release SBOM) reads .csproj files but not Directory.Packages.props. -->
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/RELEASING.md b/RELEASING.md
index 8a82c45..91b7334 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -56,8 +56,9 @@ input; the upload step then creates the `vX.Y.Z` tag.
| `VT_API_KEY` | VirusTotal scan + links | optional (step skipped if unset) |
| `DISCORD_RELEASES_WEBHOOK` (or `DISCORD_REPO_WEBHOOK`) | Release announcement to Discord | optional |
| `DISCORD_PING_ROLE_ID` | Role ping on stable releases | optional |
-| `DISCORD_CI_WEBHOOK` | Build/SonarCloud failure alerts to Discord | optional |
+| `DISCORD_CI_WEBHOOK` | Build/SonarCloud/Qodana failure alerts to Discord | optional |
| `SONAR_TOKEN` | SonarCloud analysis and coverage (`sonarcloud.yml`) | for the SonarCloud workflow (runs without it are skipped) |
+| `QODANA_TOKEN` | Qodana Cloud project token; selects the Ultimate licence (`qodana.yml`) | for the Qodana workflow (runs without it are skipped) |
> `poli0981` is a user account (not an org), so secrets are set **per repository**
> (Settings → Secrets and variables → Actions).
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index b0f81c9..8a0995e 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -11,7 +11,7 @@ versions.
|---|---|---|---|
| WPF-UI (+ WPF-UI.Abstractions) | 4.3.0 | MIT | https://github.com/lepoco/wpfui |
| CommunityToolkit.Mvvm | 8.4.2 | MIT | https://github.com/CommunityToolkit/dotnet |
-| Microsoft.Extensions.DependencyInjection (+ .Abstractions) | 10.0.14 | MIT | https://github.com/dotnet/runtime |
+| Microsoft.Extensions.DependencyInjection (+ .Abstractions) | 10.0.15 | MIT | https://github.com/dotnet/runtime |
| Serilog | 4.4.0 | Apache-2.0 | https://github.com/serilog/serilog |
| Serilog.Sinks.File | 7.0.0 | Apache-2.0 | https://github.com/serilog/serilog-sinks-file |
| Serilog.Sinks.Async | 2.1.0 | Apache-2.0 | https://github.com/serilog/serilog-sinks-async |
@@ -25,14 +25,14 @@ and the Fluent System Icons (below); see the `ThirdPartyNotices.txt` in the WPF-
| Component | Version | License | Project |
|---|---|---|---|
-| Microsoft.Windows.CsWin32 | 0.3.367 | MIT | https://github.com/microsoft/CsWin32 |
-| SonarAnalyzer.CSharp | 10.35.0.4138 | SONAR Source-Available License v1.0 | https://github.com/SonarSource/sonar-dotnet |
-| dotnet-sonarscanner (SonarScanner for .NET, CI only) | 12.0.0 | LGPL-3.0 | https://github.com/SonarSource/sonar-scanner-msbuild |
+| Microsoft.Windows.CsWin32 | 0.3.371 | MIT | https://github.com/microsoft/CsWin32 |
+| SonarAnalyzer.CSharp | 10.36.0.15337 | SONAR Source-Available License v1.0 | https://github.com/SonarSource/sonar-dotnet |
+| dotnet-sonarscanner (SonarScanner for .NET, CI only) | 12.1.0 | LGPL-3.0 | https://github.com/SonarSource/sonar-scanner-msbuild |
| vpk (Velopack CLI) | 1.2.161 | MIT | https://github.com/velopack/velopack |
-| xunit.v3 (`xunit.v3.mtp-off`) | 4.0.2 | Apache-2.0 | https://github.com/xunit/xunit |
+| xunit.v3 (`xunit.v3.mtp-off`) | 4.0.3 | Apache-2.0 | https://github.com/xunit/xunit |
| xunit.runner.visualstudio | 4.0.1 | Apache-2.0 | https://github.com/xunit/visualstudio.xunit |
-| Microsoft.NET.Test.Sdk | 18.11.0 | MIT | https://github.com/microsoft/vstest |
-| coverlet.collector | 10.1.0 | MIT | https://github.com/coverlet-coverage/coverlet |
+| Microsoft.NET.Test.Sdk | 18.12.0 | MIT | https://github.com/microsoft/vstest |
+| coverlet.collector | 10.1.1 | MIT | https://github.com/coverlet-coverage/coverlet |
## Runtime & platform
diff --git a/global.json b/global.json
index d9997a0..ae54ccd 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "10.0.403",
+ "version": "10.0.404",
"rollForward": "latestFeature"
}
}
diff --git a/qodana.yaml b/qodana.yaml
new file mode 100644
index 0000000..fcf6f23
--- /dev/null
+++ b/qodana.yaml
@@ -0,0 +1,103 @@
+# Qodana's settings for .github/workflows/qodana.yml.
+#
+# The linter is Qodana for .NET (`qodana-dotnet`: Rider's engine) in NATIVE mode, on the job's own
+# Windows runner with the .NET SDK that global.json names: the WPF projects (net10.0-windows) load
+# only on Windows. It needs the Ultimate licence of the Qodana Cloud project; the token is the
+# QODANA_TOKEN repository secret.
+#
+# Everything a run needs is here and nothing is an action argument, so `qodana scan` in the
+# repository root of a developer's PC (with QODANA_TOKEN set) reads the same settings. The linter's
+# version is the action's: the workflow pins the action, the action its CLI, the CLI its linter.
+version: "1.0"
+linter: qodana-dotnet
+withinDocker: false
+
+# WHERE AN INSPECTION IS SWITCHED OFF: one of ReSharper's (C#, XAML, .resx) in .editorconfig
+# (`resharper_*_highlighting`), where Rider and ReSharper read it too. Here only what has no key
+# there: a whole severity, and the IntelliJ platform's own inspections (Markdown, XML). Each one with
+# its reason above it.
+profile:
+ base:
+ name: qodana.recommended
+ groups:
+ # A HINT is what the editor offers without underlining anything (ReSharper's lowest level; this
+ # linter files it as TYPO, Qodana as Low): "invert if", "convert to LINQ", a trailing comma, and
+ # every Roslyn analyzer message below the level this build makes an error. They are suggestions,
+ # not problems, and the build already fails on every warning.
+ - groupId: Hints
+ groups:
+ - "severity:TYPO"
+ inspections:
+ - group: Hints
+ enabled: false
+ # Windows application manifests: the linter has no schema for urn:schemas-microsoft-com:asm.v1
+ # and reports every element of the file as undeclared.
+ - inspection: XmlHighlighting
+ ignore:
+ - "src/CommandForge.Wpf/app.manifest"
+ - "helper/CommandForge.Elevator/app.manifest"
+
+dotnet:
+ solution: CommandForge.slnx
+ configuration: Release
+
+# What is not CommandForge's code, or not in the repository: build, package and test output, local
+# tool caches, and the git-ignored local folders a developer's PC has (internal notes, IDE state).
+exclude:
+ - name: All
+ paths:
+ - Releases
+ - publish
+ - TestResults
+ - .nuget
+ - .sonarqube
+ - docs
+ - .claude
+ - .idea
+ - .vs
+ # JETBRAINS' SECURITY RULES (the OpenGrep plugin) stay on, and the files their results were READ in
+ # are listed here - so a new file that starts a process is reported. "A process started with
+ # something that is not a literal" fired 11 times on the first run (2026-11-16): starting processes
+ # is what CommandForge is for. What each file starts, and where its path and arguments come from,
+ # is in tests/CommandForge.Tests/ProcessStartSitesTests.cs, which also fails on a new file. The
+ # name is the plugin's one inspection, not a rule's: a rule's own id is honoured nowhere, so a
+ # listed file is left out of all of the plugin's rules - the price.
+ - name: OpenGrepInspection
+ paths:
+ - src/CommandForge.Infrastructure/Execution/SystemProcessRunner.cs
+ - src/CommandForge.Infrastructure/Elevation/BrokerElevationService.cs
+ - src/CommandForge.Wpf/Services/ShellService.cs
+ # The tests start what they test (a read-only PowerShell, the echo of the executor test).
+ - tests
+ # THE LINTER'S OWN FAULT, not the file's: resolving PInvoke.CreateJobObject(null, null) - CsWin32's
+ # null-to-PCWSTR conversion - the engine loses the constructor and reports its locals, its field,
+ # the class and the file's usings as unused. The compiler builds the file with warnings as errors
+ # (IDE0005 fails a redundant using). The same engine fault is known from PInvoke.EnumDisplaySettings
+ # (null, ...). To be removed when a linter build reads the file.
+ - name: RedundantUsingDirective
+ paths:
+ - src/CommandForge.Infrastructure/Execution/ProcessJob.cs
+ - name: UnusedVariable.Compiler
+ paths:
+ - src/CommandForge.Infrastructure/Execution/ProcessJob.cs
+ - name: NotAccessedField.Compiler
+ paths:
+ - src/CommandForge.Infrastructure/Execution/ProcessJob.cs
+ - name: UnusedField.Compiler
+ paths:
+ - src/CommandForge.Infrastructure/Execution/ProcessJob.cs
+ - name: ClassCannotBeInstantiated
+ paths:
+ - src/CommandForge.Infrastructure/Execution/ProcessJob.cs
+ # The cancellation callback's token source: the registration that captures it is declared after
+ # it, so it is disposed first, and disposing a registration waits for a callback that is running -
+ # the source is never used after its disposal.
+ - name: AccessToDisposedClosure
+ paths:
+ - src/CommandForge.Infrastructure/Elevation/BrokerElevationService.cs
+
+# The gate: no problem at all. What the linter reports is settled where it is found — fixed, or its
+# inspection switched off with the reason beside it — so a count above zero is something new.
+failureConditions:
+ severityThresholds:
+ any: 0
diff --git a/src/CommandForge.Infrastructure/CommandForge.Infrastructure.csproj b/src/CommandForge.Infrastructure/CommandForge.Infrastructure.csproj
index 3d5ac3c..78ccaed 100644
--- a/src/CommandForge.Infrastructure/CommandForge.Infrastructure.csproj
+++ b/src/CommandForge.Infrastructure/CommandForge.Infrastructure.csproj
@@ -25,7 +25,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/src/CommandForge.Infrastructure/Execution/SystemProcessRunner.cs b/src/CommandForge.Infrastructure/Execution/SystemProcessRunner.cs
index 752871b..75daaee 100644
--- a/src/CommandForge.Infrastructure/Execution/SystemProcessRunner.cs
+++ b/src/CommandForge.Infrastructure/Execution/SystemProcessRunner.cs
@@ -34,25 +34,27 @@ internal sealed class SystemProcessRunner : IProcessRunner
{
ArgumentNullException.ThrowIfNull(output);
- using var process = new Process
+ // The start info is built first: if resolving the executable throws, there is no Process yet
+ // to leak (an object initializer would run after `new Process()` and outside the `using`).
+ var startInfo = new ProcessStartInfo
{
- StartInfo = new ProcessStartInfo
- {
- FileName = ExecutableResolver.Resolve(fileName),
- Arguments = arguments,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- // Redirect stdin so we can close it immediately: a process that reads input (e.g. an
- // interactive "cmd" with no /c) gets EOF and exits instead of hanging forever.
- RedirectStandardInput = true,
- UseShellExecute = false,
- CreateNoWindow = true,
- // Pin the working directory to System32 so nothing is resolved from an
- // attacker-controlled current directory — this runner also serves elevated commands.
- WorkingDirectory = SystemPaths.System32,
- },
+ FileName = ExecutableResolver.Resolve(fileName),
+ Arguments = arguments,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ // Redirect stdin so we can close it immediately: a process that reads input (e.g. an
+ // interactive "cmd" with no /c) gets EOF and exits instead of hanging forever.
+ RedirectStandardInput = true,
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ // Pin the working directory to System32 so nothing is resolved from an
+ // attacker-controlled current directory — this runner also serves elevated commands.
+ WorkingDirectory = SystemPaths.System32,
};
- _configureEnvironment?.Invoke(process.StartInfo.Environment);
+ _configureEnvironment?.Invoke(startInfo.Environment);
+
+ using var process = new Process();
+ process.StartInfo = startInfo;
try
{
diff --git a/src/CommandForge.Infrastructure/History/JsonExecutionHistoryService.cs b/src/CommandForge.Infrastructure/History/JsonExecutionHistoryService.cs
index b5c5278..2eaf5c8 100644
--- a/src/CommandForge.Infrastructure/History/JsonExecutionHistoryService.cs
+++ b/src/CommandForge.Infrastructure/History/JsonExecutionHistoryService.cs
@@ -29,7 +29,15 @@ public sealed class JsonExecutionHistoryService : IExecutionHistoryService
}
///
- public IReadOnlyList GetRecent() => _records;
+ public IReadOnlyList GetRecent()
+ {
+ // The list is replaced, never changed, under the gate; reading the reference under it too
+ // makes the newest one visible to every thread.
+ lock (_gate)
+ {
+ return _records;
+ }
+ }
///
public void Record(ExecutionRecord record)
diff --git a/src/CommandForge.Infrastructure/SingleInstanceGuard.cs b/src/CommandForge.Infrastructure/SingleInstanceGuard.cs
index f27934d..a7a82d0 100644
--- a/src/CommandForge.Infrastructure/SingleInstanceGuard.cs
+++ b/src/CommandForge.Infrastructure/SingleInstanceGuard.cs
@@ -86,7 +86,7 @@ public sealed class SingleInstanceGuard : IDisposable
private void ListenLoop(Action onActivateRequested)
{
- var handles = new WaitHandle[] { _activateEvent, _stopEvent.WaitHandle };
+ WaitHandle[] handles = [_activateEvent, _stopEvent.WaitHandle];
while (true)
{
if (WaitHandle.WaitAny(handles) == 1)
diff --git a/src/CommandForge.Wpf/CommandForge.Wpf.csproj b/src/CommandForge.Wpf/CommandForge.Wpf.csproj
index 663d130..f740df1 100644
--- a/src/CommandForge.Wpf/CommandForge.Wpf.csproj
+++ b/src/CommandForge.Wpf/CommandForge.Wpf.csproj
@@ -26,7 +26,7 @@
-
+
diff --git a/src/CommandForge.Wpf/Services/ShellService.cs b/src/CommandForge.Wpf/Services/ShellService.cs
index 403e550..d9e656f 100644
--- a/src/CommandForge.Wpf/Services/ShellService.cs
+++ b/src/CommandForge.Wpf/Services/ShellService.cs
@@ -5,13 +5,23 @@ using Serilog;
namespace CommandForge.Desktop.Services;
-/// backed by ShellExecute.
+///
+/// backed by ShellExecute — for the project's own web pages and mail
+/// addresses and the app's own folders only. ShellExecute runs whatever it is handed: a file:
+/// address or an unknown protocol handler is a program, so anything else is refused.
+///
public sealed class ShellService : IShellService
{
///
public bool TryOpen(string target)
{
ArgumentException.ThrowIfNullOrWhiteSpace(target);
+ if (!IsAllowedTarget(target, Directory.Exists))
+ {
+ Log.Warning("Refused to open {Target}: only https and mailto addresses and existing folders are opened.", target);
+ return false;
+ }
+
try
{
using var process = Process.Start(new ProcessStartInfo(target) { UseShellExecute = true });
@@ -39,4 +49,22 @@ public sealed class ShellService : IShellService
return false;
}
}
+
+ ///
+ /// Pure: whether is a web page (https:), a mail address
+ /// (mailto:) or an existing folder given by its full path.
+ ///
+ public static bool IsAllowedTarget(string target, Func folderExists)
+ {
+ ArgumentNullException.ThrowIfNull(target);
+ ArgumentNullException.ThrowIfNull(folderExists);
+
+ // "C:\Users\…" parses as a file: URI too, so a path is checked as a path.
+ if (Uri.TryCreate(target, UriKind.Absolute, out var uri) && !uri.IsFile && !uri.IsUnc)
+ {
+ return uri.Scheme == Uri.UriSchemeHttps || uri.Scheme == Uri.UriSchemeMailto;
+ }
+
+ return Path.IsPathFullyQualified(target) && folderExists(target);
+ }
}
diff --git a/src/CommandForge.Wpf/Views/AboutView.xaml b/src/CommandForge.Wpf/Views/AboutView.xaml
index 7fdc718..06b3ab6 100644
--- a/src/CommandForge.Wpf/Views/AboutView.xaml
+++ b/src/CommandForge.Wpf/Views/AboutView.xaml
@@ -34,11 +34,11 @@
-
-
-
diff --git a/tests/CommandForge.Tests/CommandForge.Tests.csproj b/tests/CommandForge.Tests/CommandForge.Tests.csproj
index 956fa95..c232492 100644
--- a/tests/CommandForge.Tests/CommandForge.Tests.csproj
+++ b/tests/CommandForge.Tests/CommandForge.Tests.csproj
@@ -8,10 +8,10 @@
-
-
-
-
+
+
+
+
diff --git a/tests/CommandForge.Tests/ProcessStartSitesTests.cs b/tests/CommandForge.Tests/ProcessStartSitesTests.cs
new file mode 100644
index 0000000..ac5b123
--- /dev/null
+++ b/tests/CommandForge.Tests/ProcessStartSitesTests.cs
@@ -0,0 +1,81 @@
+using System.Text.RegularExpressions;
+using CommandForge.Desktop.Services;
+
+namespace CommandForge.Tests;
+
+///
+/// Every place that starts a process was read (golden rule #1: only vetted catalog commands run, and
+/// only through the elevation broker when they need admin). Qodana's security rules report a process
+/// start whose arguments aren't literals, and these files are left out of that rule in qodana.yaml
+/// because they were read; this tripwire fails on a new file that starts a process, so it is read too.
+///
+public sealed partial class ProcessStartSitesTests
+{
+ /// The files read, and what each starts.
+ private static readonly Dictionary ReadSites = new(StringComparer.OrdinalIgnoreCase)
+ {
+ // A catalog command (resolved to a Windows directory by ExecutableResolver) or the user's own
+ // non-elevated command; arguments from the vetted template and trusted tokens; no shell.
+ ["src/CommandForge.Infrastructure/Execution/SystemProcessRunner.cs"] = "catalog and user commands",
+
+ // CommandForge.Elevator.exe beside the app, with a fresh pipe name, through UAC ("runas").
+ ["src/CommandForge.Infrastructure/Elevation/BrokerElevationService.cs"] = "the Elevator",
+
+ // The browser or mail client for https:/mailto: addresses, Explorer for an existing folder
+ // (anything else is refused: IsAllowedTarget), and System32\shutdown.exe /r /t 0.
+ ["src/CommandForge.Wpf/Services/ShellService.cs"] = "links, folders and the restart",
+ };
+
+ [Fact]
+ public void EveryFileThatStartsAProcessHasBeenRead()
+ {
+ var root = FindRepositoryRoot();
+ var separators = new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
+ var unread = Directory.EnumerateFiles(Path.Combine(root, "src"), "*.cs", SearchOption.AllDirectories)
+ .Where(path => !path.Split(separators).Any(part => part is "bin" or "obj"))
+ .Where(path => ProcessStart().IsMatch(File.ReadAllText(path)))
+ .Select(path => Path.GetRelativePath(root, path).Replace('\\', '/'))
+ .Where(path => !ReadSites.ContainsKey(path))
+ .ToList();
+
+ Assert.True(unread.Count == 0, "Read these, then list them here and in qodana.yaml (OpenGrepInspection): " + string.Join(", ", unread));
+ }
+
+ [Fact]
+ public void EveryReadSiteStillExists()
+ {
+ var root = FindRepositoryRoot();
+ Assert.All(ReadSites.Keys, path => Assert.True(File.Exists(Path.Combine(root, path)), path));
+ }
+
+ [Theory]
+ [InlineData("https://github.com/poli0981/CommandForge", true)]
+ [InlineData("mailto:security@poli0981.dev", true)]
+ [InlineData("http://example.com", false)]
+ [InlineData("file:///C:/Windows/System32/cmd.exe", false)]
+ [InlineData("ms-settings:display", false)]
+ [InlineData(@"C:\Windows\System32\cmd.exe", false)] // a file, not a folder
+ [InlineData(@"relative\folder", false)]
+ public void TheShellOpensOnlyWebPagesMailAndFolders(string target, bool allowed)
+ => Assert.Equal(allowed, ShellService.IsAllowedTarget(target, _ => false));
+
+ [Fact]
+ public void TheShellOpensTheAppsOwnFolders()
+ => Assert.True(ShellService.IsAllowedTarget(@"C:\Users\me\AppData\Roaming\CommandForge", _ => true));
+
+ private static string FindRepositoryRoot()
+ {
+ for (var directory = new DirectoryInfo(AppContext.BaseDirectory); directory is not null; directory = directory.Parent)
+ {
+ if (File.Exists(Path.Combine(directory.FullName, "CommandForge.slnx")))
+ {
+ return directory.FullName;
+ }
+ }
+
+ throw new InvalidOperationException("Could not find the repository root (CommandForge.slnx) above " + AppContext.BaseDirectory);
+ }
+
+ [GeneratedRegex(@"Process\.Start\(|new ProcessStartInfo\b|ProcessStartInfo\s*\{|CreateProcess\w*\(|ShellExecute\w*\(", RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 2000)]
+ private static partial Regex ProcessStart();
+}
diff --git a/tests/CommandForge.Tests/ResxKeyTests.cs b/tests/CommandForge.Tests/ResxKeyTests.cs
index 733ba4c..b1374b5 100644
--- a/tests/CommandForge.Tests/ResxKeyTests.cs
+++ b/tests/CommandForge.Tests/ResxKeyTests.cs
@@ -2,6 +2,7 @@ using System.Globalization;
using System.Resources;
using System.Text.RegularExpressions;
using CommandForge.Desktop.Resources;
+using CommandForge.Domain;
using CommandForge.Infrastructure.Catalog;
namespace CommandForge.Tests;
@@ -255,8 +256,8 @@ public sealed partial class ResxKeyTests
public void DynamicKeys_ExistInResx_AllCultures()
{
// Keys built at runtime from enum names: Danger_{level}, Estimate_{duration}.
- var keys = Enum.GetNames().Select(level => "Danger_" + level)
- .Concat(Enum.GetNames().Select(duration => "Estimate_" + duration));
+ var keys = Enum.GetNames().Select(level => "Danger_" + level)
+ .Concat(Enum.GetNames().Select(duration => "Estimate_" + duration));
AssertKeysExist(keys);
}
diff --git a/tests/CommandForge.Tests/WpfHelpersTests.cs b/tests/CommandForge.Tests/WpfHelpersTests.cs
index 77269d2..56d5737 100644
--- a/tests/CommandForge.Tests/WpfHelpersTests.cs
+++ b/tests/CommandForge.Tests/WpfHelpersTests.cs
@@ -1,4 +1,4 @@
-using System.Collections.Specialized;
+using CommandForge.Application.Logging;
using CommandForge.Application.Settings;
using CommandForge.Application.UserCommands;
using CommandForge.Desktop;
@@ -29,7 +29,7 @@ public sealed class WpfHelpersTests
{
var buffer = new OutputBuffer();
var notifications = 0;
- ((INotifyCollectionChanged)buffer).CollectionChanged += (_, _) => notifications++;
+ buffer.CollectionChanged += (_, _) => notifications++;
buffer.Append(Enumerable.Range(0, 500).Select(i => new OutputLine(i.ToString(System.Globalization.CultureInfo.InvariantCulture), false)).ToList());
buffer.Add(new OutputLine("one more", true));
@@ -42,7 +42,7 @@ public sealed class WpfHelpersTests
public void OutputBuffer_ClearResetsTheDroppedCount()
{
var buffer = new OutputBuffer(capacity: 10);
- buffer.Append(Enumerable.Range(0, 30).Select(i => new OutputLine("x", false)).ToList());
+ buffer.Append(Enumerable.Range(0, 30).Select(_ => new OutputLine("x", false)).ToList());
buffer.Clear();
@@ -101,7 +101,7 @@ public sealed class WpfHelpersTests
Assert.Equal(AppTheme.System, settings.Theme);
Assert.Equal(string.Empty, settings.Language);
Assert.Empty(settings.FavoriteCommandIds);
- Assert.Equal(CommandForge.Application.Logging.LogLevel.Warning, settings.LogLevel);
+ Assert.Equal(LogLevel.Warning, settings.LogLevel);
}
finally
{