本文整理匯總了Python中kitty.data.report.Report類的典型用法代碼示例。如果您正苦於以下問題:Python Report類的具體用法?Python Report怎麽用?Python Report使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Report類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testDataEntry
def testDataEntry(self):
report = Report(self.report_name)
entry_name = 'my entry'
entry_data = 'some data'
report.add(entry_name, entry_data)
self.assertEqual(report.get(entry_name), entry_data)
self.assertEqual(report.get(entry_name), entry_data)
示例2: BaseController
class BaseController(KittyObject):
'''
Base class for controllers. Defines basic variables and implements basic behavior.
'''
def __init__(self, name, logger=None):
'''
:param name: name of the object
:param logger: logger for the object (default: None)
'''
super(BaseController, self).__init__(name, logger)
self.report = None
self.test_number = 0
def setup(self):
'''
Called at the beginning of the fuzzing session.
You should override it with the actual implementation of victim setup.
'''
pass
def teardown(self):
'''
Called at the end of the fuzzing session.
You should override it with the actual implementation of victim teardown.
'''
pass
def pre_test(self, test_number):
'''
Called before a test is started. Call super if overriden.
:param test_number: current test number
'''
self.report = Report(self.name)
self.report.add('start_time', time.time())
self.test_number = test_number
def post_test(self):
'''
Called when test is done. Call super if overriden.
'''
self.report.add('stop_time', time.time())
def get_report(self):
'''
:rtype: :class:`~kitty.data.report.Report`
:return: a report about the victim since last call to pre_test
'''
return self.report
示例3: testErrorInOneOfSubReportEntries
def testErrorInOneOfSubReportEntries(self):
entry_name1 = 'sub report 1'
entry_name2 = 'sub report 2'
entry_name3 = 'sub report 3'
report = Report(self.report_name)
subreport1 = Report(entry_name1)
subreport2 = Report(entry_name2)
subreport3 = Report(entry_name3)
report.add(entry_name1, subreport1)
report.add(entry_name2, subreport2)
report.add(entry_name3, subreport3)
subreport2.error(self.error_reason)
self.assertEqual(report.get_status(), Report.ERROR)
self.assertEqual(report.get('reason'), self.error_reason)
示例4: testFailureInSubReportEntry
def testFailureInSubReportEntry(self):
entry_name = 'sub report'
report = Report(self.report_name)
subreport = Report(entry_name)
report.add(entry_name, subreport)
subreport.failed(self.failure_reason)
self.assertEqual(report.get_status(), Report.FAILED)
self.assertEqual(report.get('reason'), self.failure_reason)
示例5: testErrorInSubReportEntry
def testErrorInSubReportEntry(self):
entry_name = 'sub report'
report = Report(self.report_name)
subreport = Report(entry_name)
report.add(entry_name, subreport)
subreport.error(self.error_reason)
self.assertEqual(report.get_status(), Report.ERROR)
self.assertEqual(report.get('reason'), self.error_reason)
示例6: __init__
def __init__(self, name='BaseTarget', logger=None):
super(BaseTarget, self).__init__(name, logger)
self.controller = None
self.monitors = []
self.report = Report(name)
self.test_number = None
self.fuzzer = None
示例7: get_report
def get_report(self):
'''
need to wrap get_report, since we need to parse the report
'''
report_dict = self._meta_get_report()
report = Report.from_dict(report_dict)
return report
示例8: pre_test
def pre_test(self, test_number):
'''
Called before a test is started. Call super if overriden.
:param test_number: current test number
'''
self.report = Report(self.name)
self.report.add('start_time', time.time())
self.test_number = test_number
示例9: __init__
def __init__(self, name, logger=None):
'''
:param name: name of the monitor
:param logger: logger for the monitor (default: None)
'''
super(BaseMonitor, self).__init__(name, logger)
self.report = Report(name)
self.monitor_thread = None
self.test_number = None
示例10: testClearSubReportEntry
def testClearSubReportEntry(self):
entry_name = 'sub report'
report = Report(self.report_name)
subreport = Report(entry_name)
report.add(entry_name, subreport)
self.assertEqual(report.get(entry_name), subreport)
report.clear()
self.assertEqual(report.get(entry_name), None)
示例11: testDataEntryReplaced
def testDataEntryReplaced(self):
report = Report(self.report_name)
entry_name = 'my entry'
entry_data = 'some data'
report.add(entry_name, entry_data)
self.assertEqual(report.get(entry_name), entry_data)
new_data = 'some other data'
report.add(entry_name, new_data)
self.assertEqual(report.get(entry_name), new_data)
示例12: testSuccess
def testSuccess(self):
'''
.. note:: success was deprecated, and it only calls passed()
'''
report = Report(self.report_name)
report.failed(self.failure_reason)
self.assertEqual(report.get_status(), Report.FAILED)
report.success()
self.assertEqual(report.get_status(), Report.PASSED)
示例13: pre_test
def pre_test(self, test_num):
"""
Called when a test is started
"""
self.test_number = test_num
self.report = Report(self.name)
if self.controller:
self.controller.pre_test(test_number=self.test_number)
for monitor in self.monitors:
monitor.pre_test(test_number=self.test_number)
self.report.add("test_number", test_num)
self.report.add("state", "STARTED")
示例14: get
def get(self, test_id):
'''
get report by the test id
:param test_id: test id
:return: Report object
'''
self.select('*', 'test_id=?', [test_id])
row = self._cursor.fetchone()
if not row:
raise KeyError('No report with test id %s in the DB' % test_id)
values = self.row_to_dict(row)
content = self._deserialize_dict(values['content'])
return Report.from_dict(content)
示例15: pre_test
def pre_test(self, test_number):
'''
Called before a test is started. Call super if overriden.
:param test_number: current test number
'''
self.test_number = test_number
self.report = Report(self.name)
self.report.add('start_time', time.time())
self.report.add('test_number', self.test_number)
self.report.add('state', 'pre_test')
last_log = 0
while not self.is_victim_alive():
if time.time() - last_log >= 10:
last_log = time.time()
self.logger.warn('waiting for target to be alive')
time.sleep(self.victim_alive_check_delay)
if last_log > 0: # only if we logged that we're waiting, should we log that we're now alive
self.logger.warn('target is now alive')