embark-mythx
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

Status Embark plugin for MythX

Running MythX analyses in Status Embark

GitHub license npm

This plugin brings MythX to Status Embark. Simply call verify from the Embark console and embark-mythx sends your contracts off for analysis. It is inspired by sabre and uses its source mapping and reporting functions.

This project was bootstrapped with TSDX.

QuickStart

  1. Create a .env file in the root of your project and provide your MythX API Key. Free MythX accounts can be created at https://dashboard.mythx.io/#/registration. Once an account is created, generate an API key at https://dashboard.mythx.io/#/console/tools.
MYTHX_USERNAME="<mythx-username>"
MYTHX_PASSWORD="<password>"
MYTHX_API_KEY="<mythx-api-key>"

NOTE: MYTHX_ETH_ADDRESS has been deprecated in favour of MYTHX_USERNAME and will be removed in future versions. As of version 2.0, MYTHX_API_KEY is also required. Please update your .env file or your environment variables accordingly.

MYTHX_USERNAME may be either of:

  • MythX User ID (assigned by MythX API to any registered user);
  • Ethereum address, if user account is associated with an address;
  • A verified email address, if the user account is associated with an email address, and that address has been verified by visiting the verification link in the verification email sent by the MythX API each time when user email is set or modified in the MythX settings.

For more information, please see the MythX API Login documentation.

  1. Run verify [options] [contracts] in the Embark console. When the call returns, it will look something like this:
Embark (development) > verify
Authenticating MythX user...
Running MythX analysis...
Analysis job submitted: https://dashboard.mythx.io/#/console/analyses/9a294be9-8656-416a-afbc-06cb299f5319
Analyzing Bank in quick mode...
Analysis job submitted: https://dashboard.mythx.io/#/console/analyses/0741a098-6b81-43dc-af06-0416eda2a076
Analyzing Hack in quick mode...
Retrieving Bank analysis results...
Retrieving Hack analysis results...
Rendering Bank analysis report...
 
Bank.sol
  18:12  error    persistent state read after call               https://swcregistry.io/docs/SWC-107
  14:28  warning  A call to a user-supplied address is executed  https://swcregistry.io/docs/SWC-107
   1:0   warning  A floating pragma is set                       https://swcregistry.io/docs/SWC-103
 
✖ 3 problems (1 error, 2 warnings)
 
Rendering Hack analysis report...
 
Hack.sol
  1:0  warning  A floating pragma is set  https://swcregistry.io/SWC-registry/docs/SWC-103
 
✖ 1 problem (0 errors, 1 warning)
 
Done!

Installation

  1. Install this plugin from the root of your Embark project:
$ npm i embark-mythx
# or 
$ npm i flex-dapps/embark-mythx
  1. Add embark-mythx to the plugins section of your embark.json file. To have the plugin permanently ignore one or multiple contracts, add them to the configuration:
"plugins"{
  "embark-mythx": {
    "ignore": ["Ownable", "Migrations"]
  }
}

Usage

The following usage guide can also be obtained by running verify help in the Embark console.

Available Commands
 
  verify <options> [contracts]    Runs MythX verification. If array of contracts are specified, only those contracts will be analysed. 
  verify report [--format] uuid   Get the report of a completed analysis.                                                              
  verify status uuid              Get the status of an already submitted analysis.                                                     
  verify list                     Displays a list of the last 20 submitted analyses in a table.                                        
  verify help                     Display this usage guide.                                                                            
 
Examples
 
  verify --mode full SimpleStorage ERC20                                Runs a full MythX verification for the SimpleStorage and ERC20 contracts only. 
  verify status 0d60d6b3-e226-4192-b9c6-66b45eca3746                    Gets the status of the MythX analysis with the specified uuid.                 
  verify report --format stylish 0d60d6b3-e226-4192-b9c6-66b45eca3746   Gets the status of the MythX analysis with the specified uuid.                 
 
Verify options
 
  -m, --mode string        Analysis mode. Options: quick, standard, deep (default: quick).               
  -o, --format string      Output format. Options: text, stylish, compact, table, html, json (default:   
                           stylish).                                                                     
  -c, --no-cache-lookup    Deactivate MythX cache lookups (default: false).                              
  -d, --debug              Print MythX API request and response.                                         
  -l, --limit number       Maximum number of concurrent analyses (default: 10).                          
  -t, --timeout number         Timeout in secs to wait for analysis to finish (default: smart default based  
                           on mode).   

Example Usage

# Quick analysis on all contracts in project 
$ verify
 
# 'ERC20' and 'Ownable' full analysis 
$ verify --mode full ERC20 Ownable
 
# Check status of previous or ongoing analysis 
$ verify status ef5bb083-c57a-41b0-97c1-c14a54617812
 
# Get list of 20 previous analyses 
$ verify list

embark-mythx Development

Contributions are very welcome! If you'd like to contribute, the following commands will help you get up and running. The library was built using TSDX, so these commands are specific to TSDX.

npm run start or yarn start

Runs the project in development/watch mode. embark-mythx will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.

Your library will be rebuilt if you make edits.

npm run build or yarn build

Bundles the package to the dist folder. The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).

npm test or yarn test

Runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.1.1
    0
    • latest

Version History

Package Sidebar

Install

npm i embark-mythx

Weekly Downloads

0

Version

2.1.1

License

MIT

Unpacked Size

481 kB

Total Files

34

Last publish

Collaborators

  • semuelle