A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.
feat: implement antivirus verification for release files and add regression tests
CristianOlivera1284c72dfe3a8
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex e5ab3fe..b4ff264 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -29,6 +29,10 @@ jobs:shell: pwshrun: ./scripts/Test-CodeSigning.ps1+ - name: Check release antivirus verification without malware or Defender changes+ shell: pwsh+ run: ./scripts/Test-ReleaseAntivirus.ps1+# The settings app embeds its built front end at compile time.- name: Build settings UIworking-directory: apps/settingsdiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex d7d537d..fa095b8 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -207,6 +207,29 @@ jobs:If a signature remains invalid, send its status/message and the signing request IDs to SignPath support.'@ >> $env:GITHUB_STEP_SUMMARY+ - name: Update Defender definitions for release analysis+ if: env.SIGNING_MODE != 'Test'+ timeout-minutes: 5+ shell: pwsh+ run: Update-MpSignature -ErrorAction Stop++ - name: Analyze the final release files with Microsoft Defender+ if: env.SIGNING_MODE != 'Test'+ timeout-minutes: 10+ shell: pwsh+ run: |+ ./scripts/Assert-ReleaseAntivirus.ps1 -ReportDirectory antivirus-report -Path `+ target/release/muelle-settings.exe,apps/settings/src-tauri/binaries/muelle-x86_64-pc-windows-msvc.exe,"target/release/bundle/nsis/Muelle_${env:VERSION}_x64-setup.exe"++ - name: Keep antivirus verification evidence+ if: always() && env.SIGNING_MODE != '' && env.SIGNING_MODE != 'Test'+ uses: actions/upload-artifact@v7+ with:+ name: antivirus-${{ env.VERSION }}+ path: antivirus-report/+ if-no-files-found: warn+ retention-days: 14+# latest.json is what the in-app updater reads; Muelle-Setup.exe is a# stable name for the website's "latest" download link.- name: Prepare release filesdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 450cda7..f21b29f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,10 @@ copia la sección de la versión que se publica a la release de GitHub.### English+- Release now scans the final Dock, Settings and installer bytes with Microsoft+ Defender before creating updater metadata or a draft release, and retains+ hashes, signature details and scan evidence. Detections and incomplete scans+ stop publication; runtime app behavior is unchanged.- Added Simplified Chinese, Hindi, Arabic, Bengali and Portuguese to Settings,Dock menus and menu-bar panels. Language now uses a dropdown with nativelanguage names and an Automatic option that follows Windows. Arabic Settings@@ -65,6 +69,10 @@ copia la sección de la versión que se publica a la release de GitHub.### Español+- Release analiza los binarios finales del Dock, Ajustes y el instalador con+ Microsoft Defender antes de crear el manifiesto del actualizador o el borrador,+ conservando hashes, firmas y el resultado. Las detecciones o análisis fallidos+ detienen la publicación; no cambia el funcionamiento de la app.- Añadidos chino simplificado, hindi, árabe, bengalí y portugués en Ajustes,menús del Dock y paneles de la barra superior. El idioma se elige en undesplegable con nombres nativos y Automático para seguir Windows. Ajustesdiff --git a/scripts/Assert-ReleaseAntivirus.ps1 b/scripts/Assert-ReleaseAntivirus.ps1new file mode 100644index 0000000..e1289cd--- /dev/null+++ b/scripts/Assert-ReleaseAntivirus.ps1@@ -0,0 +1,79 @@+# Analyze release bytes without executing them or changing Defender preferences.+[CmdletBinding()]+param(+ [Parameter(Mandatory)][string[]]$Path,+ [Parameter(Mandatory)][string]$ReportDirectory+)+$ErrorActionPreference = 'Stop'++function Get-ReleaseDefenderScanner {+ $platform = Join-Path $env:ProgramData 'Microsoft/Windows Defender/Platform'+ $latest = Get-ChildItem -LiteralPath $platform -Directory -ErrorAction SilentlyContinue |+ Sort-Object LastWriteTime -Descending | Select-Object -First 1+ if ($latest) {+ $candidate = Join-Path $latest.FullName 'MpCmdRun.exe'+ if (Test-Path -LiteralPath $candidate -PathType Leaf) { return $candidate }+ }+ $fallback = Join-Path $env:ProgramFiles 'Windows Defender/MpCmdRun.exe'+ if (-not (Test-Path -LiteralPath $fallback -PathType Leaf)) {+ throw 'Microsoft Defender scanner is unavailable. Use a Windows runner with Defender installed.'+ }+ $fallback+}++function Invoke-ReleaseDefenderScan([string]$Scanner, [string]$File) {+ # This flag affects only this analysis: it ignores the hosted runner's broad+ # build exclusions and scans archives. Defender itself remains enabled.+ # Detected files are never executed or published; a nonzero result fails CI.+ $PSNativeCommandUseErrorActionPreference = $false+ & $Scanner -Scan -ScanType 3 -File $File -DisableRemediation | Out-Host+ if ($LASTEXITCODE -ne 0) {+ throw "Defender rejected $File or could not complete its analysis (exit $LASTEXITCODE)."+ }+}++function Assert-ReleaseAntivirus([string[]]$Path, [string]$ReportDirectory) {+ $report = [ordered]@{ passed = $false; scannedAt = [DateTime]::UtcNow.ToString('o'); files = @() }+ New-Item -ItemType Directory -Path $ReportDirectory -Force | Out-Null+ try {+ $status = Get-MpComputerStatus -ErrorAction Stop+ if (-not $status.AMServiceEnabled -or -not $status.AntivirusEnabled) {+ throw 'Microsoft Defender is unavailable or disabled. Antivirus verification cannot be skipped.'+ }+ $report.engineVersion = [string]$status.AMEngineVersion+ $report.signatureVersion = [string]$status.AntivirusSignatureVersion+ if ($null -eq $status.AntivirusSignatureAge -or $status.AntivirusSignatureAge -gt 1 -or+ [string]::IsNullOrWhiteSpace($report.engineVersion) -or [string]::IsNullOrWhiteSpace($report.signatureVersion)) {+ throw 'Defender definitions are older than one day. Update signatures on the build runner and retry.'+ }+ $scanner = Get-ReleaseDefenderScanner+ foreach ($file in $Path) {+ $resolved = (Resolve-Path -LiteralPath $file -ErrorAction Stop).Path+ $hash = (Get-FileHash -LiteralPath $resolved -Algorithm SHA256).Hash+ $signature = Get-AuthenticodeSignature -LiteralPath $resolved+ $row = [ordered]@{+ file = [IO.Path]::GetFileName($resolved); sha256 = $hash+ fileVersion = [Diagnostics.FileVersionInfo]::GetVersionInfo($resolved).FileVersion+ authenticode = [string]$signature.Status+ publisher = if ($signature.SignerCertificate) { $signature.SignerCertificate.Subject } else { $null }+ passed = $false+ }+ $report.files += $row+ Invoke-ReleaseDefenderScan -Scanner $scanner -File $resolved+ # A removed, quarantined or changed file cannot inherit a clean result.+ if ((Get-FileHash -LiteralPath $resolved -Algorithm SHA256 -ErrorAction Stop).Hash -ne $hash) {+ throw "Release bytes changed during antivirus verification: $resolved"+ }+ $row.passed = $true+ }+ $report.passed = $true+ } catch {+ $report.error = $_.Exception.Message+ throw+ } finally {+ $report | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $ReportDirectory 'antivirus-report.json') -Encoding utf8NoBOM+ }+}++# Dot-sourcing exposes the orchestration for offline tests; normal runs scan.+if ($MyInvocation.InvocationName -ne '.') { Assert-ReleaseAntivirus @PSBoundParameters }diff --git a/scripts/Test-ReleaseAntivirus.ps1 b/scripts/Test-ReleaseAntivirus.ps1new file mode 100644index 0000000..44eecc9--- /dev/null+++ b/scripts/Test-ReleaseAntivirus.ps1@@ -0,0 +1,74 @@+# Offline regression tests: no real scan, malware, network or Defender changes.+$ErrorActionPreference = 'Stop'+$root = Join-Path ([IO.Path]::GetTempPath()) ("muelle-antivirus-test-" + [guid]::NewGuid())+New-Item -ItemType Directory -Path $root | Out-Null+$fixture = Join-Path $root 'fixture.exe'+$reportDir = Join-Path $root 'report'+Set-Content -LiteralPath $fixture -Value 'test-owned inert bytes'+$verifier = Join-Path $PSScriptRoot 'Assert-ReleaseAntivirus.ps1'+. $verifier -Path $fixture -ReportDirectory $reportDir+$state = @{ enabled = $true; age = 0; scan = 'clean'; calls = 0 }+function Get-MpComputerStatus {+ [pscustomobject]@{ AMServiceEnabled = $state.enabled; AntivirusEnabled = $state.enabled+ AntivirusSignatureAge = $state.age; AMEngineVersion = 'test-engine'; AntivirusSignatureVersion = 'test-definitions' }+}+function Get-ReleaseDefenderScanner { 'test-only scanner' }+function Invoke-ReleaseDefenderScan([string]$Scanner, [string]$File) {+ if ($Scanner -ne 'test-only scanner') { throw 'A real scanner must never run in offline tests.' }+ $state.calls+++ switch ($state.scan) {+ 'detected' { throw 'Fixture threat detected.' }+ 'error' { throw 'Fixture scanner could not finish.' }+ 'changed' { Add-Content -LiteralPath $File -Value 'changed bytes' }+ 'removed' { Remove-Item -LiteralPath $File }+ }+}+function Read-Report { Get-Content -LiteralPath (Join-Path $reportDir 'antivirus-report.json') -Raw | ConvertFrom-Json }+function Assert-Rejected([string]$Name, [scriptblock]$Action) {+ $rejected = $false+ try { & $Action } catch { $rejected = $true }+ if (-not $rejected -or (Read-Report).passed) { throw "Failed to reject: $Name" }+ Write-Host "PASS: $Name"+}+try {+ foreach ($file in @($verifier, $PSCommandPath)) {+ $tokens = $null; $errors = $null+ $null = [Management.Automation.Language.Parser]::ParseFile($file, [ref]$tokens, [ref]$errors)+ if ($errors) { throw ($errors | Out-String) }+ }+ Assert-ReleaseAntivirus -Path $fixture -ReportDirectory $reportDir+ $report = Read-Report+ if (-not $report.passed -or $report.files[0].sha256 -ne (Get-FileHash -LiteralPath $fixture).Hash -or+ $report.signatureVersion -ne 'test-definitions' -or $state.calls -ne 1) { throw 'Clean report is incomplete.' }+ Write-Host 'PASS: completed scan records the exact bytes and definition version'+ foreach ($mode in @('detected', 'error', 'changed', 'removed')) {+ $state.scan = $mode+ Assert-Rejected $mode { Assert-ReleaseAntivirus -Path $fixture -ReportDirectory $reportDir }+ Set-Content -LiteralPath $fixture -Value 'test-owned inert bytes'+ }+ $state.scan = 'clean'+ $state.enabled = $false+ $calls = $state.calls+ Assert-Rejected 'disabled antivirus cannot pass' { Assert-ReleaseAntivirus -Path $fixture -ReportDirectory $reportDir }+ if ($state.calls -ne $calls) { throw 'A disabled engine was used.' }+ $state.enabled = $true+ $state.age = 2+ Assert-Rejected 'stale definitions cannot pass' { Assert-ReleaseAntivirus -Path $fixture -ReportDirectory $reportDir }+ $state.age = $null+ Assert-Rejected 'unknown definitions cannot pass' { Assert-ReleaseAntivirus -Path $fixture -ReportDirectory $reportDir }+ $state.age = 0+ Assert-Rejected 'missing release file cannot pass' { Assert-ReleaseAntivirus -Path (Join-Path $root 'missing.exe') -ReportDirectory $reportDir }+ $workflow = Get-Content (Join-Path $PSScriptRoot '../.github/workflows/release.yml') -Raw+ $scan = $workflow.IndexOf('- name: Analyze the final release files with Microsoft Defender')+ $prepare = $workflow.IndexOf('- name: Prepare release files')+ $publish = $workflow.IndexOf('- name: Create draft release')+ if ($scan -lt 0 -or $scan -ge $prepare -or $prepare -ge $publish) { throw 'Scan must precede updater manifest and release creation.' }+ Write-Host 'PASS: rejected files cannot reach updater metadata or a draft release'+} finally {+ # Only this test's newly created absolute temp directory may be removed.+ $resolved = [IO.Path]::GetFullPath($root)+ $temp = [IO.Path]::GetFullPath([IO.Path]::GetTempPath())+ if (-not $resolved.StartsWith($temp, [StringComparison]::OrdinalIgnoreCase) -or+ [IO.Path]::GetFileName($resolved) -notlike 'muelle-antivirus-test-*') { throw 'Unsafe test cleanup path.' }+ Remove-Item -LiteralPath $resolved -Recurse -Force+}