Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 e39e613cf7 test: cover ShellLauncher's start info, including the elevated path
The 2.0.2 fix (Explorer by its full path when elevated) had no test, and
its two lines were the only uncovered new code that kept SonarQube
Cloud's quality gate red (coverage on new code 33.3% < 80%).
StartInfo is now a pure function: one test checks that the elevated
path starts explorer.exe from the Windows folder by its full path, the
other that TryOpen returns false for a missing file (not elevated, no
UI, nothing is launched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:36:37 +07:00
poli0981andClaude Opus 5.5 ac378452a8 ci: send the product version to SonarQube Cloud (#67)
Without a project version every analysis reports "not provided", so the
"previous version" new-code period never moves past the first analysis:
the master quality gate measured coverage on all code changed since
2026-10-16 (33.3% < 80%). The scan now passes the version from
Directory.Build.props (eng/Get-BuildInfo.ps1), so new code starts at the
last version change.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 12:28:46 +00:00
dependabot[bot] 280253c3ba chore(actions): Bump zizmorcore/zizmor-action (#66)
Bumps the actions group with 1 update: [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action).


Updates `zizmorcore/zizmor-action` from 0.7.0 to 0.7.1
- [Release notes](https://github.com/zizmorcore/zizmor-action/releases)
- [Commits](https://github.com/zizmorcore/zizmor-action/compare/f9597c869b2e67095f9b527070297a13a6efe928...85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e)

---
updated-dependencies:
- dependency-name: zizmorcore/zizmor-action
  dependency-version: 0.7.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-22 12:16:34 +00:00
dependabot[bot] abb6b4ae20 chore(sdk): Bump dotnet-sdk from 10.0.401 to 10.0.402 (#65)
Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 10.0.401 to 10.0.402.
- [Release notes](https://github.com/dotnet/sdk/releases)
- [Commits](https://github.com/dotnet/sdk/compare/v10.0.401...v10.0.402)

---
updated-dependencies:
- dependency-name: dotnet-sdk
  dependency-version: 10.0.402
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-22 12:13:35 +00:00
poli0981 6db1b4c2a1 Merge pull request #63 from poli0981/ci/sonarcloud-scanner
ci: SonarQube Cloud analysis in CI with SonarScanner for .NET
2026-10-22 19:07:21 +07:00
poli0981andClaude Opus 5.5 1908464811 refactor: drop SonarCloud suppressions the CI analysis does not need
With a real build the analyzer binds WinEventWatcher's factory calls
(S3453), and the test projects are analyzed as tests, where the
main-code rule S2245 does not apply. The by-design suppressions (S4790,
S6640) stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:00:21 +07:00
poli0981andClaude Opus 5.5 67484ec2ce ci: analyze with SonarScanner for .NET instead of Automatic Analysis
SonarQube Cloud's Automatic Analysis does not build: it counted tests/
as product code and could not see CsWin32's generated PInvoke code,
which produced false positives (S2245 in tests, S3453 on
WinEventWatcher).

The new sonarcloud workflow builds, runs the tests with Cobertura
coverage and uploads the analysis (multi-language scan keeps the
workflows, YAML and PowerShell files). Test projects are recognized by
their TestContainer capability. Not a required check; Dependabot and
fork pull requests skip it (no SONAR_TOKEN). The scanner is pinned in
the tool manifest and updated with the other tools by Dependabot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:00:21 +07:00
poli0981 2dd57b90e5 Merge pull request #62 from poli0981/fix/sonarcloud-findings
fix: resolve the SonarQube Cloud findings (2.0.2)
2026-10-22 18:54:06 +07:00
poli0981andClaude Opus 5.5 18453dd2d3 chore(release): 2.0.2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:44:40 +07:00
poli0981andClaude Opus 5.5 179e94e128 ci: least-privilege Scorecard defaults and HTTPS-only curl
- scorecard.yml: workflow default "contents: read" instead of read-all;
  the job keeps its own permissions (S8234).
- workflow-lint.yml: restrict the actionlint download to HTTPS, also
  across redirects (S6506).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:44:40 +07:00
poli0981andClaude Opus 5.5 f243521e20 fix: resolve SonarQube Cloud findings
- ShellLauncher: start Explorer by its full path when elevated. A bare
  "explorer.exe" is searched in the app folder first (user-writable), so a
  planted copy would have run with administrator rights (S4036).
- ClickSession: start the loop with an explicit CancellationToken.None.
  The session token would cancel a loop stopped before it starts without
  running it, leaving the session Running (S8949).
- StaThread: hand the test outcome back through a TaskCompletionSource
  instead of a captured local (S2583 false positive); a new test checks
  that failures are still rethrown.
- Justified suppressions for by-design findings: SHA1 only reproduces the
  v1 mutex and pipe names (S4790), reviewed token queries without a safe
  CsWin32 overload (S6640), seeded Random in tests (S2245; automatic
  analysis treats tests/ as product code) and factory-created
  WinEventWatcher (S3453; the analysis cannot see CsWin32-generated code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:44:40 +07:00
poli0981 2a3ec3976f Merge pull request #60 from poli0981/fix/dark-theme-text
fix(ui): readable text and charts in the Dark theme (2.0.1)
2026-10-16 07:05:12 +07:00
17 changed files with 181 additions and 17 deletions

No files matched your search

+7
View File
@@ -36,6 +36,13 @@
"reportgenerator"
],
"rollForward": false
},
"dotnet-sonarscanner": {
"version": "12.0.0",
"commands": [
"dotnet-sonarscanner"
],
"rollForward": false
}
}
}
+1
View File
@@ -62,6 +62,7 @@ updates:
- "nuget-license"
- "microsoft.sbom.dotnettool"
- "dotnet-reportgenerator-globaltool"
- "dotnet-sonarscanner"
- "Microsoft.Windows.CsWin32"
- package-ecosystem: "dotnet-sdk"
+2 -1
View File
@@ -11,7 +11,8 @@ on:
branches: [master]
workflow_dispatch:
permissions: read-all
permissions:
contents: read
jobs:
analysis:
+82
View File
@@ -0,0 +1,82 @@
name: SonarCloud
# SonarQube Cloud analysis with SonarScanner for .NET: issues, security hotspots and test coverage
# for the C# code (test projects are recognized as tests), plus the workflows, YAML and PowerShell
# files. Informational: not a required check. It replaces SonarQube Cloud's Automatic Analysis,
# which must stay turned off for the project (the scan fails otherwise). Dependabot and fork pull
# requests cannot read the SONAR_TOKEN secret and skip the job.
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: sonarcloud-${{ 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:
sonarcloud:
name: sonarcloud
if: >-
github.actor != 'dependabot[bot]' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
runs-on: windows-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # full history: SonarQube Cloud uses blame to find new code
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Restore
run: |
dotnet tool restore
dotnet restore AutoClick.slnx
- name: Build info
id: info
shell: pwsh
run: ./eng/Get-BuildInfo.ps1
# The product version lets the "previous version" new-code period start at the last version
# change; without it, new code would count from the project's first analysis.
# The scanner provisions its own Java runtime. Build output and restore files are not sources.
- name: Begin analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
VERSION: ${{ steps.info.outputs.version }}
run: >-
dotnet sonarscanner begin /k:poli0981_autoclick /o:poli0981 /v:"$env:VERSION"
/d:sonar.host.url=https://sonarcloud.io /d:sonar.token="$env:SONAR_TOKEN"
"/d:sonar.cs.cobertura.reportsPaths=artifacts/test-results/**/*.cobertura.xml"
"/d:sonar.exclusions=**/bin/**,**/obj/**,artifacts/**"
# A plain build: the regular CI job already builds with warnings as errors.
- name: Build
run: dotnet build AutoClick.slnx -c Release --no-restore --no-incremental --disable-build-servers
- name: Test with coverage
run: >-
dotnet test --solution AutoClick.slnx -c Release --no-build
--results-directory artifacts/test-results --coverage --coverage-output-format cobertura
- name: End analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.token="$env:SONAR_TOKEN"
+2 -2
View File
@@ -41,7 +41,7 @@ jobs:
SHA256: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
run: |
archive="actionlint_${VERSION}_linux_amd64.tar.gz"
curl -fsSLo "$archive" "https://github.com/rhysd/actionlint/releases/download/v${VERSION}/${archive}"
curl --proto '=https' --tlsv1.2 -fsSLo "$archive" "https://github.com/rhysd/actionlint/releases/download/v${VERSION}/${archive}"
echo "${SHA256} ${archive}" | sha256sum --check --strict
tar -xzf "$archive" actionlint
@@ -59,7 +59,7 @@ jobs:
persist-credentials: false
- name: Run zizmor
uses: zizmorcore/zizmor-action@f9597c869b2e67095f9b527070297a13a6efe928 # v0.7.0
uses: zizmorcore/zizmor-action@85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e # v0.7.1
with:
version: 1.31.0
# Fail the job on findings instead of uploading them to code scanning.
+10 -1
View File
@@ -8,6 +8,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [Unreleased]
## [2.0.2] - 2026-10-22
Security hardening from a static analysis review (SonarQube Cloud). Settings, profiles and sessions are unchanged.
### Security
- When AutoClick runs as administrator, links, files and folders are now opened with the Explorer of the Windows folder. Before, Explorer was looked up by name, so a program called `explorer.exe` placed in the AutoClick folder could have been started with administrator rights.
## [2.0.1] - 2026-10-16
Fixes for the Dark theme. Settings, profiles and sessions are unchanged.
@@ -358,7 +366,8 @@ Platform bridge release: no feature or data-format changes, so it is safe to upd
- `ManualResetEventSlim` for pause/resume, `CancellationToken` for stop
- `DispatcherTimer` for UI refresh and process monitoring
[Unreleased]: https://github.com/poli0981/autoclick/compare/v2.0.1...HEAD
[Unreleased]: https://github.com/poli0981/autoclick/compare/v2.0.2...HEAD
[2.0.2]: https://github.com/poli0981/autoclick/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/poli0981/autoclick/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/poli0981/autoclick/compare/v1.3.4...v2.0.0
[1.3.4]: https://github.com/poli0981/autoclick/compare/v1.3.3...v1.3.4
+1
View File
@@ -38,6 +38,7 @@ dotnet jb inspectcode AutoClick.slnx --no-build --properties:Configuration=Relea
- LiveCharts' WPF charts always use the light LiveCharts theme and clear their canvas white unless `Background` is a solid brush: keep `Background="Transparent"` and paint the text from the WPF-UI theme (`DashboardViewModel.ApplyThemeAndTexts`).
- `ThemeService.ThemeChanged` relays WPF-UI's `ApplicationThemeManager.Changed`, so it also fires when Windows switches the theme; it is raised asynchronously, once per burst.
- The smoke test uses `%TEMP%\AutoClick-smoke`. A normal run uses `%LocalAppData%\AutoClick`, which is also the folder of an installed AutoClick (and a running installed copy takes over through the single-instance pipe): delete it after local manual tests only if it did not exist before.
- SonarQube Cloud runs in CI (`.github/workflows/sonarcloud.yml`, secret `SONAR_TOKEN`). Its Automatic Analysis must stay off, or the scan fails; it also counted `tests/` as product code and could not see CsWin32's generated code. Suppress a finding only with `[SuppressMessage]` and a `Justification`.
- Commits in this repository are GPG-signed; never bypass signing.
## Releasing
+3
View File
@@ -29,6 +29,8 @@ The design is described in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md); the tes
| **dependency-review** | The pull request adds no vulnerable package and no disallowed license (build and test tools that are never shipped are exempt; the list is in the workflow) | GitHub only |
| **analyze (csharp)** | CodeQL security analysis | GitHub only |
SonarQube Cloud also analyzes every pull request from this repository (the **sonarcloud** check, not required): issues, security hotspots and test coverage of the changed code. Pull requests from forks and Dependabot skip it because they cannot read the `SONAR_TOKEN` secret.
Local equivalents of build-test and dead-code (PowerShell):
```powershell
@@ -58,6 +60,7 @@ Please also:
- **File formats are a contract:** profiles keep the 1.x JSON layout (property names, enums as numbers) so 1.x can still read them; settings and sessions are versioned (`schemaVersion`) and older versions must keep loading. Add tests with fixture files under `tests/Fixtures` for any change.
- **Win32:** add new APIs to `src/AutoClick.Win32/NativeMethods.txt` (CsWin32). Anything that converts game coordinates runs inside a `DpiScope` for the game window.
- **No unused code:** the dead-code check fails on it. For a deliberate exception, write `// ReSharper disable once <rule>` with a reason.
- **SonarQube Cloud findings** are fixed, or, when the code is right as it is, suppressed with `[SuppressMessage("Category", "Sxxxx:Title", Justification = "why")]`.
## Translations
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- Single source of truth for the product version (release tags must match it). -->
<PropertyGroup>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
<AssemblyVersion>$(Version).0</AssemblyVersion>
<FileVersion>$(Version).0</FileVersion>
<InformationalVersion>$(Version)</InformationalVersion>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.401",
"version": "10.0.402",
"rollForward": "latestFeature"
},
"test": {
@@ -116,7 +116,9 @@ public sealed class ClickSession : IDisposable
internal void Start()
{
_logger.LogInformation("Auto-click started for {Process} ({Points} steps)", _info.ProcessName, _info.Points.Count);
Completion = Task.Run(RunAsync);
// Not the session token: a stop requested before the loop starts would cancel the task
// without running it, and the session would never report that it stopped.
Completion = Task.Run(RunAsync, CancellationToken.None);
}
public void Pause()
@@ -34,6 +34,7 @@ public sealed class SingleInstance : IDisposable
/// <summary>Same names as v1, so v1 and v2 never run side by side.</summary>
[SuppressMessage("Security", "CA5350:Do Not Use Weak Cryptographic Algorithms", Justification = "Not security related: the hash only reproduces v1's object names.")]
[SuppressMessage("Security", "S4790:Weak hashing algorithms should not be used", Justification = "Not security related: the hash only reproduces v1's object names.")]
private static string UserKey { get; } =
Convert.ToHexString(SHA1.HashData(Encoding.UTF8.GetBytes(Environment.UserName ?? "default")))[..16];
+3
View File
@@ -1,5 +1,6 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using AutoClick.Core.Abstractions;
using Microsoft.Win32.SafeHandles;
@@ -91,6 +92,7 @@ public sealed class ElevationService : IElevationService
}
}
[SuppressMessage("Security", "S6640:Unsafe code blocks should not be used", Justification = "Reviewed: CsWin32 has no safe overload; the struct has the size passed to the call.")]
private static bool GetOwnElevation()
{
using var token = OpenOwnToken();
@@ -120,6 +122,7 @@ public sealed class ElevationService : IElevationService
}
/// <summary>The integrity level RID (e.g. 0x2000 medium, 0x3000 high), or -1.</summary>
[SuppressMessage("Security", "S6640:Unsafe code blocks should not be used", Justification = "Reviewed: CsWin32 has no safe overloads; the buffer has the size the first call reports and stays pinned while it is read.")]
private static unsafe int GetIntegrityLevel(SafeHandle token)
{
PInvoke.GetTokenInformation(token, TOKEN_INFORMATION_CLASS.TokenIntegrityLevel, null, 0, out var size);
+10 -4
View File
@@ -7,6 +7,10 @@ namespace AutoClick.Win32;
/// <summary>Opens URLs, files and folders with their default handler.</summary>
public sealed class ShellLauncher(IElevationService elevation)
{
// A full path: a bare "explorer.exe" is searched in AutoClick's own folder first, which
// the user can write to, and would then run with administrator rights.
private static string ExplorerPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe");
/// <summary>
/// When AutoClick runs elevated, the target is opened through Explorer so the browser or
/// editor does not inherit administrator rights.
@@ -15,10 +19,7 @@ public sealed class ShellLauncher(IElevationService elevation)
{
try
{
var startInfo = elevation.IsCurrentProcessElevated
? new ProcessStartInfo("explorer.exe") { ArgumentList = { target }, UseShellExecute = false }
: new ProcessStartInfo(target) { UseShellExecute = true };
using var process = Process.Start(startInfo);
using var process = Process.Start(StartInfo(target, elevation.IsCurrentProcessElevated));
return true;
}
catch (Exception ex) when (ex is Win32Exception or InvalidOperationException)
@@ -26,4 +27,9 @@ public sealed class ShellLauncher(IElevationService elevation)
return false;
}
}
internal static ProcessStartInfo StartInfo(string target, bool elevated) =>
elevated
? new ProcessStartInfo(ExplorerPath) { ArgumentList = { target }, UseShellExecute = false }
: new ProcessStartInfo(target) { UseShellExecute = true };
}
@@ -0,0 +1,37 @@
using System.IO;
using AutoClick.Core.Abstractions;
namespace AutoClick.Win32.Tests;
public class ShellLauncherTests
{
[Fact]
public void StartInfo_Elevated_StartsExplorerByItsFullPath()
{
var startInfo = ShellLauncher.StartInfo("https://example.com", elevated: true);
// A bare "explorer.exe" would be searched in AutoClick's own, user-writable folder first.
Assert.True(Path.IsPathFullyQualified(startInfo.FileName));
Assert.Equal(Environment.GetFolderPath(Environment.SpecialFolder.Windows), Path.GetDirectoryName(startInfo.FileName), ignoreCase: true);
Assert.Equal("explorer.exe", Path.GetFileName(startInfo.FileName), ignoreCase: true);
Assert.True(File.Exists(startInfo.FileName));
Assert.Equal("https://example.com", Assert.Single(startInfo.ArgumentList));
Assert.False(startInfo.UseShellExecute);
}
[Fact]
public void TryOpen_MissingFile_ReturnsFalse()
{
// Not elevated: the default handler reports the missing file without showing any UI.
var launcher = new ShellLauncher(new NotElevated());
Assert.False(launcher.TryOpen(Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid():N}.autoclick-missing")));
}
private sealed class NotElevated : IElevationService
{
public bool IsCurrentProcessElevated => false;
public ElevationState GetRelativeElevation(int processId) => ElevationState.SameOrLower;
}
}
+5 -6
View File
@@ -7,16 +7,18 @@ internal static class StaThread
{
public static void Run(Action action)
{
Exception? failure = null;
// The task carries the outcome back; GetResult rethrows a failure with its original stack.
var outcome = new TaskCompletionSource();
var thread = new Thread(() =>
{
try
{
action();
outcome.SetResult();
}
catch (Exception ex)
{
failure = ex;
outcome.SetException(ex);
}
finally
{
@@ -26,10 +28,7 @@ internal static class StaThread
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
Assert.True(thread.Join(TimeSpan.FromSeconds(30)), "STA test thread timed out.");
if (failure is not null)
{
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(failure).Throw();
}
outcome.Task.GetAwaiter().GetResult();
}
/// <summary>Pumps messages until <paramref name="task"/> completes (or the timeout elapses).</summary>
@@ -0,0 +1,12 @@
namespace AutoClick.Win32.Tests;
public class StaThreadTests
{
[Fact]
public void Run_TestCodeThrows_RethrowsTheSameException()
{
var failure = Assert.Throws<InvalidOperationException>(() => StaThread.Run(() => throw new InvalidOperationException("boom")));
Assert.Equal("boom", failure.Message);
}
}