Compare commits

...
Author SHA1 Message Date
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
13 changed files with 49 additions and 12 deletions

No files matched your search

+2 -1
View File
@@ -11,7 +11,8 @@ on:
branches: [master]
workflow_dispatch:
permissions: read-all
permissions:
contents: read
jobs:
analysis:
+1 -1
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
+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 -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>
@@ -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);
+5 -1
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.
@@ -16,7 +20,7 @@ public sealed class ShellLauncher(IElevationService elevation)
try
{
var startInfo = elevation.IsCurrentProcessElevated
? new ProcessStartInfo("explorer.exe") { ArgumentList = { target }, UseShellExecute = false }
? new ProcessStartInfo(ExplorerPath) { ArgumentList = { target }, UseShellExecute = false }
: new ProcessStartInfo(target) { UseShellExecute = true };
using var process = Process.Start(startInfo);
return true;
+2
View File
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Windows.Win32;
using Windows.Win32.UI.Accessibility;
@@ -7,6 +8,7 @@ namespace AutoClick.Win32;
/// Out-of-context WinEvent hook. Callbacks arrive on the thread that created the watcher
/// (it must pump messages, e.g. the WPF UI thread).
/// </summary>
[SuppressMessage("Reliability", "S3453:Classes should not have only \"private\" constructors", Justification = "Instances come from the static factories below.")]
public sealed class WinEventWatcher : IDisposable
{
private const uint WinEventOutOfContext = 0x0000;
@@ -1,7 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using AutoClick.Core.Models;
namespace AutoClick.Core.Tests;
[SuppressMessage("Security", "S2245:Pseudorandom number generators (PRNGs) should not be used in security contexts", Justification = "Seeded Random keeps the tests reproducible.")]
public class TimingAndColorTests
{
[Fact]
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using AutoClick.Core.Abstractions;
using AutoClick.Core.Models;
using AutoClick.Core.Sessions;
@@ -13,6 +14,7 @@ public class ClickEngineTests
private readonly FakeWindowInspector _window = new();
private readonly FakePixelReader _pixels = new();
[SuppressMessage("Security", "S2245:Pseudorandom number generators (PRNGs) should not be used in security contexts", Justification = "Seeded Random keeps the tests reproducible.")]
private ClickEngine CreateEngine() =>
new(_input, _window, _pixels, _time, TestLog.For<ClickEngine>(), () => new Random(7));
+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);
}
}