hackedteam/vector-edk

View on GitHub
vector-uefi/fd/tool/chipsec/helper/linux/helper.py

Summary

Maintainability
F
5 days
Test Coverage

LinuxHelper has 42 functions (exceeds 20 allowed). Consider refactoring.
Open

class LinuxHelper:

    def __init__(self):
        import platform
        self.os_system  = platform.system()
Severity: Minor
Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py - About 5 hrs to fix

    File helper.py has 358 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/helper/linux/helper.py - About 4 hrs to fix

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

          def EFIVARS_set_EFI_variable(self, name, guid, value, attrs=None):
              if not name:
                  name = '*'
              if not guid:
                  guid = '*'
      Severity: Minor
      Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.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 do_hypercall has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def do_hypercall(self, vector, arg1, arg2, arg3, arg4, arg5, use_peach):
      Severity: Major
      Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py - About 50 mins to fix

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

            def send_sw_smi( self, SMI_code_data, _rax, _rbx, _rcx, _rdx, _rsi, _rdi ):
        Severity: Major
        Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py - About 50 mins to fix

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

              def VARS_list_EFI_variables ( self, infcls=2 ):
                  varlist = os.listdir('/sys/firmware/efi/vars')
                  variables = dict()
                  for v in varlist:
                      name = v[:-37]
          Severity: Minor
          Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.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

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

              def VARS_get_efivar_from_sys( self, filename ):     
                  off = 0
                  buf = list()
                  hdr = 0
                  try:
          Severity: Minor
          Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.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

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

              def VARS_set_EFI_variable(self,  name, guid, value ):
                  ret = True
                  if not name:
                      name = '*'
                  if not guid:
          Severity: Minor
          Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.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

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

              def EFIVARS_list_EFI_variables ( self, infcls=2 ):
                  varlist = os.listdir('/sys/firmware/efi/efivars')
                  variables = dict()
                  for v in varlist:
                      name = v[:-37]
          Severity: Minor
          Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.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

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

              def write_pci_reg( self, bus, device, function, offset, value, size = 4 ):
          Severity: Minor
          Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py - About 45 mins to fix

            Function read_pci_reg has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def read_pci_reg( self, bus, device, function, offset, size = 4 ):
            Severity: Minor
            Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py - About 35 mins to fix

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

                  def init( self ):
                      x64 = True if sys.maxsize > 2**32 else False
                      global _DEV_FH
                      _DEV_FH = None
                      
              Severity: Minor
              Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.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

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

                  def VARS_list_EFI_variables ( self, infcls=2 ):
                      varlist = os.listdir('/sys/firmware/efi/vars')
                      variables = dict()
                      for v in varlist:
                          name = v[:-37]
              Severity: Major
              Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py and 1 other location - About 1 day to fix
              vector-uefi/fd/tool/chipsec/helper/linux/helper.py on lines 401..413

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

              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

                  def EFIVARS_list_EFI_variables ( self, infcls=2 ):
                      varlist = os.listdir('/sys/firmware/efi/efivars')
                      variables = dict()
                      for v in varlist:
                          name = v[:-37]
              Severity: Major
              Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py and 1 other location - About 1 day to fix
              vector-uefi/fd/tool/chipsec/helper/linux/helper.py on lines 332..344

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

              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

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

                      try:
                          f = open('/sys/firmware/efi/efivars/'+filename, 'r')
                          data = f.read()
                          attr = struct.unpack_from("<I",data)[0] 
                          data = data[4:]
              Severity: Major
              Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py and 1 other location - About 3 hrs to fix
              vector-uefi/fd/tool/chipsec/helper/linux/helper.py on lines 384..389

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

              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

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

                  try:
                          f = open('/sys/firmware/efi/efivars/'+filename, 'r')
                          data = f.read() 
                          attr = struct.unpack_from("<I",data)[0]   
                          data = data[4:]
              Severity: Major
              Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py and 1 other location - About 3 hrs to fix
              vector-uefi/fd/tool/chipsec/helper/linux/helper.py on lines 417..422

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

              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

                      try:
                          f =open('/sys/firmware/efi/vars/'+filename+'/data', 'r')
                      data = f.read()
                          f.close()
              
              Severity: Major
              Found in vector-uefi/fd/tool/chipsec/helper/linux/helper.py and 1 other location - About 1 hr to fix
              vector-uefi/fd/tool/chipsec/helper/linux/helper.py on lines 384..395

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

              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