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

Validate manifest installers (MSIX) #2215

Merged

Conversation

AmelBawa-msft
Copy link
Contributor

@AmelBawa-msft AmelBawa-msft commented Jun 3, 2022

What was done?

  • Added msix and msixbundle manifest validation
    • Validate package family name.
    • Validate package version.
    • Validate Minimum OS Version.

Test

  • Added test installers (msix and msixbundle) to test the validation functionality
  • Added manifest installer validation tests
  • Added installer package fields reader tests
Microsoft Reviewers: Open in CodeFlow

@AmelBawa-msft AmelBawa-msft requested a review from a team as a code owner June 3, 2022 18:45
@github-actions
Copy link

github-actions bot commented Jun 3, 2022

@check-spelling-bot Report

Unrecognized words, please review:

  • Bge
  • bh
  • BSYWF
  • EZk
  • Fnvs
  • Gj
  • ij
  • jm
  • Memoize
  • memoized
  • NJa
  • Qk
  • qo
  • SVpu
  • TF
  • tj
  • ud
  • UZ
  • WWu
  • xa
  • XE
  • xf
  • xjr
  • Zf
  • ZM
Previously acknowledged words that are now absent activatable amd Archs dsc enr FWW Globals hackathon lww mytool OSVERSION Packagedx parametermap symlink Uninitialize WDAG whatif wsb
To accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the [email protected]:AmelBawa-msft/winget-cli.git repository
on the validate-manifest-installer branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
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);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/microsoft/winget-cli/issues/comments/1146262353" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")
  

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u

src/AppInstallerCommonCore/Public/winget/MsixManifest.h Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Public/winget/MsixManifest.h Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Public/winget/MsixManifest.h Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Versions.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Versions.cpp Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Jun 6, 2022

@check-spelling-bot Report

Unrecognized words, please review:

  • Bge
  • bh
  • BSYWF
  • EZk
  • Fnvs
  • Gj
  • ij
  • jm
  • NJa
  • Qk
  • qo
  • SVpu
  • TF
  • tj
  • ud
  • UZ
  • WWu
  • xa
  • XE
  • xf
  • xjr
  • Zf
  • ZM
Previously acknowledged words that are now absent activatable amd Archs dsc enr FWW Globals hackathon lww mytool OSVERSION Packagedx parametermap symlink Uninitialize WDAG whatif wsb
To accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the [email protected]:AmelBawa-msft/winget-cli.git repository
on the validate-manifest-installer branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
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);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/microsoft/winget-cli/issues/comments/1147756108" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")
  

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u

@yao-msft
Copy link
Contributor

yao-msft commented Jun 6, 2022

To fix the spelling, you can add .msixbundle type to the excludes.txt under spelling.

src/AppInstallerCLITests/TestCommon.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLITests/Versions.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLITests/Versions.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLITests/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLITests/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Versions.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Versions.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Versions.cpp Show resolved Hide resolved
src/AppInstallerCLITests/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLITests/Versions.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/MsixManifest.cpp Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Public/AppInstallerDownloader.h Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Public/winget/MsixManifest.h Outdated Show resolved Hide resolved
src/AppInstallerCommonCore/Public/winget/MsixManifest.h Outdated Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback Issue needs attention from issue or PR author and removed Needs-Author-Feedback Issue needs attention from issue or PR author labels Jun 7, 2022
@JohnMcPMS
Copy link
Member

/azp run

@azure-pipelines
Copy link

Pull request contains merge conflicts.

@yao-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ghost ghost added the Needs-Author-Feedback Issue needs attention from issue or PR author label Jun 16, 2022
@ghost ghost removed the Needs-Author-Feedback Issue needs attention from issue or PR author label Jun 20, 2022
@AmelBawa-msft AmelBawa-msft merged commit 9056c0f into microsoft:master Jun 22, 2022
@AmelBawa-msft AmelBawa-msft deleted the validate-manifest-installer branch July 22, 2022 03:05
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