Skip to content

Commit 05cd24c

Browse files
committed
index.js: Implement embark-mythx plugin.
The embark-mythx plugin uses Mythos (https://github.com/cleanunicorn/mythos) to connect to MythX cloud service. Create your own MythX API account and add "plugins": { "@cryptomental/embark-mythx": { "mythxEthAddress": "YourMythXEthAddress", "mythxPassword": "YourMythXEthPassword" } }
1 parent cc60734 commit 05cd24c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

index.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const shelljs = require("shelljs");
2+
3+
function isMythosInstalled() {
4+
return shelljs.test("-f", "node_modules/.bin/mythos");
5+
}
6+
7+
function executeMythos(contractFilePath, contractName, mythxEthAddress, mythxPassword, logger) {
8+
shelljs.exec(`node_modules/.bin/mythos analyze ${contractFilePath} ${contractName} --mythxEthAddress=${mythxEthAddress} --mythxPassword=${mythxPassword}`,
9+
{ silent: true }, function (code, stdout, stderr) {
10+
if (stderr) {
11+
logger.info(stderr);
12+
}
13+
logger.info(stdout);
14+
});
15+
}
16+
17+
async function run(embark, compilationResult) {
18+
if (!isMythosInstalled()) {
19+
embark.logger.warn("Mythos not found! Plugin dependencies were not installed correctly.");
20+
return;
21+
}
22+
23+
Object.keys(compilationResult.contracts).map((contractFilePath) => {
24+
Object.keys(compilationResult.contracts[contractFilePath]).map((contractName) => {
25+
embark.logger.info(`Requesting analysis of ${contractName} from ${contractFilePath}`);
26+
executeMythos(contractFilePath, contractName, embark.pluginConfig.mythxEthAddress, embark.pluginConfig.mythxPassword, embark.logger);
27+
});
28+
});
29+
30+
}
31+
32+
function register(embark) {
33+
embark.events.on("contracts:compiled:solc", run.bind(null, embark));
34+
}
35+
36+
module.exports = register;

0 commit comments

Comments
 (0)