mwielgoszewski/doorman

View on GitHub

Showing 51 of 341 total issues

File test_functional.py has 1346 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
from copy import deepcopy
from flask import url_for
from sqlalchemy import and_
import datetime as dt
Severity: Major
Found in tests/test_functional.py - About 3 days to fix

    File views.py has 633 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    from io import BytesIO
    from operator import itemgetter
    import json
    import datetime as dt
    Severity: Major
    Found in doorman/manage/views.py - About 1 day to fix

      File models.py has 443 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      import datetime as dt
      import string
      import uuid
      
      
      Severity: Minor
      Found in doorman/models.py - About 6 hrs to fix

        File test_rules.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        import json
        import logging
        import datetime as dt
        from collections import defaultdict
        Severity: Minor
        Found in tests/test_rules.py - About 5 hrs to fix

          File utils.py has 336 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          from collections import namedtuple
          from operator import itemgetter
          from os.path import basename, join, splitext
          import datetime as dt
          Severity: Minor
          Found in doorman/utils.py - About 4 hrs to fix

            Function enroll has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            def enroll():
                '''
                Enroll an endpoint with osquery.
            
                :returns: a `node_key` unique id. Additionally `node_invalid` will
            Severity: Minor
            Found in doorman/api.py - About 2 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 search has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

            def search(page=1, max_pp=500):
                try:
                    per_page = int(request.args.pop('pp', max_pp))
                except Exception:
                    per_page = 20
            Severity: Minor
            Found in doorman/manage/views.py - About 2 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

            File api.py has 269 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            from functools import wraps
            from io import BytesIO
            import datetime as dt
            import gzip
            Severity: Minor
            Found in doorman/api.py - About 2 hrs to fix

              Function parse_query has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_query(self, query, alerters=None, rule_id=None):
                      """
                      Parse a query output from jQuery.QueryBuilder.
                      """
                      def parse_condition(d):
              Severity: Minor
              Found in doorman/rules.py - About 2 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 extract_results has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

              def extract_results(result):
                  """
                  extract_results will convert the incoming log data into a series of Fields,
                  normalizing and/or aggregating both batch and event format into batch
                  format, which is used throughout the rest of doorman.
              Severity: Minor
              Found in doorman/utils.py - About 2 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 create_query_pack_from_upload has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              def create_query_pack_from_upload(upload):
                  '''
                  Create a pack and queries from a query pack file. **Note**, if a
                  pack already exists under the filename being uploaded, then any
                  queries defined here will be added to the existing pack! However,
              Severity: Minor
              Found in doorman/utils.py - About 2 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 learn_from_result has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              def learn_from_result(result, node):
                  if not result['data']:
                      return
              
                  capture_columns = set(
              Severity: Minor
              Found in doorman/utils.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 test_enroll_secret_tags has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def test_enroll_secret_tags(self, db, node, testapp):
                      testapp.app.config['DOORMAN_ENROLL_SECRET_TAG_DELIMITER'] = ':'
                      testapp.app.config['DOORMAN_EXPECTS_UNIQUE_HOST_ID'] = True
                      enroll_secret = testapp.app.config['DOORMAN_ENROLL_SECRET'][0]
                      resp = testapp.post_json(url_for('api.enroll'), {
              Severity: Minor
              Found in tests/test_functional.py - About 1 hr to fix

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

                    def __init__(self, name, query=None, sql=None, interval=3600, platform=None,
                Severity: Major
                Found in doorman/models.py - About 1 hr to fix

                  Function test_config has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def test_config(self):
                          node = NodeFactory(host_identifier='foo')
                          tag = Tag.create(value='foo')
                          node.tags.append(tag)
                          node.save()
                  Severity: Minor
                  Found in tests/test_models.py - About 1 hr to fix

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

                    def distributed_write(node=None):
                        '''
                        '''
                        data = request.get_json()
                    
                    
                    Severity: Minor
                    Found in doorman/api.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 test_configuration_has_all_required_values has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def test_configuration_has_all_required_values(self, node, testapp):
                            tag = TagFactory(value='foobar')
                            tag2 = TagFactory(value='barbaz')
                            pack = PackFactory(name='foobar')
                            pack.tags.append(tag)
                    Severity: Minor
                    Found in tests/test_functional.py - About 1 hr to fix

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

                          def __init__(self, line=None, message=None, severity=None,
                      Severity: Major
                      Found in doorman/models.py - About 1 hr to fix

                        Function add_distributed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def add_distributed():
                            form = AddDistributedQueryForm()
                            form.set_choices()
                        
                            if form.validate_on_submit():
                        Severity: Minor
                        Found in doorman/manage/views.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 node_required has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def node_required(f):
                            @wraps(f)
                            def decorated_function(*args, **kwargs):
                                # in v1.7.4, the Content-Encoding header is set when
                                # --logger_tls_compress=true
                        Severity: Minor
                        Found in doorman/api.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

                        Severity
                        Category
                        Status
                        Source
                        Language