leifj/pyXMLSecurity

View on GitHub

Showing 26 of 80 total issues

Function _process_references has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

def _process_references(t, sig, verify_mode=True, sig_path=".//{%s}Signature" % NS['ds'], drop_signature=False):
    """
    :returns: hash algorithm as string
    """

Severity: Minor
Found in src/xmlsec/__init__.py - About 1 day 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 __init__.py has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# This code was inspired by https://github.com/andrewdyates/xmldsig
# and includes https://github.com/andrewdyates/rsa_x509_pem with
# permission from the author.

__author__ = 'leifj'
Severity: Minor
Found in src/xmlsec/__init__.py - About 5 hrs to fix

    Function sign_cmd has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def sign_cmd():
        """
        xmlsign command entrypoint
        """
    
    
    Severity: Minor
    Found in src/xmlsec/tools.py - About 4 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 sign_verify_test.py has 358 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from defusedxml import lxml
    from lxml import etree
    import os
    import copy
    import unittest
    Severity: Minor
    Found in src/xmlsec/test/sign_verify_test.py - About 4 hrs to fix

      File p11_test.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      Testing the PKCS#11 shim layer
      """
      
      __author__ = 'leifj'
      Severity: Minor
      Found in src/xmlsec/test/p11_test.py - About 3 hrs to fix

        Function sign has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        def sign(t, key_spec, cert_spec=None, reference_uri='', insert_index=0, sig_path=".//{%s}Signature" % NS['ds']):
            """
            Sign an XML document. This means to 'complete' all Signature elements in the XML.
        
            :param t: XML as lxml.etree
        Severity: Minor
        Found in src/xmlsec/__init__.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 verify_cmd has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def verify_cmd():
            """
            xmlverify command entrypoint
            """
        
        
        Severity: Minor
        Found in src/xmlsec/tools.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

        File crypto.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import io
        import os
        import base64
        import logging
        import threading
        Severity: Minor
        Found in src/xmlsec/crypto.py - About 2 hrs to fix

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

          def _verify(t, keyspec, sig_path=".//{%s}Signature" % NS['ds'], drop_signature=False):
              """
              Verify the signature(s) in an XML document.
          
              Throws an XMLSigException on any non-matching signatures.
          Severity: Minor
          Found in src/xmlsec/__init__.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 parse_uri has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          def parse_uri(pk11_uri):
              o = urlparse(pk11_uri)
              if o.scheme != 'pkcs11':
                  raise XMLSigException("Bad URI scheme in pkcs11 URI %s" % pk11_uri)
          
          
          Severity: Minor
          Found in src/xmlsec/pk11.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 unescape_xml_entities has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          def unescape_xml_entities(text):
              """
              Removes HTML or XML character references and entities from a text string.
              @param text The HTML (or XML) source text.
              @return The plain text, as a Unicode string, if necessary.
          Severity: Minor
          Found in src/xmlsec/utils.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 delete_elt has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          def delete_elt(elt):
              if elt.getparent() is None:
                  raise XMLSigException("Cannot delete root")
              if elt.tail is not None:
                  #logging.debug("tail: '%s'" % elt.tail)
          Severity: Minor
          Found in src/xmlsec/utils.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 _session has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def _session(library, slot=None, pin=None, pk11_uri=None):
              _session_lock.acquire()
          
              # XXX: adhoc fix -- should test cases where slot, pin and pk11_uri
              # contradict or both are 'None'
          Severity: Minor
          Found in src/xmlsec/pk11.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 add_enveloped_signature has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def add_enveloped_signature(t,
          Severity: Major
          Found in src/xmlsec/__init__.py - About 50 mins to fix

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

            def sign(t, key_spec, cert_spec=None, reference_uri='', insert_index=0, sig_path=".//{%s}Signature" % NS['ds']):
            Severity: Minor
            Found in src/xmlsec/__init__.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if nsprefix in r.nsmap:
                                      obj_copy.nsmap[nsprefix] = r.nsmap[nsprefix]
              
              
              Severity: Major
              Found in src/xmlsec/__init__.py - About 45 mins to fix

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

                def _load_keyspec(keyspec, private=False, signature_element=None):
                    if private and hasattr(keyspec, '__call__'):
                        return XMLSecCryptoCallable(keyspec)
                    if isinstance(keyspec, six.string_types):
                        if os.path.isfile(keyspec):
                Severity: Minor
                Found in src/xmlsec/crypto.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 _process_references has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def _process_references(t, sig, verify_mode=True, sig_path=".//{%s}Signature" % NS['ds'], drop_signature=False):
                Severity: Minor
                Found in src/xmlsec/__init__.py - About 35 mins to fix

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

                  def _transform(uri, t, tr=None, schema=None, sig_path=".//{%s}Signature" % NS['ds']):
                  Severity: Minor
                  Found in src/xmlsec/__init__.py - About 35 mins to fix

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

                    def _c14n(t, exclusive, with_comments, inclusive_prefix_list=None, schema=None):
                    Severity: Minor
                    Found in src/xmlsec/__init__.py - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language