Skip to content

Commit 04f3ca5

Browse files
authored
Merge pull request #9 from emizzle/feat/allow-uppercase-uuids
feat: allow case-insensitive UUIDs
2 parents d79f027 + 13480b7 commit 04f3ca5

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

mythx.js

+20-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ const { MythXIssues, doReport } = require('./lib/issues2eslint');
99

1010
const defaultConcurrentAnalyses = 4
1111

12+
function checkEnvVariables(embark) {
13+
if (process.env.MYTHX_ETH_ADDRESS) {
14+
process.env.MYTHX_USERNAME = process.env.MYTHX_ETH_ADDRESS;
15+
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.");
16+
}
17+
18+
// Connect to MythX via armlet
19+
if (!process.env.MYTHX_USERNAME || !process.env.MYTHX_PASSWORD) {
20+
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.");
21+
}
22+
}
23+
1224
async function analyse(contracts, cfg, embark) {
1325

1426
cfg.logger = embark.logger
@@ -25,15 +37,7 @@ async function analyse(contracts, cfg, embark) {
2537
return 1
2638
}
2739

28-
if (process.env.MYTHX_ETH_ADDRESS) {
29-
process.env.MYTHX_USERNAME = process.env.MYTHX_ETH_ADDRESS;
30-
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.");
31-
}
32-
33-
// Connect to MythX via armlet
34-
if (!process.env.MYTHX_USERNAME || !process.env.MYTHX_PASSWORD) {
35-
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.");
36-
}
40+
checkEnvVariables(embark);
3741

3842
const armletClient = new armlet.Client(
3943
{
@@ -83,16 +87,20 @@ async function analyse(contracts, cfg, embark) {
8387

8488
async function getStatus(uuid, embark) {
8589

90+
checkEnvVariables(embark);
91+
8692
// Connect to MythX via armlet
8793
const armletClient = new armlet.Client(
8894
{
8995
clientToolName: "embark-mythx",
9096
password: process.env.MYTHX_PASSWORD,
9197
ethAddress: process.env.MYTHX_USERNAME,
92-
})
93-
98+
});
99+
100+
await armletClient.login();
101+
94102
try {
95-
const results = await armletClient.getIssues(uuid);
103+
const results = await armletClient.getIssues(uuid.toLowerCase());
96104
return ghettoReport(embark.logger, results);
97105
} catch (err) {
98106
embark.logger.warn(err);

0 commit comments

Comments
 (0)