node-opcua/node-opcua-crypto

View on GitHub

Showing 108 of 108 total issues

Avoid too many return statements within this function.
Open

            return {
                status: "BadCertificateInvalid",
                reason: "subjectKeyIdentifier authorityKeyIdentifier in child certificate do not match subjectKeyIdentifier of parent certificate",
            };
Severity: Major
Found in packages/node-opcua-crypto/source/verify_certificate_signature.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return {
            status: "Good",
            reason: `certificate chain is valid(length = ${certificateChain.length})`,
        };
    Severity: Major
    Found in packages/node-opcua-crypto/source/verify_certificate_signature.ts - About 30 mins to fix

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

      export async function _coercePrivateKey(privateKey: any): Promise<KeyObject> {
          const KeyObject = (crypto as any).KeyObject;
          if (privateKey instanceof Buffer) {
              const privateKey1 = await derToPrivateKey(privateKey); //
              return KeyObject.from(privateKey1);
      Severity: Minor
      Found in packages/node-opcua-crypto/source/x509/coerce_private_key.ts - 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 toPem has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export function toPem(raw_key: Buffer | string, pem: string): string {
          assert(raw_key, "expecting a key");
          assert(typeof pem === "string");
          let pemType = identifyPemType(raw_key);
          if (pemType) {
      Severity: Minor
      Found in packages/node-opcua-crypto/source/crypto_utils.ts - 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 _readGeneralNames has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function _readGeneralNames(buffer: Buffer, block: BlockInfo) {
          const _data: { [key: number]: { name: string; type: string } } = {
              1: { name: "rfc822Name", type: "IA5String" },
              2: { name: "dNSName", type: "IA5String" },
              3: { name: "x400Address", type: "ORAddress" },
      Severity: Minor
      Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - 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 parseBitString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export function parseBitString(buffer: Buffer, start: number, end: number, maxLength: number): string {
          const unusedBit = buffer.readUInt8(start),
              lenBit = ((end - start - 1) << 3) - unusedBit,
              intro = "(" + lenBit + " bit)\n";
      
      
      Severity: Minor
      Found in packages/node-opcua-crypto/source/asn1.ts - 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

      Parsing error: parser.parse is not a function
      Open

      const { exploreCertificateInfo } = require("../../node-opcua-crypto");

      For more information visit Source: http://eslint.org/docs/rules/

      HACK found
      Open

              createVerify("RSA-SHA256").update("Hello**HACK**World").verify(alice_public_key, signature).should.equal(false);
      Severity
      Category
      Status
      Source
      Language