Skip to content

Commit

Permalink
allowListVerificationProvider should only receive one allowList
Browse files Browse the repository at this point in the history
  • Loading branch information
PatoBeltran committed Oct 4, 2018
1 parent 50de97f commit aa2e608
Show file tree
Hide file tree
Showing 52 changed files with 777 additions and 1,957 deletions.
5 changes: 2 additions & 3 deletions src/NuGet.Clients/NuGet.CommandLine/Commands/AddCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ public override async Task ExecuteCommandAsync()
var packageExtractionContext = new PackageExtractionContext(
Expand ? PackageSaveMode.Defaultv3 : PackageSaveMode.Nuspec | PackageSaveMode.Nupkg,
PackageExtractionBehavior.XmlDocFileSaveMode,
Console,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(Settings, Console));
ClientPolicyContext.GetClientPolicy(Settings, Console),
Console);

var offlineFeedAddContext = new OfflineFeedAddContext(
packagePath,
Expand Down
8 changes: 3 additions & 5 deletions src/NuGet.Clients/NuGet.CommandLine/Commands/InitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ public override async Task ExecuteCommandAsync()

if (packagePaths.Count > 0)
{
var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var signingSettings = SignedPackageVerifierSettings.GetClientPolicy(Settings, Console);
var clientPolicyContext = ClientPolicyContext.GetClientPolicy(Settings, Console);

var packageExtractionContext = new PackageExtractionContext(
Expand ? PackageSaveMode.Defaultv3 : PackageSaveMode.Nuspec | PackageSaveMode.Nupkg,
PackageExtractionBehavior.XmlDocFileSaveMode,
Console,
signedPackageVerifier,
signingSettings);
clientPolicyContext,
Console);

foreach (var packagePath in packagePaths)
{
Expand Down
24 changes: 10 additions & 14 deletions src/NuGet.Clients/NuGet.CommandLine/Commands/InstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,27 +199,24 @@ private async Task PerformV2RestoreAsync(string packagesConfigFilePath, string i
cacheContext.NoCache = NoCache;
cacheContext.DirectDownload = DirectDownload;

var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var signingSettings = SignedPackageVerifierSettings.GetClientPolicy(Settings, Console);
var clientPolicyContext = ClientPolicyContext.GetClientPolicy(Settings, Console);

var projectContext = new ConsoleProjectContext(Console)
{
PackageExtractionContext = new PackageExtractionContext(
Packaging.PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
Console,
signedPackageVerifier,
signingSettings)
clientPolicyContext,
Console)
};

var downloadContext = new PackageDownloadContext(cacheContext, installPath, DirectDownload)
{
ExtractionContext = new PackageExtractionContext(
Packaging.PackageSaveMode.Defaultv3,
PackageExtractionBehavior.XmlDocFileSaveMode,
Console,
signedPackageVerifier,
signingSettings)
clientPolicyContext,
Console)
};

var result = await PackageRestoreManager.RestoreMissingPackagesAsync(
Expand Down Expand Up @@ -381,16 +378,15 @@ private async Task InstallPackageAsync(
}
else
{
var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var signingVerificationSettings = SignedPackageVerifierSettings.GetClientPolicy(Settings, Console);
var clientPolicyContext = ClientPolicyContext.GetClientPolicy(Settings, Console);

var projectContext = new ConsoleProjectContext(Console)
{
PackageExtractionContext = new PackageExtractionContext(
Packaging.PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
Console,
signingVerificationSettings)
clientPolicyContext,
Console)
};

resolutionContext.SourceCacheContext.NoCache = NoCache;
Expand All @@ -401,8 +397,8 @@ private async Task InstallPackageAsync(
ExtractionContext = new PackageExtractionContext(
Packaging.PackageSaveMode.Defaultv3,
PackageExtractionBehavior.XmlDocFileSaveMode,
Console,
signingVerificationSettings)
clientPolicyContext,
Console)
};

if (EffectivePackageSaveMode != Packaging.PackageSaveMode.None)
Expand Down
11 changes: 5 additions & 6 deletions src/NuGet.Clients/NuGet.CommandLine/Commands/RestoreCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,14 @@ private async Task<RestoreSummary> PerformNuGetV2RestoreAsync(PackageRestoreInpu

CheckRequireConsent();

var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var signingVerificationSettings = SignedPackageVerifierSettings.GetClientPolicy(Settings, collectorLogger);
var clientPolicyContext = ClientPolicyContext.GetClientPolicy(Settings, collectorLogger);
var projectContext = new ConsoleProjectContext(collectorLogger)
{
PackageExtractionContext = new PackageExtractionContext(
Packaging.PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
collectorLogger,
signingVerificationSettings)
clientPolicyContext,
collectorLogger)
};

if (EffectivePackageSaveMode != Packaging.PackageSaveMode.None)
Expand All @@ -355,8 +354,8 @@ private async Task<RestoreSummary> PerformNuGetV2RestoreAsync(PackageRestoreInpu
ExtractionContext = new PackageExtractionContext(
Packaging.PackageSaveMode.Defaultv3,
PackageExtractionBehavior.XmlDocFileSaveMode,
collectorLogger,
signingVerificationSettings)
clientPolicyContext,
collectorLogger)
};

