natlas/natlas-libnmap

View on GitHub

Showing 30 of 120 total issues

File parser.py has 586 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-


try:
    import xml.etree.cElementTree as ET
Severity: Major
Found in libnmap/parser.py - About 1 day to fix

    File host.py has 385 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    
    from libnmap.diff import NmapDiff
    from libnmap.objects.os import NmapOSFingerprint
    
    
    Severity: Minor
    Found in libnmap/objects/host.py - About 5 hrs to fix

      NmapHost has 39 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class NmapHost(object):
          """
              NmapHost is a class representing a host object of NmapReport
          """
      
      
      Severity: Minor
      Found in libnmap/objects/host.py - About 5 hrs to fix

        File os.py has 341 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        
        import warnings
        from libnmap.objects.cpe import CPE
        
        
        Severity: Minor
        Found in libnmap/objects/os.py - About 4 hrs to fix

          File report.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          from libnmap.diff import NmapDiff
          
          
          class NmapReport(object):
          Severity: Minor
          Found in libnmap/objects/report.py - About 3 hrs to fix

            Function __parse_script has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                def __parse_script(cls, script_data):
                    """
                        Private method parsing the data from NSE scripts output
            
                        :param script_data: portion of XML describing the results of the
            Severity: Minor
            Found in libnmap/parser.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

            NmapReport has 26 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class NmapReport(object):
                """
                    NmapReport is the usual interface for the end user to
                    read scans output.
            
            
            Severity: Minor
            Found in libnmap/objects/report.py - About 3 hrs to fix

              NmapService has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class NmapService(object):
                  """
                      NmapService represents a nmap scanned service. Its id() is comprised
                      of the protocol and the port.
              
              
              Severity: Minor
              Found in libnmap/objects/service.py - About 2 hrs to fix

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

                    def __init__(self, osfp_data):
                        self.__osmatches = []
                        self.__ports_used = []
                        self.__fingerprints = []
                
                
                Severity: Minor
                Found in libnmap/objects/os.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 service.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # -*- coding: utf-8 -*-
                from libnmap.diff import NmapDiff
                from libnmap.objects.os import CPE
                
                
                
                Severity: Minor
                Found in libnmap/objects/service.py - About 2 hrs to fix

                  Function _parse_xml_host has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _parse_xml_host(cls, scanhost_data):
                          """
                              Protected method parsing a portion of a nmap scan result.
                              Receives a <host> XML tag representing a scanned host with
                              its services.
                  Severity: Minor
                  Found in libnmap/parser.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

                  NmapParser has 21 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class NmapParser(object):
                      @classmethod
                      def parse(cls, nmap_data=None, data_type="XML", incomplete=False):
                          """
                              Generic class method of NmapParser class.
                  Severity: Minor
                  Found in libnmap/parser.py - About 2 hrs to fix

                    Function __init__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __init__(
                            self,
                            portid,
                            protocol="tcp",
                            state=None,
                    Severity: Minor
                    Found in libnmap/objects/service.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 __init__ has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __init__(
                            self,
                            starttime: str = "",
                            endtime: str = "",
                            address: dict = None,
                    Severity: Minor
                    Found in libnmap/objects/host.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 print_diff_changed has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def print_diff_changed(obj1, obj2, changes):
                        for mkey in changes:
                            nested = nested_obj(mkey)
                            subobj1 = None
                            subobj2 = None
                    Severity: Minor
                    Found in examples/diff_sample2.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 banner has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def banner(self):
                            """
                                Accessor for the service's banner. Only available
                                if the nmap option -sV or similar was used.
                    
                    
                    Severity: Minor
                    Found in libnmap/objects/service.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 print_diff_added has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def print_diff_added(obj1, obj2, added):
                        for akey in added:
                            nested = nested_obj(akey)
                            subobj1 = None
                            if nested is not None:
                    Severity: Minor
                    Found in examples/diff_sample2.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 print_diff_removed has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def print_diff_removed(obj1, obj2, removed):
                        for rkey in removed:
                            nested = nested_obj(rkey)
                            subobj2 = None
                            if nested is not None:
                    Severity: Minor
                    Found in examples/diff_sample2.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 _parse_xml_port has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _parse_xml_port(cls, scanport_data):
                            """
                                Protected method parsing a scanned service from a targeted host.
                                This protected method cannot be called directly.
                                A <port/> tag can be directly passed to parse() and the below
                    Severity: Minor
                    Found in libnmap/parser.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 _parse_xml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _parse_xml(cls, nmap_data=None, incomplete=False):
                            """
                                Protected class method used to process a specific data type.
                                In this case: XML. This method is called by cls.parse class
                                method and receives nmap scan results data (in XML).
                    Severity: Minor
                    Found in libnmap/parser.py - About 55 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