24 lines
1.9 KiB
PowerShell
24 lines
1.9 KiB
PowerShell
param([Parameter(Mandatory)][string]$ApkPath,[Parameter(Mandatory)][string]$EvidenceDir)
|
|
$ErrorActionPreference='Stop'
|
|
$projectRoot=Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
|
|
$toolRoot=Join-Path $projectRoot 'artifacts/tools/apk-inspector'
|
|
$python=Join-Path $toolRoot 'Scripts/python.exe'
|
|
New-Item -ItemType Directory -Path $EvidenceDir -Force|Out-Null
|
|
$commands=[Collections.Generic.List[object]]::new()
|
|
try {
|
|
if(!(Test-Path -LiteralPath $python)){
|
|
& python -m venv $toolRoot *> (Join-Path $EvidenceDir 'venv-create.log');$code=$LASTEXITCODE
|
|
$commands.Add(@{command='python -m venv '+$toolRoot;exitCode=$code});if($code-ne0){throw 'QA inspector environment creation failed'}
|
|
}
|
|
$version=& $python -c 'import importlib.metadata; print(importlib.metadata.version("UnityPy"))' 2>$null
|
|
if($LASTEXITCODE-ne0-or$version-ne'1.25.4'){
|
|
& $python -m pip install UnityPy==1.25.4 *> (Join-Path $EvidenceDir 'tool-install.log');$code=$LASTEXITCODE
|
|
$commands.Add(@{command='isolated QA venv pip install UnityPy==1.25.4';exitCode=$code});if($code-ne0){throw 'Pinned APK voice inspector installation failed'}
|
|
}
|
|
& $python -m pip freeze | Set-Content -LiteralPath (Join-Path $EvidenceDir 'tool-packages.txt')
|
|
& $python -I (Join-Path $PSScriptRoot 'inspect-voice-payload.py') --apk $ApkPath --project $projectRoot --evidence $EvidenceDir *> (Join-Path $EvidenceDir 'inspection.log')
|
|
$code=$LASTEXITCODE;$commands.Add(@{command=('inspect-voice-payload.py --apk '+$ApkPath+' --project '+$projectRoot+' --evidence '+$EvidenceDir);exitCode=$code})
|
|
if($code-ne0){throw 'Actual APK voice payload verification failed'}
|
|
}finally{@{sourceCommit=(& git rev-parse HEAD);sourceDirty=[bool](& git status --porcelain);commands=$commands.ToArray()}|ConvertTo-Json -Depth 5|Set-Content -LiteralPath (Join-Path $EvidenceDir 'inspection-commands.json')}
|
|
exit 0
|