diff --git a/.github/workflows/ci-devsecops.yml b/.github/workflows/ci-devsecops.yml new file mode 100644 index 0000000..cd51dba --- /dev/null +++ b/.github/workflows/ci-devsecops.yml @@ -0,0 +1,36 @@ +name: CI DevSecOps + +on: + push: + branches: ["main", "master"] + pull_request: + +jobs: + build-and-scan: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "8.0.x" + + - name: Restore + run: dotnet restore "ThreadPilot.csproj" + + - name: Build Debug + run: dotnet build "ThreadPilot.csproj" --configuration Debug --no-restore + + - name: Build Release + run: dotnet build "ThreadPilot.csproj" --configuration Release --no-restore + + - name: Dependency Audit + run: dotnet list "ThreadPilot.csproj" package --vulnerable --include-transitive + + - name: Secret Scan + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index e3733b6..3105e88 100644 --- a/.gitignore +++ b/.gitignore @@ -131,3 +131,4 @@ GAME_BOOST_VALIDATION.md PROJECT_STRUCTURE.md TRADEMARK.md UI_STYLE_GUIDE.md +COMPLIANCE_AUDIT.md diff --git a/App.xaml.cs b/App.xaml.cs index 563ab20..1c963a4 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -34,6 +34,8 @@ namespace ThreadPilot public partial class App : System.Windows.Application { private Mutex? _singleInstanceMutex; + private int _uiExceptionDialogOpen; + private DateTime _lastUiExceptionDialogUtc = DateTime.MinValue; public IServiceProvider ServiceProvider { get; private set; } public App() @@ -135,6 +137,24 @@ namespace ThreadPilot } #endif + try + { + var settingsService = ServiceProvider.GetRequiredService(); + var themeService = ServiceProvider.GetRequiredService(); + + Task.Run(async () => await settingsService.LoadSettingsAsync()).GetAwaiter().GetResult(); + var settings = settingsService.Settings; + var useDarkTheme = settings.HasUserThemePreference + ? settings.UseDarkTheme + : themeService.GetSystemUsesDarkTheme(); + + themeService.ApplyTheme(useDarkTheme); + } + catch (Exception ex) + { + logger.LogWarning(ex, "Failed to preload theme settings during startup"); + } + var mainWindow = ServiceProvider.GetRequiredService(); // Handle startup behavior with comprehensive error handling @@ -148,15 +168,27 @@ namespace ThreadPilot throw new InvalidOperationException("MainWindow could not be created"); } - // Show the window with explicit visibility settings - mainWindow.Visibility = Visibility.Visible; - mainWindow.WindowState = (startMinimized || isAutostart) - ? WindowState.Minimized - : WindowState.Normal; - mainWindow.Show(); - if (mainWindow.WindowState != WindowState.Minimized) + if (isAutostart) { - mainWindow.Activate(); + mainWindow.ShowInTaskbar = false; + mainWindow.Visibility = Visibility.Hidden; + mainWindow.WindowState = WindowState.Minimized; + mainWindow.Show(); + mainWindow.Hide(); + } + else + { + // Show the window with explicit visibility settings + mainWindow.ShowInTaskbar = true; + mainWindow.Visibility = Visibility.Visible; + mainWindow.WindowState = startMinimized + ? WindowState.Minimized + : WindowState.Normal; + mainWindow.Show(); + if (mainWindow.WindowState != WindowState.Minimized) + { + mainWindow.Activate(); + } } logger.LogInformation("Main window displayed successfully"); @@ -247,6 +279,21 @@ namespace ThreadPilot logger?.LogError(e.Exception, "Unhandled dispatcher exception occurred"); + if (Interlocked.CompareExchange(ref _uiExceptionDialogOpen, 1, 0) != 0) + { + e.Handled = true; + return; + } + + if (DateTime.UtcNow - _lastUiExceptionDialogUtc < TimeSpan.FromSeconds(2)) + { + e.Handled = true; + Interlocked.Exchange(ref _uiExceptionDialogOpen, 0); + return; + } + + _lastUiExceptionDialogUtc = DateTime.UtcNow; + var errorMessage = $"An error occurred in the user interface:\n\n{e.Exception.Message}\n\nDo you want to continue?"; var result = System.Windows.MessageBox.Show(errorMessage, "UI Error", MessageBoxButton.YesNo, MessageBoxImage.Error); @@ -259,6 +306,8 @@ namespace ThreadPilot { e.Handled = false; // Let the application crash } + + Interlocked.Exchange(ref _uiExceptionDialogOpen, 0); } } } diff --git a/MainWindow.xaml b/MainWindow.xaml index 0378015..54a021f 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -13,18 +13,6 @@ WindowStartupLocation="CenterScreen"> - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + - - - - - - - - + + - - - - - - - - - - - - -