GithubHelp home page GithubHelp logo

twilio-cli-core's Introduction

twilio-cli-core

Learn with TwilioQuest

This module contains core functionality for the twilio-cli.

Requirements

Currently, Node 14+ is supported. We support the LTS versions of Node.

Base commands

BaseCommand

The base command class for all twilio-cli commands. Includes support for configuration management, logging, and output formatting.

TwilioClientCommand

A base command class for commands that need a Twilio client to make API requests. Handles loading credentials from the profile configuration.

Services

Output formats

Formatters to take a JSON array and write to the stdout. Current formatters include:

  • Columns (default, human readable)
  • JSON (raw API output)
  • TSV

CliRequestClient

A custom http client for the Twilio helper library to allow us to log API requests as well as modify the User-Agent header.

Usage with proxy

  • HTTP_PROXY: If using Twilio CLI behind a proxy, set the URL of the proxy in an environment variable called HTTP_PROXY.

Config

Manages the CLI configuration options, such as Twilio profiles and credentials.

Logger

Standardizes logging output of debug, info, warning, and error messages to stderr (all go to stderr to allow differentiation between command output and logging messages).

twilio-cli-core's People

Contributors

alecnicolas avatar asabuhere avatar charan678 avatar childish-sambino avatar david-amores-anz avatar dependabot[bot] avatar dprothero avatar eshanholtz avatar jennifermah avatar kridai avatar ktalebian avatar kwhinnery avatar maylonpedroso avatar onuzbee avatar philnash avatar ravali-rimmalapudi avatar sbansla avatar semantic-release-bot avatar sergiofbsilva avatar shrutiburman avatar shwetha-manvinkurke avatar sindhura3 avatar sr010 avatar thinkingserious avatar twilio-ci avatar twilio-dx avatar twilio-product-security avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twilio-cli-core's Issues

-o json changes naming scheme of top level keys

Issue Summary

When the json output mode is used, top level keys are converted from snake case to camel case. Lower level keys are not modified.

Steps to Reproduce

  1. Fetch CustomerProfile evaluation with curl: curl https://trusthub.twilio.com/v1/CustomerProfiles/BUba422222159fd9b24ec6ab18f391650d/Evaluations/EL97cbd107e00509fdb56c0bc30fec6991 -u '<redacted>'
  2. Fetch same evaluation with CLI, using 'raw' json output: twilio api:trusthub:v1:customer-profiles:evaluations:fetch --sid=EL97cbd107e00509fdb56c0bc30fec6991 --customer-profile-sid=BUba422222159fd9b24ec6ab18f391650d -o json --profile=brand-test
  3. Compare the json

Example

From twilio cli

...
    "accountSid": "AC6a4293256e150602674ce979da94c34c",
    "customerProfileSid": "BUba422222159fd9b24ec6ab18f391650d",
    "dateCreated": "2021-10-30T00:41:32.000Z",
    "policySid": "RNdfbf3fae0e1107f8aded0e7cead80bf5",
    "results": [
...

From CURL

...
"account_sid": "AC6a4293256e150602674ce979da94c34c", "date_created": "2021-10-30T00:41:32Z", "sid": "EL97cbd107e00509fdb56c0bc30fec6991", "policy_sid": "RNdfbf3fae0e1107f8aded0e7cead80bf5", "customer_profile_sid": "BUba422222159fd9b24ec6ab18f391650d"}
...

Example from twilio cli of nested field:

