marcus67/little_brother

View on GitHub

Showing 111 of 152 total issues

Avoid deeply nested control flow statements.
Open

                        if not unix_user_handler_config.is_active():
                            unix_user_handler_config.admin_username = status_server_config.admin_username
                            unix_user_handler_config.admin_password = status_server_config.admin_password

Severity: Major
Found in little_brother/app.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                for device in devices:
                                    if request.form['submit'] == device.delete_html_key:
                                        self.device_entity_manager.delete_device(
                                            p_session_context=session_context, p_id=device.id)
    
    
    Severity: Major
    Found in little_brother/web/devices_view_handler.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if self.prometheus_client is not None:
                                  self.prometheus_client.count_forced_logouts(p_username=p_user.username)
      
      
      Severity: Major
      Found in little_brother/process_handler_manager.py - About 45 mins to fix

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

            def __init__(self, p_version=None, p_revision=None, p_python_version=None,
        Severity: Minor
        Found in little_brother/client_stats.py - About 45 mins to fix

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

              def queue_event(self, p_event, p_to_master=False, p_is_action=False):
          
                  if p_is_action:
                      if p_event.hostname == self._host_name:
                          self.queue_event_locally(p_event=p_event)
          Severity: Minor
          Found in little_brother/event_handler.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, p_username, p_reference_time, p_max_lookback_in_days, p_min_activity_duration,
          Severity: Minor
          Found in little_brother/process_statistics.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if (pinfo.processname is None or
                                        (pinfo.processname is not None and user.regex_process_name_pattern.match(
                                            pinfo.processname))):
                                    stat_info = user_stat_infos.get(ruleset.context)
            
            
            Severity: Major
            Found in little_brother/process_statistics.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if pinfo.end_time is not None:
                                              event = self.create_admin_event_process_start_from_pinfo(p_pinfo=pinfo)
                                              events.append(event)
              
              
              Severity: Major
              Found in little_brother/client_process_handler.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if current_pinfo is not None:
                                            event = self.create_admin_event_process_end_from_pinfo(
                                                p_pinfo=current_pinfo,
                                                p_reference_time=p_reference_time)
                                            events.append(event)
                Severity: Major
                Found in little_brother/client_device_handler.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if current_pinfo is None:
                                              event = admin_event.AdminEvent(
                                                  p_event_type=admin_event.EVENT_TYPE_PROCESS_START,
                                                  p_hostname=device_info.hostname,
                                                  p_hostlabel=device_info.device_name,
                  Severity: Major
                  Found in little_brother/client_device_handler.py - About 45 mins to fix

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

                        def set_time_extension_for_session(self, p_session_context, p_user_name, p_delta, p_session_active,
                    Severity: Minor
                    Found in little_brother/persistence/persistent_time_extension_entity_manager.py - About 45 mins to fix

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

                          def get_admin_info_for_user(self, p_session_context, p_user_infos, p_time_extensions, p_days, p_username):
                      Severity: Minor
                      Found in little_brother/admin_data_handler.py - About 35 mins to fix

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

                        def get_process_statistics(
                        Severity: Minor
                        Found in little_brother/process_statistics.py - About 35 mins to fix

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

                              def set_time_extension(cls, p_session_context, p_username, p_reference_datetime, p_start_datetime, p_time_delta):
                          Severity: Minor
                          Found in little_brother/persistence/persistent_time_extension_entity_manager.py - About 35 mins to fix

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

                                def __init__(self, p_is_master, p_host_name, p_client_stats: ClientStats, p_maximum_client_ping_interval=None,
                            Severity: Minor
                            Found in little_brother/client_info.py - About 35 mins to fix

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

                                  def get_user_info_for_user(self, p_session_context, p_user, p_reference_time,
                              Severity: Minor
                              Found in little_brother/admin_data_handler.py - About 35 mins to fix

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

                                    def __init__(self,
                                Severity: Minor
                                Found in little_brother/process_handler_manager.py - About 35 mins to fix

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

                                      def __init__(self, p_device_name, p_max_active_ping_delay, p_min_activity_duration, p_sample_size,
                                  Severity: Minor
                                  Found in little_brother/client_device_handler.py - About 35 mins to fix

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

                                        def set_time_extension_for_admin_info_and_session(self, p_session_context, p_user_name, p_delta, p_admin_info,
                                    Severity: Minor
                                    Found in little_brother/persistence/persistent_time_extension_entity_manager.py - About 35 mins to fix

                                      Function read_forward_entries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def read_forward_entries(self):
                                      
                                              if self._entries is not None and self._last_table_scan is not None:
                                                  if datetime.datetime.now() < self._last_table_scan + datetime.timedelta(seconds=self._config.cache_ttl):
                                                      return
                                      Severity: Minor
                                      Found in little_brother/devices/firewall_handler.py - About 35 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