Skip to content

Commit 325e4ab

Browse files
authored
Merge branch 'develop' into bcl-ciphermode
2 parents bdeefa8 + 03ae6bf commit 325e4ab

File tree

362 files changed

+2246
-13973
lines changed

Some content is hidden

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

362 files changed

+2246
-13973
lines changed

.editorconfig

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Avoid looking for .editorconfig files in parent directories
1+
# Avoid looking for .editorconfig files in parent directories
22
root=true
33

44
[*]
@@ -7,6 +7,9 @@ insert_final_newline = true
77
indent_style = space
88
indent_size = 4
99
tab_width = 4
10+
spelling_languages = en-us,en-gb
11+
spelling_exclusion_path = exclusion.dic
12+
spelling_checkable_types = all
1013

1114
[*.{xml,csproj,props}]
1215

@@ -716,7 +719,7 @@ dotnet_code_quality.CA1828.api_surface = all
716719
dotnet_diagnostic.CA1852.severity = none
717720

718721
# CA1848: don't enforce LoggerMessage pattern
719-
dotnet_diagnostic.CA1848.severity = suggestion
722+
dotnet_diagnostic.CA1848.severity = silent
720723

721724
# CA1859: Change return type for improved performance
722725
#
@@ -776,14 +779,14 @@ dotnet_diagnostic.IDE0032.severity = suggestion
776779
dotnet_diagnostic.IDE0045.severity = none
777780

778781
# IDE0046: Use conditional expression for return
779-
#
782+
#
780783
# Using a conditional expression is not always a clear win for readability.
781784
#
782785
# Configured using 'dotnet_style_prefer_conditional_expression_over_return'
783786
dotnet_diagnostic.IDE0046.severity = suggestion
784787

785788
# IDE0047: Remove unnecessary parentheses
786-
#
789+
#
787790
# Removing "unnecessary" parentheses is not always a clear win for readability.
788791
dotnet_diagnostic.IDE0047.severity = suggestion
789792

@@ -794,7 +797,7 @@ dotnet_diagnostic.IDE0047.severity = suggestion
794797
dotnet_diagnostic.IDE0130.severity = none
795798

796799
# IDE0270: Null check can be simplified
797-
#
800+
#
798801
# var inputPath = originalDossierPathList.Find(x => x.id == updatedPath.id);
799802
# if (inputPath is null)
800803
# {
@@ -938,7 +941,7 @@ csharp_new_line_before_catch = true
938941
csharp_new_line_before_finally = true
939942
# Enabling this setting breaks Resharper formatting for an enum field reference that is
940943
# deeply nested in an object initializer.
941-
#
944+
#
942945
# For an example, see TDataExchangeGeneralEnricher_CernInfrastructureObstruction.
943946
#csharp_new_line_before_members_in_object_initializers = true
944947
csharp_new_line_before_members_in_anonymous_types = true
@@ -1021,19 +1024,19 @@ dotnet_naming_rule.private_const_fields_pascal_case.severity = warning
10211024

10221025
dotnet_naming_symbols.interface.applicable_kinds = interface
10231026
dotnet_naming_symbols.interface.applicable_accessibilities = *
1024-
dotnet_naming_symbols.interface.required_modifiers =
1027+
dotnet_naming_symbols.interface.required_modifiers =
10251028

10261029
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
10271030
dotnet_naming_symbols.types.applicable_accessibilities = *
1028-
dotnet_naming_symbols.types.required_modifiers =
1031+
dotnet_naming_symbols.types.required_modifiers =
10291032

10301033
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
10311034
dotnet_naming_symbols.non_field_members.applicable_accessibilities = *
1032-
dotnet_naming_symbols.non_field_members.required_modifiers =
1035+
dotnet_naming_symbols.non_field_members.required_modifiers =
10331036

10341037
dotnet_naming_symbols.private_fields.applicable_kinds = field
10351038
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
1036-
dotnet_naming_symbols.private_fields.required_modifiers =
1039+
dotnet_naming_symbols.private_fields.required_modifiers =
10371040

10381041
dotnet_naming_symbols.private_static_fields.applicable_kinds = field
10391042
dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private
@@ -1050,18 +1053,18 @@ dotnet_naming_symbols.private_const_fields.required_modifiers = const
10501053
# Naming styles
10511054

