Skip to content

Commit

Permalink
Added enum
Browse files Browse the repository at this point in the history
  • Loading branch information
AmelBawa-msft committed Oct 16, 2024
1 parent 54b4e6b commit 1fb3c76
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Workflows/ConfigurationFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ namespace AppInstaller::CLI::Workflow

void CreateConfigurationProcessor(Context& context)
{
context << ExecuteUriValidation(true /*isConfigurationFlow*/);
context << ExecuteUriValidation(UriValidationSource::ConfigurationSource);
auto progressScope = context.Reporter.BeginAsyncProgress(true);
progressScope->Callback().SetProgressMessage(Resource::String::ConfigurationInitializing());

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Workflows/DownloadFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ namespace AppInstaller::CLI::Workflow
}

bool installerDownloadOnly = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerDownloadOnly);
context << ExecuteUriValidation(false /*isConfigurationFlow*/);
context << ExecuteUriValidation(UriValidationSource::PackageCatalogSource);

// CheckForExistingInstaller will set the InstallerPath if found
if (!context.Contains(Execution::Data::InstallerPath))
Expand Down
9 changes: 7 additions & 2 deletions src/AppInstallerCLICore/Workflows/UriValidationFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ namespace AppInstaller::CLI::Workflow
bool IsSmartScreenRequired(Settings::SecurityZoneOptions zone)
{
auto isSmartScreenEnabled = Settings::GroupPolicies().IsEnabled(Settings::TogglePolicy::Policy::SmartScreenValidation);
AICLI_LOG(Core, Info, << "SmartScreen validation is " << (isSmartScreenEnabled ? "enabled" : "disabled"));

auto isSecurityZoneCheckRequired = zone == Settings::SecurityZoneOptions::Internet || zone == Settings::SecurityZoneOptions::UntrustedSites;
AICLI_LOG(Core, Info, << "Security zone check is " << (isSecurityZoneCheckRequired ? "required" : "not required"));

return isSmartScreenEnabled && isSecurityZoneCheckRequired;
}

Expand Down Expand Up @@ -143,13 +147,14 @@ namespace AppInstaller::CLI::Workflow
// Execute the smart screen flow.
void ExecuteUriValidation::operator()(Execution::Context& context) const
{
if (m_isConfigurationFlow)
if (m_uriValidationSource == UriValidationSource::ConfigurationSource)
{
auto uriValidation = EvaluateConfigurationUri(context);
if(FAILED(uriValidation))
if (FAILED(uriValidation))
{
AICLI_TERMINATE_CONTEXT(uriValidation);
}

}
else
{
Expand Down
10 changes: 8 additions & 2 deletions src/AppInstallerCLICore/Workflows/UriValidationFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@

namespace AppInstaller::CLI::Workflow
{
enum UriValidationSource
{
ConfigurationSource,
PackageCatalogSource,
};

// Composite flow that chooses what to do based on whether or not the
// configuration flow is being run.
// Required Args: None
// Inputs: IsConfigurationFlow
// Outputs: None
struct ExecuteUriValidation: public WorkflowTask
{
ExecuteUriValidation(bool isConfigurationFlow) : WorkflowTask("ExecuteUriValidation"), m_isConfigurationFlow(isConfigurationFlow) {}
ExecuteUriValidation(UriValidationSource uriValidationSource) : WorkflowTask("ExecuteUriValidation"), m_uriValidationSource(uriValidationSource) {}

void operator()(Execution::Context& context) const override;

private:
bool m_isConfigurationFlow;
UriValidationSource m_uriValidationSource;
};
}

0 comments on commit 1fb3c76

Please sign in to comment.