Skip to content

Commit d2f6322

Browse files
committed
Merge branch 'develop' into net7
# Conflicts: # src/Renci.SshNet/BaseClient.cs # src/Renci.SshNet/Common/ThrowHelper.cs # src/Renci.SshNet/SubsystemSession.cs
2 parents 76b4ebc + 4c5d0c0 commit d2f6322

File tree

195 files changed

+3256
-11276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+3256
-11276
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ dotnet_diagnostic.S101.severity = none
2929
# This is a duplicate of CA2201 and MA0012.
3030
dotnet_diagnostic.S112.severity = none
3131

32+
# S127: "for" loop stop conditions should be invariant
33+
# https://rules.sonarsource.com/csharp/RSPEC-127
34+
#
35+
# Limited use.
36+
dotnet_diagnostic.S127.severity = none
37+
3238
# S907: Remove use of 'goto'
3339
# https://rules.sonarsource.com/csharp/RSPEC-907
3440
#
@@ -87,6 +93,10 @@ dotnet_diagnostic.S1144.severity = none
8793
# This is a duplicate of IDE0060.
8894
dotnet_diagnostic.S1172.severity = none
8995

96+
# S1199: Nested code blocks should not be used
97+
# https://rules.sonarsource.com/csharp/RSPEC-1199
98+
dotnet_diagnostic.S1199.severity = none
99+
90100
# S1481: Unused local variables should be removed
91101
# https://rules.sonarsource.com/csharp/RSPEC-1481
92102
#
@@ -124,6 +134,12 @@ dotnet_diagnostic.S2259.severity = none
124134
# This is a duplicate of IDE0032.
125135
dotnet_diagnostic.S2292.severity = none
126136

137+
# S2325: Methods and properties that don't access instance data should be static
138+
# https://rules.sonarsource.com/csharp/RSPEC-2325
139+
#
140+
# This is a duplicate of CA1822
141+
dotnet_diagnostic.S2325.severity = none
142+
127143
# S2445: Blocks should be synchronized on read-only fields
128144
# https://rules.sonarsource.com/csharp/RSPEC-2445
129145
#

Directory.Build.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Disable nullable warnings on old frameworks because of missing annotations.
3333
-->
3434
<PropertyGroup Condition=" !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0')) ">
35-
<NoWarn>$(NoWarn);CS8602</NoWarn>
35+
<NoWarn>$(NoWarn);CS8602;CS8604;CS8777</NoWarn>
3636
</PropertyGroup>
3737

3838
<!--
@@ -46,8 +46,8 @@
4646
Use fixed version of analyzers.
4747
-->
4848
<ItemGroup>
49-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
50-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.141" PrivateAssets="all" />
51-
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.19.0.84025" PrivateAssets="all" />
49+
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="all" />
50+
<PackageReference Include="Meziantou.Analyzer" PrivateAssets="all" />
51+
<PackageReference Include="SonarAnalyzer.CSharp" PrivateAssets="all" />
5252
</ItemGroup>
5353
</Project>

Directory.Packages.props

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageVersion Include="Appveyor.TestLogger" Version="2.0.0" />
8+
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
9+
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.4.0" />
10+
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
11+
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
12+
<PackageVersion Include="LiquidTestReports.Markdown" Version="1.0.9" />
13+
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.163" />
14+
<!-- Must be kept at version 1.0.0 or higher, see https://github.com/sshnet/SSH.NET/pull/1288 for details. -->
15+
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
16+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
17+
<PackageVersion Include="MSTest.TestAdapter" Version="3.6.0" />
18+
<PackageVersion Include="MSTest.TestFramework" Version="3.6.0" />
19+
<PackageVersion Include="Moq" Version="4.20.72" />
20+
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.70-alpha" />
21+
<PackageVersion Include="PolySharp" Version="1.14.1" />
22+
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" />
23+
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
24+
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
25+
<PackageVersion Include="Testcontainers" Version="3.10.0" />
26+
</ItemGroup>
27+
</Project>