10521055
dotnet_naming_style.begins_with_i.required_prefix = I
1053-
dotnet_naming_style.begins_with_i.required_suffix =
1054-
dotnet_naming_style.begins_with_i.word_separator =
1056+
dotnet_naming_style.begins_with_i.required_suffix =
1057+
dotnet_naming_style.begins_with_i.word_separator =
10551058
dotnet_naming_style.begins_with_i.capitalization = pascal_case
10561059

1057-
dotnet_naming_style.pascal_case.required_prefix =
1058-
dotnet_naming_style.pascal_case.required_suffix =
1059-
dotnet_naming_style.pascal_case.word_separator =
1060+
dotnet_naming_style.pascal_case.required_prefix =
1061+
dotnet_naming_style.pascal_case.required_suffix =
1062+
dotnet_naming_style.pascal_case.word_separator =
10601063
dotnet_naming_style.pascal_case.capitalization = pascal_case
10611064

10621065
dotnet_naming_style.camel_case_begins_with_underscore.required_prefix = _
1063-
dotnet_naming_style.camel_case_begins_with_underscore.required_suffix =
1064-
dotnet_naming_style.camel_case_begins_with_underscore.word_separator =
1066+
dotnet_naming_style.camel_case_begins_with_underscore.required_suffix =
1067+
dotnet_naming_style.camel_case_begins_with_underscore.word_separator =
10651068
dotnet_naming_style.camel_case_begins_with_underscore.capitalization = camel_case
10661069

10671070
#### .NET Compiler Platform general options ####

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
uses: actions/setup-dotnet@v4
117117

118118
- name: Setup WSL2
119-
uses: Vampire/setup-wsl@3b46b44374d5d0ae94654c45d114a3ed7a0e07a8 # v5.0.1
119+
uses: Vampire/setup-wsl@6a8db447be7ed35f2f499c02c6e60ff77ef11278 # v6.0.0
120120
with:
121121
distribution: Ubuntu-24.04
122122

Directory.Packages.props

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@
44
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageVersion Include="BenchmarkDotNet" Version="0.15.0" />
8-
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.6.1" />
7+
<PackageVersion Include="BenchmarkDotNet" Version="0.15.2" />
8+
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.6.2" />
99
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
1010
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
1111
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
12-
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.201" />
13-
12+
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.210" />
1413
<!-- Should stay on LTS .NET releases. -->
1514
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
16-
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.5" />
17-
<PackageVersion Include="MSTest" Version="3.9.1" />
15+
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.7" />
16+
<PackageVersion Include="MSTest" Version="3.10.0" />
1817
<PackageVersion Include="Moq" Version="4.20.72" />
1918
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
2019
<PackageVersion Include="PolySharp" Version="1.15.0" />
21-
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.10.0.116381" />
20+
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
2221
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
23-
2422
<!-- Should stay on LTS .NET releases. -->
2523
<PackageVersion Include="System.Formats.Asn1" Version="8.0.2" />
26-
<PackageVersion Include="Testcontainers" Version="4.5.0" />
24+
<PackageVersion Include="Testcontainers" Version="4.6.0" />
2725
</ItemGroup>
28-
</Project>
26+
</Project>

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
CONTRIBUTING.md = CONTRIBUTING.md
1515
Directory.Build.props = Directory.Build.props
1616
Directory.Packages.props = Directory.Packages.props
17+
exclusion.dic = exclusion.dic
1718
global.json = global.json
1819
LICENSE = LICENSE
1920
nuget.config = nuget.config

docfx/logging.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
Logging
22
=================
33

