-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Block admin uninstall of user package #6345
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
107cbec
CP
JohnMcPMS 27e60bb
Move to use token elevation type as UAC disabled doesn't need the check
JohnMcPMS ff1e68e
Merge branch 'master' into uninstall-scope-check
florelis b7e1338
Move e2e tests to unit to mock token state, add uninstall test
JohnMcPMS 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
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
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
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
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,47 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| #include "pch.h" | ||
| #include "TestHooks.h" | ||
| #include "TestSource.h" | ||
| #include "WorkflowCommon.h" | ||
| #include <winget/ManifestYamlParser.h> | ||
| #include <ExecutionContext.h> | ||
| #include <Workflows/ShellExecuteInstallerHandler.h> | ||
|
|
||
| using namespace TestCommon; | ||
| using namespace AppInstaller::CLI::Execution; | ||
| using namespace AppInstaller::Manifest; | ||
| using namespace AppInstaller::Repository; | ||
|
|
||
| // Tests that when the process is running with a non-default full (elevated UAC) token, | ||
| // repairing a package that was installed at user scope is blocked with | ||
| // APPINSTALLER_CLI_ERROR_ADMIN_CONTEXT_ACTION_PROHIBITED. | ||
| // This single test covers both the CLI (RepairCommand) and COM (COMRepairCommand) code paths | ||
| // because they both invoke the same ShellExecuteRepairImpl workflow step. | ||
| TEST_CASE("RepairFlow_AdminContextWithUserScopeInstall", "[RepairFlow][workflow]") | ||
| { | ||
| // Simulate running with an elevated (non-default full) token. | ||
| TestHook::SetIsRunningWithNonDefaultFullToken_Override tokenOverride(true); | ||
|
|
||
| std::ostringstream repairOutput; | ||
| TestContext context{ repairOutput, std::cin }; | ||
| auto previousThreadGlobals = context.SetForCurrentThread(); | ||
|
|
||
| // Build an installed package version with Burn type installed at user scope. | ||
| // ShellExecuteRepairImpl blocks Burn (and other Exe-family) packages installed at user scope. | ||
| auto manifest = YamlParser::CreateFromPath(TestDataFile("InstallFlowTest_Exe.yaml")); | ||
| TestPackageVersion::MetadataMap metadata | ||
| { | ||
| { PackageVersionMetadata::InstalledType, "Burn" }, | ||
| { PackageVersionMetadata::InstalledScope, "User" }, | ||
| }; | ||
| context.Add<Data::InstalledPackageVersion>(TestPackageVersion::Make(manifest, metadata)); | ||
|
|
||
| // Provide a dummy repair string; the admin-context check fires before the command is executed. | ||
| context.Add<Data::RepairString>(std::string("C:\\repair.exe /silent")); | ||
|
|
||
| context << AppInstaller::CLI::Workflow::ShellExecuteRepairImpl; | ||
|
|
||
| INFO(repairOutput.str()); | ||
| REQUIRE_TERMINATED_WITH(context, APPINSTALLER_CLI_ERROR_ADMIN_CONTEXT_ACTION_PROHIBITED); | ||
| } |
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
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
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.