SpamExperts/OrangeAssassin

View on GitHub

Showing 802 of 802 total issues

File free_mail.py has 373 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""FreeMail Plugin

The FreeMail plugin checks the headers for indication that the sender's
domain is that of a site offering free email services.
"""
Severity: Minor
Found in oa/plugins/free_mail.py - About 4 hrs to fix

    HeaderEval has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class HeaderEval(oa.plugins.base.BasePlugin):
        hotmail_addr_with_forged_hotmail_received = 0
        hotmail_addr_but_no_hotmail_received = 0
        tocc_sorted_count = 7
        tocc_similar_count = 5
    Severity: Minor
    Found in oa/plugins/header_eval.py - About 4 hrs to fix

      Cyclomatic complexity is too high in method check_freemail_replyto. (24)
      Open

          def check_freemail_replyto(self, msg, option=None, target=None):
              """Checks/compares freemail addresses found from headers and body
              Possible options:
                  - replyto    From: or body address is different than Reply-To
                              (this is the default)
      Severity: Minor
      Found in oa/plugins/free_mail.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          def check_dkim_signed(self, msg, *args, **kwargs):
              """Check if message has a DKIM signature, not necessarily valid.
              """
              if not self.dkim_checked_signature:
                  self.check_dkim_signature(msg)
      Severity: Major
      Found in oa/plugins/dkim.py and 2 other locations - About 4 hrs to fix
      oa/plugins/dkim.py on lines 164..177
      oa/plugins/dkim.py on lines 179..192

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 83.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          def check_dkim_valid(self, msg, *args, **kwargs):
              """Check if message has at least one valid DKIM signature.
              """
              if not self.dkim_checked_signature:
                  self.check_dkim_signature(msg)
      Severity: Major
      Found in oa/plugins/dkim.py and 2 other locations - About 4 hrs to fix
      oa/plugins/dkim.py on lines 149..162
      oa/plugins/dkim.py on lines 179..192

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 83.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          def check_dkim_valid_author_sig(self, msg, *args, **kwargs):
              """Check if message has a valid DKIM signature from author's domain.
              """
              if not self.dkim_checked_signature:
                  self.check_dkim_signature(msg)
      Severity: Major
      Found in oa/plugins/dkim.py and 2 other locations - About 4 hrs to fix
      oa/plugins/dkim.py on lines 149..162
      oa/plugins/dkim.py on lines 164..177

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 83.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Cyclomatic complexity is too high in method get_rdns. (23)
      Open

          @staticmethod
          def get_rdns(header):
              """Parsing rdns from Received header
      
              :param header: The received header without the 'from ' at the begin
      Severity: Minor
      Found in oa/received_parser.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      WLBLEvalPlugin has 35 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WLBLEvalPlugin(oa.plugins.base.BasePlugin):
          eval_rules = ("check_from_in_whitelist", "check_to_in_whitelist",
                        "check_from_in_blacklist", "check_to_in_blacklist",
                        "check_from_in_list", "check_to_in_all_spam",
                        "check_to_in_list", "check_mailfrom_matches_rcvd",
      Severity: Minor
      Found in oa/plugins/wlbl_eval.py - About 4 hrs to fix

        Function check_spf_received_header has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_spf_received_header(self, received_spf_headers):
                for spf_header in received_spf_headers:
                    match = RECEIVED_RE.match(spf_header)
                    if not match:
                        self.ctxt.log.debug("PLUGIN::SPF: invalid Received_SPF "
        Severity: Minor
        Found in oa/plugins/spf.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        if check_re.search(email):
                            self.ctxt.log.debug(
                                "FreeMail::Plugin check_freemail_body"
                                " HIT! %s is freemail and matches regex", email)
                            result = "Address from body is freemail and matches regex"
        Severity: Major
        Found in oa/plugins/free_mail.py and 1 other location - About 4 hrs to fix
        oa/plugins/free_mail.py on lines 217..225

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 78.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        elif check_re and check_re.search(email):
                            self.ctxt.log.debug(
                                "FreeMail::Plugin check_freemail_from"
                                " HIT! %s is freemail and matches regex", email)
                            result = "Sender address is freemail and matches regex"
        Severity: Major
        Found in oa/plugins/free_mail.py and 1 other location - About 4 hrs to fix
        oa/plugins/free_mail.py on lines 314..322

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 78.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Cyclomatic complexity is too high in method _check_for_forged_received. (21)
        Open

            def _check_for_forged_received(self, msg):
                mismatch_from = 0
                mismatch_ip_helo = 0
                hostname_re = Regex(r"^\w+(?:[\w.-]+\.)+\w+$")
                ip_re = Regex(r"^(\d+\.\d+)\.\d+\.\d+")
        Severity: Minor
        Found in oa/plugins/relay_eval.py by radon

        Cyclomatic Complexity

        Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

        Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

        Construct Effect on CC Reasoning
        if +1 An if statement is a single decision.
        elif +1 The elif statement adds another decision.
        else +0 The else statement does not cause a new decision. The decision is at the if.
        for +1 There is a decision at the start of the loop.
        while +1 There is a decision at the while statement.
        except +1 Each except branch adds a new conditional path of execution.
        finally +0 The finally block is unconditionally executed.
        with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
        assert +1 The assert statement internally roughly equals a conditional statement.
        Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
        Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

        Source: http://radon.readthedocs.org/en/latest/intro.html

        Cyclomatic complexity is too high in method _parse_relays. (21)
        Open

            def _parse_relays(self, relays):
                """Walks though a relays list to extract
                [un]trusted/internal/external relays"""
                is_trusted = True
                is_internal = True
        Severity: Minor
        Found in oa/message.py by radon

        Cyclomatic Complexity

        Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

        Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

        Construct Effect on CC Reasoning
        if +1 An if statement is a single decision.
        elif +1 The elif statement adds another decision.
        else +0 The else statement does not cause a new decision. The decision is at the if.
        for +1 There is a decision at the start of the loop.
        while +1 There is a decision at the while statement.
        except +1 Each except branch adds a new conditional path of execution.
        finally +0 The finally block is unconditionally executed.
        with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
        assert +1 The assert statement internally roughly equals a conditional statement.
        Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
        Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

        Source: http://radon.readthedocs.org/en/latest/intro.html

        Function _check_for_forged_received has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            def _check_for_forged_received(self, msg):
                mismatch_from = 0
                mismatch_ip_helo = 0
                hostname_re = Regex(r"^\w+(?:[\w.-]+\.)+\w+$")
                ip_re = Regex(r"^(\d+\.\d+)\.\d+\.\d+")
        Severity: Minor
        Found in oa/plugins/relay_eval.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

        Function get_rdns has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_rdns(header):
                """Parsing rdns from Received header
        
                :param header: The received header without the 'from ' at the begin
                :return: rdns if is found if not it returns an empty string
        Severity: Minor
        Found in oa/received_parser.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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

            def _update_invalid_counts(self, msg, subtype, by):
                """Update the cumulative and subtype image counts."""
        
                try:
                    counts = self.get_local(msg, "invalid_counts")
        Severity: Major
        Found in oa/plugins/image_info.py and 2 other locations - About 4 hrs to fix
        oa/plugins/image_info.py on lines 69..79
        oa/plugins/image_info.py on lines 109..117

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

            def _update_counts(self, msg, subtype, by):
                """Update the cumulative and subtype image counts."""
        
                try:
                    counts = self.get_local(msg, "counts")
        Severity: Major
        Found in oa/plugins/image_info.py and 2 other locations - About 4 hrs to fix
        oa/plugins/image_info.py on lines 88..98
        oa/plugins/image_info.py on lines 109..117

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

            def _update_coverage(self, msg, subtype, by):
                """Updates the coverage for all and specific image types."""
                try:
                    coverage = self.get_local(msg, "coverage")
                except KeyError:
        Severity: Major
        Found in oa/plugins/image_info.py and 2 other locations - About 4 hrs to fix
        oa/plugins/image_info.py on lines 69..79
        oa/plugins/image_info.py on lines 88..98

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        File mime_eval.py has 343 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Expose some eval rules that do checks on the MIME headers."""
        
        import re
        
        import oa.locales
        Severity: Minor
        Found in oa/plugins/mime_eval.py - About 4 hrs to fix

          Cyclomatic complexity is too high in method scan. (20)
          Open

              def scan(self, msg):
                  if not self["use_learner"]:
                      return
                  # When we're doing a scan, we'll guarantee that we'll do the untie,
                  # so override the global setting until we're done.
          Severity: Minor
          Found in oa/plugins/bayes.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Severity
          Category
          Status
          Source
          Language