mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-12 00:19:47 +02:00
Allow set of single unix or windows path check
This commit is contained in:
@ -976,9 +976,6 @@ components:
|
|||||||
description: Path to the process executable file in a Windows operating system
|
description: Path to the process executable file in a Windows operating system
|
||||||
type: string
|
type: string
|
||||||
example: "C:\ProgramData\NetBird\netbird.exe"
|
example: "C:\ProgramData\NetBird\netbird.exe"
|
||||||
required:
|
|
||||||
- path
|
|
||||||
- windows_path
|
|
||||||
Location:
|
Location:
|
||||||
description: Describe geographical location information
|
description: Describe geographical location information
|
||||||
type: object
|
type: object
|
||||||
|
@ -916,10 +916,10 @@ type PostureCheckUpdate struct {
|
|||||||
// Process Describe the operational activity within peer's system.
|
// Process Describe the operational activity within peer's system.
|
||||||
type Process struct {
|
type Process struct {
|
||||||
// Path Path to the process executable file in a Unix-like operating system
|
// Path Path to the process executable file in a Unix-like operating system
|
||||||
Path string `json:"path"`
|
Path *string `json:"path,omitempty"`
|
||||||
|
|
||||||
// WindowsPath Path to the process executable file in a Windows operating system
|
// WindowsPath Path to the process executable file in a Windows operating system
|
||||||
WindowsPath string `json:"windows_path"`
|
WindowsPath *string `json:"windows_path,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessCheck Posture Check for binaries exist and are running in the peer’s system
|
// ProcessCheck Posture Check for binaries exist and are running in the peer’s system
|
||||||
|
@ -302,10 +302,7 @@ func validatePostureChecksUpdate(req api.PostureCheckUpdate) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, process := range processCheck.Processes {
|
for _, process := range processCheck.Processes {
|
||||||
if process.WindowsPath == "" {
|
if process.Path == nil && process.WindowsPath == nil {
|
||||||
return status.Errorf(status.InvalidArgument, "windows path for process check shouldn't be empty")
|
|
||||||
}
|
|
||||||
if process.Path == "" {
|
|
||||||
return status.Errorf(status.InvalidArgument, "path for process check shouldn't be empty")
|
return status.Errorf(status.InvalidArgument, "path for process check shouldn't be empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,7 +420,10 @@ func toPeerNetworkRangeCheck(check *api.PeerNetworkRangeCheck) (*posture.PeerNet
|
|||||||
func toProcessCheckResponse(check *posture.ProcessCheck) *api.ProcessCheck {
|
func toProcessCheckResponse(check *posture.ProcessCheck) *api.ProcessCheck {
|
||||||
processes := make([]api.Process, 0, len(check.Processes))
|
processes := make([]api.Process, 0, len(check.Processes))
|
||||||
for _, process := range check.Processes {
|
for _, process := range check.Processes {
|
||||||
processes = append(processes, (api.Process)(process))
|
processes = append(processes, api.Process{
|
||||||
|
Path: &process.Path,
|
||||||
|
WindowsPath: &process.WindowsPath,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &api.ProcessCheck{
|
return &api.ProcessCheck{
|
||||||
@ -434,10 +434,15 @@ func toProcessCheckResponse(check *posture.ProcessCheck) *api.ProcessCheck {
|
|||||||
func toProcessCheck(check *api.ProcessCheck) *posture.ProcessCheck {
|
func toProcessCheck(check *api.ProcessCheck) *posture.ProcessCheck {
|
||||||
processes := make([]posture.Process, 0, len(check.Processes))
|
processes := make([]posture.Process, 0, len(check.Processes))
|
||||||
for _, process := range check.Processes {
|
for _, process := range check.Processes {
|
||||||
processes = append(processes, posture.Process{
|
var p posture.Process
|
||||||
Path: process.Path,
|
if process.Path != nil {
|
||||||
WindowsPath: process.WindowsPath,
|
p.Path = *process.Path
|
||||||
})
|
}
|
||||||
|
if process.WindowsPath != nil {
|
||||||
|
p.WindowsPath = *process.WindowsPath
|
||||||
|
}
|
||||||
|
|
||||||
|
processes = append(processes, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &posture.ProcessCheck{
|
return &posture.ProcessCheck{
|
||||||
|
@ -462,8 +462,8 @@ func TestPostureCheckUpdate(t *testing.T) {
|
|||||||
ProcessCheck: &api.ProcessCheck{
|
ProcessCheck: &api.ProcessCheck{
|
||||||
Processes: []api.Process{
|
Processes: []api.Process{
|
||||||
{
|
{
|
||||||
Path: "/usr/local/bin/netbird",
|
Path: str("/usr/local/bin/netbird"),
|
||||||
WindowsPath: "C:\\ProgramData\\NetBird\\netbird.exe",
|
WindowsPath: str("C:\\ProgramData\\NetBird\\netbird.exe"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -880,6 +880,8 @@ func TestPostureCheckUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostureCheck_validatePostureChecksUpdate(t *testing.T) {
|
func TestPostureCheck_validatePostureChecksUpdate(t *testing.T) {
|
||||||
|
str := func(s string) *string { return &s }
|
||||||
|
|
||||||
// empty name
|
// empty name
|
||||||
err := validatePostureChecksUpdate(api.PostureCheckUpdate{})
|
err := validatePostureChecksUpdate(api.PostureCheckUpdate{})
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
@ -979,8 +981,8 @@ func TestPostureCheck_validatePostureChecksUpdate(t *testing.T) {
|
|||||||
processCheck := api.ProcessCheck{
|
processCheck := api.ProcessCheck{
|
||||||
Processes: []api.Process{
|
Processes: []api.Process{
|
||||||
{
|
{
|
||||||
Path: "/usr/local/bin/netbird",
|
Path: str("/usr/local/bin/netbird"),
|
||||||
WindowsPath: "C:\\ProgramData\\NetBird\\netbird.exe",
|
WindowsPath: str("C:\\ProgramData\\NetBird\\netbird.exe"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -998,7 +1000,7 @@ func TestPostureCheck_validatePostureChecksUpdate(t *testing.T) {
|
|||||||
processCheck = api.ProcessCheck{
|
processCheck = api.ProcessCheck{
|
||||||
Processes: []api.Process{
|
Processes: []api.Process{
|
||||||
{
|
{
|
||||||
Path: "/usr/local/bin/netbird",
|
Path: str("/usr/local/bin/netbird"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1009,7 +1011,7 @@ func TestPostureCheck_validatePostureChecksUpdate(t *testing.T) {
|
|||||||
processCheck = api.ProcessCheck{
|
processCheck = api.ProcessCheck{
|
||||||
Processes: []api.Process{
|
Processes: []api.Process{
|
||||||
{
|
{
|
||||||
WindowsPath: "C:\\ProgramData\\NetBird\\netbird.exe",
|
WindowsPath: str("C:\\ProgramData\\NetBird\\netbird.exe"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user