Files
zeekay 241625e7d9 rename: ziti → zt across all paths
- Repo names: ziti-* → zt-*
- Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt
- Docker images: hanzozt/ziti-* → hanzozt/zt-*
- C/Java/JS symbols: ziti_* → zt_*
- File and directory names updated
2026-02-18 18:34:19 -08:00

48 lines
944 B
Go

package posture
import (
"github.com/hanzozt/zt/v2/common/pb/edge_ctrl_pb"
)
type MacCheck struct {
*edge_ctrl_pb.DataState_PostureCheck
*edge_ctrl_pb.DataState_PostureCheck_Mac
}
func (m MacCheck) Evaluate(state *InstanceData) *CheckError {
if state == nil {
return &CheckError{
Id: m.Id,
Name: m.Name,
Cause: NilStateError,
}
}
notInListErr := &OneInListError[Str]{}
macMap := map[string]struct{}{}
for _, macAddresses := range state.Macs.Addresses {
macMap[macAddresses] = struct{}{}
}
for _, macAddress := range m.MacAddresses {
if _, ok := macMap[macAddress]; ok {
return nil
}
}
for _, mac := range m.MacAddresses {
notInListErr.ValidValues = append(notInListErr.ValidValues, Str(mac))
}
for _, mac := range state.Macs.Addresses {
notInListErr.GivenValues = append(notInListErr.GivenValues, Str(mac))
}
return &CheckError{
Id: m.Id,
Name: m.Name,
Cause: notInListErr,
}
}