-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Allow winget configure from https location and extend winget configure validate for winget resource units #3833
Changes from 21 commits
28cfa43
b11cf33
08f9435
a9d94eb
5f0f034
196d65d
5953bf5
8a22cbf
9ae59f0
223cbf1
a7976a0
753e236
ca04cea
2cd02cf
d159f83
9d6e46c
3a0aca4
7585e34
abe58c3
d45fb3b
4140f40
c3ade49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#pragma once | ||
#include <map> | ||
#include <string> | ||
|
||
namespace winrt::Microsoft::Management::Configuration | ||
{ | ||
struct ConfigurationUnit; | ||
} | ||
|
||
namespace AppInstaller::CLI::Execution | ||
{ | ||
struct Context; | ||
} | ||
|
||
namespace AppInstaller::CLI::Configuration | ||
{ | ||
using namespace std::string_view_literals; | ||
|
||
struct WingetDscModuleUnitValidator | ||
{ | ||
bool ValidateConfigurationSetUnit(AppInstaller::CLI::Execution::Context& context, const winrt::Microsoft::Management::Configuration::ConfigurationUnit& unit); | ||
|
||
std::string_view ModuleName() { return "Microsoft.WinGet.DSC"sv; }; | ||
|
||
private: | ||
std::map<std::string, std::string> m_dependenciesSourceAndUnitIdMap; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ using namespace AppInstaller::Utility::literals; | |
using namespace AppInstaller::Pinning; | ||
using namespace AppInstaller::Repository; | ||
using namespace AppInstaller::Settings; | ||
using namespace winrt::Windows::Foundation; | ||
|
||
namespace AppInstaller::CLI::Workflow | ||
{ | ||
|
@@ -1093,6 +1094,44 @@ namespace AppInstaller::CLI::Workflow | |
} | ||
} | ||
|
||
void VerifyFileOrUri::operator()(Execution::Context& context) const | ||
{ | ||
auto path = context.Args.GetArg(m_arg); | ||
|
||
// try uri first | ||
Uri pathAsUri = nullptr; | ||
try | ||
{ | ||
pathAsUri = Uri{ Utility::ConvertToUTF16(path) }; | ||
} | ||
catch (...) {} | ||
|
||
if (pathAsUri && !pathAsUri.Suspicious()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should We could probably have an appropriately handled interactive prompt for suspicious URIs to still allow them through if the user agrees. Or we can just flat out block them until there are complaints. |
||
{ | ||
// SchemeName() always returns lower case | ||
if (L"file" == pathAsUri.SchemeName() && !Utility::CaseInsensitiveStartsWith(path, "file:")) | ||
{ | ||
// Uri constructor is smart enough to parse an absolute local file path to file uri. | ||
// In this case, we should continue with VerifyFile. | ||
context << VerifyFile(m_arg); | ||
} | ||
else if (std::find(m_supportedSchemes.begin(), m_supportedSchemes.end(), pathAsUri.SchemeName()) != m_supportedSchemes.end()) | ||
{ | ||
// Scheme supported. | ||
return; | ||
} | ||
else | ||
{ | ||
context.Reporter.Error() << Resource::String::UriSchemeNotSupported(Utility::LocIndView{ path }) << std::endl; | ||
AICLI_TERMINATE_CONTEXT(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)); | ||
} | ||
} | ||
else | ||
{ | ||
context << VerifyFile(m_arg); | ||
} | ||
} | ||
|
||
void GetManifestFromArg(Execution::Context& context) | ||
{ | ||
Logging::Telemetry().LogIsManifestLocal(true); | ||
|
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.
We do have code that extracts the file name portion from a URL that we use when downloading installers. I would use that to set
Name
similarly to what we set for the local filesystem paths.For
Origin
I think the remote URL is fine.I agree that we should not set
Path
.