Merge branch 'master' into feat/allow-uppercase-uuids

This commit is contained in:
semuelle 2020-03-16 13:07:39 +01:00 committed by GitHub
commit 13480b7bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 23 deletions

View File

@ -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);

View File

@ -162,7 +162,7 @@ const cleanAnalyzeDataEmptyProps = (data, debug, logger) => {
} }
if (debug && unusedFields.length > 0) { if (debug && unusedFields.length > 0) {
logger(`${props.contractName}: Empty JSON data fields from compilation - ${unusedFields.join(', ')}`); logger.debug(`${props.contractName}: Empty JSON data fields from compilation - ${unusedFields.join(', ')}`);
} }
return result; return result;

View File

@ -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;
@ -71,9 +71,9 @@ 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;
} }
@ -114,7 +114,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
const initialDelay = ('initial-delay' in config) ? config['initial-delay'] * 1000 : undefined; const initialDelay = ('initial-delay' in config) ? config['initial-delay'] * 1000 : undefined;
const results = await asyncPool(limit, contracts, async buildObj => { const results = await asyncPool(limit, contracts, async buildObj => {
const obj = new MythXIssues(buildObj, config); const obj = new MythXIssues(buildObj, config);
let analyzeOpts = { let analyzeOpts = {
@ -123,17 +123,17 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
initialDelay initialDelay
}; };
analyzeOpts.data = mythXUtil.cleanAnalyzeDataEmptyProps(obj.buildObj, config.debug, config.logger.debug); 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.
try { try {
//TODO: Call analyze/analyzeWithStatus asynchronously //TODO: Call analyze/analyzeWithStatus asynchronously
config.logger.info("Submitting '" + obj.contractName + "' for " + analyzeOpts.data.analysisMode + " analysis...") config.logger.info("Submitting '" + obj.contractName + "' for " + analyzeOpts.data.analysisMode + " analysis...")
const {issues, status} = await armletClient.analyzeWithStatus(analyzeOpts); const { issues, status } = await armletClient.analyzeWithStatus(analyzeOpts);
obj.uuid = status.uuid; obj.uuid = status.uuid;
if (status.status === 'Error') { if (status.status === 'Error') {
@ -141,7 +141,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
} else { } else {
obj.setIssues(issues); obj.setIssues(issues);
} }
return [null, obj]; return [null, obj];
} catch (err) { } catch (err) {
//console.log("catch", JSON.stringify(err)); //console.log("catch", JSON.stringify(err));
@ -155,7 +155,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];
@ -165,7 +165,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) {
@ -180,7 +180,7 @@ function ghettoReport(logger, results) {
results.forEach(ele => { results.forEach(ele => {
issuesCount += ele.issues.length; issuesCount += ele.issues.length;
}); });
if (issuesCount === 0) { if (issuesCount === 0) {
logger.info('No issues found'); logger.info('No issues found');
return 0; return 0;
@ -188,7 +188,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;