var result = await PackageRestoreManager.RestoreMissingPackagesAsync(
Expand Down
8 changes: 3 additions & 5 deletions src/NuGet.Clients/NuGet.CommandLine/Commands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ public override async Task ExecuteCommandAsync()
var context = new UpdateConsoleProjectContext(Console, FileConflictAction);

var logger = new LoggerAdapter(context);
var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var signedPackageVerifierSettings = SignedPackageVerifierSettings.GetClientPolicy(Settings, logger);
var clientPolicyContext = ClientPolicyContext.GetClientPolicy(Settings, logger);

context.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
signedPackageVerifierSettings);
clientPolicyContext,
logger);

string inputFileName = Path.GetFileName(inputFile);
// update with packages.config as parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ protected NuGetPowerShellBaseCommand()
PackageRestoreManager = ServiceLocator.GetInstance<IPackageRestoreManager>();
_deleteOnRestartManager = ServiceLocator.GetInstance<IDeleteOnRestartManager>();

var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var logger = new LoggerAdapter(this);
PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(ConfigSettings, logger));
ClientPolicyContext.GetClientPolicy(ConfigSettings, logger),
logger);

if (_commonOperations != null)
{
Expand Down Expand Up @@ -267,9 +265,8 @@ protected async Task CheckMissingPackagesAsync()
ExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv3,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(ConfigSettings, logger))
ClientPolicyContext.GetClientPolicy(ConfigSettings, logger),
logger)
};

var result = await PackageRestoreManager.RestoreMissingPackagesAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,8 @@ private async Task RestoreMissingPackagesInSolutionAsync(
ExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv3,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger))
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger)
};

await _packageRestoreManager.RestoreMissingPackagesAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ public VsPackageInstaller(
projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger));
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger);

return projectContext;
});
Expand Down Expand Up @@ -179,14 +178,12 @@ private Task InstallPackageAsync(string source, Project project, string packageI

var projectContext = new VSAPIProjectContext();
var logger = new LoggerAdapter(projectContext);
var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());

projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger));
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger);

return InstallInternalAsync(project, toInstall, GetSources(sources), projectContext, includePrerelease, ignoreDependencies, CancellationToken.None);
}
Expand Down Expand Up @@ -241,15 +238,13 @@ public void InstallPackagesFromRegistryRepository(string keyName, bool isPreUnzi
var disableBindingRedirects = skipAssemblyReferences;

var projectContext = new VSAPIProjectContext(skipAssemblyReferences, disableBindingRedirects);
var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var logger = new LoggerAdapter(projectContext);

projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger));
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger);

await InstallInternalAsync(
project,
Expand Down Expand Up @@ -301,14 +296,12 @@ public void InstallPackagesFromVSExtensionRepository(string extensionId, bool is
var disableBindingRedirects = skipAssemblyReferences;

var projectContext = new VSAPIProjectContext(skipAssemblyReferences, disableBindingRedirects);
var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var logger = new LoggerAdapter(projectContext);
projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger));
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger);

return InstallInternalAsync(
project,
Expand Down Expand Up @@ -479,15 +472,13 @@ internal async Task InstallInternalAsync(
var disableBindingRedirects = skipAssemblyReferences;

var projectContext = new VSAPIProjectContext(skipAssemblyReferences, disableBindingRedirects);
var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var logger = new LoggerAdapter(projectContext);

projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger));
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger);

await InstallInternalAsync(
project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ private async Task<FallbackPackagePathResolver> GetPackagesPathResolverAsync(Bui
projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger));
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger);

var nuGetProject = await _solutionManager.GetOrCreateProjectAsync(
project,
Expand Down Expand Up @@ -178,9 +177,8 @@ public IEnumerable<IVsPackageMetadata> GetInstalledPackages(Project project)
projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger));
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger);

var nuGetProject = await _solutionManager.GetOrCreateProjectAsync(
project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,12 @@ public void UninstallPackage(Project project, string packageId, bool removeDepen
UninstallationContext uninstallContext = new UninstallationContext(removeDependencies, false);
VSAPIProjectContext projectContext = new VSAPIProjectContext();

var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var logger = new LoggerAdapter(projectContext);
projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
logger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings, logger));
ClientPolicyContext.GetClientPolicy(_settings, logger),
logger);

// find the project
NuGetProject nuGetProject = await _solutionManager.GetOrCreateProjectAsync(project, projectContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@ public VsPathContextProvider(
_projectContext = new Lazy<INuGetProjectContext>(() => {
var projectContext = new VSAPIProjectContext();

var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var adapterLogger = new LoggerAdapter(projectContext);
projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
adapterLogger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(_settings.Value, adapterLogger));
ClientPolicyContext.GetClientPolicy(_settings.Value, adapterLogger),
adapterLogger);

return projectContext;
});
Expand Down Expand Up @@ -113,14 +111,12 @@ public VsPathContextProvider(
_projectContext = new Lazy<INuGetProjectContext>(() => {
var projectContext = new VSAPIProjectContext();

var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());
var adapterLogger = new LoggerAdapter(projectContext);
projectContext.PackageExtractionContext = new PackageExtractionContext(
PackageSaveMode.Defaultv2,
PackageExtractionBehavior.XmlDocFileSaveMode,
adapterLogger,
signedPackageVerifier,
SignedPackageVerifierSettings.GetClientPolicy(settings, adapterLogger));
ClientPolicyContext.GetClientPolicy(_settings.Value, adapterLogger),
adapterLogger);

return projectContext;
});
Expand Down
Loading

0 comments on commit aa2e608

Please sign in to comment.