Hackman238/legion

View on GitHub

Showing 217 of 217 total issues

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

                if not self.__services[i]['product'] == None and not self.__services[i]['product'] == '':
                    value = str(self.__services[i]['product'])
Severity: Major
Found in ui/models/servicemodels.py and 1 other location - About 4 hrs to fix
ui/models/servicemodels.py on lines 86..87

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

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

                if not self.__services[row]['product'] == None and not self.__services[row]['product'] == '':
                    value = str(self.__services[row]['product'])
Severity: Major
Found in ui/models/servicemodels.py and 1 other location - About 4 hrs to fix
ui/models/servicemodels.py on lines 136..137

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

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 runToolsFor has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def runToolsFor(self, service, hostname, ip, port, protocol='tcp'):
        log.info('Running tools for: ' + service + ' on ' + ip + ':' + port)

        if service.endswith("?"):  # when nmap is not sure it will append a ?, so we need to remove it
            service=service[:-1]
Severity: Minor
Found in controller/controller.py - About 4 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 gui.py has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
"""
LEGION (https://shanewilliamscott.com)
Copyright (c) 2024 Shane Scott

Severity: Minor
Found in ui/gui.py - About 4 hrs to fix

    Function data has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def data(self, index, role):
            if role == QtCore.Qt.ItemDataRole.DecorationRole:                            # to show the open/closed/filtered icons
                if index.column() == 0 or index.column() == 2:
                    tmp_state = self.__services[index.row()]['state']
    
    
    Severity: Minor
    Found in ui/models/servicemodels.py - About 4 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 setupTerminalCommandsTab has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def setupTerminalCommandsTab(self):
            self.actionTerminalLabel = QtWidgets.QLabel()
            self.actionTerminalLabel.setText('Tools')
            
            self.toolForTerminalTableWidget = QtWidgets.QTableWidget(self.portTerminalActionsWidget)
    Severity: Major
    Found in ui/settingsDialog.py - About 4 hrs to fix

      Function setupPortCommandsTab has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def setupPortCommandsTab(self):
              self.label11 = QtWidgets.QLabel()
              self.label11.setText('Tools')
      
              self.toolForServiceTableWidget = QtWidgets.QTableWidget(self.PortActionsWidget)
      Severity: Major
      Found in ui/settingsDialog.py - About 4 hrs to fix

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

            def getProcessStatusForId(self, dbId):
                for i in range(len(self.__processes)):
                    if str(self.__processes[i]['id']) == str(dbId):
                        return self.__processes[i]['status']
        Severity: Major
        Found in ui/models/processmodels.py and 3 other locations - About 3 hrs to fix
        ui/models/hostmodels.py on lines 188..191
        ui/models/processmodels.py on lines 154..157
        ui/models/processmodels.py on lines 162..165

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

        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 getProcessPidForId(self, dbId):
                for i in range(len(self.__processes)):
                    if str(self.__processes[i]['id']) == str(dbId):
                        return self.__processes[i]['pid']
        Severity: Major
        Found in ui/models/processmodels.py and 3 other locations - About 3 hrs to fix
        ui/models/hostmodels.py on lines 188..191
        ui/models/processmodels.py on lines 162..165
        ui/models/processmodels.py on lines 167..170

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

        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 getProcessStatusForPid(self, pid):
                for i in range(len(self.__processes)):
                    if str(self.__processes[i]['pid']) == str(pid):
                        return self.__processes[i]['status']
        Severity: Major
        Found in ui/models/processmodels.py and 3 other locations - About 3 hrs to fix
        ui/models/hostmodels.py on lines 188..191
        ui/models/processmodels.py on lines 154..157
        ui/models/processmodels.py on lines 167..170

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

        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 getHostCheckStatusForIp(self, ip):
                for i in range(len(self.__hosts)):
                    if str(self.__hosts[i]['ip']) == str(ip):
                        return self.__hosts[i]['checked']
        Severity: Major
        Found in ui/models/hostmodels.py and 3 other locations - About 3 hrs to fix
        ui/models/processmodels.py on lines 154..157
        ui/models/processmodels.py on lines 162..165
        ui/models/processmodels.py on lines 167..170

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

        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

        AddSettingsDialog has 60 functions (exceeds 50 allowed). Consider refactoring.
        Open

        class AddSettingsDialog(QtWidgets.QDialog):  # dialog shown when the user selects settings menu
            def __init__(self, shell: Shell, parent=None):
                QtWidgets.QDialog.__init__(self, parent)
        
                self.setupLayout()
        Severity: Major
        Found in ui/settingsDialog.py - About 3 hrs to fix

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

                  if len(HostNode.getElementsByTagName('uptime')) > 0:
                      self.uptime = HostNode.getElementsByTagName('uptime')[0].getAttribute('seconds')
                      self.lastboot = HostNode.getElementsByTagName('uptime')[0].getAttribute('lastboot')
          Severity: Major
          Found in parsers/Host.py and 1 other location - About 3 hrs to fix
          parsers/Host.py on lines 45..47

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

          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

                  if len(HostNode.getElementsByTagName('extraports')) > 0:
                      self.state = HostNode.getElementsByTagName('extraports')[0].getAttribute('state')
                      self.count = HostNode.getElementsByTagName('extraports')[0].getAttribute('count')
          Severity: Major
          Found in parsers/Host.py and 1 other location - About 3 hrs to fix
          parsers/Host.py on lines 40..42

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

          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 updateToolForTerminalInformation has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def updateToolForTerminalInformation(self, update = True):
                  #if self.commandTabsValidate() == True:
                  if self.validateCommandTabs(self.terminalActionNameText, self.terminalLabelText, self.terminalCommandText):
                      # do not update anything the first time or when you remove a line
                      if self.terminalTableRow == -1 or update == False:
          Severity: Minor
          Found in ui/settingsDialog.py - About 3 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 updateToolForServiceInformation has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def updateToolForServiceInformation(self, update = True):
                  #if self.commandTabsValidate() == True:
                  if self.validateCommandTabs(self.portActionNameText, self.portLabelText, self.portCommandText):
                      # the first time do not update anything
                      if self.portTableRow == -1 or update == False:
          Severity: Minor
          Found in ui/settingsDialog.py - About 3 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 handleProcessAction has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def handleProcessAction(self, selectedProcesses, action):
                  if action.text() == 'Kill':
                      if self.view.killProcessConfirmation():
                          for p in selectedProcesses:
                              if p[1] != "Running":
          Severity: Minor
          Found in controller/controller.py - About 3 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 populateAutomatedAttacksTab has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def populateAutomatedAttacksTab(self):   # TODO: this one is still to big and ugly. needs work.
                  self.typeDic = {}
                  for i in range(len(self.settings.portActions)):
                      # the dictionary contains the name, the text input and the layout for each tool
                      self.typeDic.update({self.settings.portActions[i][1]:[QtWidgets.QLabel(),QtWidgets.QLineEdit(),
          Severity: Minor
          Found in ui/settingsDialog.py - About 3 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 setupRightPanel has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def setupRightPanel(self):
                  self.ServicesTabWidget = QtWidgets.QTabWidget()
                  self.ServicesTabWidget.setEnabled(True)
                  self.sizePolicy2.setHeightForWidth(self.ServicesTabWidget.sizePolicy().hasHeightForWidth())
                  self.ServicesTabWidget.setSizePolicy(self.sizePolicy2)
          Severity: Major
          Found in ui/gui.py - About 3 hrs to fix

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

                def callAddHosts(self):
                    hostListStr = str(self.adddialog.txtHostList.toPlainText()).replace(';',' ')
                    nmapOptions = []
                    scanMode = 'Unset'
            
            
            Severity: Minor
            Found in ui/view.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

            Severity
            Category
            Status
            Source
            Language