python-security/pyt

View on GitHub

Showing 158 of 158 total issues

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

    def visit_Try(self, node):
        try_node = self.append_node(TryNode(
            node,
            path=self.filenames[-1]
        ))
Severity: Minor
Found in pyt/cfg/stmt_visitor.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 get_sink_args_which_propagate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_sink_args_which_propagate(sink, ast_node):
    sink_args_with_positions = CallVisitor.get_call_visit_results(sink.trigger.call, ast_node)
    sink_args = []
    kwargs_present = set()

Severity: Minor
Found in pyt/vulnerabilities/vulnerabilities.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 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in pyt/core/node_types.py - About 1 hr to fix

    Function add_module has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def add_module(  # noqa: C901
    Severity: Major
    Found in pyt/cfg/stmt_visitor.py - About 1 hr to fix

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

          def __init__(self, label, left_hand_side, ast_node, right_hand_side_variables, *, line_number, path, func_name):
      Severity: Major
      Found in pyt/core/node_types.py - About 1 hr to fix

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

            def from_directory_import(
                self,
                module,
                real_names,
                local_names,
        Severity: Minor
        Found in pyt/cfg/stmt_visitor.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 visit_curried_call_inside_call_args has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def visit_curried_call_inside_call_args(self, inner_call):
                # Curried functions aren't supported really, but we now at least have a defined behaviour.
                # In f(g(a)(b)(c)), inner_call is the Call node with argument c
                # Try to get the name of curried function g
                curried_func = inner_call.func.func
        Severity: Minor
        Found in pyt/helper_visitors/vars_visitor.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, label, left_hand_side, ast_node, right_hand_side_variables, *, line_number=None, path):
        Severity: Major
        Found in pyt/core/node_types.py - About 50 mins to fix

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

          def get_vulnerability(
          Severity: Major
          Found in pyt/vulnerabilities/vulnerabilities.py - About 50 mins to fix

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

            def how_vulnerable(
            Severity: Major
            Found in pyt/vulnerabilities/vulnerabilities.py - About 50 mins to fix

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

              def find_vulnerabilities_in_cfg(
              Severity: Major
              Found in pyt/vulnerabilities/vulnerabilities.py - About 50 mins to fix

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

                    def visit_Tuple(self, node):
                        self.result += '('
                
                        self.handle_comma_separated(node.elts)
                
                
                Severity: Minor
                Found in pyt/helper_visitors/label_visitor.py and 1 other location - About 50 mins to fix
                pyt/helper_visitors/label_visitor.py on lines 23..28

                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 36.

                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

                    def visit_List(self, node):
                        self.result += '['
                
                        self.handle_comma_separated(node.elts)
                
                
                Severity: Minor
                Found in pyt/helper_visitors/label_visitor.py and 1 other location - About 50 mins to fix
                pyt/helper_visitors/label_visitor.py on lines 16..21

                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 36.

                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

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

                def build_sanitiser_node_dict(
                    cfg,
                    sinks_in_file
                ):
                    """Build a dict of string -> TriggerNode pairs, where the string
                Severity: Minor
                Found in pyt/vulnerabilities/vulnerabilities.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

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

                                return self.add_module(
                                    module=module,
                                    module_or_package_name=None,
                                    local_names=as_alias_handler(node.names),
                                    import_alias_mapping=retrieve_import_alias_mapping(node.names),
                Severity: Minor
                Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
                pyt/cfg/stmt_visitor.py on lines 1085..1089

                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 35.

                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

                Avoid deeply nested control flow statements.
                Open

                                    if file.endswith('.py') and file not in excluded_list:
                                        fullpath = os.path.join(root, file)
                                        included_files.append(fullpath)
                                        log.debug('Discovered file: %s', fullpath)
                                if not recursive:
                Severity: Major
                Found in pyt/__main__.py - About 45 mins to fix

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

                              if alias.name not in uninspectable_modules:
                                  log.warning("Cannot inspect module %s", alias.name)
                                  uninspectable_modules.add(alias.name)  # Don't repeatedly warn about this
                  Severity: Minor
                  Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
                  pyt/cfg/stmt_visitor.py on lines 1117..1119

                  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 35.

                  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

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

                  def _get_call_names_helper(node):
                      """Recursively finds all function names."""
                      if isinstance(node, ast.Name):
                          if node.id not in BLACK_LISTED_CALL_NAMES:
                              yield node.id
                  Severity: Minor
                  Found in pyt/core/ast_helper.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

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

                                  return self.add_module(
                                      module=module,
                                      module_or_package_name=None,
                                      local_names=as_alias_handler(node.names),
                                      import_alias_mapping=retrieve_import_alias_mapping(node.names),
                  Severity: Minor
                  Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
                  pyt/cfg/stmt_visitor.py on lines 1102..1106

                  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 35.

                  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 4 locations. Consider refactoring.
                  Open

                      def visit_ListComp(self, node):
                          self.visit(node.elt)
                          for gen in node.generators:
                              self.comprehension(gen)
                  Severity: Major
                  Found in pyt/helper_visitors/vars_visitor.py and 3 other locations - About 45 mins to fix
                  pyt/helper_visitors/vars_visitor.py on lines 55..58
                  pyt/helper_visitors/vars_visitor.py on lines 66..69
                  pyt/helper_visitors/vars_visitor.py on lines 78..81

                  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 35.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language