diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /config/helpers/patched_crypto.js | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'config/helpers/patched_crypto.js')
-rw-r--r-- | config/helpers/patched_crypto.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/config/helpers/patched_crypto.js b/config/helpers/patched_crypto.js new file mode 100644 index 00000000000..235242195b1 --- /dev/null +++ b/config/helpers/patched_crypto.js @@ -0,0 +1,22 @@ +/** + * Webpack 4 uses md4 internally because it is fast. + * Some loaders also use md5 directly. + * It is not available systems with FIPS enabled node. + * + * This is a hack to monkey patch the crypto function to use + * another algorithm if md4 or md5 is expected. + * + * https://github.com/webpack/webpack/issues/13572#issuecomment-923736472 + * + * This hack can be removed once we upgrade to webpack v5 as + * it includes native support for configuring hash options: + * https://github.com/webpack/webpack/pull/14306 + */ +const crypto = require('crypto'); + +const cryptoHashOriginal = crypto.createHash; + +crypto.createHash = (algorithm) => + cryptoHashOriginal(['md4', 'md5'].includes(algorithm) ? 'sha256' : algorithm); + +module.exports = crypto; |