Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e39e613cf7
|
||
|
|
ac378452a8 | ||
|
|
280253c3ba | ||
|
|
abb6b4ae20 | ||
|
|
6db1b4c2a1 | ||
|
|
1908464811
|
||
|
|
67484ec2ce
|
||
|
|
2dd57b90e5 | ||
|
|
18453dd2d3
|
||
|
|
179e94e128
|
||
|
|
f243521e20
|
||
|
|
2a3ec3976f |
No files matched your search
@@ -36,6 +36,13 @@
|
||||
"reportgenerator"
|
||||
],
|
||||
"rollForward": false
|
||||
},
|
||||
"dotnet-sonarscanner": {
|
||||
"version": "12.0.0",
|
||||
"commands": [
|
||||
"dotnet-sonarscanner"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ updates:
|
||||
- "nuget-license"
|
||||
- "microsoft.sbom.dotnettool"
|
||||
- "dotnet-reportgenerator-globaltool"
|
||||
- "dotnet-sonarscanner"
|
||||
- "Microsoft.Windows.CsWin32"
|
||||
|
||||
- package-ecosystem: "dotnet-sdk"
|
||||
|
||||
@@ -11,7 +11,8 @@ on:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: read-all
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
|
||||
@@ -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"
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
@@ -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];
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user