OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.97k stars 950 forks source link

Added a minimal rogue client detection mechanism at the transport level #2850

Open mrsuciu opened 3 days ago

mrsuciu commented 3 days ago

Proposed changes

Clients that behave rogue by repeatedly sending invalid messages in a certain interval of time are now tracked and blocked from connecting for a predefined amount of time. Time calculations are independent of system time.

Related Issues

Types of changes

What types of changes does your code introduce? Put an x in the boxes that apply. You can also fill these out after creating the PR.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

codecov[bot] commented 3 days ago

Codecov Report

Attention: Patch coverage is 18.08511% with 77 lines in your changes missing coverage. Please review.

Project coverage is 55.25%. Comparing base (3672ebe) to head (97da591). Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
...tack/Opc.Ua.Core/Stack/Tcp/TcpTransportListener.cs 14.44% 72 Missing and 5 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2850 +/- ## ========================================== - Coverage 57.23% 55.25% -1.98% ========================================== Files 352 352 Lines 75520 67427 -8093 Branches 15988 13822 -2166 ========================================== - Hits 43223 37258 -5965 + Misses 27870 26082 -1788 + Partials 4427 4087 -340 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

romanett commented 3 days ago

@mrsuciu tests fail on some pipelines: The active test run was aborted. Reason: Test host process crashed : Unhandled exception.Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at Opc.Ua.Bindings.TcpTransportListener.OnAccept(Object sender, SocketAsyncEventArgs e) in /_/Stack/Opc.Ua.Core/Stack/Tcp/TcpTransportListener.cs:line 761 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

mrsuciu commented 2 days ago

@mrsuciu tests fail on some pipelines: The active test run was aborted. Reason: Test host process crashed : Unhandled exception.Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at Opc.Ua.Bindings.TcpTransportListener.OnAccept(Object sender, SocketAsyncEventArgs e) in /_/Stack/Opc.Ua.Core/Stack/Tcp/TcpTransportListener.cs:line 761 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

@romanett This did not happen on my local runs, but somehow the test machines running the tests do not provide IP Addresses.

mregen commented 1 day ago

Hi @mrsuciu, I would only chose a less offending name than RogueClient, e.g just ClientTracker or ClientActivity etc. and make sure there are not too many info messages.