diff --git a/management/server/posture/process.go b/management/server/posture/process.go index 234bca82a..b8a2be406 100644 --- a/management/server/posture/process.go +++ b/management/server/posture/process.go @@ -27,14 +27,14 @@ func (p *ProcessCheck) Check(peer nbpeer.Peer) (bool, error) { switch peer.Meta.GoOS { case "darwin", "linux": for _, process := range p.Processes { - if !slices.Contains(peerActiveProcesses, process.Path) { + if process.Path == "" || !slices.Contains(peerActiveProcesses, process.Path) { return false, nil } } return true, nil case "windows": for _, process := range p.Processes { - if !slices.Contains(peerActiveProcesses, process.WindowsPath) { + if process.WindowsPath == "" || !slices.Contains(peerActiveProcesses, process.WindowsPath) { return false, nil } } diff --git a/management/server/posture/process_test.go b/management/server/posture/process_test.go index 271dde6f9..92b32cddc 100644 --- a/management/server/posture/process_test.go +++ b/management/server/posture/process_test.go @@ -35,6 +35,26 @@ func TestProcessCheck_Check(t *testing.T) { wantErr: false, isValid: true, }, + { + name: "darwin with windows process paths", + input: peer.Peer{ + Meta: peer.PeerSystemMeta{ + GoOS: "darwin", + Processes: []peer.Process{ + {Path: "process1"}, + {Path: "process2"}, + }, + }, + }, + check: ProcessCheck{ + Processes: []Process{ + {WindowsPath: "process1"}, + {WindowsPath: "process2"}, + }, + }, + wantErr: false, + isValid: false, + }, { name: "linux with matching processes", input: peer.Peer{ @@ -55,6 +75,26 @@ func TestProcessCheck_Check(t *testing.T) { wantErr: false, isValid: true, }, + { + name: "linux with windows process paths", + input: peer.Peer{ + Meta: peer.PeerSystemMeta{ + GoOS: "linux", + Processes: []peer.Process{ + {Path: "process1"}, + {Path: "process2"}, + }, + }, + }, + check: ProcessCheck{ + Processes: []Process{ + {WindowsPath: "process1"}, + {WindowsPath: "process2"}, + }, + }, + wantErr: false, + isValid: false, + }, { name: "linux with non-matching processes", input: peer.Peer{ @@ -95,6 +135,26 @@ func TestProcessCheck_Check(t *testing.T) { wantErr: false, isValid: true, }, + { + name: "windows with darwin process paths", + input: peer.Peer{ + Meta: peer.PeerSystemMeta{ + GoOS: "windows", + Processes: []peer.Process{ + {Path: "process1"}, + {Path: "process2"}, + }, + }, + }, + check: ProcessCheck{ + Processes: []Process{ + {Path: "process1"}, + {Path: "process2"}, + }, + }, + wantErr: false, + isValid: false, + }, { name: "windows with non-matching processes", input: peer.Peer{