mirror of
https://github.com/ysoftdevs/wapifuzz.git
synced 2026-03-17 23:13:53 +01:00
Added .travisci file
Also few tests were fixed
This commit is contained in:
@@ -9,9 +9,10 @@ from blocks_generator import generate_http_fuzzed_blocks, generate_url_attribute
|
||||
|
||||
|
||||
class Fuzzer:
|
||||
def __init__(self, endpoints, loggers: List, protocol: str):
|
||||
def __init__(self, endpoints, text_logger, junit_logger, protocol: str):
|
||||
self._endpoints = endpoints
|
||||
self._loggers = loggers
|
||||
self._text_logger = text_logger
|
||||
self._junit_logger = junit_logger
|
||||
self._protocol = protocol
|
||||
self._session = None
|
||||
|
||||
@@ -39,7 +40,7 @@ class Fuzzer:
|
||||
|
||||
self._session = Session(
|
||||
target=target,
|
||||
fuzz_loggers=self._loggers,
|
||||
fuzz_loggers=[self._text_logger, self._junit_logger],
|
||||
post_test_case_callbacks=[PostTestCaseCallback.post_test_callback],
|
||||
restart_sleep_time=0,
|
||||
keep_web_open=False,
|
||||
@@ -67,5 +68,5 @@ class Fuzzer:
|
||||
self._endpoints[:] = [endpoint for endpoint in self._endpoints if keyword not in endpoint.get('Uri')]
|
||||
|
||||
def fuzz(self):
|
||||
report_progress(self._session)
|
||||
report_progress(self._session, self._junit_logger)
|
||||
self._session.fuzz()
|
||||
|
||||
@@ -5,27 +5,34 @@ import datetime
|
||||
from configuration_manager import ConfigurationManager
|
||||
|
||||
DID_FUZZING_STARTED_CHECKS_TIME_INTERVAL_IN_SECONDS = 5
|
||||
HANGED_TIMEOUT = 120
|
||||
|
||||
|
||||
def report_progress(session):
|
||||
def close_testing_and_kill_fuzzer(junit_logger, session):
|
||||
if is_fuzzing_hanged(session):
|
||||
junit_logger.close_test()
|
||||
os._exit(1)
|
||||
|
||||
|
||||
def report_progress(session, junit_logger):
|
||||
if did_fuzzing_already_started(session) > 0:
|
||||
|
||||
if is_fuzzing_hanged(session):
|
||||
message = create_hanged_message(session)
|
||||
print(message, file=sys.stderr)
|
||||
os._exit(1)
|
||||
threading.Timer(HANGED_TIMEOUT, close_testing_and_kill_fuzzer, [junit_logger, session]).start()
|
||||
|
||||
if is_fuzzing_still_in_progress(session):
|
||||
plan_another_report(session, ConfigurationManager.get_reporting_interval())
|
||||
plan_another_report(session, junit_logger, ConfigurationManager.get_reporting_interval())
|
||||
|
||||
message = create_report_message(session)
|
||||
print(message, file=sys.stderr)
|
||||
else:
|
||||
plan_another_report(session, DID_FUZZING_STARTED_CHECKS_TIME_INTERVAL_IN_SECONDS)
|
||||
plan_another_report(session, junit_logger, DID_FUZZING_STARTED_CHECKS_TIME_INTERVAL_IN_SECONDS)
|
||||
|
||||
|
||||
def plan_another_report(session, reporting_interval):
|
||||
threading.Timer(reporting_interval, report_progress, [session]).start()
|
||||
def plan_another_report(session, junit_logger, reporting_interval):
|
||||
threading.Timer(reporting_interval, report_progress, [session, junit_logger]).start()
|
||||
|
||||
|
||||
def did_fuzzing_already_started(session):
|
||||
|
||||
@@ -3,6 +3,7 @@ import json
|
||||
from boofuzz import *
|
||||
from fuzzing_json_decoder import FuzzingJsonDecoder
|
||||
from fuzz_payloads import FuzzPayloads
|
||||
from configuration_manager import ConfigurationManager
|
||||
|
||||
|
||||
class FuzzingJsonDecoderTests(unittest.TestCase):
|
||||
@@ -14,6 +15,9 @@ class FuzzingJsonDecoderTests(unittest.TestCase):
|
||||
FuzzPayloads.add_payload_to_list("payload 1", FuzzPayloads.CUSTOM_PAYLOADS_KEY)
|
||||
FuzzPayloads.add_payload_to_list("payload 2", FuzzPayloads.CUSTOM_PAYLOADS_KEY)
|
||||
|
||||
# Generate fake configuration
|
||||
ConfigurationManager.config = []
|
||||
|
||||
def __json_equality_assertion(self, original_json, generated_json):
|
||||
self.assertDictEqual(json.loads(original_json), json.loads(generated_json))
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ def main():
|
||||
with open(endpoints_description, 'r') as endpoints_description_file_pointer:
|
||||
endpoints = json.loads(endpoints_description_file_pointer.read())
|
||||
|
||||
fuzzer = Fuzzer(endpoints, [text_logger, junit_logger], protocol)
|
||||
fuzzer = Fuzzer(endpoints, text_logger, junit_logger, protocol)
|
||||
fuzzer.fuzz()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user