def RunXinetdCheck(self, chk_id, svc, disabled, sym, found, xinetd=False, should_detect=True): host_data = self.SetKnowledgeBase() cfgs = linux_service_parser_test.GenXinetd(svc, disabled) stats, files = linux_service_parser_test.GenTestData( cfgs, cfgs.values()) data = list(self.parser(stats, files, None)) # create entries on whether xinetd itself is setup to start or not if xinetd: cfgs = linux_service_parser_test.GenInit( "xinetd", "the extended Internet services daemon") stats, files = linux_service_parser_test.GenTestData( cfgs, cfgs.values()) lsb_parser = linux_service_parser.LinuxLSBInitParser() data.extend(list(lsb_parser.ParseMultiple(stats, files, None))) host_data["LinuxServices"] = self.SetArtifactData(parsed=data) results = self.RunChecks(host_data) if should_detect: self.assertCheckDetectedAnom(chk_id, results, sym, found) else: self.assertCheckUndetected(chk_id, results)
def RunXinetdCheck(self, chk_id, svc, disabled, exp, found): host_data = self.SetKnowledgeBase() cfgs = linux_service_parser_test.GenXinetd(svc, disabled) stats, files = linux_service_parser_test.GenTestData( cfgs, cfgs.values()) data = list(self.parser(stats, files, None)) host_data["LinuxServices"] = self.SetArtifactData(parsed=data) results = self.RunChecks(host_data) self.assertCheckDetectedAnom(chk_id, results, exp, found)
def RunSysVChecks(self): host_data = self.SetKnowledgeBase() links = ["/etc/rc2.d/S50xinetd", "/etc/rc2.d/S60wu-ftpd", "/etc/rc2.d/S10ufw"] stats, files = linux_service_parser_test.GenTestData( links, [""] * len(links), st_mode=41471) parsed = list(self.parser(stats, files, None)) host_data["LinuxServices"] = self.SetArtifactData(parsed=parsed) self.results = self.RunChecks(host_data)