Skip to content

Commit 7ad39fe

Browse files
authored
Add a system for testing correlation E2E (#2071)
This change adds a few scripts, a test project, and one small product change, all around enabling end-to-end validation of our correlation between system artifacts and packages in external sources.
1 parent a10744a commit 7ad39fe

17 files changed

Lines changed: 1414 additions & 1 deletion

.github/actions/spelling/allow.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ createtables
9090
cref
9191
csproj
9292
CStr
93+
csv
9394
CURSORPOSITON
9495
CUSTOMHEADER
9596
cwctype
@@ -189,7 +190,9 @@ hfile
189190
HGLOBAL
190191
HIDECANCEL
191192
hinternet
193+
HKCU
192194
HKEY
195+
HKLM
193196
hmac
194197
HMODULE
195198
Homepage
@@ -448,6 +451,7 @@ screenshots
448451
SCROLLER
449452
SCROLLVIEWER
450453
sdk
454+
sdks
451455
seekg
452456
seinfo
453457
selectany
@@ -544,6 +548,7 @@ TEXTFORMAT
544548
TEXTINCLUDE
545549
Threadpool
546550
Timeline
551+
tls
547552
todo
548553
tokenizer
549554
tolower

.github/actions/spelling/excludes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ ignore$
3838
^src/JsonCppLib/
3939
^src/Valijson/
4040
^src/YamlCppLib/
41+
# Because it doesn't handle argument -Words well
42+
^tools/CorrelationTestbed/.*\.ps1$
4143
^\.github/

.github/actions/spelling/expect.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ vscode
411411
vstest
412412
vy
413413
wcslen
414+
WDAG
414415
webpages
415416
Webserver
416417
website
@@ -426,6 +427,7 @@ winreg
426427
withstarts
427428
wn
428429
Workflows
430+
wsb
429431
wsl
430432
wsv
431433
wto

src/AppInstallerCLIPackage/Package.appxmanifest

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<Dependencies>
1717
<!-- Minimum supported version is 1809 (October 2018 Update, aka RS5) -->
1818
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19033.0" />
19-
<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.25426.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
2019
</Dependencies>
2120
<Resources>
2221
<Resource Language="x-generate" />

src/Microsoft.Management.Deployment/PackageManager.idl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ namespace Microsoft.Management.Deployment
270270
{
271271
/// Checks if this package version has at least one applicable installer.
272272
Boolean HasApplicableInstaller(InstallOptions options);
273+
274+
/// Gets the publisher string for this package version, if one is available.
275+
String Publisher { get; };
273276
}
274277

275278
/// DESIGN NOTE:

src/Microsoft.Management.Deployment/PackageVersionInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ namespace winrt::Microsoft::Management::Deployment::implementation
4848
{
4949
return winrt::to_hstring(m_packageVersion->GetProperty(::AppInstaller::Repository::PackageVersionProperty::Name).get());
5050
}
51+
hstring PackageVersionInfo::Publisher()
52+
{
53+
return winrt::to_hstring(m_packageVersion->GetProperty(::AppInstaller::Repository::PackageVersionProperty::Publisher).get());
54+
}
5155
hstring PackageVersionInfo::Version()
5256
{
5357
return winrt::to_hstring(m_packageVersion->GetProperty(::AppInstaller::Repository::PackageVersionProperty::Version).get());

src/Microsoft.Management.Deployment/PackageVersionInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation
1717
hstring GetMetadata(winrt::Microsoft::Management::Deployment::PackageVersionMetadataField const& metadataField);
1818
hstring Id();
1919
hstring DisplayName();
20+
hstring Publisher();
2021
hstring Version();
2122
hstring Channel();
2223
winrt::Windows::Foundation::Collections::IVectorView<hstring> PackageFamilyNames();
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
Param(
2+
[String] $DesktopAppInstallerPath,
3+
[String[]] $DesktopAppInstallerDependencyPath,
4+
[String] $PackageIdentifier,
5+
[String] $SourceName,
6+
[String] $OutputPath,
7+
[Switch] $UseDev
8+
)
9+
10+
function Get-ARPTable {
11+
$registry_paths = @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
12+
return Get-ItemProperty $registry_paths -ErrorAction SilentlyContinue |
13+
Select-Object DisplayName, DisplayVersion, Publisher, @{N='ProductCode'; E={$_.PSChildName}} |
14+
Where-Object {$null -ne $_.DisplayName }
15+
}
16+
17+
$ProgressPreference = 'SilentlyContinue'
18+
19+
$desktopPath = "C:\Users\WDAGUtilityAccount\Desktop"
20+
21+
$regFilesDirPath = Join-Path $desktopPath "RegFiles"
22+
23+
if (Test-Path $regFilesDirPath)
24+
{
25+
foreach ($regFile in (Get-ChildItem $regFilesDirPath))
26+
{
27+
28+
Write-Host @"
29+
--> Importing reg file $($regFile.FullName)
30+
"@
31+
reg import $($regFile.FullName)
32+
}
33+
}
34+
35+
Write-Host @"
36+
--> Installing WinGet
37+
38+
"@
39+
40+
if ($UseDev)
41+
{
42+
foreach($dependency in $DesktopAppInstallerDependencyPath)
43+
{
44+
Write-Host @"
45+
----> Installing $dependency
46+
"@
47+
Add-AppxPackage -Path $dependency
48+
}
49+
50+
Write-Host @"
51+
----> Enabling dev mode
52+
"@
53+
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
54+
55+
$devPackageManifestPath = Join-Path $desktopPath "DevPackage\AppxManifest.xml"
56+
Write-Host @"
57+
----> Installing $devPackageManifestPath
58+
"@
59+
Add-AppxPackage -Path $devPackageManifestPath -Register
60+
}
61+
else
62+
{
63+
Add-AppxPackage -Path $DesktopAppInstallerPath -DependencyPath $DesktopAppInstallerDependencyPath
64+
}
65+
66+
$originalARP = Get-ARPTable
67+
68+
Write-Host @"
69+
70+
--> Installing $PackageIdentifier
71+
72+
"@
73+
74+
$installAndCorrelateOutPath = Join-Path $OutputPath "install_and_correlate.json"
75+
76+
$installAndCorrelationExpression = Join-Path $desktopPath "InstallAndCheckCorrelation\InstallAndCheckCorrelation.exe"
77+
$installAndCorrelationExpression = -join($installAndCorrelationExpression, ' -id "', $PackageIdentifier, '" -src "', $SourceName, '" -out "', $installAndCorrelateOutPath, '"')
78+
79+
if ($UseDev)
80+
{
81+
$installAndCorrelationExpression = -join($installAndCorrelationExpression, ' -dev')
82+
}
83+
84+
Invoke-Expression $installAndCorrelationExpression
85+
86+
Write-Host @"
87+
88+
--> Copying logs
89+
"@
90+
91+
if ($UseDev)
92+
{
93+
Copy-Item -Recurse (Join-Path $env:LOCALAPPDATA "Packages\WinGetDevCLI_8wekyb3d8bbwe\LocalState\DiagOutputDir") $OutputPath
94+
}
95+
else
96+
{
97+
Copy-Item -Recurse (Join-Path $env:LOCALAPPDATA "Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir") $OutputPath
98+
}
99+
100+
101+
Write-Host @"
102+
103+
--> Comparing ARP Entries
104+
"@
105+
106+
$arpCompared = (Compare-Object (Get-ARPTable) $originalARP -Property DisplayName,DisplayVersion,Publisher,ProductCode)
107+
$arpCompared | Select-Object -Property * -ExcludeProperty SideIndicator | Format-Table
108+
109+
$arpCompared | Select-Object -Property * -ExcludeProperty SideIndicator | Format-Table | Out-File (Join-Path $OutputPath "ARPCompare.txt")
110+
111+
"Done" | Out-File (Join-Path $OutputPath "done.txt")
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31911.196
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InstallAndCheckCorrelation", "InstallAndCheckCorrelation\InstallAndCheckCorrelation.vcxproj", "{204CD25F-AAEA-4CA1-AB9F-A26747976932}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Debug|x64.ActiveCfg = Debug|x64
17+
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Debug|x64.Build.0 = Debug|x64
18+
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Debug|x86.ActiveCfg = Debug|Win32
19+
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Debug|x86.Build.0 = Debug|Win32
20+
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Release|x64.ActiveCfg = Release|x64
21+
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Release|x64.Build.0 = Release|x64
22+
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Release|x86.ActiveCfg = Release|Win32
23+
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {77ED5C57-8A8C-4D87-9818-ABFB99B8E9D2}
30+
EndGlobalSection
31+
EndGlobal

0 commit comments

Comments
 (0)