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

Implement Group Policy #810

Merged
merged 26 commits into from
Mar 29, 2021
Merged

Implement Group Policy #810

merged 26 commits into from
Mar 29, 2021

Conversation

florelis
Copy link
Member

@florelis florelis commented Mar 18, 2021

Implementing group policy. Interface is roughly based on ExperimentalFeatures and UserSettings.

This is still a draft. Still pending:

  • E2E testing
  • Better reporting and logging
  • Use final registry keys/values from ADMX definition
  • Implement policies for additional/allowed sources
  • Showing policies enabled on winget --info

Related: #809 #154

Microsoft Reviewers: Open in CodeFlow

@github-actions
Copy link

Misspellings found, please review:

  • declval
  • Overriden
  • POLICYMAPPING
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"usersettingstest validator valijson valueiterator "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"declval Overriden POLICYMAPPING "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

@JohnMcPMS
Copy link
Member

JohnMcPMS commented Mar 19, 2021

    // Settings can be loaded from settings.json or settings.json.backup files.

If settings is disabled by policy, we should just quit before ever even loading a file. #Closed


Refers to: src/AppInstallerCommonCore/UserSettings.cpp:252 in b96cf8a. [](commit_id = b96cf8a, deletion_comment = False)

Luis Chacón and others added 2 commits March 24, 2021 17:22
@github-actions
Copy link

Misspellings found, please review:

  • declval
  • POLICYMAPPING
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"usersettingstest validator valijson valueiterator "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"declval POLICYMAPPING "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

@florelis florelis marked this pull request as ready for review March 26, 2021 04:04
@florelis florelis requested a review from a team as a code owner March 26, 2021 04:04
@florelis
Copy link
Member Author

This is still missing E2E tests and the policies for controlling sources. I'll submit that as a separate PR as this one already got too big.

@@ -87,14 +87,27 @@ namespace AppInstaller::Registry
template <Type T>
typename details::ValueTypeSpecifics<static_cast<DWORD>(T)>::value_t GetValue() const
{
EnsureType(T);
THROW_HR_IF(E_INVALIDARG, !HasCompatibleType(T));
Copy link
Member

Choose a reason for hiding this comment

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

THROW_HR_IF(E_INVALIDARG, !HasCompatibleType(T)); [](start = 12, length = 49)

nit (for now): Better to implement by calling TryGetValue and throwing when it returns nullopt to prevent future changes from needing to be made to both code paths.

@florelis florelis merged commit 9879f07 into microsoft:master Mar 29, 2021
@florelis florelis deleted the GroupPolicy branch March 29, 2021 21:27
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.

4 participants