natlas/natlas-libnmap

View on GitHub

Showing 30 of 120 total issues

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

    def __init__(
Severity: Major
Found in libnmap/objects/host.py - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if not isinstance(tdict[tkey], list):
                                tdict[tkey] = [
                                    tdict[tkey],
                                ]
                            tdict[tkey].append(telem.text)
    Severity: Major
    Found in libnmap/parser.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      for cpe in osm.get_cpe():
                          print(f"\t    CPE: {cpe}")
      Severity: Major
      Found in examples/check_cpe.py - About 45 mins to fix

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

            def __init__(
        Severity: Minor
        Found in libnmap/objects/service.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          for osc in osm.osclasses:
                              print(f"\tOS Class: {osc.description}")
                              for cpe in osc.cpelist:
                                  print(f"\tCPE: {cpe.cpestring}")
                  else:
          Severity: Major
          Found in examples/os_fingerprint.py - About 45 mins to fix

            Function __parse_os_fingerprint has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def __parse_os_fingerprint(cls, os_data):
                    """
                        Private method parsing the data from an OS fingerprint (-O).
                        Contents of <os> is returned as a dict.
            
            
            Severity: Minor
            Found in libnmap/parser.py - About 25 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 osclass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def osclass(self, min_accuracy=90):
                    warnings.warn(
                        "NmapOSFingerprint.osclass() is deprecated: "
                        "use NmapOSFingerprint.osclasses() if applicable",
                        DeprecationWarning,
            Severity: Minor
            Found in libnmap/objects/os.py - About 25 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 osclasses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def osclasses(self, min_accuracy=0):
                    osc_array = []
                    for _osm in self.osmatches:
                        for _osc in _osm.osclasses:
                            if _osc.accuracy >= min_accuracy:
            Severity: Minor
            Found in libnmap/objects/os.py - About 25 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, osmatch_dict):
                    _osmatch_dict = osmatch_dict["osmatch"]
                    if (
                        "name" not in _osmatch_dict
                        or "line" not in _osmatch_dict
            Severity: Minor
            Found in libnmap/objects/os.py - About 25 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 _parse_xml_report has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _parse_xml_report(cls, root=None):
                    """
                        This method parses out a full nmap scan report from its XML root
                        node: <nmaprun>.
            
            
            Severity: Minor
            Found in libnmap/parser.py - About 25 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