testcontainers / testcontainers-node

Testcontainers is a NodeJS library that supports tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.com
MIT License
1.87k stars 183 forks source link

RandomUuid.nextUuid use of md5 hash fails on FIPS enabled machine #804

Closed jej2003 closed 1 month ago

jej2003 commented 2 months ago

I am trying to use testcontainers on a machine with FIPS enabled. When running I am getting the following error because of the use of the md5 hash on a FIPS enabled machine. The code is fairly straight forward and is incldued below for situational awareness.

error:060800C8:digital envelope routines:EVP_DigestInit_ex:disabled for FIPS
      24 |   }
      25 |
    > 26 |   mysqlContainer = await new GenericContainer('mysql:8.0.32')
         |                    ^
      27 |     .withEnvironment({
      28 |       MYSQL_ALLOW_EMPTY_PASSWORD: 'true',
      29 |       MYSQL_DATABASE: 'test',
      at hash (../node_modules/testcontainers/src/common/hash.ts:4:17)
      at RandomUuid.nextUuid (../node_modules/testcontainers/src/common/uuid.ts:10:16)
      at ../node_modules/testcontainers/src/reaper/reaper.ts:31:94
      at withFileLock (../node_modules/testcontainers/src/common/file-lock.ts:14:12)
      at getReaper (../node_modules/testcontainers/src/reaper/reaper.ts:29:12)
      at GenericContainer.start (../node_modules/testcontainers/src/generic-container/generic-container.ts:104:22)
      at Object.<anonymous> (src/service/service.test.ts:26:20)
  mysqlContainer = await new GenericContainer('mysql:8.0.32')
    .withEnvironment({
      MYSQL_ALLOW_EMPTY_PASSWORD: 'true',
      MYSQL_DATABASE: 'test',
    })
    .withExposedPorts(3306)
    .withStartupTimeout(500000)
    .start()

What is the recommended way to run testcontaienrs-node on a FIPS enabled machine?

cristianrgreco commented 2 months ago

There's no reason why we couldn't use a sha256 hash instead of md5, I'll raise a PR