Skip to content
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

Add support for setting source trust level #4216

Merged
merged 26 commits into from
Mar 26, 2024

Conversation

ryfu-msft
Copy link
Contributor

@ryfu-msft ryfu-msft commented Feb 29, 2024

Summary:
This PR adds support for specifying the trust level and making a source explicit when adding a new source. If a source is explicit, the source will not be discoverable unless explictly declared when searching for a package. i.e. winget search foo.bar --source explicitSource

  • Added two new source arguments for --trust-level and --explicit.
  • Supports specifying multiple trust levels such as --trust-level 'trusted|storeOrigin
  • Also went through policy review and got approval for adding these optional fields to the registry.
  • winget source list will also show their current state. The only way to remove the trust level or explicit state is by removing the source entirely.

Added unit and E2E tests to verify these behaviors.

Microsoft Reviewers: Open in CodeFlow

@ryfu-msft
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ryfu-msft ryfu-msft marked this pull request as ready for review March 19, 2024 18:43
@ryfu-msft ryfu-msft requested a review from a team as a code owner March 19, 2024 18:43
Copy link
Member

@JohnMcPMS JohnMcPMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that StoreOrigin should even be exposed. It doesn't really hurt anything directly, but I also don't foresee anyone using it (except us for testing). My expectation is only that it causes confusion. I would suggest that it be supported but undocumented (including in the argument description and error messages).

src/AppInstallerSharedLib/Public/AppInstallerStrings.h Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Command.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/SourceFlow.cpp Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/ISource.h Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/RepositorySource.cpp Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/RepositorySource.cpp Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/SourceList.cpp Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/RepositorySource.cpp Outdated Show resolved Hide resolved
src/AppInstallerSharedLib/GroupPolicy.cpp Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/Rest/RestSourceFactory.cpp Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/SourceList.cpp Outdated Show resolved Hide resolved
src/AppInstallerRepositoryCore/SourceList.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/SourceFlow.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Command.cpp Outdated Show resolved Hide resolved

// Trust level is represented as an array of trust level strings since there can be multiple flags set.
int i = 0;
for (std::string entry : TrustLevel)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: There is a for loop syntax that is designed just for this...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

JohnMcPMS
JohnMcPMS previously approved these changes Mar 25, 2024
@@ -357,7 +357,8 @@ namespace AppInstaller::Settings
json["Explicit"] = Explicit;

// Trust level is represented as an array of trust level strings since there can be multiple flags set.
for (int i = 0; i < TrustLevel.size(); ++i)
int trustLevelLength = static_cast<int>(TrustLevel.size());
for (int i = 0; i < trustLevelLength; ++i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The better solution is generally to use size_t i.

@ryfu-msft ryfu-msft merged commit e9d3465 into microsoft:master Mar 26, 2024
8 checks passed
@ryfu-msft ryfu-msft deleted the trustLevel branch March 26, 2024 18:31
@jantari
Copy link

jantari commented Apr 2, 2024

Is this the fix for #4046 (installations from REST sources hanging indefinitely due to MotW)?

@denelon
Copy link
Contributor

denelon commented Apr 2, 2024

@jantari, yes, this work will accrue to unblocking the hang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants