mirror of
https://github.com/embarklabs/embark-mythx.git
synced 2025-02-02 13:53:59 +00:00
Merge branch 'master' into feat/add-summary-fix-sources
This commit is contained in:
commit
c9d6ef51d8
@ -16,7 +16,7 @@ MYTHX_USERNAME="<mythx-username>"
|
|||||||
MYTHX_PASSWORD="<password>"
|
MYTHX_PASSWORD="<password>"
|
||||||
```
|
```
|
||||||
|
|
||||||
> **NOTE:** `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.
|
> **NOTE:** `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.
|
||||||
|
|
||||||
`MYTHX_USERNAME` may be either of:
|
`MYTHX_USERNAME` may be either of:
|
||||||
* MythX User ID (assigned by MythX API to any registered user);
|
* MythX User ID (assigned by MythX API to any registered user);
|
||||||
|
28
mythx.js
28
mythx.js
@ -40,30 +40,30 @@ async function analyse(contracts, cfg, embark) {
|
|||||||
checkEnvVariables(embark);
|
checkEnvVariables(embark);
|
||||||
|
|
||||||
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,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Filter contracts based on parameter choice
|
// Filter contracts based on parameter choice
|
||||||
let toSubmit = { "contracts": {}, "sources": contracts.sources };
|
let toSubmit = { "contracts": {}, "sources": contracts.sources };
|
||||||
if(!("ignore" in embark.pluginConfig)) {
|
if (!("ignore" in embark.pluginConfig)) {
|
||||||
embark.pluginConfig.ignore = []
|
embark.pluginConfig.ignore = []
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let [filename, contractObjects] of Object.entries(contracts.contracts)) {
|
for (let [filename, contractObjects] of Object.entries(contracts.contracts)) {
|
||||||
for (let [contractName, contract] of Object.entries(contractObjects)) {
|
for (let [contractName, contract] of Object.entries(contractObjects)) {
|
||||||
if(!("contracts" in cfg)) {
|
if (!("contracts" in cfg)) {
|
||||||
if (embark.pluginConfig.ignore.indexOf(contractName) == -1) {
|
if (embark.pluginConfig.ignore.indexOf(contractName) == -1) {
|
||||||
if(!toSubmit.contracts[filename]) {
|
if (!toSubmit.contracts[filename]) {
|
||||||
toSubmit.contracts[filename] = {}
|
toSubmit.contracts[filename] = {}
|
||||||
}
|
}
|
||||||
toSubmit.contracts[filename][contractName] = contract;
|
toSubmit.contracts[filename][contractName] = contract;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cfg.contracts.indexOf(contractName) >= 0 && embark.pluginConfig.ignore.indexOf(contractName) == -1) {
|
if (cfg.contracts.indexOf(contractName) >= 0 && embark.pluginConfig.ignore.indexOf(contractName) == -1) {
|
||||||
if(!toSubmit.contracts[filename]) {
|
if (!toSubmit.contracts[filename]) {
|
||||||
toSubmit.contracts[filename] = {}
|
toSubmit.contracts[filename] = {}
|
||||||
}
|
}
|
||||||
toSubmit.contracts[filename][contractName] = contract;
|
toSubmit.contracts[filename][contractName] = contract;
|
||||||
@ -73,7 +73,7 @@ async function analyse(contracts, cfg, embark) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop here if no contracts are left
|
// Stop here if no contracts are left
|
||||||
if(Object.keys(toSubmit.contracts).length === 0) {
|
if (Object.keys(toSubmit.contracts).length === 0) {
|
||||||
embark.logger.info("No contracts to submit.");
|
embark.logger.info("No contracts to submit.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
|
|||||||
analyzeOpts.data = mythXUtil.cleanAnalyzeDataEmptyProps(obj.buildObj, config.debug, config.logger);
|
analyzeOpts.data = mythXUtil.cleanAnalyzeDataEmptyProps(obj.buildObj, config.debug, config.logger);
|
||||||
analyzeOpts.data.analysisMode = config.full ? "full" : "quick";
|
analyzeOpts.data.analysisMode = config.full ? "full" : "quick";
|
||||||
if (config.debug > 1) {
|
if (config.debug > 1) {
|
||||||
config.logger.debug("analyzeOpts: " + `${util.inspect(analyzeOpts, {depth: null})}`);
|
config.logger.debug("analyzeOpts: " + `${util.inspect(analyzeOpts, { depth: null })}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// request analysis to armlet.
|
// request analysis to armlet.
|
||||||
@ -156,7 +156,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (errStr.includes('User or default timeout reached after')
|
if (errStr.includes('User or default timeout reached after')
|
||||||
|| errStr.includes('Timeout reached after')) {
|
|| errStr.includes('Timeout reached after')) {
|
||||||
return [(buildObj.contractName + ": ").yellow + errStr, null];
|
return [(buildObj.contractName + ": ").yellow + errStr, null];
|
||||||
} else {
|
} else {
|
||||||
return [(buildObj.contractName + ": ").red + errStr, null];
|
return [(buildObj.contractName + ": ").red + errStr, null];
|
||||||
@ -166,7 +166,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
|
|||||||
});
|
});
|
||||||
|
|
||||||
return results.reduce((accum, curr) => {
|
return results.reduce((accum, curr) => {
|
||||||
const [ err, obj ] = curr;
|
const [err, obj] = curr;
|
||||||
if (err) {
|
if (err) {
|
||||||
accum.errors.push(err);
|
accum.errors.push(err);
|
||||||
} else if (obj) {
|
} else if (obj) {
|
||||||
@ -189,7 +189,7 @@ function ghettoReport(logger, results) {
|
|||||||
for (const group of results) {
|
for (const group of results) {
|
||||||
logger.info(group.sourceList.join(', ').underline);
|
logger.info(group.sourceList.join(', ').underline);
|
||||||
for (const issue of group.issues) {
|
for (const issue of group.issues) {
|
||||||
logger.info(yaml.safeDump(issue, {'skipInvalid': true}));
|
logger.info(yaml.safeDump(issue, { 'skipInvalid': true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user