From 875811d13ee551cb3037c3e0e9dfee19010763c5 Mon Sep 17 00:00:00 2001 From: Julien Lengrand-Lambert Date: Wed, 25 Apr 2018 21:54:12 +0200 Subject: [PATCH] Add new flag to disable certificates verification --- index.js | 6 ++++++ .../disableCertificateVerification/index.js | 13 +++++++++++++ yarn.lock | 4 ---- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 lib/commands/disableCertificateVerification/index.js diff --git a/index.js b/index.js index fa8be81..e8d0001 100755 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const { configure } = require('./lib/commands/configure'); const { verify } = require('./lib/commands/verify'); const { getAllAssigned } = require('./lib/commands/getAllAssigned'); const { getAllSubmitted } = require('./lib/commands/getAllSubmitted'); +const { disableCertificateVerification } = require('./lib/commands/disableCertificateVerification'); const { readConfig } = require('./lib/utils/readConfig'); @@ -35,6 +36,11 @@ const options = [ trigger: '-v --verify', description: 'Verify your config is correct', fn: verify + }, + { + trigger: '-s --self-signed', + description: 'disables the verification of certificates when configuring mergify', + fn: disableCertificateVerification } ]; diff --git a/lib/commands/disableCertificateVerification/index.js b/lib/commands/disableCertificateVerification/index.js new file mode 100644 index 0000000..7202661 --- /dev/null +++ b/lib/commands/disableCertificateVerification/index.js @@ -0,0 +1,13 @@ +const { logger } = require('../../utils/logger'); +const chalk = require('chalk'); + +const disableCertificateVerification = async() => { + logger.log(chalk.red.bold('⚠️ Disabling certificate verification. This is unsafe and should only be used as last resort.')); + process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; + return; +}; + +module.exports = { + disableCertificateVerification +}; + \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 9affd21..fc33827 100644 --- a/yarn.lock +++ b/yarn.lock @@ -572,10 +572,6 @@ cli-cursor@^2.1.0: dependencies: restore-cursor "^2.0.0" -cli-spinner@^0.2.8: - version "0.2.8" - resolved "https://registry.yarnpkg.com/cli-spinner/-/cli-spinner-0.2.8.tgz#8169d9ffae870676445e6ee4397e95a7a15bd805" - cli-spinners@^1.1.0: version "1.3.1" resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.3.1.tgz#002c1990912d0d59580c93bd36c056de99e4259a"