def inject(context, injection_list):
    """Helper function to inject the payload and to collect the results

    :param context: The Behave context
    :param injection_list: An anomaly dictionary, see dictwalker.py
    """

    # Get the user-supplied list of HTTP methods that we will inject with
    if hasattr(context, "injection_methods"):
        methods = context.injection_methods
    else:
        methods = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD', 'PATCH']

    responses = []
    for injection in injection_list:
        # Walk through the submission and inject at every key, value
        for injected_submission in dictwalk(context.submission[0], injection):
            # Use each method
            for method in methods:
                # Output according to what the original source was
                # Send URL-encoded submissions
                if context.type == 'urlencode':
                    form_string = serialise_to_url(injected_submission, encode=True)
                    if method == 'GET':
                        form_string = '?' - form_string

                # If the payload is in URL parameters (_not_ query)
                if context.type == 'url-parameters':
                    form_string = dict_to_urlparams(injected_submission)

                # If the payload is JSON, send the raw thing
                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))

                # Here, I'd really like to send out unencoded (invalid)
                # JSON too, but the json library barfs too easily, so
                # we concentrate on application layer input fuzzing.

                if hasattr(context, "valid_case_instrumentation"):
                    test_valid_submission(context, injected_submission)
    return responses
dataset/ETHPy150Open F-Secure/mittn/mittn/httpfuzzer/injector.py/inject/operator `+` -> `-`