* Bump the dependencies group with 8 updates
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Add upper bounds on the number of banner lines and line length before the SSH identification
string, analogous to OpenSSH. Also don't buffer all the data unnecessarily.
This adds an SftpException which sits between the existing SftpPathNotFoundException/
SftpPermissionDeniedException and SshException, and which contains the response code
from the SSH_FXP_STATUS packet, along with a default message if one was not provided.
SftpPathNotFoundException also gains a Path property which is populated in cases where
it makes sense.
* Avoid rounding issues when checking Timeout values (#1700)
AsTimeout is called from the SshCommand constructor with
Timeout.InfiniteTimeSpan. In this scenario the range check should never
fail, but unfortunately it does in certain scenarios, due to a runtime
or compiler bug (as soon as optimizations are turned off the issue
miraculously disappears).
Closes#1700
* fix tests
---------
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
* Bump the dependencies group with 4 updates
Bumps BouncyCastle.Cryptography from 2.6.1 to 2.6.2
Bumps Meziantou.Analyzer from 2.0.205 to 2.0.210
Bumps MSTest from 3.9.3 to 3.10.0
Bumps SonarAnalyzer.CSharp from 10.13.0.120203 to 10.15.0.120848
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Where beneficial, add additional overrides from the base Stream class. Namely the Span
variants and for PipeStream, the WriteAsync variants (see comments).
The change also adds an internal type borrowed from the runtime repo for easier buffer
management, which could also be used elsewhere.
* Drop net6.0 target
* Update src/Renci.SshNet/Common/TaskToAsyncResult.cs
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
* remove redundant #if
for some reason this made the compiler suddenly
realize that the plain text variables are unused.
* use TargetFrameworkIdentifier
this doesn't work in Directory.Build.props, moved it to Directory.Build.targets.
* fix null reference warnings in Benchmarks
seems like the warnings were (somehow) disabled here
before and were fixed by the previous TargetFrameworkIdentifier
change.
* fix unused plainTextOffset in AesGcmCipher.BclImpl
* CI retry
* more cosmetics
* more
* update README
* Revert "use TargetFrameworkIdentifier"
This reverts commit 076ede161d.
---------
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
* Update SonarAnalyzer.CSharp
* fix S3993: Custom attributes should be marked with "System.AttributeUsageAttribute"
https://rules.sonarsource.com/csharp/RSPEC-3993/
* fix S6966: Awaitable method should be used
Introduced abstractions for CancellationTokenSource.CancelAsync()
and Stream.DisposeAsync() to avoid #ifdef.
Supressed pipeStream.WriteAsync because it deadlocks the test.
I assume because PipeStream doesn't override WriteAsync.
https://rules.sonarsource.com/csharp/RSPEC-6966/
temp
* fix S3431: "[ExpectedException]" should not be used
Removed the Connect() from Multifactor_PublicKeyWithEmptyPassPhrase
because the Exception is already thrown in the factory.
https://rules.sonarsource.com/csharp/RSPEC-3431/
* fix S2325: Methods and properties that don't access instance data should be static
This one is pretty redundant with CA1822 (which is also disabled in the
tests).
It caught a few more cases in the library itself, most of which can't
be changed because they are public API.
https://rules.sonarsource.com/csharp/RSPEC-2325/
* fix S127: "for" loop stop conditions should be invariant
not sure if this one is worth having. The only cases it found
are imho legitimate or not worth fixing, so I supressed them.
https://rules.sonarsource.com/csharp/RSPEC-127/
* fix S1964: An abstract class should have both abstract and concrete methods
Suppressed for public APIs, changed ExtendedReplyInfo to interface.
https://rules.sonarsource.com/csharp/RSPEC-1694/
* Remove redundant test
this is already covered by Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshPassPhraseNullOrEmptyExceptionWhenPassphraseIsNull
* Revert "fix S2325: Methods and properties that don't access instance data should be static"
suppress it instead
This reverts commit 2020604958.
* Revert "fix S127: "for" loop stop conditions should be invariant"
suppress it instead
This reverts commit 1d8b4ac335.
* Ref System.Memory for net462 and netstandard2.0.
Use System.Buffers.Binary.BinaryPrimitives instead of Renci.SshNet.Common.Pack
* Remove unnecessary `AsSpan()`
* Apply suggestions from code review
* that's what I get for being lazy
---------
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
Apply similar treatment to PipeStream as #1322 did to ShellStream
PipeStream now behaves much more Stream-like. In particular, it performs partial
reads (instead of blocking until a certain amount of data is available), blocks
until data is available (instead of returning 0 prematurely) and removes the
Stream-unlike properties `BlockLastReadBuffer` and `MaxBufferLength`.
Sadly I gave up trying to make a benchmark compatible with all the quirks of the
previous implementation, but a dumb throughput test (reading and writing simultaneously)
shows about 5.2GB/s with this implementation compared to 140MB/s previously.
Some cleanup of its usage in the library followed.
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
* Preparation to enforce formatting and style in CI
- enabled IDE0055 to enforce formatting on build
- disabled SA1137 and SA1025 because they are already
covered by IDE0055
- disabled SA1021 because it conflicts with csharp_space_after_cast
* Cleanup formatting and style on codebase
This commit has no manual changes, it is the result
of running "dotnet format whitespace" and "dotnet format style"
* new formatting fixes after merge
* appveyor: set git autocrlf
as suggested by sharwell to hopefully fix Windows CI.
* use autocrlf input
to hopefully fix Linux tests
* fix formatting
* use autocrlf input for Linux only
* set csharp_space_after_cast to false
* Revert SA1021 suppression
---------
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
* Fixed warnings in tests.
* Fixed warnings in main project.
* Fix public key.
* Further warning cleanup.
* Muted remaining warnings.
* Final cleanup.
* Fix warning.
* Fix test classes.
* Fix more internals.
* Revert "internal" in test projects
* Revert more internals.
* Revert all non-analyzer changes.
---------
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
* Added guard clauses to various timeouts to ensure they don't exceed an Int32 in milliseconds.
* Fixed guard clauses.
* Updated build tags.
* Added guard clauses to various timeouts to ensure they don't exceed an Int32 in milliseconds.
* Fixed tests.
* Added additional tests.
* Replaced NoWarn with .editorconfig setting
* Fixed references to parameter names.
This paves the way for asynchronous synchronisation via WaitAsync
(and eliminates a timing test which sometimes fails in CI)
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
* Fix analyzer errors in Renci.SshNet and Renci.SshNet.TestTools.OpenSSH.
Suppress all errors in unit tests and integration tests.
* Update unit tests now that we pass 'mode' as argument name when we throw ArgumentException.
* Remove stale comment and add unit tests for SshData.ReadBytes(int length).
* Remove unnessary suppression.
* Remove Visual Studio magic.
* Removed duplicate source file.
* Clarified that suppression hides a false positive.
* Remove suppressions for S2372.
* Update ReadExtensionPair() to return concrete dictionary.
* Move test projects to test folder.
Move global.json to root of repo.
Update solution items in solution.
* Move test projects to test folder.
Move global.json to root of repo.
Update solution items in solution.
Update appveyor configuration/
* Attempt to have appveyor use the correct .NET SDK.
* Update .NET SDK to version 7.0.402.
* Move Data folder below Renci.SshNet.Tests.
* Make csinst less chatty.
* Move Data folder directly below test folder as it's used by multiple test projects.
* Remove CS1591 nowarn from concrete test projects as this is already defined in the Directory.Build.props that is in the test folder.
* Fix integration test after moving test projects
---------
Co-authored-by: drieseng <gert.driesen@telenet.be>