Skip to content

Commit

Permalink
[ROBO-3413] fix rdp license leak (#33)
Browse files Browse the repository at this point in the history
[ROBO-3413] fix rdp license leak
  • Loading branch information
mihainradu authored Jan 26, 2024
1 parent e85a079 commit 99ee4ed
Show file tree
Hide file tree
Showing 18 changed files with 790 additions and 370 deletions.
6 changes: 3 additions & 3 deletions .ci/Scripts/PrepareFreeRdpDev.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
call .\getOpenSsl
call .\buildOpenSsl
call .\buildFreeRDP Debug
call %~dp0\getOpenSsl
call %~dp0\buildOpenSsl
call %~dp0\buildFreeRDP Debug
4 changes: 0 additions & 4 deletions .ci/Scripts/buildOpenSsl.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ pushd .
cd %freeRdpDir%\..\OpenSSL
git clean -xdff

pushd .
call "%vsDir%\VC\Auxiliary\Build\vcvars64.bat"
popd

perl Configure VC-WIN64A no-asm no-shared no-module --prefix=%~dp0\..\..\..\OpenSSL-VC-64
nmake
nmake install_dev
Expand Down
2 changes: 1 addition & 1 deletion .ci/Scripts/getOpenSsl.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cd %freeRdpDir%\..
rem checkout openssl
mkdir OpenSSL
cd OpenSSL
git clone https://github.com/openssl/openssl .
git clone --no-checkout --filter=tree:0 --depth=1 --single-branch --branch=%openSSLTag% https://github.com/openssl/openssl .
git branch buildOpenSSl %openSSLTag%
git checkout buildOpenSSl
popd
5 changes: 4 additions & 1 deletion .ci/Scripts/getvars.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@echo off
if defined freeRdpDir (exit /b)

set openSSLTag=openssl-3.0.12

set freeRdpDir=%~dp0\..\..
Expand All @@ -14,4 +16,5 @@ for /f "usebackq delims=" %%i in (`%vswhere% -prerelease -latest -property insta
set vsDir=%%i
)

call "%vsdir%\Common7\Tools\vsdevcmd.bat"
call "%vsdir%\Common7\Tools\vsdevcmd.bat" -arch=amd64

4 changes: 2 additions & 2 deletions .ci/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps:
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'

- task: NuGetAuthenticate@0
- task: NuGetAuthenticate@1

- script: |
call .ci\Scripts\getVars
Expand Down Expand Up @@ -110,5 +110,5 @@ steps:
name: publishOpenSSL
inputs:
targetPath: '..\OpenSSL-VC-64'
artifactName: 'openSSL'
artifactName: 'OpenSSL-VC-64'
parallel: true
2 changes: 1 addition & 1 deletion UiPath.FreeRdpClient/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<AppVersion>23.12.0</AppVersion>
<AppVersion>24.2.0</AppVersion>
<Product>UiPath</Product>
<Company>UiPath</Company>
<Authors>UiPath</Authors>
Expand Down
18 changes: 5 additions & 13 deletions UiPath.FreeRdpClient/UiPath.FreeRdpClient.Tests/LoggingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ public class LoggingTests : TestsBase
private readonly ConcurrentDictionary<string, ConcurrentBag<(LogLevel logLevel, string message)>> _logsByCategory = new();
private readonly ConcurrentBag<object> _scopes = new();
private readonly Mock<ILogger> _loggerMock = new();
private Wts WtsApi => Host.GetWts();

private IFreeRdpClient FreeRdpClient => Host.GetRequiredService<IFreeRdpClient>();
private ILogger Log => Host.GetRequiredService<ILogger<RdpClientTests>>();

private async Task<IAsyncDisposable> Connect(RdpConnectionSettings connectionSettings)
{
using var logScope = Log.BeginScope($"{NativeLoggingForwarder.ScopeName}", connectionSettings.ClientName + "_fromTest");
return await FreeRdpClient.Connect(connectionSettings);
return await Host.Connect(connectionSettings);
}

public LoggingTests(ITestOutputHelper output) : base(output)
Expand Down Expand Up @@ -63,14 +58,13 @@ public async Task ShouldProduceLogsFromFreerdp()
var connectionSettings = user.ToRdpConnectionSettings();

await using var sut = await Connect(connectionSettings);
var sessionId = WtsApi.FindFirstSessionByClientName(connectionSettings.ClientName)
.ShouldNotBeNull();
await WaitFor.Predicate(() => WtsApi.QuerySessionInformation(sessionId).ConnectState()
var sessionId = await Host.FindSession(connectionSettings);
await WaitFor.Predicate(() => Host.GetWts().QuerySessionInformation(sessionId).ConnectState()
is Windows.Win32.System.RemoteDesktop.WTS_CONNECTSTATE_CLASS.WTSActive
or Windows.Win32.System.RemoteDesktop.WTS_CONNECTSTATE_CLASS.WTSConnected);

await sut.DisposeAsync();
await WaitFor.Predicate(() => WtsApi.FindFirstSessionByClientName(connectionSettings.ClientName) == null);
await Host.WaitNoSession(connectionSettings);

const string acceptedDebugCategory = "com.freerdp.core.nego";
var negoLogs = _logsByCategory.Where(kv => kv.Key.StartsWith(acceptedDebugCategory))
Expand All @@ -94,7 +88,7 @@ is Windows.Win32.System.RemoteDesktop.WTS_CONNECTSTATE_CLASS.WTSActive
nonDebugFreeRdpLogs.ShouldContain(l => l.message.Contains("forwardFreeRdpLogs:true"));

var scopes = _scopes.OfType<IReadOnlyList<KeyValuePair<string, object?>>>()
.Where(kvl => kvl.Any(kv => kv.Key == NativeLoggingForwarder.ScopeName && connectionSettings.ClientName.Equals(kv.Value)))
.Where(kvl => kvl.Any(kv => kv.Key == NativeLoggingForwarder.ScopeName && connectionSettings.ScopeName.Equals(kv.Value)))
.ToArray();
scopes.ShouldNotBeEmpty();
}
Expand Down Expand Up @@ -139,6 +133,4 @@ public async Task ErrorLogsShouldBeFilteredAndTranslatedToWarn()
testLogs.Where(l => l.logLevel is LogLevel.Error)
.ShouldBeEmpty();
}


}
Loading

0 comments on commit 99ee4ed

Please sign in to comment.