Пример #1
0
func (f *File) Validate(sys *system.System) []TestResult {
	skip := false
	sysFile := sys.NewFile(f.Path, sys, util.Config{})

	var results []TestResult
	results = append(results, ValidateValue(f, "exists", f.Exists, sysFile.Exists, skip))
	if shouldSkip(results) {
		skip = true
	}
	if f.Mode != nil {
		results = append(results, ValidateValue(f, "mode", f.Mode, sysFile.Mode, skip))
	}
	if f.Owner != nil {
		results = append(results, ValidateValue(f, "owner", f.Owner, sysFile.Owner, skip))
	}
	if f.Group != nil {
		results = append(results, ValidateValue(f, "group", f.Group, sysFile.Group, skip))
	}
	if f.LinkedTo != nil {
		results = append(results, ValidateValue(f, "linkedto", f.LinkedTo, sysFile.LinkedTo, skip))
	}
	if f.Filetype != nil {
		results = append(results, ValidateValue(f, "filetype", f.Filetype, sysFile.Filetype, skip))
	}
	if len(f.Contains) > 0 {
		results = append(results, ValidateContains(f, "contains", f.Contains, sysFile.Contains, skip))
	}
	if f.Size != nil {
		results = append(results, ValidateValue(f, "size", f.Size, sysFile.Size, skip))
	}
	return results
}
Пример #2
0
func (f *File) Validate(sys *system.System) []TestResult {
	sysFile := sys.NewFile(f.Path, sys)

	var results []TestResult

	results = append(results, ValidateValue(f, "exists", f.Exists, sysFile.Exists))

	if f.Mode != "" {
		results = append(results, ValidateValue(f, "mode", f.Mode, sysFile.Mode))
	}

	if f.Owner != "" {
		results = append(results, ValidateValue(f, "owner", f.Owner, sysFile.Owner))
	}

	if f.Group != "" {
		results = append(results, ValidateValue(f, "group", f.Group, sysFile.Group))
	}

	if f.LinkedTo != "" {
		results = append(results, ValidateValue(f, "linkedto", f.LinkedTo, sysFile.LinkedTo))
	}

	if f.Filetype != "" {
		results = append(results, ValidateValue(f, "filetype", f.Filetype, sysFile.Filetype))
	}

	if len(f.Contains) != 0 {
		results = append(results, ValidateContains(f, "contains", f.Contains, sysFile.Contains))
	}

	return results
}
Пример #3
0
func (p *Process) Validate(sys *system.System) []TestResult {
	skip := false
	sysProcess := sys.NewProcess(p.Executable, sys, util.Config{})

	var results []TestResult
	results = append(results, ValidateValue(p, "running", p.Running, sysProcess.Running, skip))
	return results
}
Пример #4
0
func (a *KernelParam) Validate(sys *system.System) []TestResult {
	skip := false
	sysKernelParam := sys.NewKernelParam(a.Key, sys, util.Config{})

	var results []TestResult
	results = append(results, ValidateValue(a, "value", a.Value, sysKernelParam.Value, skip))
	return results
}
Пример #5
0
func (r PortMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Port, system.Port, bool) {
	sysres := sys.NewPort(sr, sys)
	res := NewPort(sysres, []string{})
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #6
0
func (r ResourceTypeMap) AppendSysResourceIfExists(sr string, sys *system.System) (*ResourceType, system.ResourceType, bool) {
	sysres := sys.NewResourceType(sr, sys)
	res := NewResourceType(sysres, []string{})
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #7
0
func (s *Service) Validate(sys *system.System) []TestResult {
	skip := false
	sysservice := sys.NewService(s.Service, sys, util.Config{})

	var results []TestResult
	results = append(results, ValidateValue(s, "enabled", s.Enabled, sysservice.Enabled, skip))
	results = append(results, ValidateValue(s, "running", s.Running, sysservice.Running, skip))
	return results
}
Пример #8
0
func (r GossfileMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Gossfile, error) {
	sysres := sys.NewGossfile(sr, sys, config)
	res, err := NewGossfile(sysres, config)
	if err != nil {
		return nil, err
	}
	r[res.ID()] = res
	return res, nil
}
Пример #9
0
func (r CommandMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Command, error) {
	sysres := sys.NewCommand(sr, sys, config)
	res, err := NewCommand(sysres, config)
	if err != nil {
		return nil, err
	}
	r[res.ID()] = res
	return res, nil
}
Пример #10
0
func (p *Process) Validate(sys *system.System) []TestResult {
	sysProcess := sys.NewProcess(p.Executable, sys)

	var results []TestResult

	results = append(results, ValidateValue(p, "running", p.Running, sysProcess.Running))

	return results
}
Пример #11
0
func (r DNSMap) AppendSysResourceIfExists(sr string, sys *system.System) (*DNS, system.DNS, bool) {
	sysres := sys.NewDNS(sr, sys)
	res := NewDNS(sysres)
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #12
0
func (r CommandMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Command, system.Command, bool) {
	sysres := sys.NewCommand(sr, sys)
	res := NewCommand(sysres)
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #13
0
func (r ServiceMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Service, system.Service, bool) {
	sysres := sys.NewService(sr, sys)
	res := NewService(sysres)
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #14
0
func (r ProcessMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Process, system.Process, bool) {
	sysres := sys.NewProcess(sr, sys)
	res := NewProcess(sysres)
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #15
0
func (r GroupMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Group, system.Group, bool) {
	sysres := sys.NewGroup(sr, sys)
	res := NewGroup(sysres)
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #16
0
func (s *Service) Validate(sys *system.System) []TestResult {
	sysservice := sys.NewService(s.Service, sys)

	var results []TestResult

	results = append(results, ValidateValue(s.Service, "enabled", s.Enabled, sysservice.Enabled))
	results = append(results, ValidateValue(s.Service, "running", s.Running, sysservice.Running))

	return results
}
Пример #17
0
func (h *Addr) Validate(sys *system.System) []TestResult {
	sysAddr := sys.NewAddr(h.Address, sys)
	sysAddr.Timeout = h.Timeout

	var results []TestResult

	results = append(results, ValidateValue(h.Address, "reachable", h.Reachable, sysAddr.Reachable))

	return results
}
Пример #18
0
func (r CommandMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Command, system.Command, bool) {
	sysres := sys.NewCommand(sr, sys, util.Config{})
	// FIXME: Do we want to be silent about errors?
	res, _ := NewCommand(sysres, util.Config{})
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #19
0
func (a *Addr) Validate(sys *system.System) []TestResult {
	skip := false
	if a.Timeout == 0 {
		a.Timeout = 500
	}
	sysAddr := sys.NewAddr(a.Address, sys, util.Config{Timeout: a.Timeout})

	var results []TestResult
	results = append(results, ValidateValue(a, "reachable", a.Reachable, sysAddr.Reachable, skip))
	return results
}
Пример #20
0
func (p *Package) Validate(sys *system.System) []TestResult {
	sysPkg := sys.NewPackage(p.Name, sys, util.Config{})

	var results []TestResult

	results = append(results, ValidateValue(p, "installed", p.Installed, sysPkg.Installed))

	if len(p.Versions) > 0 {
		results = append(results, ValidateValues(p, "version", p.Versions, sysPkg.Versions))
	}

	return results
}
Пример #21
0
func (g *Group) Validate(sys *system.System) []TestResult {
	sysgroup := sys.NewGroup(g.Groupname, sys)

	var results []TestResult

	results = append(results, ValidateValue(g, "exists", g.Exists, sysgroup.Exists))

	if g.Gid != "" {
		results = append(results, ValidateValue(g, "gid", g.Gid, sysgroup.Gid))
	}

	return results
}
Пример #22
0
func (p *Port) Validate(sys *system.System) []TestResult {
	sysPort := sys.NewPort(p.Port, sys, util.Config{})

	var results []TestResult

	results = append(results, ValidateValue(p, "listening", p.Listening, sysPort.Listening))

	if len(p.IP) > 0 {
		results = append(results, ValidateValues(p, "ip", p.IP, sysPort.IP))
	}

	return results
}
Пример #23
0
func (p *Port) Validate(sys *system.System) []TestResult {
	sysPort := sys.NewPort(p.Port, sys)

	var results []TestResult

	results = append(results, ValidateValue(p.Port, "listening", p.Listening, sysPort.Listening))
	if !p.Listening {
		return results
	}
	results = append(results, ValidateValue(p.Port, "ip", p.IP, sysPort.IP))

	return results
}
Пример #24
0
func (s *Group) Validate(sys *system.System) []TestResult {
	sysgroup := sys.NewGroup(s.Groupname, sys)

	var results []TestResult

	results = append(results, ValidateValue(s.Groupname, "exists", s.Exists, sysgroup.Exists))
	if !s.Exists {
		return results
	}
	results = append(results, ValidateValue(s.Gid, "gid", s.Gid, sysgroup.Gid))

	return results
}
Пример #25
0
func (r ProcessMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Process, error) {
	sysres := sys.NewProcess(sr, sys, config)
	res, err := NewProcess(sysres, config)
	if err != nil {
		return nil, err
	}
	if old_res, ok := r[res.ID()]; ok {
		res.Title = old_res.Title
		res.Meta = old_res.Meta
	}
	r[res.ID()] = res
	return res, nil
}
Пример #26
0
func (p *Package) Validate(sys *system.System) []TestResult {
	sysPkg := sys.NewPackage(p.Name, sys)

	var results []TestResult

	results = append(results, ValidateValue(p.Name, "installed", p.Installed, sysPkg.Installed))
	if !p.Installed {
		return results
	}
	results = append(results, ValidateValues(p.Name, "version", p.Versions, sysPkg.Versions))

	return results
}
Пример #27
0
func (r ProcessMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Process, system.Process, bool) {
	sysres := sys.NewProcess(sr, sys, util.Config{})
	// FIXME: Do we want to be silent about errors?
	res, _ := NewProcess(sysres, util.Config{})
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	if old_res, ok := r[res.ID()]; ok {
		res.Title = old_res.Title
		res.Meta = old_res.Meta
	}
	r[res.ID()] = res
	return res, sysres, true
}
Пример #28
0
func (d *DNS) Validate(sys *system.System) []TestResult {
	sysDNS := sys.NewDNS(d.Host, sys)
	sysDNS.Timeout = d.Timeout

	var results []TestResult

	results = append(results, ValidateValue(d.Host, "resolveable", d.Resolveable, sysDNS.Resolveable))
	if !d.Resolveable {
		return results
	}
	results = append(results, ValidateValues(d.Host, "addrs", d.Addrs, sysDNS.Addrs))

	return results
}
Пример #29
0
func (p *Package) Validate(sys *system.System) []TestResult {
	skip := false
	sysPkg := sys.NewPackage(p.Name, sys, util.Config{})

	var results []TestResult
	results = append(results, ValidateValue(p, "installed", p.Installed, sysPkg.Installed, skip))
	if shouldSkip(results) {
		skip = true
	}
	if p.Versions != nil {
		results = append(results, ValidateValue(p, "version", p.Versions, sysPkg.Versions, skip))
	}
	return results
}
Пример #30
0
func (p *Port) Validate(sys *system.System) []TestResult {
	skip := false
	sysPort := sys.NewPort(p.Port, sys, util.Config{})

	var results []TestResult
	results = append(results, ValidateValue(p, "listening", p.Listening, sysPort.Listening, skip))
	if shouldSkip(results) {
		skip = true
	}
	if p.IP != nil {
		results = append(results, ValidateValue(p, "ip", p.IP, sysPort.IP, skip))
	}
	return results
}