예제 #1
0
    def setUpClass(cls):
        cls.timeout = 30
        cls.wait_for_email = 60
        mail = utility.get_email_details()

        cls.refresh_interval = 5

        super(TestFileSize, cls).setUpClass()
        cls.config = BaseConfig()
        cls.pether3 = cls.config.pether3
        cls.host = cls.config.host
        utility.remove_ssh_keys(cls.host)

        cls.init_browser()
        access.login2(cls.browser)

        cls.chan, cls.client = utility.connect(cls.host, 22, const.LMS_USERNAME, const.LMS_PASSWORD)
        utility.execute(cls.chan, 'en')
        utility.execute(cls.chan, '_shell', '#')
예제 #2
0
        ve = {}def file_size_greater_than_overall_max_file_size(self):
        utility.email_analysis_delete_all(self.host)
        self.exec_conf_cmd(self.clear)
        change = ['analysis file max-size 2','analysis file max-size da 1']
        self.exec_conf_cmd(change)
        mail = utility.get_email_details()
        util.send_email(
            mail.subject, mail.body,
            mail.sender, mail.recipient,
            Enums.test_sample,
            host=self.host, mta_ip=self.pether3
        )
        #self.wait(5)
        self.execute_cmds_shell(self.copy_logs)

        # CLI Verification
        sub_id = utility.execute_sql(self.chan, self.get_sub_id)
        st = sub_id[0]['id']

        cli_status= ['show submission id ' + st]
        cmd_run = self.exec_conf_cmd(cli_status)
        verify = {}
        regex = ['Status\s+: file_too_large', 'md5sum\s+: 6a71416cd84147f7297b75b5a200580b']
        for r in regex:
            verify[r] = bool(re.search(r, cmd_run[-1]))

        utility.log_info('{}'.format(verify))
        self.assertTrue(all(verify.values()))

        # DB Verification
        status_code = utility.execute_sql(self.chan, self.get_status_code)
        st = status_code[0]['status_code']
        self.assertTrue(st=='14')
        print "status_code verified"

        error_code = utility.execute_sql(self.chan, self.get_error_code)
        #print "error_code", error_code
        st = error_code[0]['error_code']
        self.assertTrue(st=='46')
        print "error_code verified"

        # Log Verification
        log_test1 = [def file_size_greater_than_overall_max_file_size(self):
        utility.email_analysis_delete_all(self.host)
        self.exec_conf_cmd(self.clear)
        change = ['analysis file max-size 2','analysis file max-size da 1']
        self.exec_conf_cmd(change)
        mail = utility.get_email_details()
        util.send_email(
            mail.subject, mail.body,
            mail.sender, mail.recipient,
            Enums.test_sample,
            host=self.host, mta_ip=self.pether3
        )
        #self.wait(5)
        self.execute_cmds_shell(self.copy_logs)

        # CLI Verification
        sub_id = utility.execute_sql(self.chan, self.get_sub_id)
        st = sub_id[0]['id']

        cli_status= ['show submission id ' + st]
        cmd_run = self.exec_conf_cmd(cli_status)
        verify = {}
        regex = ['Status\s+: file_too_large', 'md5sum\s+: 6a71416cd84147f7297b75b5a200580b']
        for r in regex:
            verify[r] = bool(re.search(r, cmd_run[-1]))

        utility.log_info('{}'.format(verify))
        self.assertTrue(all(verify.values()))

        # DB Verification
        status_code = utility.execute_sql(self.chan, self.get_status_code)
        st = status_code[0]['status_code']
        self.assertTrue(st=='14')
        print "status_code verified"

        error_code = utility.execute_sql(self.chan, self.get_error_code)
        #print "error_code", error_code
        st = error_code[0]['error_code']
        self.assertTrue(st=='46')
        print "error_code verified"

        # Log Verification
        log_test1 = [
        'cat /var/home/root/test_logs/messages | '
        'grep -i "Email/Malware Done: total url: 0 total attach: 1 is_malicious: 0, error_code 46" >> /var/home/root/test_logs/temp1.txt',
        'cat /var/home/root/test_logs/temp1.txt']

        res = self.execute_cmds_shell(log_test1)
        ve = {}
        for v in res:
            ve[v] = v in res[-1]
        utility.log_info('{}'.format(ve))
        self.assertTrue(all(ve.values()))

        log_test2 = [
        'cat /var/home/root/test_logs/messages | '
        'grep -i "Analysis incomplete for one or more objects. Error: FILE_TOO_LARGE" >> /var/home/root/test_logs/temp2.txt',
        'cat /var/home/root/test_logs/temp2.txt']

        res = self.execute_cmds_shell(log_test2)
        ve = {}
        for v in res:
            ve[v] = v in res[-1]
        utility.log_info('{}'.format(ve))
        self.assertTrue(all(ve.values()))

        # UI Verification
        se.navigate(self.browser)
        se.wait_for_email(self.browser, mail.sender)
        se_data = se.get_table_data_search_emails(self.browser)
        self.assertIn('Scan Incomplete', str(se_data))
        'cat /var/home/root/test_logs/messages | '
        'grep -i "Email/Malware Done: total url: 0 total attach: 1 is_malicious: 0, error_code 46" >> /var/home/root/test_logs/temp1.txt',
        'cat /var/home/root/test_logs/temp1.txt']

        res = self.execute_cmds_shell(log_test1)
        ve = {}
        for v in res:
            ve[v] = v in res[-1]
        utility.log_info('{}'.format(ve))
        self.assertTrue(all(ve.values()))

        log_test2 = [
        'cat /var/home/root/test_logs/messages | '
        'grep -i "Analysis incomplete for one or more objects. Error: FILE_TOO_LARGE" >> /var/home/root/test_logs/temp2.txt',
        'cat /var/home/root/test_logs/temp2.txt']

        res = self.execute_cmds_shell(log_test2)
        ve = {}
        for v in res:
            ve[v] = v in res[-1]
        utility.log_info('{}'.format(ve))
        self.assertTrue(all(ve.values()))

        # UI Verification
        se.navigate(self.browser)
        se.wait_for_email(self.browser, mail.sender)
        se_data = se.get_table_data_search_emails(self.browser)
        self.assertIn('Scan Incomplete', str(se_data))
        for v in res:
            ve[v] = v in res[-1]
        utility.log_info('{}'.format(ve))
        self.assertTrue(all(ve.values()))

        # UI Verification
        se.navigate(self.browser)
        se.wait_for_email(self.browser, mail.sender)
        se_data = se.get_table_data_search_emails(self.browser)
        self.assertIn('Scan Incomplete', str(se_data))
        se.navigate(self.browser)
        se.wait_for_email(self.browser, mail.sender)
        se_data = se.get_table_data_search_emails(self.browser)
        self.assertIn('Scan Incomplete', str(se_data))

        error_code = utility.execute_sql(self.chan, self.get_error_code)
        #print "error_code", error_code
        st = error_code[0]['error_code']
        self.assertTrue(st=='46')
        print "error_code verified"

        # Log Verification
        log_test1 = [
        'cat /var/home/root/test_logs/messages | '
        'grep -i "Email/Malware Done: total url: 0 total attach: 1 is_malicious: 0, error_code 46" >> /var/home/root/test_logs/temp1.txt',
        'cat /var/home/root/test_logs/temp1.txt']

        res = self.execute_cmds_shell(log_test1)
        ve = {}
        for v in res:
            ve[v] = v in res[-1]
        utility.log_info('{}'.format(ve))
        self.assertTrue(all(ve.values()))

        log_test2 = [
        'cat /var/home/root/test_logs/messages | '
        'grep -i "Analysis incomplete for one or more objects. Error: FILE_TOO_LARGE" >> /var/home/root/test_logs/temp2.txt',
        'cat /var/home/root/test_logs/temp2.txt']

        res = self.execute_cmds_shell(log_test2)
        ve = {}
        for v in res:
            ve[v] = v in res[-1]
        utility.log_info('{}'.format(ve))
        self.assertTrue(all(ve.values()))

        # UI Verification
        se.navigate(self.browser)
        se.wait_for_email(self.browser, mail.sender)
        se_data = se.get_table_data_search_emails(self.browser)
        self.assertIn('Scan Incomplete', str(se_data))