hackedteam/vector-edk

View on GitHub
vector-uefi/fd/tool/chipsec/hal/uefi_platform.py

Summary

Maintainability
F
4 days
Test Coverage

Function getEFIvariables_NVAR has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

def getEFIvariables_NVAR( nvram_buf ):
   start = nvram_buf.find( NVAR_EFIvar_signature )
   nvram_size = len(nvram_buf)
   EFI_HDR_NVAR = "<4sH3sB"
   nvar_size = struct.calcsize(EFI_HDR_NVAR)
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py - About 5 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 EFIvar_EVSA has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

def EFIvar_EVSA(nvram_buf):
   image_size = len(nvram_buf)
   sn = 0
   EVSA_RECORD = "<IIII"
   evsa_rec_size = struct.calcsize(EVSA_RECORD)
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py - About 5 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 uefi_platform.py has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/local/bin/python
#CHIPSEC: Platform Security Assessment Framework
#Copyright (c) 2010-2014, Intel Corporation
# 
#This program is free software; you can redistribute it and/or
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py - About 5 hrs to fix

    Function getNVstore_EVSA has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def getNVstore_EVSA( nvram_buf ):
       l = (-1, -1, None)
       FvOffset, FsGuid, FvLength, FvAttributes, FvHeaderLength, FvChecksum, ExtHeaderOffset, FvImage, CalcSum = NextFwVolume(nvram_buf) 
       while FvOffset != None:
          if (FsGuid == VARIABLE_STORE_FV_GUID):
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.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 _getEFIvariables_VSS has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _getEFIvariables_VSS( nvram_buf, _fwtype ):
        nvsize = len(nvram_buf)
        if (FWType.EFI_FW_TYPE_VSS == _fwtype):
            hdr_fmt  = HDR_FMT_VSS
        elif (FWType.EFI_FW_TYPE_VSS_NEW == _fwtype):
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.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 getNVstore_NVAR has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def getNVstore_NVAR( nvram_buf ):
       l = (-1, -1, None)
       FvOffset, FsGuid, FvLength, FvAttributes, FvHeaderLength, FvChecksum, ExtHeaderOffset, FvImage, CalcSum = NextFwVolume(nvram_buf)
       while FvOffset != None:
          polarity = bit_set(FvAttributes, EFI_FVB2_ERASE_POLARITY)
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.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

    Consider simplifying this complex logical expression.
    Open

             if   (Tag0 == 0xED) or (Tag0 == 0xE1):  # guid
                GuidId, guid0, guid1, guid2, guid3 = struct.unpack(GUID_RECORD, value)
                g = guid_str(guid0, guid1, guid2, guid3)
                guid_map[GuidId] = g
             elif (Tag0 == 0xEE) or (Tag0 == 0xE2):  # var name
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py - About 1 hr to fix

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

      def getEFIvariables_NVAR_simple( nvram_buf ):
          nvsize = len(nvram_buf)
          hdr_fmt = NVAR_HDR_FMT
          hdr_size = struct.calcsize( hdr_fmt )
          variables = dict()
      Severity: Minor
      Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.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

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

      class EFI_HDR_VSS( namedtuple('EFI_HDR_VSS', 'StartId State Reserved Attributes NameSize DataSize guid0 guid1 guid2 guid3') ):
            __slots__ = ()
            def __str__(self):
                return """
      Header (VSS)
      Severity: Major
      Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py and 1 other location - About 5 hrs to fix
      vector-uefi/fd/tool/chipsec/helper/win/win32helper.py on lines 165..176

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

      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 3 locations. Consider refactoring.
      Open

      class EFI_HDR_NVAR1( namedtuple('EFI_HDR_NVAR1', 'StartId TotalSize Reserved1 Reserved2 Reserved3 Attributes State') ):
            __slots__ = ()
            def __str__(self):
                return """
      Header (NVAR)
      Severity: Major
      Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py and 2 other locations - About 2 hrs to fix
      vector-uefi/fd/tool/chipsec/cfg/common.py on lines 247..256
      vector-uefi/fd/tool/chipsec/modules/common/smm.py on lines 38..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 51.

      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 bit_set(lattributes, NVRAM_ATTR_EXTHDR):
               lesize, = struct.unpack("<H", nvram_buf[lof+lsize-2:lof+lsize])
      Severity: Major
      Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py and 1 other location - About 1 hr to fix
      vector-uefi/fd/tool/chipsec/hal/uefi_platform.py on lines 242..242

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

      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

               esize, = struct.unpack("<H", nvram_buf[nof+size-2:nof+size])
      Severity: Major
      Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py and 1 other location - About 1 hr to fix
      vector-uefi/fd/tool/chipsec/hal/uefi_platform.py on lines 270..271

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

      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

               guid0, guid1, guid2, guid3 = struct.unpack(GUID, nvram_buf[nof+nvar_size:nof+nvar_size+guid_size])
      Severity: Minor
      Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py and 1 other location - About 40 mins to fix
      vector-uefi/fd/tool/chipsec/hal/uefi_platform.py on lines 509..509

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

      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

               Tag0, Tag1, Size = struct.unpack(TLV_HEADER, nvram_buf[start + bof: start + bof + tlv_h_size])
      Severity: Minor
      Found in vector-uefi/fd/tool/chipsec/hal/uefi_platform.py and 1 other location - About 40 mins to fix
      vector-uefi/fd/tool/chipsec/hal/uefi_platform.py on lines 228..228

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

      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

      There are no issues that match your filters.

      Category
      Status