...
        "fields": [
          {
            "object_field": "bundle_sid",
            "error_code": null,
            "friendly_name": "Supporting Bundle Status",
            "passed": true,
            "failure_reason": null
          }
...

Technical details:

  • twilio-cli-core version: twilio-cli/2.32.1 darwin-x64 node-v14.16.1
  • node version: v14.16.1

config.js tries to create dir without checking if it already exists

Issue Summary

When using the twilio login command on terminal, I would encounter failure after entering the Short identifier for your profile field. When executing the command with -l debug, I can see that the config.js tries to create a directory ~/.twilio-cli which had been already existing from when I installed twilio-cli (this dir currently has a version file). Even after deleting the dir and trying to run twilio-login from scratch, the dir gets created before config.js wants to create the file using line 183 and therefore, it encounters the error again.

I have fixed this and could then run the twilio login command successfully but I am unable to push my branch.

Steps to Reproduce

  1. Execute twilio-login
  2. Enter details as required by the cli tool
  3. Encounter failure (if the dir .twilio-cli exists on $HOME)

Code Snippet

    183|    fs.mkdirSync(this.configDir, { recursive: true });

Exception/Log

 » twilio-cli encountered an unexpected error. To report this issue, execute the command with the "-l debug" flag, then copy the output to a new issue here: "https://github.com/twilio/twilio-cli/issues"
[DEBUG] EEXIST: file already exists, mkdir '/Users/aakashverma/.twilio-cli'
[DEBUG] Error: EEXIST: file already exists, mkdir '/Users/aakashverma/.twilio-cli'
    at Object.fs.mkdirSync (fs.js:905:18)
    at Config.save (/Users/aakashverma/.nvm/versions/node/v9.4.0/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/services/config.js:183:8)
    at Login.saveCredentials (/Users/aakashverma/.nvm/versions/node/v9.4.0/lib/node_modules/twilio-cli/src/commands/profiles/create.js:242:54)
    at <anonymous>

Technical details:

  • twilio-cli-core version: 5.4.0
  • node version: v9.4.0

Incorrect schema for Flex interactions

Issue Summary

When updating a participant on a Flex Interaction the following error is returned

» Flag value validation errors:
»   sid: "UT1493d308a78395346xxxxxxxxxxxx" does not match pattern "^UO[0-9a-fA-F]{32}$"
    TypeError: Cannot read properties of undefined (reading 'constructor')

Steps to Reproduce

  1. Create a Flex interaction
  2. Add a participant to the interaction
  3. Attempt to update the interaction participant with the following command

Code Snippet

twilio api:flex:v1:interactions:channels:participants:update --channel-sid=UO{32} --interaction-sid=KD{32} --sid=UT{32} --status=closed

Exception/Log

[DEBUG] Config File: /.twilio-cli/config.json
[DEBUG] Using profile: dev
[DEBUG] Schema for "channel-sid": {"type":"string","minLength":34,"maxLength":34,"pattern":"^UO[0-9a-fA-F]{32}$"}
[DEBUG] Schema for "interaction-sid": {"type":"string","minLength":34,"maxLength":34,"pattern":"^KD[0-9a-fA-F]{32}$"}
[DEBUG] Schema for "sid": {"type":"string","minLength":34,"maxLength":34,"pattern":"^UO[0-9a-fA-F]{32}$"}
[DEBUG] Schema for "status": {"type":"string","$ref":"#/components/schemas/interaction_channel_participant_enum_status","description":"The Participant's status. Can be: `closed` or `wrapup`.  Participant must be an agent."}
[DEBUG] Provided flags: {"channel-sid":"UO{32}","interaction-sid":"KD{32}","sid":"UT{32}","status":"closed","cli-output-format":"json","cli-log-level":"debug","silent":false,"skip-parameter-validation":false,"properties":"sid"}

Technical details:

twilio-cli/5.3.3 darwin-x64 node-v16.19.0

Issue can be fixed by changing the pattern here to start with UT

The documentation here shows that the sid for a participant update should have a sid that starts with UT.

Vulnerable version of ansi-regex

Issue Summary

We use @twilio/cli-core to build our own Twilio CLI plugin. Our security scan has detected a vulnerability with a transitive dependency of @twilio/cli-core. The vulnerable package is ansi-regex, please notice in the vulnerability page the 7.5 CVSS Score, which we use internally for assessment. I notice the columnify package is the one including the outdated version of ansi-regex and they haven't given updates in 6 years: https://www.npmjs.com/package/columnify. Is there a way to address this issue? Perhaps finding an alternative to columnify.

Steps to Reproduce

  1. Initialise a directory with npm init
  2. Add @twilio/cli-core as a dependency in a package.json
  3. Run npm install
  4. Check that the ansi-regex is in the vulnerable version

Code Snippet

Dependency is here

Exception/Log

GHSA-93q8-gq69-wqmw

Technical details:

  • twilio-cli-core version: 5.24.0
  • node version: 12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.