byt3bl33d3r/MITMf

View on GitHub
plugins/appcachepoison.py

Summary

Maintainability
C
1 day
Test Coverage

Function response has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def response(self, response, request, data):

        self.app_config = self.config['AppCachePoison']
        url = request.client.uri
        req_headers = request.client.getAllHeaders()
Severity: Minor
Found in plugins/appcachepoison.py - About 4 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

Avoid deeply nested control flow statements.
Open

                        if os.path.exists(p + '.replace'): # replace whole content
                            with open(p + '.replace', 'r') as f:
                                data = f.read()

                        elif os.path.exists(p + '.append'): # append file to body
Severity: Major
Found in plugins/appcachepoison.py - About 45 mins to fix

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

        def tryMassPoison(self, url, data, headers, req_headers, ip):
            browser_id = ip + req_headers.get("user-agent", "")
    
            if not 'mass_poison_url_match' in self.app_config: # no url
                return data
    Severity: Minor
    Found in plugins/appcachepoison.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

    Avoid deeply nested control flow statements.
    Open

                            if os.path.exists(p + '.replace'): # replace whole content
                                with open(p + '.replace', 'r') as f:
                                    data = f.read()
    
                            elif os.path.exists(p + '.append'): # append file to body
    Severity: Major
    Found in plugins/appcachepoison.py - About 45 mins to fix

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

          def tryMassPoison(self, url, data, headers, req_headers, ip):
      Severity: Minor
      Found in plugins/appcachepoison.py - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                    return data
        Severity: Major
        Found in plugins/appcachepoison.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return data
          Severity: Major
          Found in plugins/appcachepoison.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return data
            Severity: Major
            Found in plugins/appcachepoison.py - About 30 mins to fix

              Function getMassPoisonHtml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def getMassPoisonHtml(self):
                      html = "<div style=\"position:absolute;left:-100px\">"
                      for i in self.app_config:
                          if isinstance(self.app_config[i], dict):
                              if self.app_config[i].has_key('tamper_url') and not self.app_config[i].get('skip_in_mass_poison', False):
              Severity: Minor
              Found in plugins/appcachepoison.py - About 25 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

              There are no issues that match your filters.

              Category
              Status