diff --git a/src/NuGet.Core/NuGet.Protocol/GlobalSuppressions.cs b/src/NuGet.Core/NuGet.Protocol/GlobalSuppressions.cs index 356fdfebbba..fbb29505816 100644 --- a/src/NuGet.Core/NuGet.Protocol/GlobalSuppressions.cs +++ b/src/NuGet.Core/NuGet.Protocol/GlobalSuppressions.cs @@ -143,7 +143,6 @@ [assembly: SuppressMessage("Build", "CA1031:Modify 'Receive' to catch a more specific allowed exception type, or rethrow the exception.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.Plugins.StandardInputReceiver.Receive(System.Object)")] [assembly: SuppressMessage("Build", "CA1031:Modify 'OnLineRead' to catch a more specific allowed exception type, or rethrow the exception.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.Plugins.StandardOutputReceiver.OnLineRead(System.Object,NuGet.Protocol.Plugins.LineReadEventArgs)")] [assembly: SuppressMessage("Build", "CA1031:Modify 'GetTimeout' to catch a more specific allowed exception type, or rethrow the exception.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.Plugins.TimeoutUtilities.GetTimeout(System.String,System.TimeSpan)~System.TimeSpan")] -[assembly: SuppressMessage("Build", "CA1303:Method 'bool UnixAndMonoPlatformsEmbeddedSignatureVerifier.IsValid(string filePath)' passes a literal string as parameter 'message' of a call to 'ArgumentException.ArgumentException(string message)'. Retrieve the following string(s) from a resource table instead: \"filePath\".", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier.IsValid(System.String)~System.Boolean")] [assembly: SuppressMessage("Build", "CA1801:Parameter ex of method ProxyAuthenticationRequired is never used. Remove the parameter or use it in the method body.", Justification = "Workaround for mono", Scope = "member", Target = "~M:NuGet.Protocol.ProxyAuthenticationHandler.AcquireCredentialsAsync(System.Uri,System.Guid,NuGet.Common.ILogger,System.Threading.CancellationToken)~System.Threading.Tasks.Task{System.Boolean}")] [assembly: SuppressMessage("Build", "CA1031:Modify 'PromptForProxyCredentialsAsync' to catch a more specific allowed exception type, or rethrow the exception.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.ProxyAuthenticationHandler.PromptForProxyCredentialsAsync(System.Uri,System.Net.IWebProxy,NuGet.Common.ILogger,System.Threading.CancellationToken)~System.Threading.Tasks.Task{System.Net.NetworkCredential}")] [assembly: SuppressMessage("Build", "CA1031:Modify 'SearchPage' to catch a more specific allowed exception type, or rethrow the exception.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.RawSearchResourceV3.SearchPage(System.String,NuGet.Protocol.Core.Types.SearchFilter,System.Int32,System.Int32,NuGet.Common.ILogger,System.Threading.CancellationToken)~System.Threading.Tasks.Task{Newtonsoft.Json.Linq.JObject}")] diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/EmbeddedSignatureVerifier.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/EmbeddedSignatureVerifier.cs deleted file mode 100644 index d3b0309eb1e..00000000000 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/EmbeddedSignatureVerifier.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using NuGet.Common; - -namespace NuGet.Protocol.Plugins -{ - /// - /// Base class for embedded signature verifiers. - /// - public abstract class EmbeddedSignatureVerifier - { - /// - /// Checks if a file has a valid embedded signature. - /// - /// The path of a file to be checked. - /// if the file has a valid signature; otherwise, . - /// Thrown if - /// is either or an empty string. - /// Thrown if the current platform is unsupported. - public abstract bool IsValid(string filePath); - - /// - /// Creates an embedded signature verifier for the current platform. - /// - /// An embedded signature verifier. - public static EmbeddedSignatureVerifier Create() - { - if (RuntimeEnvironmentHelper.IsWindows) - { - return new WindowsEmbeddedSignatureVerifier(); - } - - if (RuntimeEnvironmentHelper.IsLinux || RuntimeEnvironmentHelper.IsMacOSX || RuntimeEnvironmentHelper.IsMono) - { - return new UnixAndMonoPlatformsEmbeddedSignatureVerifier(); - } - - return new FallbackEmbeddedSignatureVerifier(); - } - } -} diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/FallbackEmbeddedSignatureVerifier.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/FallbackEmbeddedSignatureVerifier.cs deleted file mode 100644 index 8aae17dfb21..00000000000 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/FallbackEmbeddedSignatureVerifier.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace NuGet.Protocol.Plugins -{ - /// - /// A fallback embedded signature verifier for unsupported platforms. - /// - public sealed class FallbackEmbeddedSignatureVerifier : EmbeddedSignatureVerifier - { - /// - /// Checks if a file has a valid embedded signature. - /// - /// The path of a file to be checked. - /// if the file has a valid signature; otherwise, . - /// Thrown always. - public override bool IsValid(string filePath) - { - throw new PlatformNotSupportedException(); - } - } -} diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginDiscoverer.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginDiscoverer.cs index 1a9eb98db69..830ba4d4142 100644 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginDiscoverer.cs +++ b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginDiscoverer.cs @@ -20,23 +20,14 @@ public sealed class PluginDiscoverer : IPluginDiscoverer private readonly string _rawPluginPaths; private IEnumerable _results; private readonly SemaphoreSlim _semaphore; - private readonly EmbeddedSignatureVerifier _verifier; /// /// Instantiates a new class. /// /// The raw semicolon-delimited list of supposed plugin file paths. - /// An embedded signature verifier. - /// Thrown if is . - public PluginDiscoverer(string rawPluginPaths, EmbeddedSignatureVerifier verifier) + public PluginDiscoverer(string rawPluginPaths) { - if (verifier == null) - { - throw new ArgumentNullException(nameof(verifier)); - } - _rawPluginPaths = rawPluginPaths; - _verifier = verifier; _semaphore = new SemaphoreSlim(initialCount: 1, maxCount: 1); } @@ -116,25 +107,18 @@ private List GetPluginFiles(CancellationToken cancellationToken) foreach (var filePath in filePaths) { - cancellationToken.ThrowIfCancellationRequested(); - - if (PathValidator.IsValidLocalPath(filePath) || PathValidator.IsValidUncPath(filePath)) + var pluginFile = new PluginFile(filePath, new Lazy(() => { - if (File.Exists(filePath)) + if (PathValidator.IsValidLocalPath(filePath) || PathValidator.IsValidUncPath(filePath)) { - var state = new Lazy(() => _verifier.IsValid(filePath) ? PluginFileState.Valid : PluginFileState.InvalidEmbeddedSignature); - - files.Add(new PluginFile(filePath, state)); + return File.Exists(filePath) ? PluginFileState.Valid : PluginFileState.NotFound; } else { - files.Add(new PluginFile(filePath, new Lazy(() => PluginFileState.NotFound))); + return PluginFileState.InvalidFilePath; } - } - else - { - files.Add(new PluginFile(filePath, new Lazy(() => PluginFileState.InvalidFilePath))); - } + })); + files.Add(pluginFile); } return files; diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginFileState.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginFileState.cs index da7eba69663..e20d95576bd 100644 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginFileState.cs +++ b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginFileState.cs @@ -26,6 +26,7 @@ public enum PluginFileState /// /// The file exists but it has either no embedded signature or an invalid embedded signature. /// + /// No longer used. InvalidEmbeddedSignature } } diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs index 53f992281d2..53dfa731769 100644 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs +++ b/src/NuGet.Core/NuGet.Protocol/Plugins/PluginManager.cs @@ -360,9 +360,7 @@ private async Task> GetPluginOperationClaimsAsync( private PluginDiscoverer InitializeDiscoverer() { - var verifier = EmbeddedSignatureVerifier.Create(); - - return new PluginDiscoverer(_rawPluginPaths, verifier); + return new PluginDiscoverer(_rawPluginPaths); } private bool IsPluginPossiblyAvailable() diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/UnixAndMonoPlatformsEmbeddedSignatureVerifier.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/UnixAndMonoPlatformsEmbeddedSignatureVerifier.cs deleted file mode 100644 index 696a3fa6ff7..00000000000 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/UnixAndMonoPlatformsEmbeddedSignatureVerifier.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace NuGet.Protocol.Plugins -{ - /// - /// Embedded Signature Verifier for the MacOS, Linux and Mono platforms. - /// - public class UnixAndMonoPlatformsEmbeddedSignatureVerifier : EmbeddedSignatureVerifier - { - /// - /// Checks if a file has a valid embedded signature. - /// - /// The path of a file to be checked. - /// if the file has a valid signature; otherwise, . - /// Thrown if - /// is either or an empty string. - /// Thrown if the current platform is unsupported. - public override bool IsValid(string filePath) - { - if (string.IsNullOrEmpty(filePath)) - { - throw new ArgumentException(Strings.Argument_Cannot_Be_Null_Or_Empty, nameof(filePath)); - } - // There's no embedded signature verification on Linux, MacOS and Mono platforms - return true; - } - } -} diff --git a/src/NuGet.Core/NuGet.Protocol/Plugins/WindowsEmbeddedSignatureVerifier.cs b/src/NuGet.Core/NuGet.Protocol/Plugins/WindowsEmbeddedSignatureVerifier.cs deleted file mode 100644 index 36619ad65c8..00000000000 --- a/src/NuGet.Core/NuGet.Protocol/Plugins/WindowsEmbeddedSignatureVerifier.cs +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Runtime.InteropServices; - -namespace NuGet.Protocol.Plugins -{ - /// - /// Windows Authenticode signature verifier. - /// - public sealed class WindowsEmbeddedSignatureVerifier : EmbeddedSignatureVerifier - { - [DllImport("wintrust.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] - private static extern int WinVerifyTrust([In] IntPtr hwnd, - [In][MarshalAs(UnmanagedType.LPStruct)] Guid pgActionID, - [In] WINTRUST_DATA pWVTData); - - /// - /// Checks if a file has a valid Authenticode signature. - /// - /// The path of a file to be checked. - /// if the file has a valid signature; otherwise, . - /// Thrown if - /// is either or an empty string. - public override bool IsValid(string filePath) - { - if (string.IsNullOrEmpty(filePath)) - { - throw new ArgumentException(Strings.ArgumentCannotBeNullOrEmpty, nameof(filePath)); - } - - var WINTRUST_ACTION_GENERIC_VERIFY_V2 = new Guid("{00AAC56B-CD44-11D0-8CC2-00C04FC295EE}"); - - using (var pFilePath = new SafeCoTaskMem(filePath)) - { - var fileInfo = new WINTRUST_FILE_INFO() { pcwszFilePath = pFilePath.DangerousGetHandle() }; - - using (var pFile = new SafeCoTaskMem((int)fileInfo.cbStruct)) - { - Marshal.StructureToPtr(fileInfo, pFile.DangerousGetHandle(), fDeleteOld: false); - - var data = new WINTRUST_DATA() { pFile = pFile.DangerousGetHandle() }; - - return WinVerifyTrust(IntPtr.Zero, WINTRUST_ACTION_GENERIC_VERIFY_V2, data) == 0; - } - } - } - - private sealed class SafeCoTaskMem : SafeHandle - { - private SafeCoTaskMem() : base(IntPtr.Zero, ownsHandle: true) - { - } - - internal SafeCoTaskMem(int cbSize) : this() - { - handle = Marshal.AllocCoTaskMem(cbSize); - } - - internal SafeCoTaskMem(string value) : this() - { - handle = Marshal.StringToCoTaskMemUni(value); - } - - public override bool IsInvalid - { - get { return handle == IntPtr.Zero || handle == IntPtr.Zero; } - } - - protected override bool ReleaseHandle() - { - if (!IsInvalid) - { - Marshal.FreeCoTaskMem(handle); - } - - return true; - } - } - - private enum UIChoice : uint - { - WTD_UI_ALL = 1, - WTD_UI_NONE = 2, - WTD_UI_NOBAD = 3, - WTD_UI_NOGOOD = 4 - } - - private enum RevocationChecks : uint - { - WTD_REVOKE_NONE = 0, - WTD_REVOKE_WHOLECHAIN = 1 - } - - private enum UnionChoice : uint - { - WTD_CHOICE_FILE = 1, - WTD_CHOICE_CATALOG = 2, - WTD_CHOICE_BLOB = 3, - WTD_CHOICE_SIGNER = 4, - WTD_CHOICE_CERT = 5 - } - - private enum StateAction : uint - { - WTD_STATEACTION_IGNORE = 0, - WTD_STATEACTION_VERIFY = 1, - WTD_STATEACTION_CLOSE = 2, - WTD_STATEACTION_AUTO_CACHE = 3, - WTD_STATEACTION_AUTO_CACHE_FLUSH = 4 - } - - [Flags] - private enum ProviderFlags : uint - { - WTD_USE_IE4_TRUST_FLAG = 1, - WTD_NO_IE4_CHAIN_FLAG = 2, - WTD_NO_POLICY_USAGE_FLAG = 4, - WTD_REVOCATION_CHECK_NONE = 16, - WTD_REVOCATION_CHECK_END_CERT = 32, - WTD_REVOCATION_CHECK_CHAIN = 64, - WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 128, - WTD_SAFER_FLAG = 256, - WTD_HASH_ONLY_FLAG = 512, - WTD_USE_DEFAULT_OSVER_CHECK = 1024, - WTD_LIFETIME_SIGNING_FLAG = 2048, - WTD_CACHE_ONLY_URL_RETRIEVAL = 4096, - WTD_DISABLE_MD2_MD4 = 8192, - WTD_MOTW = 16384 - } - - [Flags] - private enum UIContext : uint - { - WTD_UICONTEXT_EXECUTE = 0, - WTD_UICONTEXT_INSTALL = 1 - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - private sealed class WINTRUST_FILE_INFO - { -#if IS_DESKTOP - internal uint cbStruct = (uint)Marshal.SizeOf(typeof(WINTRUST_FILE_INFO)); -#else - internal uint cbStruct = (uint)Marshal.SizeOf(); -#endif - internal IntPtr pcwszFilePath; - internal IntPtr hFile; - internal IntPtr pgKnownSubject; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - private sealed class WINTRUST_DATA - { -#if IS_DESKTOP - internal uint cbStruct = (uint)Marshal.SizeOf(typeof(WINTRUST_DATA)); -#else - internal uint cbStruct = (uint)Marshal.SizeOf(); -#endif - internal IntPtr pPolicyCallbackData = IntPtr.Zero; - internal IntPtr pSIPClientData = IntPtr.Zero; - internal UIChoice dwUIChoice = UIChoice.WTD_UI_NONE; - internal RevocationChecks fdwRevocationChecks = RevocationChecks.WTD_REVOKE_NONE; - internal UnionChoice dwUnionChoice = UnionChoice.WTD_CHOICE_FILE; - internal IntPtr pFile; - internal StateAction dwStateAction = StateAction.WTD_STATEACTION_IGNORE; - internal IntPtr hWVTStateData = IntPtr.Zero; - internal string pwszURLReference = null; - internal ProviderFlags dwProvFlags = ProviderFlags.WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT - | ProviderFlags.WTD_DISABLE_MD2_MD4; - internal UIContext dwUIContext = UIContext.WTD_UICONTEXT_EXECUTE; - } - } -} diff --git a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Shipped.txt b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Shipped.txt index 00d918eb6d2..def020375d4 100644 --- a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Shipped.txt +++ b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Shipped.txt @@ -891,10 +891,6 @@ NuGet.Protocol.Plugins.CopyNupkgFileRequest NuGet.Protocol.Plugins.CopyNupkgFileResponse NuGet.Protocol.Plugins.CopyNupkgFileResponse.CopyNupkgFileResponse(NuGet.Protocol.Plugins.MessageResponseCode responseCode) -> void NuGet.Protocol.Plugins.CopyNupkgFileResponse.ResponseCode.get -> NuGet.Protocol.Plugins.MessageResponseCode -NuGet.Protocol.Plugins.EmbeddedSignatureVerifier -NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.EmbeddedSignatureVerifier() -> void -NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier.FallbackEmbeddedSignatureVerifier() -> void NuGet.Protocol.Plugins.Fault ~NuGet.Protocol.Plugins.Fault.Fault(string message) -> void ~NuGet.Protocol.Plugins.Fault.Message.get -> string @@ -1203,7 +1199,6 @@ NuGet.Protocol.Plugins.PluginCreationResult NuGet.Protocol.Plugins.PluginDiscoverer ~NuGet.Protocol.Plugins.PluginDiscoverer.DiscoverAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task> NuGet.Protocol.Plugins.PluginDiscoverer.Dispose() -> void -~NuGet.Protocol.Plugins.PluginDiscoverer.PluginDiscoverer(string rawPluginPaths, NuGet.Protocol.Plugins.EmbeddedSignatureVerifier verifier) -> void NuGet.Protocol.Plugins.PluginDiscoveryResult ~NuGet.Protocol.Plugins.PluginDiscoveryResult.Message.get -> string ~NuGet.Protocol.Plugins.PluginDiscoveryResult.PluginDiscoveryResult(NuGet.Protocol.Plugins.PluginFile pluginFile) -> void @@ -1337,10 +1332,6 @@ NuGet.Protocol.Plugins.SymmetricHandshake.Dispose() -> void ~NuGet.Protocol.Plugins.SymmetricHandshake.HandshakeAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task ~NuGet.Protocol.Plugins.SymmetricHandshake.SymmetricHandshake(NuGet.Protocol.Plugins.IConnection connection, System.TimeSpan handshakeTimeout, NuGet.Versioning.SemanticVersion protocolVersion, NuGet.Versioning.SemanticVersion minimumProtocolVersion) -> void NuGet.Protocol.Plugins.TimeoutUtilities -NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier.UnixAndMonoPlatformsEmbeddedSignatureVerifier() -> void -NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier.WindowsEmbeddedSignatureVerifier() -> void NuGet.Protocol.ProtocolConstants NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider.OwnerDetailsUriResourceV3Provider() -> void @@ -1568,7 +1559,6 @@ abstract NuGet.Protocol.Core.Types.ResourceProvider.TryCreate(NuGet.Protocol.Cor ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackage(NuGet.Packaging.Core.PackageIdentity identity, NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> NuGet.Protocol.LocalPackageInfo ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackage(System.Uri path, NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> NuGet.Protocol.LocalPackageInfo ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackages(NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> System.Collections.Generic.IEnumerable -~abstract NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.IsValid(string filePath) -> bool abstract NuGet.Protocol.Plugins.OutboundRequestContext.Dispose(bool disposing) -> void abstract NuGet.Protocol.Plugins.OutboundRequestContext.HandleCancelResponse() -> void ~abstract NuGet.Protocol.Plugins.OutboundRequestContext.HandleFault(NuGet.Protocol.Plugins.Message fault) -> void @@ -1787,7 +1777,6 @@ override NuGet.Protocol.Model.PackageVulnerabilityInfo.GetHashCode() -> int ~override NuGet.Protocol.PackageUpdateResourceV2Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task> ~override NuGet.Protocol.PackageUpdateResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task> ~override NuGet.Protocol.PluginFindPackageByIdResourceProvider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task> -~override NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier.IsValid(string filePath) -> bool override NuGet.Protocol.Plugins.OutboundRequestContext.HandleCancelResponse() -> void ~override NuGet.Protocol.Plugins.OutboundRequestContext.HandleFault(NuGet.Protocol.Plugins.Message fault) -> void ~override NuGet.Protocol.Plugins.OutboundRequestContext.HandleProgress(NuGet.Protocol.Plugins.Message progress) -> void @@ -1845,8 +1834,6 @@ override NuGet.Protocol.Plugins.PluginPackageReader.IsServiceable() -> bool override NuGet.Protocol.Plugins.StandardInputReceiver.Connect() -> void override NuGet.Protocol.Plugins.StandardOutputReceiver.Close() -> void override NuGet.Protocol.Plugins.StandardOutputReceiver.Connect() -> void -~override NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier.IsValid(string filePath) -> bool -~override NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier.IsValid(string filePath) -> bool override NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository! source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task!>! override NuGet.Protocol.Providers.VulnerabilityInfoResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository! source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task!>! ~override NuGet.Protocol.ProxyAuthenticationHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task @@ -2008,7 +1995,6 @@ static NuGet.Protocol.Events.ProtocolDiagnostics.ResourceEvent -> NuGet.Protocol ~static NuGet.Protocol.PackageDetailsUriResourceV3.CreateOrNull(string uriTemplate) -> NuGet.Protocol.PackageDetailsUriResourceV3 ~static NuGet.Protocol.Plugins.AutomaticProgressReporter.Create(NuGet.Protocol.Plugins.IConnection connection, NuGet.Protocol.Plugins.Message request, System.TimeSpan interval, System.Threading.CancellationToken cancellationToken) -> NuGet.Protocol.Plugins.AutomaticProgressReporter ~static NuGet.Protocol.Plugins.ConnectionOptions.CreateDefault(NuGet.Common.IEnvironmentVariableReader reader = null) -> NuGet.Protocol.Plugins.ConnectionOptions -~static NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.Create() -> NuGet.Protocol.Plugins.EmbeddedSignatureVerifier ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.Deserialize(string json) -> T ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.FromObject(object value) -> Newtonsoft.Json.Linq.JObject ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.Serialize(Newtonsoft.Json.JsonWriter writer, object value) -> void diff --git a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Unshipped.txt index 7dc5c58110b..9f62b32fec7 100644 --- a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ #nullable enable +~NuGet.Protocol.Plugins.PluginDiscoverer.PluginDiscoverer(string rawPluginPaths) -> void diff --git a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Shipped.txt b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Shipped.txt index 13f5869448a..86a9ec539e4 100644 --- a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Shipped.txt +++ b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -891,10 +891,6 @@ NuGet.Protocol.Plugins.CopyNupkgFileRequest NuGet.Protocol.Plugins.CopyNupkgFileResponse NuGet.Protocol.Plugins.CopyNupkgFileResponse.CopyNupkgFileResponse(NuGet.Protocol.Plugins.MessageResponseCode responseCode) -> void NuGet.Protocol.Plugins.CopyNupkgFileResponse.ResponseCode.get -> NuGet.Protocol.Plugins.MessageResponseCode -NuGet.Protocol.Plugins.EmbeddedSignatureVerifier -NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.EmbeddedSignatureVerifier() -> void -NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier.FallbackEmbeddedSignatureVerifier() -> void NuGet.Protocol.Plugins.Fault ~NuGet.Protocol.Plugins.Fault.Fault(string message) -> void ~NuGet.Protocol.Plugins.Fault.Message.get -> string @@ -1203,7 +1199,6 @@ NuGet.Protocol.Plugins.PluginCreationResult NuGet.Protocol.Plugins.PluginDiscoverer ~NuGet.Protocol.Plugins.PluginDiscoverer.DiscoverAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task> NuGet.Protocol.Plugins.PluginDiscoverer.Dispose() -> void -~NuGet.Protocol.Plugins.PluginDiscoverer.PluginDiscoverer(string rawPluginPaths, NuGet.Protocol.Plugins.EmbeddedSignatureVerifier verifier) -> void NuGet.Protocol.Plugins.PluginDiscoveryResult ~NuGet.Protocol.Plugins.PluginDiscoveryResult.Message.get -> string ~NuGet.Protocol.Plugins.PluginDiscoveryResult.PluginDiscoveryResult(NuGet.Protocol.Plugins.PluginFile pluginFile) -> void @@ -1337,10 +1332,6 @@ NuGet.Protocol.Plugins.SymmetricHandshake.Dispose() -> void ~NuGet.Protocol.Plugins.SymmetricHandshake.HandshakeAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task ~NuGet.Protocol.Plugins.SymmetricHandshake.SymmetricHandshake(NuGet.Protocol.Plugins.IConnection connection, System.TimeSpan handshakeTimeout, NuGet.Versioning.SemanticVersion protocolVersion, NuGet.Versioning.SemanticVersion minimumProtocolVersion) -> void NuGet.Protocol.Plugins.TimeoutUtilities -NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier.UnixAndMonoPlatformsEmbeddedSignatureVerifier() -> void -NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier.WindowsEmbeddedSignatureVerifier() -> void NuGet.Protocol.ProtocolConstants NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider.OwnerDetailsUriResourceV3Provider() -> void @@ -1564,7 +1555,6 @@ abstract NuGet.Protocol.Core.Types.ResourceProvider.TryCreate(NuGet.Protocol.Cor ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackage(NuGet.Packaging.Core.PackageIdentity identity, NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> NuGet.Protocol.LocalPackageInfo ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackage(System.Uri path, NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> NuGet.Protocol.LocalPackageInfo ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackages(NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> System.Collections.Generic.IEnumerable -~abstract NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.IsValid(string filePath) -> bool abstract NuGet.Protocol.Plugins.OutboundRequestContext.Dispose(bool disposing) -> void abstract NuGet.Protocol.Plugins.OutboundRequestContext.HandleCancelResponse() -> void ~abstract NuGet.Protocol.Plugins.OutboundRequestContext.HandleFault(NuGet.Protocol.Plugins.Message fault) -> void @@ -1778,7 +1768,6 @@ override NuGet.Protocol.Model.PackageVulnerabilityInfo.GetHashCode() -> int ~override NuGet.Protocol.PackageUpdateResourceV2Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task> ~override NuGet.Protocol.PackageUpdateResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task> ~override NuGet.Protocol.PluginFindPackageByIdResourceProvider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task> -~override NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier.IsValid(string filePath) -> bool override NuGet.Protocol.Plugins.OutboundRequestContext.HandleCancelResponse() -> void ~override NuGet.Protocol.Plugins.OutboundRequestContext.HandleFault(NuGet.Protocol.Plugins.Message fault) -> void ~override NuGet.Protocol.Plugins.OutboundRequestContext.HandleProgress(NuGet.Protocol.Plugins.Message progress) -> void @@ -1836,8 +1825,6 @@ override NuGet.Protocol.Plugins.PluginPackageReader.IsServiceable() -> bool override NuGet.Protocol.Plugins.StandardInputReceiver.Connect() -> void override NuGet.Protocol.Plugins.StandardOutputReceiver.Close() -> void override NuGet.Protocol.Plugins.StandardOutputReceiver.Connect() -> void -~override NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier.IsValid(string filePath) -> bool -~override NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier.IsValid(string filePath) -> bool override NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository! source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task!>! override NuGet.Protocol.Providers.VulnerabilityInfoResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository! source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task!>! ~override NuGet.Protocol.ProxyAuthenticationHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task @@ -1998,7 +1985,6 @@ static NuGet.Protocol.Events.ProtocolDiagnostics.ResourceEvent -> NuGet.Protocol ~static NuGet.Protocol.PackageDetailsUriResourceV3.CreateOrNull(string uriTemplate) -> NuGet.Protocol.PackageDetailsUriResourceV3 ~static NuGet.Protocol.Plugins.AutomaticProgressReporter.Create(NuGet.Protocol.Plugins.IConnection connection, NuGet.Protocol.Plugins.Message request, System.TimeSpan interval, System.Threading.CancellationToken cancellationToken) -> NuGet.Protocol.Plugins.AutomaticProgressReporter ~static NuGet.Protocol.Plugins.ConnectionOptions.CreateDefault(NuGet.Common.IEnvironmentVariableReader reader = null) -> NuGet.Protocol.Plugins.ConnectionOptions -~static NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.Create() -> NuGet.Protocol.Plugins.EmbeddedSignatureVerifier ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.Deserialize(string json) -> T ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.FromObject(object value) -> Newtonsoft.Json.Linq.JObject ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.Serialize(Newtonsoft.Json.JsonWriter writer, object value) -> void diff --git a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 7dc5c58110b..9f62b32fec7 100644 --- a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ #nullable enable +~NuGet.Protocol.Plugins.PluginDiscoverer.PluginDiscoverer(string rawPluginPaths) -> void diff --git a/src/NuGet.Core/NuGet.Protocol/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/src/NuGet.Core/NuGet.Protocol/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt index 13f5869448a..86a9ec539e4 100644 --- a/src/NuGet.Core/NuGet.Protocol/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt +++ b/src/NuGet.Core/NuGet.Protocol/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt @@ -891,10 +891,6 @@ NuGet.Protocol.Plugins.CopyNupkgFileRequest NuGet.Protocol.Plugins.CopyNupkgFileResponse NuGet.Protocol.Plugins.CopyNupkgFileResponse.CopyNupkgFileResponse(NuGet.Protocol.Plugins.MessageResponseCode responseCode) -> void NuGet.Protocol.Plugins.CopyNupkgFileResponse.ResponseCode.get -> NuGet.Protocol.Plugins.MessageResponseCode -NuGet.Protocol.Plugins.EmbeddedSignatureVerifier -NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.EmbeddedSignatureVerifier() -> void -NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier.FallbackEmbeddedSignatureVerifier() -> void NuGet.Protocol.Plugins.Fault ~NuGet.Protocol.Plugins.Fault.Fault(string message) -> void ~NuGet.Protocol.Plugins.Fault.Message.get -> string @@ -1203,7 +1199,6 @@ NuGet.Protocol.Plugins.PluginCreationResult NuGet.Protocol.Plugins.PluginDiscoverer ~NuGet.Protocol.Plugins.PluginDiscoverer.DiscoverAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task> NuGet.Protocol.Plugins.PluginDiscoverer.Dispose() -> void -~NuGet.Protocol.Plugins.PluginDiscoverer.PluginDiscoverer(string rawPluginPaths, NuGet.Protocol.Plugins.EmbeddedSignatureVerifier verifier) -> void NuGet.Protocol.Plugins.PluginDiscoveryResult ~NuGet.Protocol.Plugins.PluginDiscoveryResult.Message.get -> string ~NuGet.Protocol.Plugins.PluginDiscoveryResult.PluginDiscoveryResult(NuGet.Protocol.Plugins.PluginFile pluginFile) -> void @@ -1337,10 +1332,6 @@ NuGet.Protocol.Plugins.SymmetricHandshake.Dispose() -> void ~NuGet.Protocol.Plugins.SymmetricHandshake.HandshakeAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task ~NuGet.Protocol.Plugins.SymmetricHandshake.SymmetricHandshake(NuGet.Protocol.Plugins.IConnection connection, System.TimeSpan handshakeTimeout, NuGet.Versioning.SemanticVersion protocolVersion, NuGet.Versioning.SemanticVersion minimumProtocolVersion) -> void NuGet.Protocol.Plugins.TimeoutUtilities -NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier.UnixAndMonoPlatformsEmbeddedSignatureVerifier() -> void -NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier -NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier.WindowsEmbeddedSignatureVerifier() -> void NuGet.Protocol.ProtocolConstants NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider.OwnerDetailsUriResourceV3Provider() -> void @@ -1564,7 +1555,6 @@ abstract NuGet.Protocol.Core.Types.ResourceProvider.TryCreate(NuGet.Protocol.Cor ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackage(NuGet.Packaging.Core.PackageIdentity identity, NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> NuGet.Protocol.LocalPackageInfo ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackage(System.Uri path, NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> NuGet.Protocol.LocalPackageInfo ~abstract NuGet.Protocol.FindLocalPackagesResource.GetPackages(NuGet.Common.ILogger logger, System.Threading.CancellationToken token) -> System.Collections.Generic.IEnumerable -~abstract NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.IsValid(string filePath) -> bool abstract NuGet.Protocol.Plugins.OutboundRequestContext.Dispose(bool disposing) -> void abstract NuGet.Protocol.Plugins.OutboundRequestContext.HandleCancelResponse() -> void ~abstract NuGet.Protocol.Plugins.OutboundRequestContext.HandleFault(NuGet.Protocol.Plugins.Message fault) -> void @@ -1778,7 +1768,6 @@ override NuGet.Protocol.Model.PackageVulnerabilityInfo.GetHashCode() -> int ~override NuGet.Protocol.PackageUpdateResourceV2Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task> ~override NuGet.Protocol.PackageUpdateResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task> ~override NuGet.Protocol.PluginFindPackageByIdResourceProvider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository source, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task> -~override NuGet.Protocol.Plugins.FallbackEmbeddedSignatureVerifier.IsValid(string filePath) -> bool override NuGet.Protocol.Plugins.OutboundRequestContext.HandleCancelResponse() -> void ~override NuGet.Protocol.Plugins.OutboundRequestContext.HandleFault(NuGet.Protocol.Plugins.Message fault) -> void ~override NuGet.Protocol.Plugins.OutboundRequestContext.HandleProgress(NuGet.Protocol.Plugins.Message progress) -> void @@ -1836,8 +1825,6 @@ override NuGet.Protocol.Plugins.PluginPackageReader.IsServiceable() -> bool override NuGet.Protocol.Plugins.StandardInputReceiver.Connect() -> void override NuGet.Protocol.Plugins.StandardOutputReceiver.Close() -> void override NuGet.Protocol.Plugins.StandardOutputReceiver.Connect() -> void -~override NuGet.Protocol.Plugins.UnixAndMonoPlatformsEmbeddedSignatureVerifier.IsValid(string filePath) -> bool -~override NuGet.Protocol.Plugins.WindowsEmbeddedSignatureVerifier.IsValid(string filePath) -> bool override NuGet.Protocol.Providers.OwnerDetailsUriResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository! source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task!>! override NuGet.Protocol.Providers.VulnerabilityInfoResourceV3Provider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository! source, System.Threading.CancellationToken token) -> System.Threading.Tasks.Task!>! ~override NuGet.Protocol.ProxyAuthenticationHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task @@ -1998,7 +1985,6 @@ static NuGet.Protocol.Events.ProtocolDiagnostics.ResourceEvent -> NuGet.Protocol ~static NuGet.Protocol.PackageDetailsUriResourceV3.CreateOrNull(string uriTemplate) -> NuGet.Protocol.PackageDetailsUriResourceV3 ~static NuGet.Protocol.Plugins.AutomaticProgressReporter.Create(NuGet.Protocol.Plugins.IConnection connection, NuGet.Protocol.Plugins.Message request, System.TimeSpan interval, System.Threading.CancellationToken cancellationToken) -> NuGet.Protocol.Plugins.AutomaticProgressReporter ~static NuGet.Protocol.Plugins.ConnectionOptions.CreateDefault(NuGet.Common.IEnvironmentVariableReader reader = null) -> NuGet.Protocol.Plugins.ConnectionOptions -~static NuGet.Protocol.Plugins.EmbeddedSignatureVerifier.Create() -> NuGet.Protocol.Plugins.EmbeddedSignatureVerifier ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.Deserialize(string json) -> T ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.FromObject(object value) -> Newtonsoft.Json.Linq.JObject ~static NuGet.Protocol.Plugins.JsonSerializationUtilities.Serialize(Newtonsoft.Json.JsonWriter writer, object value) -> void diff --git a/src/NuGet.Core/NuGet.Protocol/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Protocol/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index 7dc5c58110b..9f62b32fec7 100644 --- a/src/NuGet.Core/NuGet.Protocol/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Protocol/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ #nullable enable +~NuGet.Protocol.Plugins.PluginDiscoverer.PluginDiscoverer(string rawPluginPaths) -> void diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/EmbeddedSignatureVerifierTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/EmbeddedSignatureVerifierTests.cs deleted file mode 100644 index a2a12c7ffa9..00000000000 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/EmbeddedSignatureVerifierTests.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using NuGet.Test.Utility; -using Xunit; - -namespace NuGet.Protocol.Plugins.Tests -{ - public class EmbeddedSignatureVerifierTests - { - [PlatformFact(Platform.Windows)] - public void Create_ReturnsWindowsEmbeddedSignatureVerifierOnWindows() - { - var verifier = EmbeddedSignatureVerifier.Create(); - - Assert.IsType(verifier); - } - - [PlatformFact(Platform.Darwin)] - public void Create_ReturnsUnixPlatformsEmbeddedSignatureVerifierOnMacOS() - { - var verifier = EmbeddedSignatureVerifier.Create(); - - Assert.IsType(verifier); - } - - [PlatformFact(Platform.Linux)] - public void Create_ReturnsUnixPlatformsEmbeddedSignatureVerifierOnLinux() - { - var verifier = EmbeddedSignatureVerifier.Create(); - - Assert.IsType(verifier); - } - } -} diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/FallbackEmbeddedSignatureVerifierTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/FallbackEmbeddedSignatureVerifierTests.cs deleted file mode 100644 index 658c2de0d05..00000000000 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/FallbackEmbeddedSignatureVerifierTests.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Xunit; - -namespace NuGet.Protocol.Plugins.Tests -{ - public class FallbackEmbeddedSignatureVerifierTests - { - [Fact] - public void IsValid_Throws() - { - var verifier = new FallbackEmbeddedSignatureVerifier(); - - Assert.Throws(() => verifier.IsValid(filePath: "a")); - } - } -} diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/PluginDiscovererTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/PluginDiscovererTests.cs index a67b08e1c18..f48460dee65 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/PluginDiscovererTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/PluginDiscovererTests.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Moq; using NuGet.Test.Utility; using Xunit; @@ -21,56 +20,25 @@ public class PluginDiscovererTests [InlineData(" ")] public void Constructor_AcceptsAnyString(string rawPluginPaths) { - using (new PluginDiscoverer(rawPluginPaths, Mock.Of())) + using (new PluginDiscoverer(rawPluginPaths)) { } } - [Fact] - public void DiscoverAsync_ThrowsForNullVerifier() - { - var exception = Assert.Throws( - () => new PluginDiscoverer(rawPluginPaths: "", verifier: null)); - - Assert.Equal("verifier", exception.ParamName); - } - [Fact] public async Task DiscoverAsync_ThrowsIfCancelled() { - using (var discoverer = new PluginDiscoverer( - rawPluginPaths: "", - verifier: Mock.Of())) + using (var discoverer = new PluginDiscoverer(rawPluginPaths: "")) { await Assert.ThrowsAsync( () => discoverer.DiscoverAsync(new CancellationToken(canceled: true))); } } - [Fact] - public async Task DiscoverAsync_ThrowsPlatformNotSupportedIfEmbeddedSignatureVerifierIsRequired() - { - using (var testDirectory = TestDirectory.Create()) - { - var pluginPath = Path.Combine(testDirectory.Path, "a"); - - File.WriteAllText(pluginPath, string.Empty); - - using (var discoverer = new PluginDiscoverer(pluginPath, new FallbackEmbeddedSignatureVerifier())) - { - var plugins = await discoverer.DiscoverAsync(CancellationToken.None); - Assert.Throws( - () => plugins.SingleOrDefault().PluginFile.State.Value); - } - } - } - [Fact] public async Task DiscoverAsync_DoesNotThrowIfNoValidFilePathsAndFallbackEmbeddedSignatureVerifier() { - using (var discoverer = new PluginDiscoverer( - rawPluginPaths: ";", - verifier: new FallbackEmbeddedSignatureVerifier())) + using (var discoverer = new PluginDiscoverer(rawPluginPaths: ";")) { var pluginFiles = await discoverer.DiscoverAsync(CancellationToken.None); @@ -91,9 +59,8 @@ public async Task DiscoverAsync_PerformsDiscoveryOnlyOnce() { { pluginPath, true } }; - var verifierStub = new EmbeddedSignatureVerifierStub(responses); - using (var discoverer = new PluginDiscoverer(pluginPath, verifierStub)) + using (var discoverer = new PluginDiscoverer(pluginPath)) { var results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray(); @@ -103,41 +70,10 @@ public async Task DiscoverAsync_PerformsDiscoveryOnlyOnce() } Assert.Equal(1, results.Length); - Assert.Equal(1, verifierStub.IsValidCallCount); results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray(); Assert.Equal(1, results.Length); - Assert.Equal(1, verifierStub.IsValidCallCount); - } - } - } - - [Fact] - public async Task DiscoverAsync_SignatureIsVerifiedLazily() - { - using (var testDirectory = TestDirectory.Create()) - { - var pluginPath = Path.Combine(testDirectory.Path, "a"); - - File.WriteAllText(pluginPath, string.Empty); - - var responses = new Dictionary() - { - { pluginPath, true } - }; - var verifierStub = new EmbeddedSignatureVerifierStub(responses); - - using (var discoverer = new PluginDiscoverer(pluginPath, verifierStub)) - { - var results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray(); - - Assert.Equal(1, results.Length); - Assert.Equal(0, verifierStub.IsValidCallCount); - - var pluginState = results.SingleOrDefault().PluginFile.State.Value; - - Assert.Equal(1, verifierStub.IsValidCallCount); } } } @@ -147,49 +83,32 @@ public async Task DiscoverAsync_HandlesAllPluginFileStates() { using (var testDirectory = TestDirectory.Create()) { - var pluginPaths = new[] { "a", "b", "c", "d" } + var pluginPaths = new[] { "a", "b", } .Select(fileName => Path.Combine(testDirectory.Path, fileName)) .ToArray(); File.WriteAllText(pluginPaths[1], string.Empty); - File.WriteAllText(pluginPaths[2], string.Empty); - var responses = new Dictionary() - { - { pluginPaths[0], false }, - { pluginPaths[1], false }, - { pluginPaths[2], true }, - { pluginPaths[3], false }, - { "e", true } - }; - var verifierStub = new EmbeddedSignatureVerifierStub(responses); - var rawPluginPaths = string.Join(";", responses.Keys); + string rawPluginPaths = + $"{pluginPaths[0]};{pluginPaths[1]};c"; - using (var discoverer = new PluginDiscoverer(rawPluginPaths, verifierStub)) + using (var discoverer = new PluginDiscoverer(rawPluginPaths)) { var results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray(); - Assert.Equal(5, results.Length); + Assert.Equal(3, results.Length); Assert.Equal(pluginPaths[0], results[0].PluginFile.Path); Assert.Equal(PluginFileState.NotFound, results[0].PluginFile.State.Value); Assert.Equal($"A plugin was not found at path '{pluginPaths[0]}'.", results[0].Message); Assert.Equal(pluginPaths[1], results[1].PluginFile.Path); - Assert.Equal(PluginFileState.InvalidEmbeddedSignature, results[1].PluginFile.State.Value); - Assert.Equal($"The plugin at '{pluginPaths[1]}' did not have a valid embedded signature.", results[1].Message); + Assert.Equal(PluginFileState.Valid, results[1].PluginFile.State.Value); + Assert.Null(results[1].Message); - Assert.Equal(pluginPaths[2], results[2].PluginFile.Path); - Assert.Equal(PluginFileState.Valid, results[2].PluginFile.State.Value); - Assert.Null(results[2].Message); - - Assert.Equal(pluginPaths[3], results[3].PluginFile.Path); - Assert.Equal(PluginFileState.NotFound, results[3].PluginFile.State.Value); - Assert.Equal($"A plugin was not found at path '{pluginPaths[3]}'.", results[3].Message); - - Assert.Equal("e", results[4].PluginFile.Path); - Assert.Equal(PluginFileState.InvalidFilePath, results[4].PluginFile.State.Value); - Assert.Equal($"The plugin file path 'e' is invalid.", results[4].Message); + Assert.Equal("c", results[2].PluginFile.Path); + Assert.Equal(PluginFileState.InvalidFilePath, results[2].PluginFile.State.Value); + Assert.Equal($"The plugin file path 'c' is invalid.", results[2].Message); } } } @@ -202,9 +121,8 @@ public async Task DiscoverAsync_HandlesAllPluginFileStates() public async Task DiscoverAsync_DisallowsNonRootedFilePaths(string pluginPath) { var responses = new Dictionary() { { pluginPath, true } }; - var verifierStub = new EmbeddedSignatureVerifierStub(responses); - using (var discoverer = new PluginDiscoverer(pluginPath, verifierStub)) + using (var discoverer = new PluginDiscoverer(pluginPath)) { var results = (await discoverer.DiscoverAsync(CancellationToken.None)).ToArray(); @@ -223,51 +141,17 @@ public async Task DiscoverAsync_IsIdempotent() File.WriteAllText(pluginPath, string.Empty); - var verifierSpy = new Mock(); - - verifierSpy.Setup(spy => spy.IsValid(It.IsAny())) - .Returns(true); - - using (var discoverer = new PluginDiscoverer(pluginPath, verifierSpy.Object)) + using (var discoverer = new PluginDiscoverer(pluginPath)) { var firstResult = await discoverer.DiscoverAsync(CancellationToken.None); var firstState = firstResult.SingleOrDefault().PluginFile.State.Value; - verifierSpy.Verify(spy => spy.IsValid(It.IsAny()), - Times.Once); - var secondResult = await discoverer.DiscoverAsync(CancellationToken.None); var secondState = secondResult.SingleOrDefault().PluginFile.State.Value; - verifierSpy.Verify(spy => spy.IsValid(It.IsAny()), - Times.Once); - Assert.Same(firstResult, secondResult); } } } - - private sealed class EmbeddedSignatureVerifierStub : EmbeddedSignatureVerifier - { - private readonly Dictionary _responses; - - internal int IsValidCallCount { get; private set; } - - public EmbeddedSignatureVerifierStub(Dictionary responses) - { - _responses = responses; - } - - public override bool IsValid(string filePath) - { - ++IsValidCallCount; - - bool value; - - Assert.True(_responses.TryGetValue(filePath, out value)); - - return value; - } - } } } diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/WindowsEmbeddedSignatureVerifierTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/WindowsEmbeddedSignatureVerifierTests.cs deleted file mode 100644 index 8f930c13de0..00000000000 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/WindowsEmbeddedSignatureVerifierTests.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; -using NuGet.Test.Utility; -using Xunit; - -namespace NuGet.Protocol.Plugins.Tests -{ - public class WindowsEmbeddedSignatureVerifierTests - { - private readonly WindowsEmbeddedSignatureVerifier _verifier; - - public WindowsEmbeddedSignatureVerifierTests() - { - _verifier = new WindowsEmbeddedSignatureVerifier(); - } - - [Theory] - [InlineData(null)] - [InlineData("")] - public void IsValid_ThrowsForNullOrEmpty(string filePath) - { - var expectedMessage = "Argument cannot be null or empty."; - var expectedParam = "filePath"; - var exception = Assert.Throws(() => _verifier.IsValid(filePath)); - - Assert.Contains(expectedMessage, exception.Message); - Assert.Equal(expectedParam, exception.ParamName); - //Remove the expected message from the exception message, the rest part should have param info. - //Background of this change: System.ArgumentException(string message, string paramName) used to generate two lines of message before, but changed to generate one line - //in PR: https://github.com/dotnet/coreclr/pull/25185/files#diff-0365d5690376ef849bf908dfc225b8e8 - var paramPart = exception.Message.Substring(exception.Message.IndexOf(expectedMessage) + expectedMessage.Length); - Assert.Contains(expectedParam, paramPart); - } - - [PlatformFact(Platform.Windows)] - public void IsValid_ReturnsTrueForValidFile() - { - var filePath = Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "System32", "wintrust.dll"); - - var actualResult = _verifier.IsValid(filePath); - - Assert.True(actualResult); - } - - [PlatformFact(Platform.Windows)] - public void IsValid_ReturnsFalseForNonExistentFilePath() - { - var filePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - var actualResult = _verifier.IsValid(filePath); - - Assert.False(actualResult); - } - - [PlatformFact(Platform.Windows)] - public void IsValid_ReturnsFalseForInvalidFile() - { - using (var testDirectory = TestDirectory.Create()) - { - // This is the build output from a default class library project. - // There is nothing special about it; any unsigned DLL would work just as well. - // This is a better test than an arbitrary file (e.g.: file.txt) because - // this is a portable executable (PE) file. Authenticode signatures are - // expected in PE files. - var fileName = "DefaultClassLibrary.dll"; - var resourceName = $"NuGet.Protocol.Tests.compiler.resources.{fileName}"; - var filePath = Path.Combine(testDirectory.Path, fileName); - - ResourceTestUtility.CopyResourceToFile(resourceName, GetType(), filePath); - - var actualResult = _verifier.IsValid(filePath); - - Assert.False(actualResult); - } - } - } -}