node-opcua/node-opcua-crypto

View on GitHub
packages/node-opcua-crypto-test/test/test_crypto.ts

Summary

Maintainability
F
3 days
Test Coverage

File test_crypto.ts has 378 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// ---------------------------------------------------------------------------------------------------------------------
// node-opcua-crypto
// ---------------------------------------------------------------------------------------------------------------------
// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org
// Copyright (c) 2022-2024 - Sterfive.com
Severity: Minor
Found in packages/node-opcua-crypto-test/test/test_crypto.ts - About 5 hrs to fix

    Function make_suite has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function make_suite(algorithm: string, signatureLength: number) {
            it("should sign with a private key and verify with the public key - " + algorithm, function () {
                const alice_private_key = readPrivateKey(alice_private_key_filename);
                const options1 = {
                    algorithm,
    Severity: Major
    Found in packages/node-opcua-crypto-test/test/test_crypto.ts - About 3 hrs to fix

      HACK found
      Open

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

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

              it("should sign with a other private key and verify with a OUT OF DATE certificate (ASCII) - " + algorithm, function () {
                  const privateKey = readPrivateKey(bob_private_key_filename);
                  const options1 = {
                      algorithm,
                      signatureLength,
      Severity: Major
      Found in packages/node-opcua-crypto-test/test/test_crypto.ts and 1 other location - About 6 hrs to fix
      packages/node-opcua-crypto-test/test/test_crypto.ts on lines 523..544

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

      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

              it("should sign with a private key and verify with the certificate (DER) - " + algorithm, function () {
                  const alice_private_key = readPrivateKey(alice_private_key_filename);
                  const options1 = {
                      algorithm,
                      signatureLength,
      Severity: Major
      Found in packages/node-opcua-crypto-test/test/test_crypto.ts and 1 other location - About 6 hrs to fix
      packages/node-opcua-crypto-test/test/test_crypto.ts on lines 546..570

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

      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

      function encrypt_buffer(buffer: Buffer, algorithm: string, key: Buffer): Buffer {
          const iv = Buffer.alloc(16, 0); // Initialization vector.
          const cipher = createCipheriv(algorithm, key, iv);
          const encrypted_chunks: Buffer[] = [];
          encrypted_chunks.push(cipher.update(buffer));
      Severity: Major
      Found in packages/node-opcua-crypto-test/test/test_crypto.ts and 1 other location - About 3 hrs to fix
      packages/node-opcua-crypto-test/test/test_crypto.ts on lines 107..114

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

      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

      function decrypt_buffer(buffer: Buffer, algorithm: string, key: Buffer): Buffer {
          const iv = Buffer.alloc(16, 0); // Initialization vector.
          const decipher = createDecipheriv(algorithm, key, iv);
          const decrypted_chunks: Buffer[] = [];
          decrypted_chunks.push(decipher.update(buffer));
      Severity: Major
      Found in packages/node-opcua-crypto-test/test/test_crypto.ts and 1 other location - About 3 hrs to fix
      packages/node-opcua-crypto-test/test/test_crypto.ts on lines 98..105

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

      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

                  should(function () {
                      encryptedBuffer = publicEncrypt(Buffer.allocUnsafe(128), john_public_key, RSA_PKCS1_OAEP_PADDING);
                      console.log(" D encryptedBuffer length = ", encryptedBuffer.length);
                      //xx encryptedBuffer.length.should.eql(128);
                  }).throwError();
      Severity: Major
      Found in packages/node-opcua-crypto-test/test/test_crypto.ts and 1 other location - About 1 hr to fix
      packages/node-opcua-crypto-test/test/test_crypto.ts on lines 270..274

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

      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

                  should(function () {
                      encryptedBuffer = publicEncrypt(Buffer.allocUnsafe(259), bob_public_key, RSA_PKCS1_OAEP_PADDING);
                      console.log(" D encryptedBuffer length = ", encryptedBuffer.length);
                      //xx encryptedBuffer.length.should.eql(128);
                  }).throwError();
      Severity: Major
      Found in packages/node-opcua-crypto-test/test/test_crypto.ts and 1 other location - About 1 hr to fix
      packages/node-opcua-crypto-test/test/test_crypto.ts on lines 204..208

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

      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