Skip to content

Commit

Permalink
fix(CI): add KasperskyScanEngine and fix some vulnerabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
ruakbp4 authored and ruakbp4 committed Apr 23, 2024
1 parent 69f940f commit b0084a0
Show file tree
Hide file tree
Showing 63 changed files with 2,162 additions and 75 deletions.
12 changes: 12 additions & 0 deletions ViennaNET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViennaNET.WebApi.Net", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViennaNET.WebApi.Net.Tests", "tests\ViennaNET.WebApi.Net.Tests\ViennaNET.WebApi.Net.Tests.csproj", "{B9BC0212-D0E7-43A7-8295-EE571EF0BF71}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViennaNET.KasperskyScanEngine.Client", "src\ViennaNET.KasperskyScanEngine.Client\ViennaNET.KasperskyScanEngine.Client.csproj", "{F812AC9D-BD96-4966-B6CC-837542872CA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViennaNET.KasperskyScanEngine.Client.Tests", "tests\ViennaNET.KasperskyScanEngine.Client.Tests\ViennaNET.KasperskyScanEngine.Client.Tests.csproj", "{4561F7BC-0085-4480-B72E-08FA73029CCD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -717,6 +721,14 @@ Global
{B9BC0212-D0E7-43A7-8295-EE571EF0BF71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9BC0212-D0E7-43A7-8295-EE571EF0BF71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9BC0212-D0E7-43A7-8295-EE571EF0BF71}.Release|Any CPU.Build.0 = Release|Any CPU
{F812AC9D-BD96-4966-B6CC-837542872CA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F812AC9D-BD96-4966-B6CC-837542872CA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F812AC9D-BD96-4966-B6CC-837542872CA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F812AC9D-BD96-4966-B6CC-837542872CA1}.Release|Any CPU.Build.0 = Release|Any CPU
{4561F7BC-0085-4480-B72E-08FA73029CCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4561F7BC-0085-4480-B72E-08FA73029CCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4561F7BC-0085-4480-B72E-08FA73029CCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4561F7BC-0085-4480-B72E-08FA73029CCD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions src/ViennaNET.ArcSight/ViennaNET.ArcSight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Polly" Version="8.2.0" />
<PackageReference Include="SyslogNet.Client" Version="0.3.3" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ViennaNET.Diagnostic/ViennaNET.Diagnostic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/ViennaNET.EventSourcing/ViennaNET.EventSourcing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ViennaNET.Excel/ViennaNET.Excel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="NPOI" Version="2.6.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using k8s;
using Microsoft.Extensions.Configuration;

namespace ViennaNET.Extensions.Configuration.Kubernetes;
Expand Down Expand Up @@ -47,7 +48,7 @@ public static class KubernetesConfigurationExtensions
/// <returns>Ссылка на объект <see cref="IConfigurationBuilder" />.</returns>
public static IConfigurationBuilder AddJsonConfigMap(this IConfigurationBuilder builder,
string name,
string @namespace,
string? @namespace = null,
string? fileName = null,
bool reloadOnChange = true,
Action<IKubernetesClientBuilder>? configureClientBuilder = null)
Expand Down Expand Up @@ -90,7 +91,7 @@ public static IConfigurationBuilder AddJsonConfigMap(this IConfigurationBuilder
/// <returns>Ссылка на объект <see cref="IConfigurationBuilder" />.</returns>
public static IConfigurationBuilder AddKeyValueConfigMap(this IConfigurationBuilder builder,
string name,
string @namespace,
string? @namespace = null,
bool reloadOnChange = true,
Action<IKubernetesClientBuilder>? configureClientBuilder = null)
{
Expand Down Expand Up @@ -136,7 +137,7 @@ public static IConfigurationBuilder AddKeyValueConfigMap(this IConfigurationBuil
/// <returns>Ссылка на объект <see cref="IConfigurationBuilder" />.</returns>
public static IConfigurationBuilder AddJsonSecret(this IConfigurationBuilder builder,
string name,
string @namespace,
string? @namespace = null,
string? fileName = null,
bool reloadOnChange = true,
Action<IKubernetesClientBuilder>? configureClientBuilder = null)
Expand Down Expand Up @@ -180,7 +181,7 @@ public static IConfigurationBuilder AddJsonSecret(this IConfigurationBuilder bui
/// <param name="configureClientBuilder">Действие, настраивающее сборщик клиента K8S.</param>
/// <returns>Ссылка на объект <see cref="IConfigurationBuilder" />.</returns>
public static IConfigurationBuilder AddKeyValueSecret(this IConfigurationBuilder builder,
string name, string @namespace, bool reloadOnChange = true,
string name, string? @namespace = null, bool reloadOnChange = true,
Action<IKubernetesClientBuilder>? configureClientBuilder = null)
{
var metadata = (name, @namespace, Kinds.Secret);
Expand All @@ -206,7 +207,7 @@ public static IConfigurationBuilder AddKeyValueSecret(this IConfigurationBuilder
/// <returns>Ссылка на объект <see cref="IConfigurationBuilder" />.</returns>
public static IConfigurationBuilder AddKubernetes(
this IConfigurationBuilder builder,
(string name, string @namespace, Kinds kind) metadata,
(string name, string? @namespace, Kinds kind) metadata,
DataTypes dataTypes,
bool reloadOnChange = true,
string? fileName = null,
Expand All @@ -221,12 +222,22 @@ public static IConfigurationBuilder AddKubernetes(
source.Name = name;
}
if (!string.IsNullOrWhiteSpace(ns))
if (string.IsNullOrWhiteSpace(ns))
{
if (KubernetesClientConfiguration.IsInCluster())
{
var icc = KubernetesClientConfiguration.InClusterConfig();
if (!string.IsNullOrEmpty(icc.Namespace))
{
source.Namespace = icc.Namespace;
}
}
}
else
{
source.Namespace = ns;
}
source.Name = name;
source.FileName = fileName;
source.Kind = kind;
source.DataType = dataTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.4" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/ViennaNET.HttpClient/ViennaNET.HttpClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.4" />
<PackageReference Include="Polly" Version="8.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Net.Http.Headers;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using ViennaNET.Extensions.Http.DependencyInjection;

namespace ViennaNET.KasperskyScanEngine.Client.DependencyInjection;

/// <summary>
/// Предоставляет методы расширения для регистрации HTTP клиента.
/// </summary>
public static class HttpClientServiceCollectionExtensions
{
/// <summary>
/// Добавляет HTTP-клиент службы Kaspersky Scan Engine в колекцию служб.
/// </summary>
/// <param name="services">Ссылка на <see cref="IServiceCollection" />.</param>
/// <param name="configuration">Ссылка на <see cref="IConfiguration"/>.</param>
/// <param name="configure">
/// Делегат, осуществляющий настройку параметров клиента, если <see langword="null" />,
/// по умолчанию будет осущесвляться привязка к секции конфигурации
/// <see cref="KseClientOption"/>.<see cref="KseClientOption.SectionName" />.
/// </param>
/// <returns>Ссылка на <see cref="IHttpClientBuilder" />.</returns>
public static IHttpClientBuilder AddKasperskyScanEngineApi(
this IServiceCollection services,
IConfiguration configuration,
Action<KseClientOption>? configure = null)
{
var configAction = configure ?? (option => configuration.GetSection(KseClientOption.SectionName).Bind(option));

var builder = services
.Configure<JsonSerializerOptions>(IKasperskyScanEngineApi.JsonSerializerOptionsName, options =>
{
options.Converters.Add(new JsonValueConverterBooleanString());
options.WriteIndented = false;
options.AllowTrailingCommas = false;
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.TypeInfoResolver = KseClientSerializerContext.Default;
})
.AddHttpClient<IKasperskyScanEngineApi, KseApi, KseClientOption>(configAction)
.ConfigureHttpClient((provider, client) =>
{
var opt = provider.GetRequiredService<IOptionsMonitor<KseClientOption>>().CurrentValue;
if (opt.AuthorizationToken is { } token)
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
}
});

return builder;
}
}
Loading

0 comments on commit b0084a0

Please sign in to comment.