Support network monitor details

This commit is contained in:
Peter 2022-02-02 14:29:11 +01:00
parent bcceb45986
commit eaf4e75b5c
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9
7 changed files with 25 additions and 8 deletions

View file

@ -6,6 +6,7 @@ import "google/protobuf/timestamp.proto";
import "audit/v1/http_details.proto"; import "audit/v1/http_details.proto";
import "audit/v1/dns_details.proto"; import "audit/v1/dns_details.proto";
import "audit/v1/dhcp_details.proto"; import "audit/v1/dhcp_details.proto";
import "audit/v1/netmon_details.proto";
enum TransportProtocol { enum TransportProtocol {
TRANSPORT_PROTOCOL_UNSPECIFIED = 0; TRANSPORT_PROTOCOL_UNSPECIFIED = 0;
@ -52,5 +53,6 @@ message EventEntity {
HTTPDetailsEntity http = 20; HTTPDetailsEntity http = 20;
DNSDetailsEntity dns = 21; DNSDetailsEntity dns = 21;
DHCPDetailsEntity dhcp = 22; DHCPDetailsEntity dhcp = 22;
NetMonDetailsEntity net_mon = 23;
} }
} }

View file

@ -0,0 +1,8 @@
syntax = "proto3";
package inetmock.audit.v1;
message NetMonDetailsEntity {
string reverse_resolved_host = 1;
}

View file

@ -51,3 +51,13 @@ public record DhcpDetails() : EventDetails
public DHCPOpCode OpCode { get; init; } = DHCPOpCode.Unspecified; public DHCPOpCode OpCode { get; init; } = DHCPOpCode.Unspecified;
public DHCPHwType HardwareType { get; init; } = DHCPHwType.Unspecified; public DHCPHwType HardwareType { get; init; } = DHCPHwType.Unspecified;
} }
public record NetMonDetails() : EventDetails
{
public NetMonDetails(NetMonDetailsEntity entity) : this()
{
ReverseResolvedHost = entity.ReverseResolvedHost;
}
public string ReverseResolvedHost { get; init; } = string.Empty;
}

View file

@ -57,6 +57,7 @@ public record Event : EventBase
EventEntity.ProtocolDetailsOneofCase.Http => new HttpDetails(entity.Http), EventEntity.ProtocolDetailsOneofCase.Http => new HttpDetails(entity.Http),
EventEntity.ProtocolDetailsOneofCase.Dns => new DnsDetails(entity.Dns), EventEntity.ProtocolDetailsOneofCase.Dns => new DnsDetails(entity.Dns),
EventEntity.ProtocolDetailsOneofCase.Dhcp => new DhcpDetails(entity.Dhcp), EventEntity.ProtocolDetailsOneofCase.Dhcp => new DhcpDetails(entity.Dhcp),
EventEntity.ProtocolDetailsOneofCase.NetMon => new NetMonDetails(entity.NetMon),
_ => null _ => null
}; };
} }
@ -80,6 +81,7 @@ public record Event<T> : EventBase where T : EventDetails, new()
EventEntity.ProtocolDetailsOneofCase.Http => new HttpDetails(entity.Http) as T, EventEntity.ProtocolDetailsOneofCase.Http => new HttpDetails(entity.Http) as T,
EventEntity.ProtocolDetailsOneofCase.Dns => new DnsDetails(entity.Dns) as T, EventEntity.ProtocolDetailsOneofCase.Dns => new DnsDetails(entity.Dns) as T,
EventEntity.ProtocolDetailsOneofCase.Dhcp => new DhcpDetails(entity.Dhcp) as T, EventEntity.ProtocolDetailsOneofCase.Dhcp => new DhcpDetails(entity.Dhcp) as T,
EventEntity.ProtocolDetailsOneofCase.NetMon => new NetMonDetails(entity.NetMon) as T,
_ => null _ => null
}; };
} }

View file

@ -18,13 +18,7 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Protobuf Include="proto/audit/v1/dhcp_details.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" /> <Protobuf Include="proto/audit/v1/*.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/audit/v1/dns_details.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" /> <Protobuf Include="proto/rpc/v1/*.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/audit/v1/event_entity.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/audit/v1/http_details.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/rpc/v1/audit.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/rpc/v1/endpoint.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/rpc/v1/pcap.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/rpc/v1/pprof.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -11,6 +11,7 @@ public class GenericReaderTest
[Theory] [Theory]
[InlineData("test.ima")] [InlineData("test.ima")]
[InlineData("test2.ima")] [InlineData("test2.ima")]
[InlineData("test3.ima")]
public async Task Test_ReadAllAsync_AuditFile(string testFile) public async Task Test_ReadAllAsync_AuditFile(string testFile)
{ {
await using var auditFileStream = File.OpenRead(Path.Join("testdata", testFile)); await using var auditFileStream = File.OpenRead(Path.Join("testdata", testFile));

Binary file not shown.