add environment meta from grpc to store (#1651)

This commit is contained in:
pascal-fischer 2024-03-01 16:15:56 +02:00 committed by GitHub
parent 63d7957140
commit a4b9e93217
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 579 additions and 462 deletions

View File

@ -363,10 +363,11 @@ func Test_SystemMetaDataFromClient(t *testing.T) {
WiretrusteeVersion: info.WiretrusteeVersion, WiretrusteeVersion: info.WiretrusteeVersion,
KernelVersion: info.KernelVersion, KernelVersion: info.KernelVersion,
NetworkAddresses: protoNetAddr, NetworkAddresses: protoNetAddr,
SysSerialNumber: info.SystemSerialNumber, SysSerialNumber: info.SystemSerialNumber,
SysProductName: info.SystemProductName, SysProductName: info.SystemProductName,
SysManufacturer: info.SystemManufacturer, SysManufacturer: info.SystemManufacturer,
Environment: &mgmtProto.Environment{Cloud: info.Environment.Cloud, Platform: info.Environment.Platform},
} }
assert.Equal(t, ValidKey, actualValidKey) assert.Equal(t, ValidKey, actualValidKey)
@ -407,7 +408,9 @@ func isEqual(a, b *mgmtProto.PeerSystemMeta) bool {
a.GetUiVersion() == b.GetUiVersion() && a.GetUiVersion() == b.GetUiVersion() &&
a.GetSysSerialNumber() == b.GetSysSerialNumber() && a.GetSysSerialNumber() == b.GetSysSerialNumber() &&
a.GetSysProductName() == b.GetSysProductName() && a.GetSysProductName() == b.GetSysProductName() &&
a.GetSysManufacturer() == b.GetSysManufacturer() a.GetSysManufacturer() == b.GetSysManufacturer() &&
a.GetEnvironment().Cloud == b.GetEnvironment().Cloud &&
a.GetEnvironment().Platform == b.GetEnvironment().Platform
} }
func Test_GetDeviceAuthorizationFlow(t *testing.T) { func Test_GetDeviceAuthorizationFlow(t *testing.T) {

View File

@ -474,5 +474,9 @@ func infoToMetaData(info *system.Info) *proto.PeerSystemMeta {
SysSerialNumber: info.SystemSerialNumber, SysSerialNumber: info.SystemSerialNumber,
SysManufacturer: info.SystemManufacturer, SysManufacturer: info.SystemManufacturer,
SysProductName: info.SystemProductName, SysProductName: info.SystemProductName,
Environment: &proto.Environment{
Cloud: info.Environment.Cloud,
Platform: info.Environment.Platform,
},
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -92,6 +92,14 @@ message PeerKeys {
bytes wgPubKey = 2; bytes wgPubKey = 2;
} }
// Environment is part of the PeerSystemMeta and describes the environment the agent is running in.
message Environment {
// cloud is the cloud provider the agent is running in if applicable.
string cloud = 1;
// platform is the platform the agent is running on if applicable.
string platform = 2;
}
// PeerSystemMeta is machine meta data like OS and version. // PeerSystemMeta is machine meta data like OS and version.
message PeerSystemMeta { message PeerSystemMeta {
string hostname = 1; string hostname = 1;
@ -108,6 +116,7 @@ message PeerSystemMeta {
string sysSerialNumber = 12; string sysSerialNumber = 12;
string sysProductName = 13; string sysProductName = 13;
string sysManufacturer = 14; string sysManufacturer = 14;
Environment environment = 15;
} }
message LoginResponse { message LoginResponse {

View File

@ -288,6 +288,10 @@ func extractPeerMeta(loginReq *proto.LoginRequest) nbpeer.PeerSystemMeta {
SystemSerialNumber: loginReq.GetMeta().GetSysSerialNumber(), SystemSerialNumber: loginReq.GetMeta().GetSysSerialNumber(),
SystemProductName: loginReq.GetMeta().GetSysProductName(), SystemProductName: loginReq.GetMeta().GetSysProductName(),
SystemManufacturer: loginReq.GetMeta().GetSysManufacturer(), SystemManufacturer: loginReq.GetMeta().GetSysManufacturer(),
Environment: nbpeer.Environment{
Cloud: loginReq.GetMeta().GetEnvironment().GetCloud(),
Platform: loginReq.GetMeta().GetEnvironment().GetPlatform(),
},
} }
} }

View File

@ -71,6 +71,12 @@ type NetworkAddress struct {
Mac string Mac string
} }
// Environment is a system environment information
type Environment struct {
Cloud string
Platform string
}
// PeerSystemMeta is a metadata of a Peer machine system // PeerSystemMeta is a metadata of a Peer machine system
type PeerSystemMeta struct { //nolint:revive type PeerSystemMeta struct { //nolint:revive
Hostname string Hostname string
@ -87,6 +93,7 @@ type PeerSystemMeta struct { //nolint:revive
SystemSerialNumber string SystemSerialNumber string
SystemProductName string SystemProductName string
SystemManufacturer string SystemManufacturer string
Environment Environment `gorm:"serializer:json"`
} }
func (p PeerSystemMeta) isEqual(other PeerSystemMeta) bool { func (p PeerSystemMeta) isEqual(other PeerSystemMeta) bool {
@ -119,7 +126,9 @@ func (p PeerSystemMeta) isEqual(other PeerSystemMeta) bool {
p.UIVersion == other.UIVersion && p.UIVersion == other.UIVersion &&
p.SystemSerialNumber == other.SystemSerialNumber && p.SystemSerialNumber == other.SystemSerialNumber &&
p.SystemProductName == other.SystemProductName && p.SystemProductName == other.SystemProductName &&
p.SystemManufacturer == other.SystemManufacturer p.SystemManufacturer == other.SystemManufacturer &&
p.Environment.Cloud == other.Environment.Cloud &&
p.Environment.Platform == other.Environment.Platform
} }
// AddedWithSSOLogin indicates whether this peer has been added with an SSO login by a user. // AddedWithSSOLogin indicates whether this peer has been added with an SSO login by a user.