mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-10-10 20:26:16 +00:00
finished refactoring and README.md rewrite
This commit is contained in:
17
MalwareMultiScan.Scanner/Dockerfile
Normal file
17
MalwareMultiScan.Scanner/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS builder
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY MalwareMultiScan.Scanner /src/MalwareMultiScan.Scanner
|
||||
COPY MalwareMultiScan.Backends /src/MalwareMultiScan.Backends
|
||||
COPY MalwareMultiScan.Shared /src/MalwareMultiScan.Shared
|
||||
|
||||
RUN dotnet publish -c Release -r linux-x64 -o ./publish MalwareMultiScan.Scanner/MalwareMultiScan.Scanner.csproj
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/runtime:3.1
|
||||
|
||||
WORKDIR /worker
|
||||
|
||||
COPY --from=builder /src/publish /worker
|
||||
|
||||
ENTRYPOINT ["/worker/MalwareMultiScan.Scanner"]
|
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
using MalwareMultiScan.Backends.Extensions;
|
||||
using MalwareMultiScan.Backends.Services.Implementations;
|
||||
@@ -12,6 +13,7 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MalwareMultiScan.Scanner
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
internal static class Program
|
||||
{
|
||||
public static async Task Main(string[] args)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"MalwareMultiScan.ScannerWorker": {
|
||||
"MalwareMultiScan.Scanner": {
|
||||
"commandName": "Project"
|
||||
}
|
||||
}
|
||||
|
@@ -5,11 +5,13 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Consul;
|
||||
using MalwareMultiScan.Backends.Backends.Interfaces;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace MalwareMultiScan.Scanner.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Consul registration hosted service.
|
||||
/// </summary>
|
||||
public class ConsulHostedService : BackgroundService
|
||||
{
|
||||
private static readonly string ServiceId = Dns.GetHostName();
|
||||
@@ -18,9 +20,13 @@ namespace MalwareMultiScan.Scanner.Services
|
||||
private readonly IConsulClient _consulClient;
|
||||
private readonly AgentServiceRegistration _registration;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize consul hosted service.
|
||||
/// </summary>
|
||||
/// <param name="consulClient">Consul client.</param>
|
||||
/// <param name="scanBackend">Scan backend.</param>
|
||||
public ConsulHostedService(
|
||||
IConsulClient consulClient,
|
||||
IConfiguration configuration,
|
||||
IScanBackend scanBackend)
|
||||
{
|
||||
_consulClient = consulClient;
|
||||
@@ -28,7 +34,7 @@ namespace MalwareMultiScan.Scanner.Services
|
||||
_registration = new AgentServiceRegistration
|
||||
{
|
||||
ID = ServiceId,
|
||||
Name = configuration.GetValue<string>("CONSUL_SERVICE_NAME"),
|
||||
Name = "scanner",
|
||||
|
||||
Meta = new Dictionary<string, string>
|
||||
{
|
||||
|
@@ -18,8 +18,8 @@ namespace MalwareMultiScan.Scanner.Services
|
||||
{
|
||||
private readonly IScanBackend _backend;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IBackgroundJobClient _jobClient;
|
||||
private readonly ILogger<ScanBackgroundJob> _logger;
|
||||
private readonly IBackgroundJobClient _jobClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize scan background job.
|
||||
@@ -27,7 +27,7 @@ namespace MalwareMultiScan.Scanner.Services
|
||||
/// <param name="configuration">Configuration.</param>
|
||||
/// <param name="logger">Logger.</param>
|
||||
/// <param name="backend">Scan backend.</param>
|
||||
/// <param name="jobClient"></param>
|
||||
/// <param name="jobClient">Background job client.</param>
|
||||
public ScanBackgroundJob(
|
||||
IScanBackend backend,
|
||||
IConfiguration configuration,
|
||||
@@ -90,7 +90,8 @@ namespace MalwareMultiScan.Scanner.Services
|
||||
$"Sending scan results with status {result.Status}");
|
||||
|
||||
_jobClient.Create<IScanResultJob>(
|
||||
x => x.Report(message.Id, _backend.Id, result), new EnqueuedState());
|
||||
x => x.Report(message.Id, _backend.Id, result),
|
||||
new EnqueuedState("default"));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@@ -2,7 +2,6 @@
|
||||
"REDIS_ADDRESS": "localhost:6379",
|
||||
|
||||
"CONSUL_ADDRESS": "http://localhost:8500",
|
||||
"CONSUL_SERVICE_NAME": "scanner",
|
||||
|
||||
"BACKEND_ID": "dummy",
|
||||
"MAX_SCANNING_TIME": 60,
|
||||
|
Reference in New Issue
Block a user