-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Yaml manifest schemaheader validation for V.1.10.0 and above (#5126)
### Enable schema header validation for YAML manifests from version 1.10.0 onwards. **YAML Manifest Validation Changes:** 1. Introduce functions to search, parse, and validate schema headers in YAML manifests. 2. Add/Update structs and enums to support schema header validation. 3. Add new error messages and validation options, including treating schema header validation errors as warnings. Schema Header Validation Includes: 1. Validate presence of Manifest Schema Header. 2. Ensure Schema Header format correctness. 3. Verify Schema Header URL Pattern accuracy. 4. Confirm Schema Header Manifest Type matches ManifestType Property. 5. Check Schema Header Manifest Version matches ManifestVersion Property. **WinGet CLI Validation Command Changes:** - Treat schema header validation errors as warnings for 'winget validate --manifest <<path>>' command - Introduced a new option `SchemaHeaderValidationAsWarning` to the `validateOption` object and set it to `true`. - This change treats schema header validation issues as warnings instead of errors, making the validation process more lenient. [NOTE:] 1. SchemaHeaderValidation errors should be treated as warnings for the winget CLI validate command. 2. SchemaHeaderValidation errors should be treated as errors for wingetsvc community manifests. **[Test Coverage:]** - Added new test data files to validate various schema header errors in YAML manifests, including - invalid headers, - type mismatches, - version mismatches, - missing headers, and - URL pattern mismatches. - Added test coverage for WinGet Utils Interop binary and WinGet CLI Validated command **[How Validated:]** - Compiled the AppInstaller end-to-end solution incorporating the changes. - Performed the YAML manifest validation tests, WinGet Utils tests, and WinGet CLI Validate command tests, ensuring all tests passed. - Locally validated the winget CLI validation command with various schema header errors, ensuring they are treated as warnings and that no warnings are reported for a valid manifest. **[Test Results:]** YAML Manifest Validation Test Results: ![image](https://github.com/user-attachments/assets/c474a9ab-718c-482e-81fb-7fc385f37190) WinGet Utils Interop Test Results: ![image](https://github.com/user-attachments/assets/f5033c71-16e1-44a7-a9a7-886066f9e26d) Validate Command Test Results: ![image](https://github.com/user-attachments/assets/4726022c-7a8b-4885-abba-3f776d3ded4e) <!-- To check a checkbox place an "x" between the brackets. e.g: [x] --> - [x] I have signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs). - [x] This pull request is related to an issue. ----- ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/5126) --------- Co-authored-by: Madhusudhan Gumbalapura Sudarshan <[email protected]>
- Loading branch information
1 parent
f4f8abd
commit b1ac622
Showing
32 changed files
with
735 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
16 changes: 16 additions & 0 deletions
16
src/AppInstallerCLIE2ETests/TestData/Manifests/TestGoodManifestV1_10-SchemaHeader.yaml
This file contains 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,16 @@ | ||
# yaml-language-server: $schema=https://aka.ms/winget-manifest.singleton.1.10.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeader | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest with schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
16 changes: 16 additions & 0 deletions
16
...InstallerCLIE2ETests/TestData/Manifests/TestWarningManifestV1_10-SchemaHeaderInvalid.yaml
This file contains 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,16 @@ | ||
# yaml-language-server= $schema=https://aka.ms/winget-manifest.singleton.1.10.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderInvalid | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header Invalid | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has an invalid schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
16 changes: 16 additions & 0 deletions
16
...2ETests/TestData/Manifests/TestWarningManifestV1_10-SchemaHeaderManifestTypeMismatch.yaml
This file contains 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,16 @@ | ||
# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.10.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderManifestTypeMismatch | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header ManifestType Mismatch | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has a mismatched ManisfestType in the schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
15 changes: 15 additions & 0 deletions
15
...nstallerCLIE2ETests/TestData/Manifests/TestWarningManifestV1_10-SchemaHeaderNotFound.yaml
This file contains 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,15 @@ | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderNotFound | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header Not Found | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has a missing schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
16 changes: 16 additions & 0 deletions
16
...IE2ETests/TestData/Manifests/TestWarningManifestV1_10-SchemaHeaderURLPatternMismatch.yaml
This file contains 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,16 @@ | ||
# yaml-language-server: $schema=https://aka.ms/winget-manifest-invalid.singleton.1.10.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderURLPatternMismatch | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header URL Pattern Mismatch | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has a mismatched schema header URL pattern | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
16 changes: 16 additions & 0 deletions
16
...rCLIE2ETests/TestData/Manifests/TestWarningManifestV1_10-SchemaHeaderVersionMismatch.yaml
This file contains 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,16 @@ | ||
# yaml-language-server: $schema=https://aka.ms/winget-manifest.singleton.1.9.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderVersionMismatch | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header ManifestVersion Mismatch | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has a mismatched ManisfestVersion in the schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
This file contains 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 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 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 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
16 changes: 16 additions & 0 deletions
16
src/AppInstallerCLITests/TestData/ManifestV1_10-Bad-SchemaHeaderInvalid.yaml
This file contains 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,16 @@ | ||
# yaml-language-server= $schema=https://aka.ms/winget-manifest.singleton.1.10.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderInvalid | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header Invalid | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has an invalid schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
16 changes: 16 additions & 0 deletions
16
src/AppInstallerCLITests/TestData/ManifestV1_10-Bad-SchemaHeaderManifestTypeMismatch.yaml
This file contains 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,16 @@ | ||
# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.10.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderManifestTypeMismatch | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header ManifestType Mismatch | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has a mismatched ManisfestType in the schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
16 changes: 16 additions & 0 deletions
16
src/AppInstallerCLITests/TestData/ManifestV1_10-Bad-SchemaHeaderManifestVersionMismatch.yaml
This file contains 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,16 @@ | ||
# yaml-language-server: $schema=https://aka.ms/winget-manifest.singleton.1.9.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderVersionMismatch | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header ManifestVersion Mismatch | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has a mismatched ManisfestVersion in the schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
15 changes: 15 additions & 0 deletions
15
src/AppInstallerCLITests/TestData/ManifestV1_10-Bad-SchemaHeaderNotFound.yaml
This file contains 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,15 @@ | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderNotFound | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header Not Found | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has a missing schema header | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
16 changes: 16 additions & 0 deletions
16
src/AppInstallerCLITests/TestData/ManifestV1_10-Bad-SchemaHeaderURLPatternMismatch.yaml
This file contains 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,16 @@ | ||
# yaml-language-server: $schema=https://aka.ms/winget-manifest-invalid.singleton.1.10.0.schema.json | ||
PackageIdentifier: AppInstallerCliTest.SchemaHeaderURLPatternMismatch | ||
PackageVersion: 1.0.0.0 | ||
PackageLocale: en-US | ||
PackageName: AppInstaller Test Schema Header URL Pattern Mismatch | ||
Publisher: Microsoft Corporation | ||
License: Test | ||
ShortDescription: This manifest has a mismatched schema header URL pattern | ||
|
||
Installers: | ||
- Architecture: x86 | ||
InstallerUrl: https://ThisIsNotUsed | ||
InstallerType: msi | ||
InstallerSha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B | ||
ManifestType: singleton | ||
ManifestVersion: 1.10.0 |
This file contains 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
1 change: 1 addition & 0 deletions
1
...tallerCLITests/TestData/MultiFileManifestV1_10/ManifestV1_10-MultiFile-DefaultLocale.yaml
This file contains 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.
b1ac622
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok