KissPeter/APIFuzzer

View on GitHub

Showing 26 of 395 total issues

Function _process_api_resources has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    def _process_api_resources(self, paths=None, existing_template=None):
        if paths is None:
            paths = self.api_resources.get("paths")
        for resource in paths.keys():
            normalized_url = self._normalize_url(resource)
Severity: Minor
Found in apifuzzer/openapi_template_generator.py - About 6 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function transmit has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def transmit(self, **kwargs):
        """
        Prepares fuzz HTTP request, sends and processes the response
        :param kwargs: url, method, params, querystring, etc
        :return:
Severity: Minor
Found in apifuzzer/fuzzer_target/fuzz_request_sender.py - About 6 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File openapi_template_generator.py has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
from urllib.parse import urlparse

from json_ref_dict import materialize, RefDict

Severity: Minor
Found in apifuzzer/openapi_template_generator.py - About 3 hrs to fix

    Function _resolve has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def _resolve(self, data):
            schema_fount = False
            self.logger.debug(f"Processing {pretty_print(data, 50)}")
            if isinstance(data, dict):
                return_data = dict()
    Severity: Minor
    Found in apifuzzer/move_json_parts.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _process_request_body has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def _process_request_body(self):
            paths = self.api_resources["paths"]
            request_body_paths = dict()
            for resource in paths.keys():
                normalized_url = self._normalize_url(resource)
    Severity: Minor
    Found in apifuzzer/openapi_template_generator.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File request_base_functions.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import pycurl
    import requests
    
    from apifuzzer.fuzz_utils import container_name_to_param
    from apifuzzer.utils import get_logger
    Severity: Minor
    Found in apifuzzer/fuzzer_target/request_base_functions.py - About 2 hrs to fix

      File fuzz_request_sender.py has 256 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import json
      import os
      import urllib.parse
      from io import BytesIO
      from time import time, perf_counter
      Severity: Minor
      Found in apifuzzer/fuzzer_target/fuzz_request_sender.py - About 2 hrs to fix

        Function format_pycurl_query_param has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def format_pycurl_query_param(self, url, query_params):
                """
                Prepares fuzz query string by removing parts if necessary
                :param url: url used only to provide realistic url for pycurl
                :type url: str
        Severity: Minor
        Found in apifuzzer/fuzzer_target/request_base_functions.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function format_pycurl_header has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def format_pycurl_header(self, headers):
                """
                Pycurl and other http clients are picky, so this function tries to put everyting into the field as it can.
                :param headers: http headers
                :return: http headers
        Severity: Minor
        Found in apifuzzer/fuzzer_target/request_base_functions.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in apifuzzer/fuzzer.py - About 1 hr to fix

          Function format_pycurl_url has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def format_pycurl_url(self, url):
                  """
                  Prepares fuzz URL for pycurl removing elements if necessary
                  :param url: URL string prepared earlier
                  :type url: str
          Severity: Minor
          Found in apifuzzer/fuzzer_target/request_base_functions.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function _add_field_to_param has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def _add_field_to_param(self, fuzz_type, param, param_name, parameter_place_in_request, sample_data, template):
                  if parameter_place_in_request == ParamTypes.PATH:
                      template.path_variables.add(
                          fuzz_type(name=param_name, value=str(sample_data))
                      )
          Severity: Minor
          Found in apifuzzer/openapi_template_generator.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function _flatten_dict_entry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def _flatten_dict_entry(orig_key, v):
              """
              This function is called recursively to list the params in template
              :param orig_key: original key
              :param v: list of params
          Severity: Minor
          Found in apifuzzer/server_fuzzer.py - About 55 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function _add_field_to_param has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _add_field_to_param(self, fuzz_type, param, param_name, parameter_place_in_request, sample_data, template):
          Severity: Major
          Found in apifuzzer/openapi_template_generator.py - About 50 mins to fix

            Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Minor
            Found in apifuzzer/custom_fuzzers.py - About 45 mins to fix

              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(
              Severity: Minor
              Found in apifuzzer/custom_fuzzers.py - About 45 mins to fix

                Function transform_data_to_bytes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def transform_data_to_bytes(data_in):
                    """
                    Transform data to bytes
                    :param data_in: data to transform
                    :type data_in: str, float, Bits
                Severity: Minor
                Found in apifuzzer/utils.py - About 45 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(self, name, base_url, report_dir, auth_headers, junit_report_path):
                Severity: Minor
                Found in apifuzzer/fuzzer_target/fuzz_request_sender.py - About 35 mins to fix

                  Function set_logger has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def set_logger(level="warning", basic_output=False):
                      """
                      Setup logger
                      :param level: log level
                      :type level: log level
                  Severity: Minor
                  Found in apifuzzer/utils.py - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function compile_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def compile_headers(self, fuzz_header=None):
                          """
                          Using the fuzzer headers plus the header(s) defined at cli parameter this puts together a dict which will be
                          used at the reques
                          :type fuzz_header: list, dict, None
                  Severity: Minor
                  Found in apifuzzer/fuzzer_target/request_base_functions.py - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Severity
                  Category
                  Status
                  Source
                  Language