feat: allow case-insensitive `verify status` command, without being logged in
The MythX portal displays UUIDs in uppercase and therfore can’t be copy/pasted to the `verify status <uuid>` command. This PR allows for case-insensitive entry of the UUID in to the `verify status <uuid>` command. Additionally, running `verify status <uuid>` without first running a verify command would fail due to not being logged in. This PR logs in when the `verify status <uuid>` command is run, so this command can be run *before* `verify`.
This commit is contained in:
parent
7e9d7a1eae
commit
8370d4318f
38
mythx.js
38
mythx.js
|
@ -9,6 +9,18 @@ const { MythXIssues, doReport } = require('./lib/issues2eslint');
|
||||||
|
|
||||||
const defaultConcurrentAnalyses = 4
|
const defaultConcurrentAnalyses = 4
|
||||||
|
|
||||||
|
function checkEnvVariables(embark) {
|
||||||
|
if (process.env.MYTHX_ETH_ADDRESS) {
|
||||||
|
process.env.MYTHX_USERNAME = process.env.MYTHX_ETH_ADDRESS;
|
||||||
|
embark.logger.warn("The environment variable MYTHX_ETH_ADDRESS has been deprecated in favour of MYTHX_USERNAME and will be removed in future versions. Please update your .env file or your environment variables accordingly.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect to MythX via armlet
|
||||||
|
if (!process.env.MYTHX_USERNAME || !process.env.MYTHX_PASSWORD) {
|
||||||
|
throw new Error("Environment variables 'MYTHX_USERNAME' and 'MYTHX_PASSWORD' not found. Place these in a .env file in the root of your ÐApp, add them in the CLI command, ie 'MYTHX_USERNAME=xyz MYTHX_PASSWORD=123 embark run', or add them to your system's environment variables.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function analyse(contracts, cfg, embark) {
|
async function analyse(contracts, cfg, embark) {
|
||||||
|
|
||||||
cfg.logger = embark.logger
|
cfg.logger = embark.logger
|
||||||
|
@ -25,15 +37,7 @@ async function analyse(contracts, cfg, embark) {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.MYTHX_ETH_ADDRESS) {
|
checkEnvVariables(embark);
|
||||||
process.env.MYTHX_USERNAME = process.env.MYTHX_ETH_ADDRESS;
|
|
||||||
embark.logger.warn("The environment variable MYTHX_ETH_ADDRESS in favour of MYTHX_USERNAME and will be removed in future versions. Please update your .env file or your environment variables accordingly.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect to MythX via armlet
|
|
||||||
if(!process.env.MYTHX_USERNAME || !process.env.MYTHX_PASSWORD) {
|
|
||||||
throw new Error("Environment variables 'MYTHX_USERNAME' and 'MYTHX_PASSWORD' not found. Place these in a .env file in the root of your ÐApp, add them in the CLI command, ie 'MYTHX_USERNAME=xyz MYTHX_PASSWORD=123 embark run', or add them to your system's environment variables.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const armletClient = new armlet.Client(
|
const armletClient = new armlet.Client(
|
||||||
{
|
{
|
||||||
|
@ -83,16 +87,20 @@ async function analyse(contracts, cfg, embark) {
|
||||||
|
|
||||||
async function getStatus(uuid, embark) {
|
async function getStatus(uuid, embark) {
|
||||||
|
|
||||||
|
checkEnvVariables(embark);
|
||||||
|
|
||||||
// Connect to MythX via armlet
|
// Connect to MythX via armlet
|
||||||
const armletClient = new armlet.Client(
|
const armletClient = new armlet.Client(
|
||||||
{
|
{
|
||||||
clientToolName: "embark-mythx",
|
clientToolName: "embark-mythx",
|
||||||
password: process.env.MYTHX_PASSWORD,
|
password: process.env.MYTHX_PASSWORD,
|
||||||
ethAddress: process.env.MYTHX_USERNAME,
|
ethAddress: process.env.MYTHX_USERNAME,
|
||||||
})
|
});
|
||||||
|
|
||||||
|
await armletClient.login();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const results = await armletClient.getIssues(uuid);
|
const results = await armletClient.getIssues(uuid.toLowerCase());
|
||||||
return ghettoReport(embark.logger, results);
|
return ghettoReport(embark.logger, results);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
embark.logger.warn(err);
|
embark.logger.warn(err);
|
||||||
|
|
Loading…
Reference in New Issue