Skip to content

Commit

Permalink
Merge develop into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Rans4ckeR committed Jan 5, 2024
2 parents abf0a0c + e198dea commit ea49a1e
Show file tree
Hide file tree
Showing 146 changed files with 4,497 additions and 2,499 deletions.
1,514 changes: 1,217 additions & 297 deletions .editorconfig

Large diffs are not rendered by default.

24 changes: 9 additions & 15 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@main
with:
dotnet-version: '7.x.x'
dotnet-version: '8.x.x'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@main
with:
Expand All @@ -27,26 +27,20 @@ jobs:
uses: gittools/actions/gitversion/execute@main
- name: Publish
run: |
dotnet publish CipherPunk.UI/CipherPunk.UI.csproj --configuration Release --no-self-contained --framework net7.0-windows --runtime win-x86 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish CipherPunk.UI/CipherPunk.UI.csproj --configuration Release --no-self-contained --framework net7.0-windows --runtime win-x64 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish CipherPunk.UI/CipherPunk.UI.csproj --configuration Release --no-self-contained --framework net7.0-windows --runtime win-arm64 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish CipherPunk.UI/CipherPunk.UI.csproj --no-self-contained --framework net8.0-windows --runtime win-x86 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish CipherPunk.UI/CipherPunk.UI.csproj --no-self-contained --framework net8.0-windows --runtime win-x64 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
dotnet publish CipherPunk.UI/CipherPunk.UI.csproj --no-self-contained --framework net8.0-windows --runtime win-arm64 -p:PublishReadyToRun=true -p:PublishReadyToRunComposite=true -p:PublishSingleFile=true -p:DebugType=embedded -p:AssemblyVersion=$env:GitVersion_AssemblySemVer -p:FileVersion=$env:GitVersion_AssemblySemFileVer -p:InformationalVersion=$env:GitVersion_InformationalVersion
- name: Zip
run: |
7z a -r ${{ format('CipherPunk-v{0}-net7.0-windows-x86.zip', env.GitVersion_SemVer) }} ./CipherPunk.UI/bin/Release/net7.0-windows/win-x86/publish/*.*
7z a -r ${{ format('CipherPunk-v{0}-net7.0-windows-x64.zip', env.GitVersion_SemVer) }} ./CipherPunk.UI/bin/Release/net7.0-windows/win-x64/publish/*.*
7z a -r ${{ format('CipherPunk-v{0}-net7.0-windows-ARM64.zip', env.GitVersion_SemVer) }} ./CipherPunk.UI/bin/Release/net7.0-windows/win-arm64/publish/*.*
- name: Prerelease
if: ${{ env.GitVersion_PreReleaseTag != '' }}
run: gh release create ${{ format('v{0}', env.GitVersion_SemVer) }} (get-item *.zip) --generate-notes --target ${{ github.sha }} --prerelease
env:
GH_TOKEN: ${{ github.token }}
7z a -r "${{ format('CipherPunk-v{0}-net8.0-windows-x86.zip', env.GitVersion_SemVer) }}" "./CipherPunk.UI/bin/Release/net8.0-windows/win-x86/publish/*.*" "-x!*.xml"
7z a -r "${{ format('CipherPunk-v{0}-net8.0-windows-x64.zip', env.GitVersion_SemVer) }}" "./CipherPunk.UI/bin/Release/net8.0-windows/win-x64/publish/*.*" "-x!*.xml"
7z a -r "${{ format('CipherPunk-v{0}-net8.0-windows-ARM64.zip', env.GitVersion_SemVer) }}" "./CipherPunk.UI/bin/Release/net8.0-windows/win-arm64/publish/*.*" "-x!*.xml"
- name: Release
if: ${{ env.GitVersion_PreReleaseTag == '' }}
run: gh release create ${{ format('v{0}', env.GitVersion_SemVer) }} (get-item *.zip) --generate-notes --target ${{ github.sha }}
run: gh release create v${{ env.GitVersion_SemVer }} (get-item *.zip) --generate-notes --target ${{ github.sha }} ${{ env.PreReleaseTag != '' && '--prerelease' || '' }}
env:
GH_TOKEN: ${{ github.token }}
- name: Package
run: dotnet pack CipherPunk/CipherPunk.csproj --no-restore --configuration Release -p:PackageVersion=$env:GitVersion_NuGetVersionV2
run: dotnet pack CipherPunk/CipherPunk.csproj --no-restore -p:PackageVersion=$env:GitVersion_NuGetVersionV2
- name: NuGet Push
run: dotnet nuget push ${{ format('CipherPunk/bin/Release/CipherPunk.{0}.nupkg', env.GitVersion_NuGetVersionV2) }} --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: GitHub Push
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>CipherPunk.CipherSuiteInfoApi</AssemblyName>
<RootNamespace>CipherPunk.CipherSuiteInfoApi</RootNamespace>
<Title>CipherPunk.CipherSuiteInfoApi</Title>
<Product>CipherPunk.CipherSuiteInfoApi</Product>
<Copyright>Copyright 2022 (c) RS. All rights reserved.</Copyright>
<Copyright>Copyright 2022-2024 (c) RS. All rights reserved.</Copyright>
<Company>Rans4ckeR</Company>
<Configuration></Configuration>
<Trademark></Trademark>
Expand All @@ -16,18 +16,20 @@
<AnalysisLevel>preview-all</AnalysisLevel>
<LangVersion>preview</LangVersion>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.0.0.1</Version>
<FileVersion>0.0.0.1</FileVersion>
<InformationalVersion>0.0.0.1</InformationalVersion>
<Platforms>AnyCPU</Platforms>
<EnableSourceControlManagerQueries Condition="$(Configuration) == 'Debug'">true</EnableSourceControlManagerQueries> <!--https://github.com/dotnet/sdk/issues/36666-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup>
</Project>
27 changes: 8 additions & 19 deletions CipherPunk.CipherSuiteInfoApi/CipherSuiteInfoApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;

internal sealed class CipherSuiteInfoApiService : ICipherSuiteInfoApiService
internal sealed class CipherSuiteInfoApiService(IHttpClientFactory httpClientFactory)
: ICipherSuiteInfoApiService
{
private readonly IHttpClientFactory httpClientFactory;

public CipherSuiteInfoApiService(IHttpClientFactory httpClientFactory)
private static readonly JsonSerializerOptions JsonSerializerOptions = new()
{
this.httpClientFactory = httpClientFactory;
}
Converters = { new JsonStringEnumConverter() }
};

public async ValueTask<CipherSuite?> GetCipherSuiteAsync(string cipherSuiteName, CancellationToken cancellationToken = default)
{
Expand All @@ -22,7 +21,7 @@ public CipherSuiteInfoApiService(IHttpClientFactory httpClientFactory)
{
cipherSuiteResponseJson = await httpClientFactory.CreateClient(ICipherSuiteInfoApiService.HttpClientName).GetStringAsync(FormattableString.Invariant($"cs/{cipherSuiteName}"), cancellationToken);

Check warning on line 22 in CipherPunk.CipherSuiteInfoApi/CipherSuiteInfoApiService.cs

View workflow job for this annotation

GitHub Actions / build

Modify 'CipherSuiteInfoApiService.GetCipherSuiteAsync(string,

Check warning on line 22 in CipherPunk.CipherSuiteInfoApi/CipherSuiteInfoApiService.cs

View workflow job for this annotation

GitHub Actions / build

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
}
catch (HttpRequestException e) when (e.StatusCode == HttpStatusCode.NotFound)
catch (HttpRequestException e) when (e.StatusCode is HttpStatusCode.NotFound)
{
return null;
}
Expand All @@ -49,12 +48,7 @@ public CipherSuiteInfoApiService(IHttpClientFactory httpClientFactory)

stream.Position = 0L;

var options = new JsonSerializerOptions
{
Converters = { new JsonStringEnumConverter() }
};

return await JsonSerializer.DeserializeAsync<CipherSuite>(stream, options, cancellationToken);
return await JsonSerializer.DeserializeAsync<CipherSuite>(stream, JsonSerializerOptions, cancellationToken);
}

public async ValueTask<CipherSuite[]> GetAllCipherSuitesAsync(CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -91,11 +85,6 @@ public async ValueTask<CipherSuite[]> GetAllCipherSuitesAsync(CancellationToken

stream.Position = 0L;

var options = new JsonSerializerOptions
{
Converters = { new JsonStringEnumConverter() }
};

return (await JsonSerializer.DeserializeAsync<CipherSuite[]>(stream, options, cancellationToken))!;
return (await JsonSerializer.DeserializeAsync<CipherSuite[]>(stream, JsonSerializerOptions, cancellationToken))!;

Check warning on line 88 in CipherPunk.CipherSuiteInfoApi/CipherSuiteInfoApiService.cs

View workflow job for this annotation

GitHub Actions / build

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public interface ICipherSuiteInfoApiService
internal const string HttpClientName = nameof(ICipherSuiteInfoApiService);

/// <summary>
/// Retrieve online information for <see cref="cipherSuiteName"/> as a <see cref="CipherSuite"/> instance.
/// Retrieve online information for <paramref name="cipherSuiteName"/> as a <see cref="CipherSuite"/> instance.
/// </summary>
/// <param name="cipherSuiteName">The name of the cipher suite to retrieve the online information for.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to cancel the operation.</param>
Expand Down
9 changes: 9 additions & 0 deletions CipherPunk.UI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,14 @@
<DataTemplate DataType="{x:Type ui:LoggingViewModel}">
<ui:LoggingView/>
</DataTemplate>
<DataTemplate DataType="{x:Type ui:DefaultCipherSuitesViewModel}">
<ui:DefaultCipherSuitesView/>
</DataTemplate>
<DataTemplate DataType="{x:Type ui:DefaultEllipticCurvesViewModel}">
<ui:DefaultEllipticCurvesView/>
</DataTemplate>
<DataTemplate DataType="{x:Type ui:ElevationViewModel}">
<ui:ElevationView/>
</DataTemplate>
</Application.Resources>
</Application>
11 changes: 6 additions & 5 deletions CipherPunk.UI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Threading;
using CipherPunk.CipherSuiteInfoApi;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using CipherPunk.CipherSuiteInfoApi;

internal sealed partial class App
{
Expand All @@ -25,7 +25,7 @@ public App()
{
IServiceCollection unused = services
.AddSingleton<ILogger, UserInterfaceLogService>()
.AddSingleton<IUacIconService, UacIconService>()
.AddSingleton<IUacService, UacService>()
.AddSingleton<MainWindow>()
.AddSingleton<MainWindowViewModel>()
.AddSingleton<OverviewViewModel>()
Expand All @@ -37,6 +37,9 @@ public App()
.AddSingleton<EllipticCurvesGroupPolicySettingsViewModel>()
.AddSingleton<RemoteServerTestViewModel>()
.AddSingleton<LoggingViewModel>()
.AddSingleton<DefaultCipherSuitesViewModel>()
.AddSingleton<DefaultEllipticCurvesViewModel>()
.AddSingleton<ElevationViewModel>()
.AddCipherPunk()
.AddCipherSuiteInfoApi();
}).Build();
Expand Down Expand Up @@ -78,11 +81,9 @@ private static void PreventWpfFlashBang(Window window)
}

private static void SetUiCulture()
{
FrameworkElement.LanguageProperty.OverrideMetadata(
=> FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
}

private void AppDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
Expand Down
23 changes: 14 additions & 9 deletions CipherPunk.UI/CipherPunk.UI.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<AssemblyName>CipherPunk.UI</AssemblyName>
<RootNamespace>CipherPunk.UI</RootNamespace>
<Title>CipherPunk.UI</Title>
<Product>CipherPunk.UI</Product>
<Copyright>Copyright 2022 (c) RS. All rights reserved.</Copyright>
<Copyright>Copyright 2022-2024 (c) RS. All rights reserved.</Copyright>
<Company>Rans4ckeR</Company>
<Configuration></Configuration>
<Trademark></Trademark>
Expand All @@ -17,32 +17,37 @@
<AnalysisLevel>preview-all</AnalysisLevel>
<LangVersion>preview</LangVersion>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<Version>0.0.0.1</Version>
<FileVersion>0.0.0.1</FileVersion>
<InformationalVersion>0.0.0.1</InformationalVersion>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<Platforms>x86;x64;ARM64</Platforms>
<ApplicationManifest>app.manifest</ApplicationManifest>
<EnableSourceControlManagerQueries Condition="$(Configuration) == 'Debug'">true</EnableSourceControlManagerQueries> <!--https://github.com/dotnet/sdk/issues/36666-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.138-beta">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Win32Docs" Version="0.1.8-alpha">
<PackageReference Include="Microsoft.Windows.SDK.Win32Docs" Version="0.1.42-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="38.0.19-preview">
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="56.0.13-preview">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PackageReference Include="Microsoft.Windows.WDK.Win32Metadata" Version="0.9.9-experimental">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
43 changes: 43 additions & 0 deletions CipherPunk.UI/Entities/MandatoryLevel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace CipherPunk.UI;

internal enum MandatoryLevel
{
/// <summary>
/// Anonymous logged on processes. Write access is mostly blocked.
/// </summary>
Untrusted,

/// <summary>
/// Used for AppContainers, browsers that access the internet and prevent most write access to objects on the system—specifically the registry and filesystem.
/// </summary>
Low,

/// <summary>
/// Default for most processes. For authenticated users.
/// </summary>
Medium,

/// <summary>
/// Default for most processes. For authenticated users. With UIAccess rights.
/// </summary>
MediumUiAccess,

MediumPlus,

/// <summary>
/// Administrator-level processes. (Elevated) process with UAC.
/// </summary>
High,

/// <summary>
/// Reserved for system services/processes.
/// </summary>
System,

/// <summary>
/// Not seen to be used by default. Windows Internals book says it can be set by a kernel-mode caller.
/// </summary>
ProtectedProcess,

SecureProcess
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace CipherPunk.UI;

using Windows.Win32;
using CipherPunk.CipherSuiteInfoApi;
using Windows.Win32;

internal readonly record struct UiWindowsApiCipherSuiteConfiguration(
ushort Priority,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace CipherPunk.UI;

using Windows.Win32;
using CipherPunk.CipherSuiteInfoApi;
using Windows.Win32;

internal readonly record struct UiWindowsDocumentationCipherSuiteConfiguration(
ushort Priority,
Expand Down
27 changes: 14 additions & 13 deletions CipherPunk.UI/Infrastructure/BaseViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace CipherPunk.UI;

using System.ComponentModel;
using System.Windows.Media.Imaging;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
Expand All @@ -10,19 +11,19 @@ internal abstract class BaseViewModel : ObservableRecipient
{
private bool defaultCommandActive;
private bool canExecuteDefaultCommand;
private BitmapSource? uacIcon;
private bool? elevated;

protected BaseViewModel(ILogger logger)
protected BaseViewModel(ILogger logger, IUacService uacService)
: base(StrongReferenceMessenger.Default)
{
UacService = uacService;
IsActive = true;
Logger = logger;
DefaultCommand = new AsyncRelayCommand<bool?>(ExecuteDefaultCommandAsync, _ => CanExecuteDefaultCommand);
PropertyChanged += BaseViewModelPropertyChanged;

StrongReferenceMessenger.Default.Register<PropertyChangedMessage<bool>>(this, (r, m) =>
{
((BaseViewModel)r).Receive(m);
});
StrongReferenceMessenger.Default.Register<PropertyChangedMessage<bool>>(this, (r, m) => ((BaseViewModel)r).Receive(m));
}

public IAsyncRelayCommand DefaultCommand { get; }
Expand All @@ -37,8 +38,14 @@ public bool DefaultCommandActive
}
}

public BitmapSource UacIcon => uacIcon ??= UacService.GetShieldIcon();

public bool Elevated => elevated ??= UacService.GetIntegrityLevel().Elevated;

protected ILogger Logger { get; }

protected IUacService UacService { get; }

protected bool CanExecuteDefaultCommand
{
get => canExecuteDefaultCommand;
Expand Down Expand Up @@ -67,15 +74,9 @@ protected virtual void BaseViewModelPropertyChanged(object? sender, PropertyChan
}
}

protected virtual bool GetCanExecuteDefaultCommand()
{
return !DefaultCommandActive;
}
protected virtual bool GetCanExecuteDefaultCommand() => !DefaultCommandActive;

protected void UpdateCanExecuteDefaultCommand()
{
CanExecuteDefaultCommand = GetCanExecuteDefaultCommand();
}
protected void UpdateCanExecuteDefaultCommand() => CanExecuteDefaultCommand = GetCanExecuteDefaultCommand();

private async Task ExecuteDefaultCommandAsync(bool? showView, CancellationToken cancellationToken)
{
Expand Down
Loading

0 comments on commit ea49a1e

Please sign in to comment.