4-
SSH.NET uses the [Microsoft.Extensions.Logging](https://learn.microsoft.com/dotnet/core/extensions/logging) API to log diagnostic messages. In order to access the log messages of SSH.NET in your own application for diagnosis, register your own `ILoggerFactory` before using the SSH.NET APIs, for example:
4+
SSH.NET uses the [Microsoft.Extensions.Logging](https://learn.microsoft.com/dotnet/core/extensions/logging) API to log diagnostic messages.
5+
6+
It is possible to specify a logger in the `ConnectionInfo`, for example:
7+
8+
```cs
9+
using Microsoft.Extensions.Logging;
10+
11+
ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
12+
{
13+
builder.SetMinimumLevel(LogLevel.Debug);
14+
builder.AddConsole();
15+
});
16+
17+
var connectionInfo = new ConnectionInfo("sftp.foo.com",
18+
"guest",
19+
new PasswordAuthenticationMethod("guest", "pwd"));
20+
21+
connectionInfo.LoggerFactory = loggerFactory;
22+
using (var client = new SftpClient(connectionInfo))
23+
{
24+
client.Connect();
25+
}
26+
```
27+
28+
You can also register an application-wide `ILoggerFactory` before using the SSH.NET APIs, this will be used as a fallback if the `ConnectionInfo` is not set, for example:
529

630
```cs
731
using Microsoft.Extensions.Logging;

exclusion.dic

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
args
2+
atime
3+
bcrypt
4+
bigint
5+
bourne
6+
cbc
7+
chacha
8+
csproj
9+
decryptor
10+
dest
11+
diffie
12+
docfx
13+
ecdh
14+
ecdsa
15+
emerle
16+
exe
17+
fallback
18+
github
19+
hmac
20+
hostbased
21+
identd
22+
ietf
23+
impl
24+
infocmp
25+
kewl
26+
kex
27+
mindrot
28+
mtime
29+
netconf
30+
nist
31+
nistp
32+
openssh
33+
pkcs
34+
posix
35+
privatekey
36+
protoversion
37+
pubkey
38+
publickey
39+
renci
40+
ripemd
41+
slen
42+
sntrup
43+
softwareversion
44+
sshd
45+
tcpip
46+
threadpool
47+
umac
48+
unpad
49+
unix
50+
waithandle
51+
xoff
52+
xmldoc
53+
zlib

src/Renci.SshNet/.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[*.cs]
2+
spelling_languages = en-us,en-gb
3+
spelling_exclusion_path = ../exclusion.dic
4+
spelling_checkable_types = all
25

36
#### Sonar rules ####
47

@@ -191,3 +194,6 @@ dotnet_diagnostic.MA0042.severity = none
191194

192195
# S3236: Caller information arguments should not be provided explicitly
193196
dotnet_diagnostic.S3236.severity = none
197+
198+
# S3358: Ternary operators should not be nested
199+
dotnet_diagnostic.S3358.severity = none

src/Renci.SshNet/Abstractions/SocketAbstraction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public static void Send(Socket socket, byte[] data, int offset, int size)
350350
}
351351
else
352352
{
353-
throw; // any serious error occurr
353+
throw; // any serious error occur
354354
}
355355
}
356356
}

src/Renci.SshNet/BaseClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private protected BaseClient(ConnectionInfo connectionInfo, bool ownsConnectionI
192192
_connectionInfo = connectionInfo;
193193
_ownsConnectionInfo = ownsConnectionInfo;
194194
_serviceFactory = serviceFactory;
195-
_logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
195+
_logger = (connectionInfo.LoggerFactory ?? SshNetLoggingConfiguration.LoggerFactory).CreateLogger(GetType());
196196
_keepAliveInterval = Timeout.InfiniteTimeSpan;
197197
}
198198

@@ -408,7 +408,7 @@ protected virtual void OnDisconnected()
408408
{
409409
}
410410

411-
private void Session_ErrorOccured(object? sender, ExceptionEventArgs e)
411+
private void Session_ErrorOccurred(object? sender, ExceptionEventArgs e)
412412
{
413413
ErrorOccurred?.Invoke(this, e);
414414
}
@@ -558,7 +558,7 @@ private ISession CreateAndConnectSession()
558558
var session = _serviceFactory.CreateSession(ConnectionInfo, _serviceFactory.CreateSocketFactory());
559559
session.ServerIdentificationReceived += Session_ServerIdentificationReceived;
560560
session.HostKeyReceived += Session_HostKeyReceived;
561-
session.ErrorOccured += Session_ErrorOccured;
561+
session.ErrorOccured += Session_ErrorOccurred;
562562

563563
try
564564
{
@@ -577,7 +577,7 @@ private async Task<ISession> CreateAndConnectSessionAsync(CancellationToken canc
577577
var session = _serviceFactory.CreateSession(ConnectionInfo, _serviceFactory.CreateSocketFactory());
578578
session.ServerIdentificationReceived += Session_ServerIdentificationReceived;
579579
session.HostKeyReceived += Session_HostKeyReceived;
580-
session.ErrorOccured += Session_ErrorOccured;
580+
session.ErrorOccured += Session_ErrorOccurred;
581581

582582
try
583583
{
@@ -593,7 +593,7 @@ private async Task<ISession> CreateAndConnectSessionAsync(CancellationToken canc
593593

594594
private void DisposeSession(ISession session)
595595
{
596-
session.ErrorOccured -= Session_ErrorOccured;
596+
session.ErrorOccured -= Session_ErrorOccurred;
597597
session.HostKeyReceived -= Session_HostKeyReceived;
598598
session.ServerIdentificationReceived -= Session_ServerIdentificationReceived;
599599
session.Dispose();

src/Renci.SshNet/Channels/Channel.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected Channel(ISession session, uint localChannelNumber, uint localWindowSiz
8484
LocalChannelNumber = localChannelNumber;
8585
LocalPacketSize = localPacketSize;
8686
LocalWindowSize = localWindowSize;
87-
_logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
87+
_logger = session.SessionLoggerFactory.CreateLogger(GetType());
8888

8989
session.ChannelWindowAdjustReceived += OnChannelWindowAdjust;
9090
session.ChannelDataReceived += OnChannelData;
@@ -94,15 +94,15 @@ protected Channel(ISession session, uint localChannelNumber, uint localWindowSiz
9494
session.ChannelRequestReceived += OnChannelRequest;
9595
session.ChannelSuccessReceived += OnChannelSuccess;
9696
session.ChannelFailureReceived += OnChannelFailure;
97-
session.ErrorOccured += Session_ErrorOccured;
97+
session.ErrorOccured += Session_ErrorOccurred;
9898
session.Disconnected += Session_Disconnected;
9999
}
100100

101101
/// <summary>
102102
/// Gets the session.
103103
/// </summary>
104104
/// <value>
105-
/// Thhe session.
105+
/// The session.
106106
/// </value>
107107
protected ISession Session
108108
{
@@ -328,7 +328,7 @@ public void SendData(byte[] data)
328328
/// multiple chunks and will wait for the remote window size to be adjusted when it's zero.
329329
/// </para>
330330
/// <para>
331-
/// This is done to support SSH servers will a small window size that do not agressively
331+
/// This is done to support SSH servers will a small window size that do not aggressively
332332
/// increase their window size. We need to take into account that there may be SSH servers
333333
/// that only increase their window size when it has reached zero.
334334
/// </para>
@@ -586,7 +586,7 @@ protected virtual void OnDisconnected()
586586
{
587587
}
588588

589-
protected virtual void OnErrorOccured(Exception exp)
589+
protected virtual void OnErrorOccurred(Exception exp)
590590
{
591591
}
592592

@@ -609,20 +609,20 @@ private void Session_Disconnected(object sender, EventArgs e)
609609
/// </summary>
610610
/// <param name="ex">The <see cref="Exception"/>.</param>
611611
/// <remarks>
612-
/// This method will in turn invoke <see cref="OnErrorOccured(System.Exception)"/>, and
612+
/// This method will in turn invoke <see cref="OnErrorOccurred(System.Exception)"/>, and
613613
/// raise the <see cref="Exception"/> event.
614614
/// </remarks>
615615
protected void OnChannelException(Exception ex)
616616
{
617-
OnErrorOccured(ex);
617+
OnErrorOccurred(ex);
618618
RaiseExceptionEvent(ex);
619619
}
620620

621-
private void Session_ErrorOccured(object sender, ExceptionEventArgs e)
621+
private void Session_ErrorOccurred(object sender, ExceptionEventArgs e)
622622
{
623623
try
624624
{
625-
OnErrorOccured(e.Exception);
625+
OnErrorOccurred(e.Exception);
626626
}
627627
catch (Exception ex)
628628
{
@@ -854,7 +854,7 @@ protected virtual void Dispose(bool disposing)
854854
session.ChannelRequestReceived -= OnChannelRequest;
855855
session.ChannelSuccessReceived -= OnChannelSuccess;
856856
session.ChannelFailureReceived -= OnChannelFailure;
857-
session.ErrorOccured -= Session_ErrorOccured;
857+
session.ErrorOccured -= Session_ErrorOccurred;
858858
session.Disconnected -= Session_Disconnected;
859859
}
860860

0 commit comments

Comments
 (0)