def test_check_general_mailserver_relay_passwd(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_general_mailserver_relay_passwd(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_mailserver_relay_passwd(None),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_mailserver_relay_passwd("mydomain.com"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_mailserver_relay_passwd("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     del config
 def test_check_server_ip(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertEqual(config.check_server_ip("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_server_ip("value"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_server_ip(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_server_ip(None),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 3
0
 def test_save_ossim_setup_file(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH +
                                        "ossim_setup1.conf")
     tmpfile = "/tmp/tmpossimsetup.cfg.%s" % (int(time.time()))
     print config.get_error_list()
     self.assertEqual(config.save_ossim_setup_file(tmpfile),
                      AVConfigParserErrors.ALL_OK)
 def test_check_update_update_proxy_pass(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_update_update_proxy_pass(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy_pass(None),AVConfigParserErrors.ALL_OK)
     #7833 
     #self.assertNotEqual(config.check_update_update_proxy_pass("no"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy_pass("mydomain.com"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy_pass("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     del config
 def test_check_general_admin_ip(self):
     """admin ip has to be a valid IP v4 address.
     """
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertEqual(config.check_general_admin_ip("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_admin_ip("value"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_admin_ip(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_admin_ip(None),AVConfigParserErrors.ALL_OK)
     del config
 def test_make_backup(self):
     if os.path.isdir(BACKUP_FOLDER):
         config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
         config.make_backup()
         #check that there is almost on backup file
         backup_filter = "%s%s*"% (BACKUP_FOLDER,"ossim_setup1.conf")
         backup_files = glob.glob(backup_filter)
         nbackupfiles = len(backup_files)
         self.assertTrue(nbackupfiles>0)#Almost one file
         self.assertTrue(nbackupfiles<6)#no more than 5 files
     else:
         print "make backup tests couldn't be executed. %s not exists!" % BACKUP_FOLDER
Exemplo n.º 7
0
 def test_check_general_hostname(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     invalidhostname = "ab"*100
     self.assertNotEqual(config.check_general_hostname(invalidhostname),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_hostname("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_hostname("255.255.255.0"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_hostname(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_hostname("*****@*****.**"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_hostname("*****@*****.**"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_hostname(""),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_hostname("machinename-com"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 8
0
 def test_make_backup(self):
     if os.path.isdir(BACKUP_FOLDER):
         config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
         config.make_backup()
         #check that there is almost on backup file
         backup_filter = "%s%s*"% (BACKUP_FOLDER,"ossim_setup1.conf")
         backup_files = glob.glob(backup_filter)
         nbackupfiles = len(backup_files)
         self.assertTrue(nbackupfiles>0)#Almost one file
         self.assertTrue(nbackupfiles<6)#no more than 5 files
     else:
         print "make backup tests couldn't be executed. %s not exists!" % BACKUP_FOLDER
Exemplo n.º 9
0
 def test_check_update_update_proxy(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_update_update_proxy("value"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy("Invalid@Community"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy("disabled"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy("manual"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy("alienvault-proxy"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 10
0
 def test_check_general_email_notify(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_general_email_notify("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_email_notify("255.255.255.0"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_email_notify(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_email_notify("Ç"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_email_notify("*****@*****.**"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_email_notify("*****@*****.**"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_email_notify(""),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 11
0
 def test_check_firewall_active(self):
     invalidvalue = "AAAA" * 100
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     
     self.assertNotEqual(config.check_firewall_active(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_firewall_active(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_firewall_active(invalidvalue),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_firewall_active(0),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_firewall_active("TRUE"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_firewall_active("YeS"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_firewall_active("no"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_firewall_active("1"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_firewall_active("0"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 12
0
 def test_check_sensor_ids_rules_flow_control(self):
     invalidvalue = "AAAA" * 100
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     
     self.assertNotEqual(config.check_sensor_ids_rules_flow_control(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_ids_rules_flow_control(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_ids_rules_flow_control(invalidvalue),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_ids_rules_flow_control(0),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_ids_rules_flow_control("TRUE"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_sensor_ids_rules_flow_control("yes"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_sensor_ids_rules_flow_control("no"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_ids_rules_flow_control("1"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_ids_rules_flow_control("0"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 13
0
 def test_check_general_ntp_server(self):
     invaliduser = "******" * 100
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_general_ntp_server(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_ntp_server(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_ntp_server(invaliduser),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_ntp_server("invaliduser otro"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_ntp_server("1132"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_ntp_server("un-user"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_ntp_server("113.23.22.2"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 14
0
 def test_check_snmp_snmptrap(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_snmp_snmptrap("value"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_snmp_snmptrap(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_snmp_snmptrap(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_snmp_snmptrap("Invalid@Community"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_snmp_snmptrap("yes"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_snmp_snmptrap("no"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 15
0
def fetch_server_ip(raw_ip):
    if raw_ip == '0.0.0.0/0':
        # Fetch ip address of the server from ossim_setup.conf
        # when client uses DHCP
        config_parser = AVOssimSetupConfigHandler()
        server_ip = config_parser.get_general_admin_ip()
        if args.debug:
            print "Client uses DHCP: {}".format(raw_ip)
            print "Fetched ip from ossim_conf: {}".format(server_ip)
        return server_ip
    command = "ip route get {} | head -1 | tr -s ' '".format(raw_ip)
    server_ip = subprocess.check_output(
        command, shell=True, stderr=subprocess.STDOUT
        )
    if args.debug:
        print "command: ", command
        print "command output: ", server_ip.strip()
    return server_ip.strip().split()[-1]
Exemplo n.º 16
0
 def test_check_server_alienvault_ip_reputation(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_server_alienvault_ip_reputation(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_server_alienvault_ip_reputation(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_server_alienvault_ip_reputation("nnn"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_server_alienvault_ip_reputation("enabled"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_server_alienvault_ip_reputation("disabled"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 17
0
 def test_check_general_mailserver_relay(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_general_mailserver_relay(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_mailserver_relay(None),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_mailserver_relay("no"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_mailserver_relay("mydomain.com"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_mailserver_relay("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 18
0
    def test_check_sensor_interfaces(self):
        invalidvalue = "AAAA" * 100
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        
        self.assertNotEqual(config.check_sensor_interfaces(""),AVConfigParserErrors.ALL_OK)
        self.assertNotEqual(config.check_sensor_interfaces(None),AVConfigParserErrors.ALL_OK)
        self.assertNotEqual(config.check_sensor_interfaces(invalidvalue),AVConfigParserErrors.ALL_OK)
        self.assertNotEqual(config.check_sensor_interfaces(0),AVConfigParserErrors.ALL_OK)
        self.assertNotEqual(config.check_sensor_interfaces("TRUE"),AVConfigParserErrors.ALL_OK)

        invalid = "lo,wlank2"
        valid = "eth0"
        self.assertNotEqual(config.check_sensor_interfaces(invalid),AVConfigParserErrors.ALL_OK)
        self.assertEqual(config.check_sensor_interfaces(valid),AVConfigParserErrors.ALL_OK)
        del config
Exemplo n.º 19
0
 def test_check_general_domain(self):
     """admin domain has to be a valid domain
     """
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_general_domain("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_domain("255.255.255.0"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_domain(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_domain(None),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_domain("www.mydomain.com"),AVConfigParserErrors.ALL_OK)
     
     self.assertEqual(config.check_general_domain("value"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 20
0
 def test_check_general_admin_netmask(self):
     """admin netmask has to be a valid IP v4 address.
     """
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_general_admin_netmask("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_admin_netmask("value"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_admin_netmask(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_admin_netmask(None),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_admin_netmask("255.255.255.255"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_admin_netmask("255.255.255.0"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_admin_netmask("255.255.255.0"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 21
0
 def test_check_general_interface(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_general_interface("eth33443"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_interface("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_interface(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_interface(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_general_interface("lo"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_general_interface("eth0"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 22
0
 def test_check_update_update_proxy_port(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_update_update_proxy_port(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy_port(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy_port("no"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy_port("mydomain.com"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy_port("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy_port("1132"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 23
0
 def test_check_sensor_name(self):
     #check_sensor_name
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_sensor_name("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_sensor_name("value"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_name(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_name(None),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_sensor_name("value-a"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 24
0
 def test_check_update_update_proxy_dns(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_update_update_proxy_dns(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy_dns(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_update_update_proxy_dns("Invalid@Community"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy_dns("192.168.2.1"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy_dns("systemaname"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_update_update_proxy_dns("disabled"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 25
0
 def test_check_sensor_monitors(self):
     monitor_list = get_current_monitor_plugin_list_clean()
     monitor_list = ','.join(monitor_list)
     unknwon_list = "prads-monitor,pof,unknown"
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_sensor_monitors("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_monitors("value"),AVConfigParserErrors.ALL_OK)
     
     self.assertNotEqual(config.check_sensor_monitors(unknwon_list),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_sensor_monitors(""),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_sensor_monitors(monitor_list),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_monitors(None),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 26
0
 def test_framework_https_keyt(self):
     invalidvalue = "AAAA" * 100
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     
     self.assertNotEqual(config.check_framework_https_key(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_framework_https_key(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_framework_https_key(invalidvalue),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_framework_https_key(0),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_framework_https_key("TRUE"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_framework_https_key("YeS"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_framework_https_key("1"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_framework_https_key("0"),AVConfigParserErrors.ALL_OK)
     try:
         tmpfile ="/tmp/certificate.cert"
         f = open(tmpfile,"w")
         f.close()
         self.assertEqual(config.check_framework_https_key(tmpfile),AVConfigParserErrors.ALL_OK)
         os.remove(tmpfile)
     except:
         print "Can't check a valid certificate"
     del config
Exemplo n.º 27
0
 def test_check_database_user(self):
     invaliduser = "******" * 100
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     
     self.assertNotEqual(config.check_database_user(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_database_user(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_database_user(invaliduser),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_database_user("mydomain.com"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_database_user("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 28
0
 def test_check_sensor_mserver(self):
     
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertNotEqual(config.check_sensor_mserver("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_mserver("value"),AVConfigParserErrors.ALL_OK)
     
     self.assertNotEqual(config.check_sensor_mserver(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_mserver(None),AVConfigParserErrors.ALL_OK)
     #SERVER_IPPORT,SEND_EVENTS(True/False),ALLOW_FRMK_DATA(True/False),PRIORITY (0-5),FRMK_IP,FRMK_PORT; another one
     valid1= "192.168.1.2,4001,True,True,3,192.168.2.2,40003;192.168.1.3,40001,True,True,3,192.168.2.2,40003"
     invalid1= "192.168.1.2,AA,True,True,3,192.168.2.2,40003;192.168.1.3,40001,True,True,3,192.168.2.2,40003"
     self.assertEqual(config.check_sensor_mserver(valid1),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_mserver(invalid1),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 29
0
 def test_check_sensor_networks(self):
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertEqual(config.check_sensor_networks(""),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_sensor_networks(None),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_networks("nnn"),AVConfigParserErrors.ALL_OK)
     valid = "192.168.2.0/16,10.0.0.0/24"
     self.assertEqual(config.check_sensor_networks(valid),AVConfigParserErrors.ALL_OK)
     del config
    def test_get_update_update_proxy_user(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_update_update_proxy_user(),"disabled")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_update_update_proxy_user(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_update_update_proxy_user(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_update_update_proxy_user(),None)
        del config
    def test_get_sensor_interfaces_list(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_sensor_interfaces_list()[0],"eth0")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_sensor_interfaces_list(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_sensor_interfaces_list(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_sensor_interfaces_list(),None)
        del config
    def test_get_snmp_snmptrap(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_snmp_snmptrap(),"no")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_snmp_snmptrap(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_snmp_snmptrap(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_snmp_snmptrap(),None)
        del config
    def test_get_general_admin_netmask(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_general_admin_netmask(),"255.255.255.0")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_general_admin_netmask(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_general_admin_netmask(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_general_admin_netmask(),None)
        del config
    def test_get_server_alienvault_ip_reputation(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_server_alienvault_ip_reputation(),"enabled")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_server_alienvault_ip_reputation(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_server_alienvault_ip_reputation(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_server_alienvault_ip_reputation(),None)
        del config
    def test_get_server_server_ip(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_server_server_ip(),"127.0.0.1")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_server_server_ip(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_server_server_ip(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_server_server_ip(),None)
        del config
    def test_get_general_admin_ip(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_general_admin_ip(),"192.168.2.22")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_general_admin_ip(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_general_admin_ip(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_general_admin_ip(),None)
        del config
    def test_get_sensor_asec(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_sensor_asec(),"yes")
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_sensor_asec(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_sensor_asec(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_sensor_asec(),None)
        del config
    def test_get_sensor_tzone(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_sensor_tzone(),"Europe/Madrid")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_sensor_tzone(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_sensor_tzone(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_sensor_tzone(),None)
        del config
    def test_get_sensor_netflow_remote_collector_port(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_sensor_netflow_remote_collector_port(),"555")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_sensor_netflow_remote_collector_port(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_sensor_netflow_remote_collector_port(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_sensor_netflow_remote_collector_port(),None)
        del config
    def test_get_database_user(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_database_user(),"root")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_database_user(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_database_user(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_database_user(),None)
        del config
    def test_get_framework_framework_https_key(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_framework_framework_https_key(),"default")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_framework_framework_https_key(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_framework_framework_https_key(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_framework_framework_https_key(),None)
        del config
    def test_get_expert_profile(self):
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
        self.assertEqual(config.get_expert_profile(),"server")
        del config
        
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
        self.assertEqual(config.get_expert_profile(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
        self.assertEqual(config.get_expert_profile(),None)
        del config

        config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
        self.assertEqual(config.get_expert_profile(),None)
        del config
Exemplo n.º 43
0
 def test_check_sensor_ip(self):
     """sensor ip has to be a valid IP v4 address.
     """
     config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
     self.assertEqual(config.check_sensor_ip("192.168.2.2"),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_ip("value"),AVConfigParserErrors.ALL_OK)
     self.assertEqual(config.check_sensor_ip(""),AVConfigParserErrors.ALL_OK)
     self.assertNotEqual(config.check_sensor_ip(None),AVConfigParserErrors.ALL_OK)
     del config
Exemplo n.º 44
0
    def test_load_config(self):
        #1 - File doesn't exists!
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH +
                                           "ossim_setup12.conf")
        #load config it's a private function. We can't access to it directly
        self.assertEqual(config.get_general_admin_dns(), None)
        self.assertTrue(config.has_errors())
        error_list = config.get_error_list()
        self.assertTrue(error_list.has_key("FILE_ERRORS"))
        self.assertTrue(error_list["FILE_ERRORS"].has_key("file"))
        self.assertEqual(error_list["FILE_ERRORS"]["file"][0], 2000)
        del config
        #2 - Invalid File - Duplicated section
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH +
                                           "ossim_setup4.conf")
        #load config it's a private function. We can't access to it directly
        self.assertEqual(config.get_general_admin_dns(), None)
        self.assertTrue(config.has_errors())
        error_list = config.get_error_list()
        self.assertTrue(error_list.has_key("FILE_ERRORS"))
        self.assertTrue(error_list["FILE_ERRORS"].has_key("file"))
        self.assertEqual(error_list["FILE_ERRORS"]["file"][0], 2001)
        del config
        #3 - Invalid File -(invalid syntax)
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH +
                                           "ossim_setup3.conf")
        #load config it's a private function. We can't access to it directly
        self.assertEqual(config.get_general_admin_dns(), None)
        self.assertTrue(config.has_errors())
        error_list = config.get_error_list()
        self.assertTrue(error_list.has_key("FILE_ERRORS"))
        self.assertTrue(error_list["FILE_ERRORS"].has_key("file"))
        self.assertEqual(error_list["FILE_ERRORS"]["file"][0], 2001)
        del config

        #4 - Correct File
        config = AVOssimSetupConfigHandler(TEST_FILES_PATH +
                                           "ossim_setup1.conf")
        #load config it's a private function. We can't access to it directly
        #self.assertEqual(config.get_general_admin_dns(),"8.8.8.8")
        error_list = config.get_error_list()
        print error_list
        self.assertFalse(config.has_errors())
        self.assertEqual(len(error_list), 0)
        del config