winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

MsixManifestValidation.h (3108B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 #include "AppInstallerErrors.h"
      5 #include "AppInstallerMsixInfo.h"
      6 #include "winget/Manifest.h"
      7 #include "winget/ManifestValidation.h"
      8 
      9 namespace AppInstaller::Manifest
     10 {
     11     struct MsixManifestValidation
     12     {
     13         MsixManifestValidation(ValidationError::Level validationErrorLevel) : m_validationErrorLevel(validationErrorLevel) {}
     14 
     15         ~MsixManifestValidation();
     16 
     17         // Validate manifest for Msix packages and Msix bundles.
     18         std::vector<ValidationError> Validate(
     19             const Manifest& manifest,
     20             const ManifestInstaller& installer);
     21     private:
     22         std::map<std::string, std::shared_ptr<Msix::MsixInfo>> m_msixInfoCache;
     23         std::vector<std::filesystem::path> m_downloadedInstallers;
     24         ValidationError::Level m_validationErrorLevel;
     25 
     26         // Get Msix info from url/local path, or load it from cache.
     27         // Return null pointer if operation failed.
     28         std::shared_ptr<Msix::MsixInfo> GetMsixInfo(std::string installerUrl);
     29 
     30         // Get Msix info from installer url.
     31         // Return null pointer if operation failed.
     32         std::shared_ptr<Msix::MsixInfo> GetMsixInfoFromUrl(std::string installerUrl);
     33 
     34         // Download and get msix info from installer local path.
     35         // Return null pointer if operation failed.
     36         std::shared_ptr<Msix::MsixInfo> GetMsixInfoFromLocalPath(std::string installerUrl);
     37 
     38         // Download the installer.
     39         // If the download was successful, return the destination path.
     40         std::optional<std::filesystem::path> DownloadInstaller(std::string installerUrl, int retryCount);
     41 
     42         // Get manifest installer minimum OS version or nullopt if failed to
     43         // parse input.
     44         std::optional<Msix::OSVersion> GetManifestInstallerMinOSVersion(
     45             std::string minOSVersion,
     46             std::vector<ValidationError>& errors);
     47 
     48         // Validate Msix package family name.
     49         void ValidateMsixManifestPackageFamilyName(
     50             Utility::NormalizedString msixPackageFamilyName,
     51             Utility::NormalizedString manifestPackageFamilyName,
     52             std::vector<ValidationError>& errors);
     53 
     54         // Validate Msix package version.
     55         void ValidateMsixManifestPackageVersion(
     56             const Msix::PackageVersion& msixPackageVersion,
     57             const string_t& manifestPackageVersionStr,
     58             std::vector<ValidationError>& errors);
     59 
     60         // Validate Msix minimum OS version for supported platforms.
     61         void ValidateMsixManifestMinOSVersion(
     62             const std::optional<Msix::OSVersion>& msixMinOSVersion,
     63             const std::optional<Msix::OSVersion>& manifestMinOSVersion,
     64             std::string installerUrl,
     65             std::vector<ValidationError>& errors);
     66 
     67         // Validate Msix signature hash.
     68         void ValidateMsixManifestSignatureHash(
     69             const std::shared_ptr<Msix::MsixInfo> msixInfo,
     70             const Utility::SHA256::HashBuffer& manifestSignatureHash,
     71             std::vector<ValidationError>& errors);
     72     };
     73 }