README.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ The main types provided by this library are:
7070
* aes128-ctr
7171
* aes192-ctr
7272
* aes256-ctr
73-
* aes128-gcm<span></span>@openssh.com (.NET 6 and higher)
74-
* aes256-gcm<span></span>@openssh.com (.NET 6 and higher)
73+
* aes128-gcm<span></span>@openssh.com
74+
* aes256-gcm<span></span>@openssh.com
7575
* chacha20-poly1305<span></span>@openssh.com
7676
* aes128-cbc
7777
* aes192-cbc
@@ -96,19 +96,48 @@ The main types provided by this library are:
9696
## Public Key Authentication
9797

9898
**SSH.NET** supports the following private key formats:
99-
* RSA in OpenSSL PEM ("BEGIN RSA PRIVATE KEY") and ssh.com ("BEGIN SSH2 ENCRYPTED PRIVATE KEY") format
100-
* DSA in OpenSSL PEM ("BEGIN DSA PRIVATE KEY") and ssh.com ("BEGIN SSH2 ENCRYPTED PRIVATE KEY") format
101-
* ECDSA 256/384/521 in OpenSSL PEM format ("BEGIN EC PRIVATE KEY")
102-
* ECDSA 256/384/521, ED25519 and RSA in OpenSSH key format ("BEGIN OPENSSH PRIVATE KEY")
103-
104-
Private keys can be encrypted using one of the following cipher methods:
99+
* RSA in
100+
* OpenSSL traditional PEM format ("BEGIN RSA PRIVATE KEY")
101+
* OpenSSL PKCS#8 PEM format ("BEGIN PRIVATE KEY", "BEGIN ENCRYPTED PRIVATE KEY")
102+
* ssh.com format ("BEGIN SSH2 ENCRYPTED PRIVATE KEY")
103+
* OpenSSH key format ("BEGIN OPENSSH PRIVATE KEY")
104+
* DSA in
105+
* OpenSSL traditional PEM format ("BEGIN DSA PRIVATE KEY")
106+
* OpenSSL PKCS#8 PEM format ("BEGIN PRIVATE KEY", "BEGIN ENCRYPTED PRIVATE KEY")
107+
* ssh.com format ("BEGIN SSH2 ENCRYPTED PRIVATE KEY")
108+
* ECDSA 256/384/521 in
109+
* OpenSSL traditional PEM format ("BEGIN EC PRIVATE KEY")
110+
* OpenSSL PKCS#8 PEM format ("BEGIN PRIVATE KEY", "BEGIN ENCRYPTED PRIVATE KEY")
111+
* OpenSSH key format ("BEGIN OPENSSH PRIVATE KEY")
112+
* ED25519 in
113+
* OpenSSL PKCS#8 PEM format ("BEGIN PRIVATE KEY", "BEGIN ENCRYPTED PRIVATE KEY")
114+
* OpenSSH key format ("BEGIN OPENSSH PRIVATE KEY")
115+
116+
Private keys in OpenSSL traditional PEM format can be encrypted using one of the following cipher methods:
105117
* DES-EDE3-CBC
106118
* DES-EDE3-CFB
107119
* DES-CBC
108120
* AES-128-CBC
109121
* AES-192-CBC
110122
* AES-256-CBC
111123

124+
Private keys in OpenSSL PKCS#8 PEM format can be encrypted using any cipher method BouncyCastle supports.
125+
126+
Private keys in ssh.com format can be encrypted using one of the following cipher methods:
127+
* 3des-cbc
128+
129+
Private keys in OpenSSH key format can be encrypted using one of the following cipher methods:
130+
* 3des-cbc
131+
* aes128-cbc
132+
* aes192-cbc
133+
* aes256-cbc
134+
* aes128-ctr
135+
* aes192-ctr
136+
* aes256-ctr
137+
* aes128-gcm<span></span>@openssh.com
138+
* aes256-gcm<span></span>@openssh.com
139+
* chacha20-poly1305<span></span>@openssh.com
140+
112141
## Host Key Algorithms
113142

114143
**SSH.NET** supports the following host key algorithms:

