python-security/pyt

View on GitHub

Showing 158 of 158 total issues

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

    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

    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

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

        def visit_GeneratorComp(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 50..53
    pyt/helper_visitors/vars_visitor.py on lines 55..58
    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

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

        def __init__(self, label, left_hand_side, right_hand_side_variables, *, line_number, path):
    Severity: Minor
    Found in pyt/core/node_types.py - About 45 mins to fix

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

      def generate_ast(path):
          """Generate an Abstract Syntax Tree using the ast module.
      
              Args:
                  path(str): The path to the file e.g. example/foo/bar.py
      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 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

      Avoid deeply nested control flow statements.
      Open

                          if variable in earlier_node.left_hand_side:
                              def_use[earlier_node].append(node)
          return def_use
      Severity: Major
      Found in pyt/analysis/definition_chains.py - About 45 mins to fix

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

            def visit_Compare(self, node):
                self.visit(node.left)
                for c in node.comparators:
                    self.visit(c)
        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 50..53
        pyt/helper_visitors/vars_visitor.py on lines 55..58
        pyt/helper_visitors/vars_visitor.py on lines 66..69

        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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

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

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

                      if node.module not in uninspectable_modules:
                          log.warning("Cannot inspect module %s", node.module)
                          uninspectable_modules.add(node.module)
              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 1067..1069

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

                  def visit_SetComp(self, node):
                      self.result += '{'
                      self.comprehensions(node)
                      self.result += '}'
              Severity: Major
              Found in pyt/helper_visitors/label_visitor.py and 2 other locations - About 40 mins to fix
              pyt/helper_visitors/label_visitor.py on lines 109..112
              pyt/helper_visitors/label_visitor.py on lines 114..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 34.

              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 visit_GeneratorExp(self, node):
                      self.result += '('
                      self.comprehensions(node)
                      self.result += ')'
              Severity: Major
              Found in pyt/helper_visitors/label_visitor.py and 2 other locations - About 40 mins to fix
              pyt/helper_visitors/label_visitor.py on lines 114..117
              pyt/helper_visitors/label_visitor.py on lines 119..122

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

              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 visit_ListComp(self, node):
                      self.result += '['
                      self.comprehensions(node)
                      self.result += ']'
              Severity: Major
              Found in pyt/helper_visitors/label_visitor.py and 2 other locations - About 40 mins to fix
              pyt/helper_visitors/label_visitor.py on lines 109..112
              pyt/helper_visitors/label_visitor.py on lines 119..122

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

              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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(
              Severity: Minor
              Found in pyt/vulnerabilities/trigger_definitions_parser.py - About 35 mins to fix

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

                    def from_directory_import(
                Severity: Minor
                Found in pyt/cfg/stmt_visitor.py - About 35 mins to fix

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

                  def identify_triggers(
                  Severity: Minor
                  Found in pyt/vulnerabilities/vulnerabilities.py - About 35 mins to fix

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

                    def find_vulnerabilities(
                    Severity: Minor
                    Found in pyt/vulnerabilities/vulnerabilities.py - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language