twilio / twilio-cli

Unleash the power of Twilio from your command prompt
MIT License
162 stars 79 forks source link

CLI not interacting correctly with https proxy #223

Closed gkanz closed 3 years ago

gkanz commented 4 years ago

Issue Summary

We are using the cli behind a https proxy. The axios http client used by the cli is using the environment variables and sends it's request via the forward proxy (as specified by the http_proxy and https_proxy environment variables). However, it is not issuing a CONNECT for the https proxy. This results in a failed request.

See https://github.com/axios/axios/issues/2072

Steps to Reproduce

  1. Have a locally running forward proxy
  2. Be on a network behind a https authenticating proxy
  3. Run any twilio cli command

Reproduce Behaviour

This will cause a GET to be sent to the forward proxy.

const axios = require('axios');
axios.get('https://www.twilio.com')
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  })
  .then(function () {
  });

Example of good behaviour

curl https://www.twilio.com

Suggested fix

This will cause a CONNECT to be sent to the forward proxy.

const HttpsProxyAgent = require('https-proxy-agent');

const axiosConfig = {
    proxy: false,
    httpsAgent: new HttpsProxyAgent(process.env.http_proxy)
};

const axios = require('axios').create(axiosConfig);
axios.get('https://www.twilio.com')
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  })
  .then(function () {
  });

The impacted code is actually in the cli-core repo: https://github.com/twilio/twilio-cli-core/blob/main/src/services/cli-http-client.js.

Exception/Log

See below.

Technical details:

thinkingserious commented 4 years ago

Hello @gkanz,

Thank you for taking to the time to report!

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

With best regards,

Elmer

childish-sambino commented 4 years ago

Internal tracking ID: DI-889