def setUp(self): """Call before every test case.""" self.l2btools = Learn2BanTools() self.l2btools.load_train2ban_config() self.l2btools.retrieve_experiments() self.log_files = [[self.TEST_LOG_ID, self.TEST_LOG_FILENAME]] #we are testing trainin self.test_trainer = Train2Ban(self.l2btools.construct_svm_classifier()) self.test_trainer._training_set = TrainingSet( ) #clean the training set self.test_trainer.add_to_sample( self.l2btools.gather_all_features([self.TEST_LOG_FILENAME]))
def __init__(self, ban_classifier): """ Sets the classifier, initiate the fail2ban filter and other objects. Because ban_classifier is an object, self gets a reference to it and after training it is ready to use. INPUT: ban_classifier: an svm object to be trained. """ self._ban_classifier = ban_classifier self._training_set = TrainingSet() self._log_filters = [] self._malicious_ip_list = [] self._log_files = []