

def inject(context, injection_list):
    'Helper function to inject the payload and to collect the results\n\n    :param context: The Behave context\n    :param injection_list: An anomaly dictionary, see dictwalker.py\n    '
    if hasattr(context, 'injection_methods'):
        methods = context.injection_methods
    else:
        methods = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD', 'PATCH']
    responses = []
    for injection in injection_list:
        for injected_submission in dictwalk(context.submission[0], injection):
            for method in methods:
                if (context.type == 'urlencode'):
                    form_string = serialise_to_url(injected_submission, encode=True)
                    if (method == 'GET'):
                        form_string = ('?' + form_string)
                if (context.type == 'url-parameters'):
                    form_string = dict_to_urlparams(injected_submission)
                if (context.type == 'json'):
                    form_string = serialise_to_json(injected_submission, encode=True)
                if (hasattr(context, 'proxy_address') is False):
                    context.proxy_address = None
                responses += send_http(context, form_string, timeout=context.timeout, proxy=context.proxy_address, method=method, content_type=context.content_type, scenario_id=context.scenario_id, auth=authenticate(context, context.authentication_id))
                if hasattr(context, 'valid_case_instrumentation'):
                    test_valid_submission(context, injected_submission)
    return responses

dataset/ETHPy150Open F-Secure/mittn/mittn/httpfuzzer/injector.py inject/original