-
Notifications
You must be signed in to change notification settings - Fork 27
Functest: add sigverif helpers and raise driver sign timeouts #1103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
satishnaidu77
wants to merge
4
commits into
HCK-CI:master
Choose a base branch
from
satishnaidu77:functest-sigverif-helpers-x86
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4b370be
Functest: add sigverif helpers and raise driver sign timeouts.
stagiris-design 5c52643
Merge remote-tracking branch 'origin/master' into functest-sigverif-h…
stagiris-design c147418
Functest: address sigverif review comments.
stagiris-design c3641c3
Merge remote-tracking branch 'origin/master' into functest-sigverif-h…
stagiris-design File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "name": "driver_sigverif", | ||
| "description": "Verify @driver_module@.sys is Signed via Windows File Signature Verification GUI (sigverif + AutoIt), mirrors KAR win_sigverif", | ||
| "test_system_ref": "VIRT-SIGVERIF", | ||
| "timeout": 1320, | ||
| "test_steps": [ | ||
| { | ||
| "desc": "Upload common interactive/AutoIt helpers, sigverif.au3, and worker", | ||
| "files_action": [ | ||
| { | ||
| "local_path": "lib/engines/functest/tests/scripts/common/Invoke-InteractiveSession.ps1", | ||
| "remote_path": "C:\\AutoHCK\\common\\Invoke-InteractiveSession.ps1", | ||
| "direction": "local-to-remote" | ||
| }, | ||
| { | ||
| "local_path": "lib/engines/functest/tests/scripts/common/Invoke-AutoIt.ps1", | ||
| "remote_path": "C:\\AutoHCK\\common\\Invoke-AutoIt.ps1", | ||
| "direction": "local-to-remote" | ||
| }, | ||
| { | ||
| "local_path": "lib/engines/functest/tests/scripts/sigverif.au3", | ||
| "remote_path": "C:\\AutoHCK\\sigverif.au3", | ||
| "direction": "local-to-remote" | ||
| }, | ||
| { | ||
| "local_path": "lib/engines/functest/tests/scripts/sigverif_worker.ps1", | ||
| "remote_path": "C:\\AutoHCK\\sigverif_worker.ps1", | ||
| "direction": "local-to-remote" | ||
| } | ||
| ], | ||
| "timeout": 120 | ||
| }, | ||
| { | ||
| "desc": "Run sigverif GUI via AutoIt and confirm @driver_module@.sys is Signed", | ||
| "guest_run_file": "lib/engines/functest/tests/scripts/run_sigverif_gui.ps1", | ||
| "expected_output_contains": "PASS:", | ||
| "timeout": 1200 | ||
| } | ||
| ] | ||
| } | ||
127 changes: 127 additions & 0 deletions
127
lib/engines/functest/tests/scripts/common/Invoke-AutoIt.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Locate AutoIt and run a .au3 script on the current desktop session. | ||
|
|
||
| .DESCRIPTION | ||
| Intended to run inside an interactive session (e.g. after | ||
| Invoke-InteractiveSession.ps1). Requires suite extra_software: ["autoit"]. | ||
|
|
||
| Usage: upload this script (and Invoke-InteractiveSession.ps1 if needed) from | ||
| lib/engines/functest/tests/scripts/common/ via the case files_action step to | ||
| e.g. C:\AutoHCK\common\, then invoke it from the interactive worker. | ||
|
|
||
| .PARAMETER Au3Path | ||
| Absolute guest path to the .au3 script. | ||
|
|
||
| .PARAMETER TimeoutSec | ||
| Max seconds to wait for AutoIt to exit (and optional -WaitForFile). | ||
|
|
||
| .PARAMETER WaitForFile | ||
| If set, keep waiting until this file appears or TimeoutSec elapses | ||
| (even after AutoIt exits). Success requires the file to exist. | ||
|
|
||
| .PARAMETER MinimizeWindows | ||
| Call Shell.Application MinimizeAll before starting AutoIt. | ||
|
|
||
| .PARAMETER LogPath | ||
| Optional log file to append status lines to. | ||
| #> | ||
|
|
||
| param( | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$Au3Path, | ||
|
|
||
| [int]$TimeoutSec = 180, | ||
|
|
||
| [string]$WaitForFile = '', | ||
|
|
||
| [switch]$MinimizeWindows, | ||
|
|
||
| [string]$LogPath = '' | ||
| ) | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| function Write-AutoItLog([string]$Text) { | ||
| if ($LogPath) { | ||
| Add-Content -Path $LogPath -Value $Text -Encoding ASCII | ||
| } | ||
| } | ||
|
|
||
| function Get-AutoItPath { | ||
| # Native x86 OS: AutoIt3_x64.exe does not exist and ProgramFiles(x86) | ||
| # is empty, so skip both to avoid a hang/timeout. | ||
| $isNativeX86 = ($env:PROCESSOR_ARCHITECTURE -eq 'x86') -and | ||
| [string]::IsNullOrEmpty($env:PROCESSOR_ARCHITEW6432) | ||
|
|
||
| if ($isNativeX86) { | ||
| $candidates = @( | ||
| "${env:ProgramFiles}\AutoIt3\AutoIt3.exe" | ||
| ) | ||
| } else { | ||
| $candidates = @( | ||
| "${env:ProgramFiles}\AutoIt3\AutoIt3_x64.exe", | ||
| "${env:ProgramFiles}\AutoIt3\AutoIt3.exe", | ||
| "${env:ProgramFiles(x86)}\AutoIt3\AutoIt3_x64.exe", | ||
| "${env:ProgramFiles(x86)}\AutoIt3\AutoIt3.exe" | ||
| ) | ||
| } | ||
| foreach ($p in $candidates) { | ||
| if ($p -and (Test-Path $p)) { return $p } | ||
| } | ||
| return $null | ||
| } | ||
|
|
||
| $autoIt = Get-AutoItPath | ||
| if (-not $autoIt) { | ||
| Write-Output 'FAIL: AutoIt not found (suite extra_software autoit required)' | ||
| exit 1 | ||
| } | ||
| if (-not (Test-Path $Au3Path)) { | ||
| Write-Output "FAIL: AutoIt script not found at $Au3Path" | ||
| exit 1 | ||
| } | ||
|
|
||
| if ($MinimizeWindows) { | ||
| try { | ||
| $shell = New-Object -ComObject Shell.Application | ||
| $shell.MinimizeAll() | ||
| Start-Sleep -Seconds 2 | ||
| } catch { | ||
| Write-AutoItLog ("WARN: MinimizeAll failed: $($_.Exception.Message)") | ||
| } | ||
| } | ||
|
|
||
| Write-AutoItLog ("Running: $autoIt $Au3Path") | ||
| $p = Start-Process -FilePath $autoIt -ArgumentList ('"' + $Au3Path + '"') -PassThru | ||
|
|
||
| $killedOnTimeout = $false | ||
| $deadline = (Get-Date).AddSeconds($TimeoutSec) | ||
| while ((Get-Date) -lt $deadline) { | ||
| if ($WaitForFile -and (Test-Path $WaitForFile)) { break } | ||
| if ($p.HasExited -and -not $WaitForFile) { break } | ||
| # With -WaitForFile: keep polling until the file appears or deadline, | ||
| # even if AutoIt has already exited. | ||
| Start-Sleep -Seconds 2 | ||
| } | ||
|
|
||
| if (-not $p.HasExited) { | ||
| Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue | ||
| Write-AutoItLog 'WARN: AutoIt still running after timeout; killed' | ||
| $killedOnTimeout = $true | ||
| } else { | ||
| Write-AutoItLog ("AutoIt exit code=$($p.ExitCode)") | ||
| } | ||
|
|
||
| if ($WaitForFile) { | ||
| if (-not (Test-Path $WaitForFile)) { | ||
| Write-Output "FAIL: expected output file not created: $WaitForFile" | ||
| exit 1 | ||
| } | ||
| } elseif ($killedOnTimeout) { | ||
| Write-Output "FAIL: AutoIt killed after timeout (${TimeoutSec}s) with no -WaitForFile" | ||
| exit 1 | ||
| } | ||
|
Comment on lines
+107
to
+135
|
||
|
|
||
| Write-Output "PASS: AutoIt finished ($Au3Path)" | ||
| exit 0 | ||
121 changes: 121 additions & 0 deletions
121
lib/engines/functest/tests/scripts/common/Invoke-InteractiveSession.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Hop from Session 0 to the interactive desktop and run a worker script. | ||
|
|
||
| .DESCRIPTION | ||
| Functest guest_run / guest_run_file often execute in Session 0, where GUI | ||
| automation (AutoIt, etc.) cannot attach to the user desktop. This helper | ||
| registers a Scheduled Task with LogonType Interactive, starts it as the | ||
| AutoHCK autologin user, and waits for a result file. | ||
|
|
||
| Any GUI / AutoIt functest can reuse this; keep test-specific logic in the | ||
| worker script pointed at by -ScriptPath. | ||
|
|
||
| Usage: upload helpers from lib/engines/functest/tests/scripts/common/ via | ||
| the case files_action step to e.g. C:\AutoHCK\common\, then call this | ||
| script from the Session-0 launcher (see driver_sigverif). | ||
|
|
||
| .PARAMETER ScriptPath | ||
| Absolute guest path to the worker .ps1 (uploaded via files_action). | ||
|
|
||
| .PARAMETER ArgumentList | ||
| Extra arguments appended after powershell -File <ScriptPath>. | ||
|
|
||
| .PARAMETER TaskName | ||
| Scheduled Task name. Must be unique per concurrent test/client (use an | ||
| AutoHCK_ prefix plus a test-specific suffix, e.g. AutoHCK_Sigverif) so | ||
| overlapping runs do not unregister each other's tasks. | ||
|
|
||
| .PARAMETER ResultFile | ||
| Absolute path the worker writes; first line should be PASS:... or FAIL:... | ||
|
|
||
| .PARAMETER TimeoutSec | ||
| Seconds to wait for ResultFile before failing. | ||
|
|
||
| .PARAMETER WorkDir | ||
| Working directory created before the task starts. | ||
|
|
||
| .PARAMETER WorkerLog | ||
| Optional log path to dump on success/timeout (if present). | ||
| #> | ||
|
|
||
| param( | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$ScriptPath, | ||
|
|
||
| [string]$ArgumentList = '', | ||
|
|
||
| [string]$TaskName = 'AutoHCK_Interactive', | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [string]$ResultFile, | ||
|
|
||
| [int]$TimeoutSec = 240, | ||
|
|
||
| [string]$WorkDir = 'C:\AutoHCK\interactive_work', | ||
|
|
||
| [string]$WorkerLog = '' | ||
| ) | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| function Get-InteractiveUser { | ||
| # AutoHCK autologin: Winlogon DefaultUserName names the interactive user. | ||
| $winlogon = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' | ||
| $autoUser = (Get-ItemProperty -Path $winlogon -Name 'DefaultUserName' -ErrorAction SilentlyContinue).DefaultUserName | ||
| if ($autoUser) { return $autoUser } | ||
| return 'Administrator' | ||
| } | ||
|
|
||
| if (-not (Test-Path $ScriptPath)) { | ||
| Write-Output "FAIL: worker script not found at $ScriptPath (files_action upload required)" | ||
| exit 1 | ||
| } | ||
|
|
||
| New-Item -ItemType Directory -Force -Path $WorkDir | Out-Null | ||
| Remove-Item -Force $ResultFile -ErrorAction SilentlyContinue | ||
| if ($WorkerLog) { | ||
| Remove-Item -Force $WorkerLog -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| $user = Get-InteractiveUser | ||
| Write-Output "Outer session=$((Get-Process -Id $PID).SessionId); launching interactive user='$user'" | ||
| Write-Output "Worker: $ScriptPath" | ||
|
|
||
| Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue | ||
|
|
||
| $arg = "-NoProfile -ExecutionPolicy Bypass -File `"$ScriptPath`"" | ||
| if ($ArgumentList) { | ||
| $arg = "$arg $ArgumentList" | ||
| } | ||
|
|
||
| $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument $arg | ||
| $principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Highest | ||
| $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -MultipleInstances IgnoreNew | ||
| Register-ScheduledTask -TaskName $TaskName -Action $action -Principal $principal -Settings $settings -Force | Out-Null | ||
| Start-ScheduledTask -TaskName $TaskName | ||
| Write-Output "Started scheduled task '$TaskName'; waiting for result..." | ||
|
|
||
| $deadline = (Get-Date).AddSeconds($TimeoutSec) | ||
| while ((Get-Date) -lt $deadline) { | ||
| if (Test-Path $ResultFile) { | ||
| $text = (Get-Content -Path $ResultFile -Raw).Trim() | ||
| Write-Output $text | ||
| if ($WorkerLog -and (Test-Path $WorkerLog)) { | ||
| Write-Output '--- worker.log ---' | ||
| Get-Content -Path $WorkerLog | ForEach-Object { Write-Output $_ } | ||
| } | ||
| Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue | ||
| if ($text -like 'PASS:*') { exit 0 } | ||
| exit 1 | ||
| } | ||
| Start-Sleep -Seconds 2 | ||
| } | ||
|
|
||
| Write-Output "FAIL: timed out waiting for interactive worker result ($TaskName)" | ||
| if ($WorkerLog -and (Test-Path $WorkerLog)) { | ||
| Write-Output '--- worker.log ---' | ||
| Get-Content -Path $WorkerLog | ForEach-Object { Write-Output $_ } | ||
| } | ||
| Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue | ||
| exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Common functest helpers (guest scripts) | ||
| # | ||
| # Upload the scripts you need via the test case `files_action` step, for example: | ||
| # | ||
| # local_path: lib/engines/functest/tests/scripts/common/Invoke-InteractiveSession.ps1 | ||
| # remote_path: C:\AutoHCK\common\Invoke-InteractiveSession.ps1 | ||
| # | ||
| # Typical GUI flow: | ||
| # Session 0 launcher -> Invoke-InteractiveSession.ps1 (-TaskName unique per test) | ||
| # -> worker.ps1 on interactive desktop | ||
| # -> Invoke-AutoIt.ps1 (-Au3Path ..., optional -WaitForFile) | ||
| # | ||
| # Requires suite extra_software: ["autoit"] when using Invoke-AutoIt.ps1. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Run Windows File Signature Verification (sigverif) via AutoIt and confirm | ||
| @driver_module@.sys is Signed — mirrors KAR/avocado win_sigverif. | ||
|
|
||
| .DESCRIPTION | ||
| Requires suite extra_software: ["autoit"]. The test case uploads common | ||
| helpers, sigverif.au3, and sigverif_worker.ps1 via files_action. | ||
|
|
||
| This launcher only hops to the interactive desktop via | ||
| Invoke-InteractiveSession.ps1; GUI work lives in the worker. | ||
| #> | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| $moduleName = '@driver_module@' | ||
| if (-not $moduleName -or $moduleName -like '@*@') { | ||
| Write-Output 'FAIL: driver_module was not substituted by functest' | ||
| exit 1 | ||
| } | ||
|
|
||
| $workDir = 'C:\AutoHCK\sigverif_work' | ||
| $resultFile = Join-Path $workDir 'result.txt' | ||
| $workerLog = Join-Path $workDir 'worker.log' | ||
| $workerScript = 'C:\AutoHCK\sigverif_worker.ps1' | ||
| $interactiveHelper = 'C:\AutoHCK\common\Invoke-InteractiveSession.ps1' | ||
| $scanTimeoutSec = 900 | ||
|
|
||
| Write-Output "driver_module=$moduleName" | ||
|
|
||
| if (-not (Test-Path $interactiveHelper)) { | ||
| Write-Output "FAIL: interactive helper not found at $interactiveHelper (files_action upload required)" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Uploaded helpers need an explicit Bypass launch from Session 0 guest_run_file. | ||
| & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $interactiveHelper ` | ||
| -ScriptPath $workerScript ` | ||
| -ArgumentList "-ModuleName `"$moduleName`"" ` | ||
| -TaskName 'AutoHCK_Sigverif' ` | ||
| -ResultFile $resultFile ` | ||
| -TimeoutSec ($scanTimeoutSec + 60) ` | ||
| -WorkDir $workDir ` | ||
| -WorkerLog $workerLog | ||
| exit $LASTEXITCODE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #cs ---------------------------------------------------------------------------- | ||
|
|
||
| AutoIt Version: 3.3.14.5 | ||
| Author: Li Jin <lijin@redhat.com> | ||
| Script Function: | ||
| Drive File Signature Verification (sigverif.exe): Start scan, dismiss | ||
|
|
||
| result dialog, close. Used by functest driver_sigverif (KAR win_sigverif). | ||
| #ce ---------------------------------------------------------------------------- | ||
|
|
||
| Run("sigverif.exe") | ||
| WinWaitActive("File Signature Verification", "&Start") | ||
| Send("!s") | ||
| if WinWaitActive("SigVerif", "Your files have been scanned and verified as digitally signed.", 60) then | ||
|
|
||
| Send("{ENTER}") | ||
| else | ||
| Send("!c") | ||
| endif | ||
| WinWaitActive("File Signature Verification", "&Start") | ||
| Send("!c") | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.