Renci.SshNet.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1414
CODEOWNERS = CODEOWNERS
1515
CONTRIBUTING.md = CONTRIBUTING.md
1616
Directory.Build.props = Directory.Build.props
17+
Directory.Packages.props = Directory.Packages.props
1718
global.json = global.json
1819
LICENSE = LICENSE
1920
nuget.config = nuget.config

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ for:
3232
# some coverage until a proper solution for running the .NET Framework integration tests in CI is found.
3333
# Running all the tests causes problems which are not worth solving in this rare configuration.
3434
# See https://github.com/sshnet/SSH.NET/pull/1462 and related links
35-
- sh: dotnet test -f net48 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_integration_test_net_48_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_integration_test_net_48_coverage.xml --filter "Name~Ecdh|Name~Zlib" test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
35+
- sh: dotnet test -f net48 -c Debug --no-restore --no-build --results-directory artifacts --logger Appveyor --logger "console;verbosity=normal" --logger "liquid.md;LogFileName=linux_integration_test_net_48_report.md" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=../../artifacts/linux_integration_test_net_48_coverage.xml --filter "Name~Ecdh|Name~ECDsa|Name~Zlib|Name~Gcm" test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj
3636

3737
-
3838
matrix:

src/Renci.SshNet/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,6 @@ dotnet_diagnostic.MA0040.severity = none
188188
# MA0042: Do not use blocking calls in an async method
189189
# duplicate of CA1849
190190
dotnet_diagnostic.MA0042.severity = none
191+
192+
# S3236: Caller information arguments should not be provided explicitly
193+
dotnet_diagnostic.S3236.severity = none
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace Renci.SshNet.Abstractions
5+
{
6+
internal static class CancellationTokenSourceExtensions
7+
{
8+
#if !NET8_OR_GREATER
9+
public static Task CancelAsync(this CancellationTokenSource cancellationTokenSource)
10+
{
11+
cancellationTokenSource.Cancel();
12+
return Task.CompletedTask;
13+
}
14+
#endif
15+
}
16+
}

src/Renci.SshNet/Abstractions/SocketAbstraction.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static void ClearReadBuffer(Socket socket)
129129

130130
public static int ReadPartial(Socket socket, byte[] buffer, int offset, int size, TimeSpan timeout)
131131
{
132-
socket.ReceiveTimeout = timeout.AsTimeout(nameof(timeout));
132+
socket.ReceiveTimeout = timeout.AsTimeout();
133133

134134
try
135135
{
@@ -274,7 +274,7 @@ public static int Read(Socket socket, byte[] buffer, int offset, int size, TimeS
274274
var totalBytesRead = 0;
275275
var totalBytesToRead = size;
276276

277-
socket.ReceiveTimeout = readTimeout.AsTimeout(nameof(readTimeout));
277+
socket.ReceiveTimeout = readTimeout.AsTimeout();
278278

279279
do
280280
{
@@ -292,7 +292,7 @@ public static int Read(Socket socket, byte[] buffer, int offset, int size, TimeS
292292
{
293293
if (IsErrorResumable(ex.SocketErrorCode))
294294
{
295-
ThreadAbstraction.Sleep(30);
295+
Thread.Sleep(30);
296296
continue;
297297
}
298298

@@ -346,7 +346,7 @@ public static void Send(Socket socket, byte[] data, int offset, int size)
346346
if (IsErrorResumable(ex.SocketErrorCode))
347347
{
348348
// socket buffer is probably full, wait and try again
349-
ThreadAbstraction.Sleep(30);
349+
Thread.Sleep(30);
350350
}
351351
else
352352
{
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#if !NET && !NETSTANDARD2_1_OR_GREATER
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
#endif
5+
6+
namespace Renci.SshNet.Abstractions
7+
{
8+
internal static class StreamExtensions
9+
{
10+
#if !NET && !NETSTANDARD2_1_OR_GREATER
11+
public static ValueTask DisposeAsync(this Stream stream)
12+
{
13+
stream.Dispose();
14+
return default;
15+
}
16+
#endif
17+
}
18+
}

0 commit comments

Comments
 (0)