Files
frameledger/tests/FrameLedger.Infrastructure.Tests/ProcessStartSitesTests.cs
poli0981andClaude Fable 5.2 7cd933f62d ci: Qodana for .NET on the Ultimate licence reads the managed code - native on Windows, hints off, every process start read, ShellUrlOpener opens web and mail links only (Qodana PR-1, D99/D100) (#384)
The owner took an Ultimate licence for the Qodana Cloud organisation and asked for Qodana over every language. This is
the first of two pull requests: the existing job moves to Qodana for .NET (Rider's engine) and what it reports over the
managed code is settled. The C++ is the next one's, as a second report.

The job
- qodana.yaml: linter qodana-dotnet, withinDocker false (native mode on the job's Windows runner, the SDK from
  global.json; no container, no EnableWindowsTargeting, no bootstrap line). Everything a run needs is in the file.
- qodana.yml: the job is `managed` (Qodana (managed)), on windows-latest - checkout, setup-dotnet, the NuGet cache
  restored, dotnet build -c Release, then the action pinned by commit. Still advisory, still a gate of zero.

What its first run reported, and what was done (docs/13_CI_CD.md, section Qodana, has each)
- 3,953 problems, 3,607 of them hints - the level an editor offers without underlining anything; the Community linter
  never reported them. Hints are off as a severity (one group in qodana.yaml). 347 left.
- 271: a vi or ja value equal to the English one - off in .editorconfig for .resx (names, units, format strings).
- 23 + 10: two Markdown inspections (table padding; anchors computed otherwise than GitHub does) off in qodana.yaml;
  the application manifest's XML ignored for XmlHighlighting.
- 6 in PrimaryDisplay.cs are the linter's own fault (an internal assertion, in its log); two inspections are excluded
  for that file, and the file is as it was.
- 1 fixed: a test expression that carried a clause its first half implied.
- 36 from JetBrains' security rules: 35 process starts and 1 SQL text. Each was read - what it starts, where the path
  and the arguments come from (a table in the docs). None takes a value from outside the PC, except the game the user
  added. One place was hardened: ShellUrlOpener now refuses any address that is not http, https or mailto itself,
  where it trusted each caller to have checked (ShellUrlOpenerTests).
  The rules stay on. A rule's own id is honoured nowhere - a profile entry's `ignore`, an `exclude` path and
  `enabled: false` were each tried in a run of its own and every result stood: the OpenGrep plugin reports every rule
  through one inspection, OpenGrepInspection, and hands its server every rule file whatever the profile says. That
  inspection does take a path, so the eleven files of src the results were read in, and tests, are listed under its
  name in qodana.yaml: a new file that starts a process is reported.
- ProcessStartSitesTests, in the gate, is the same tripwire where a merge is blocked: it sweeps src for every way a
  process is started here - Process.Start, a ProcessStartInfo, CreateProcessWithTokenW, the logon task's
  registration - and fails on a file that has not been read and listed.

Also: ShmDrainIntegrationTests' drain under supervision supervises at least twice whatever the first drain holds. On
a busy machine the first scan was slow enough for fifty presents to be waiting, the loop ended after one evaluation,
and the test failed its own "supervised more than once" (once, in a local gate of this change).

Where an inspection is switched off (D100, amending D93's "never in qodana.yaml"): in the place the engine that raised
it reads - one of ReSharper's in .editorconfig, what has no key there in qodana.yaml.

Docs: 13_CI_CD (section Qodana rewritten above D93's account, which is kept as history), CLAUDE.md (the rule, the
layout), HANDOFF (D99, D100, this part's section, and the facts of the two releases of 2026-11-11: v0.1.0-beta.37 and
v0.1.0-alpha.4), wiki/Releasing, CHANGELOG.

Shipped code: ShellUrlOpener.cs alone. No link the App could open before stops opening.

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 02:14:04 +00:00

71 lines
3.5 KiB
C#

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FluentAssertions;
namespace FrameLedger.Infrastructure.Tests;
/// <summary>
/// Every file in <c>src</c> that starts a process — or, the logon task, has Windows start one — by name (2026-11-11,
/// <c>docs/13_CI_CD.md</c> §Qodana). Qodana's rule for it — JetBrains' <c>csharp_injection_rule-CommandInjection</c>,
/// any <c>Process.Start</c> whose argument is not a literal — reported ten of these; each was read, and its file is
/// listed in <c>qodana.yaml</c>. That rule is a pattern in an advisory job. This sweep is the same tripwire in the
/// gate, and wider: it also sees <c>CreateProcessWithTokenW</c> and the logon task. A new file that starts a process
/// fails here until someone has read what it starts and where the path and the arguments come from, and added it to
/// the list — and to <c>qodana.yaml</c> and the table in that section, where each of these is described.
/// </summary>
public sealed class ProcessStartSitesTests
{
/// <summary>Read on 2026-11-11: what each starts, and from where, is the table in <c>13_CI_CD</c> §Qodana.</summary>
private static readonly string[] _read =
[
"FrameLedger.App/Services/AgentLauncher.cs",
"FrameLedger.App/Services/AgentTool.cs",
"FrameLedger.App/Services/Explorer.cs",
"FrameLedger.App/Services/ShellStarter.cs",
"FrameLedger.App/Services/ShellUrlOpener.cs",
"FrameLedger.App/ViewModels/SettingsViewModel.cs",
"FrameLedger.Infrastructure/Capture/ProcessLauncher.cs",
"FrameLedger.Infrastructure/Diagnostics/CrashDumpWriter.cs",
"FrameLedger.Infrastructure/Startup/AgentElevation.cs",
"FrameLedger.Infrastructure/Startup/LogonTask.cs",
"FrameLedger.Infrastructure/Startup/UnelevatedProcess.cs",
];
private static string RepoRoot()
{
string? dir = AppContext.BaseDirectory;
while (dir is not null && !File.Exists(Path.Combine(dir, "FrameLedger.slnx")))
{
dir = Path.GetDirectoryName(dir);
}
return dir ?? throw new InvalidOperationException("FrameLedger.slnx not found above the test binary");
}
private static bool StartsAProcess(string file)
{
string text = File.ReadAllText(file);
return text.Contains("Process.Start(", StringComparison.Ordinal)
|| text.Contains("new ProcessStartInfo", StringComparison.Ordinal)
|| text.Contains("PInvoke.CreateProcess", StringComparison.Ordinal)
|| text.Contains("RegisterTaskDefinition(", StringComparison.Ordinal);
}
[Fact]
public void EveryFileThatStartsAProcessIsOneThatWasRead()
{
string src = Path.Combine(RepoRoot(), "src");
string obj = $"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}";
string bin = $"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}";
string[] found = [.. Directory.EnumerateFiles(src, "*.cs", SearchOption.AllDirectories)
.Where(f => !f.Contains(obj, StringComparison.Ordinal) && !f.Contains(bin, StringComparison.Ordinal))
.Where(StartsAProcess)
.Select(f => Path.GetRelativePath(src, f).Replace('\\', '/'))
.Order(StringComparer.Ordinal)];
found.Should().Equal(_read,
"a file that starts a process is read first - what it starts, and where the path and the arguments come from - and then listed here and in docs/13_CI_CD.md §Qodana");
}
}