GoVanguard/legion

View on GitHub

Showing 130 of 217 total issues

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

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

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

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

    def switchToolTabClick(self):                                       # TODO: check for duplicate code.
        if self.ToolSettingsTab.tabText(self.ToolSettingsTab.currentIndex()) == 'Host Commands':
            self.toolForHostsTableWidget.selectRow(0)
            self.updateToolForHostInformation(False)
            
Severity: Minor
Found in ui/settingsDialog.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 NmapImporter.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
LEGION (https://gotham-security.com)
Copyright (c) 2023 Gotham Security

    This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
Severity: Minor
Found in app/importers/NmapImporter.py - About 2 hrs to fix

File auxiliary.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

"""
LEGION (https://gotham-security.com)
Copyright (c) 2023 Gotham Security
Severity: Minor
Found in app/auxiliary.py - About 2 hrs to fix

Function runStagedNmap has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def runStagedNmap(self, targetHosts, discovery = True, stage = 1, stop = False):
        log.info("runStagedNmap called for stage {0}".format(str(stage)))
        runningFolder = self.logic.activeProject.properties.runningFolder
        if not stop:
            textbox = self.view.createNewTabForHost(str(targetHosts), 'nmap (stage ' + str(stage) + ')', True)
Severity: Minor
Found in controller/controller.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 buildHydraCommand has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def buildHydraCommand(self, runningfolder, userlistPath, passlistPath):
        
        self.ip = self.ipTextinput.text()
        self.port = self.portTextinput.text()
        self.service = str(self.serviceComboBox.currentText())
Severity: Minor
Found in ui/dialogs.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 contextMenuServicesTableView has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def contextMenuServicesTableView(self, pos):
        if len(self.ui.ServicesTableView.selectionModel().selectedRows()) > 0:
            # if there is only one row selected, get service name
            if len(self.ui.ServicesTableView.selectionModel().selectedRows()) == 1:
                row = self.ui.ServicesTableView.selectionModel().selectedRows()[len(
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

Function setupHostCommandsTab has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setupHostCommandsTab(self):
        self.toolForHostsTableWidget = QtWidgets.QTableWidget(self.HostActionsWidget)
        self.toolForHostsTableWidget.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
        self.toolForHostsTableWidget.setFixedWidth(180)
        self.toolForHostsTableWidget.setShowGrid(False)                 # to make the cells of the table read only
Severity: Major
Found in ui/settingsDialog.py - About 2 hrs to fix

Function setupGeneralTab has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setupGeneralTab(self):
        self.terminalLabel = QtWidgets.QLabel()
        self.terminalLabel.setText('Terminal')
        self.terminalLabel.setFixedWidth(150)
        self.terminalComboBox = QtWidgets.QComboBox()
Severity: Major
Found in ui/settingsDialog.py - About 2 hrs to fix

Function setupLeftPanel has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setupLeftPanel(self):
        self.HostsTabWidget = QtWidgets.QTabWidget(self.splitter)
        self.sizePolicy.setHeightForWidth(self.HostsTabWidget.sizePolicy().hasHeightForWidth())
        self.HostsTabWidget.setSizePolicy(self.sizePolicy2)
        self.HostsTabWidget.setObjectName(_fromUtf8("HostsTabWidget"))
Severity: Major
Found in ui/gui.py - About 2 hrs to fix

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

    def sort(self, Ncol, order):
        
        self.layoutAboutToBeChanged.emit()
        array = []
        
Severity: Minor
Found in ui/models/hostmodels.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 toolHostsClick has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def toolHostsClick(self):
        if self.ui.ToolHostsTableView.selectionModel().selectedRows():
            row = self.ui.ToolHostsTableView.selectionModel().selectedRows()[len(
                self.ui.ToolHostsTableView.selectionModel().selectedRows())-1].row()
            self.viewState.tool_host_clicked = self.ToolHostsTableModel.getProcessIdForRow(row)
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

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

    def processFinished(self, qProcess):
        processRepository = self.logic.activeProject.repositoryContainer.processRepository
        try:
            if not processRepository.isKilledProcess(
                    str(qProcess.id)):  # if process was not killed
Severity: Minor
Found in controller/controller.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