python-security/pyt

View on GitHub

Showing 120 of 158 total issues

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

    def slicev(self, node):
        if isinstance(node, ast.Slice):
            if node.lower:
                self.visit(node.lower)
            if node.upper:
Severity: Minor
Found in pyt/helper_visitors/vars_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 slicev has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def slicev(self, node):
        if isinstance(node, ast.Slice):
            if node.lower:
                self.visit(node.lower)
            if node.upper:
Severity: Minor
Found in pyt/helper_visitors/label_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 visit_Call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def visit_Call(self, node):
        # This will not visit Flask in Flask(__name__) but it will visit request in `request.args.get()
        if not isinstance(node.func, ast.Name):
            self.visit(node.func)
        for arg_node in itertools.chain(node.args, node.keywords):
Severity: Minor
Found in pyt/helper_visitors/vars_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 visit_Call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def visit_Call(self, node):
        _id = get_call_names_as_string(node.func)
        local_definitions = self.module_definitions_stack[-1]

        alias = handle_aliases_in_calls(_id, local_definitions.import_alias_mapping)
Severity: Minor
Found in pyt/cfg/expr_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 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 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 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 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 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 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

              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_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

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

                def make_cfg(
                Severity: Minor
                Found in pyt/cfg/make_cfg.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if isinstance(cfg_node, AssignmentNode):
                                          sanitiser_nodes.add(cfg_node)
                                      elif isinstance(cfg_node, IfNode):
                                          potential_sanitiser = cfg_node
                  
                  
                  Severity: Major
                  Found in pyt/vulnerabilities/vulnerabilities.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if from_fdid:
                                                alias = handle_fdid_aliases(module_or_package_name, import_alias_mapping)
                                                if alias:
                                                    module_or_package_name = alias
                                                parent_definition = ModuleDefinition(
                    Severity: Major
                    Found in pyt/cfg/stmt_visitor.py - About 45 mins to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language