@@ -27,49 +27,49 @@ async function analyse(contracts, cfg, embark) {
27
27
28
28
if ( process . env . MYTHX_ETH_ADDRESS ) {
29
29
process . env . MYTHX_USERNAME = process . env . MYTHX_ETH_ADDRESS ;
30
- 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." ) ;
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
31
}
32
32
33
33
// Connect to MythX via armlet
34
- if ( ! process . env . MYTHX_USERNAME || ! process . env . MYTHX_PASSWORD ) {
34
+ if ( ! process . env . MYTHX_USERNAME || ! process . env . MYTHX_PASSWORD ) {
35
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
36
}
37
37
38
38
const armletClient = new armlet . Client (
39
- {
40
- clientToolName : "embark-mythx" ,
41
- password : process . env . MYTHX_PASSWORD ,
42
- ethAddress : process . env . MYTHX_USERNAME ,
43
- } )
44
-
39
+ {
40
+ clientToolName : "embark-mythx" ,
41
+ password : process . env . MYTHX_PASSWORD ,
42
+ ethAddress : process . env . MYTHX_USERNAME ,
43
+ } )
44
+
45
45
// Filter contracts based on parameter choice
46
46
let toSubmit = { "contracts" : { } , "sources" : contracts . sources } ;
47
- if ( ! ( "ignore" in embark . pluginConfig ) ) {
47
+ if ( ! ( "ignore" in embark . pluginConfig ) ) {
48
48
embark . pluginConfig . ignore = [ ]
49
49
}
50
50
51
51
for ( let [ filename , contractObjects ] of Object . entries ( contracts . contracts ) ) {
52
52
for ( let [ contractName , contract ] of Object . entries ( contractObjects ) ) {
53
- if ( ! ( "contracts" in cfg ) ) {
53
+ if ( ! ( "contracts" in cfg ) ) {
54
54
if ( embark . pluginConfig . ignore . indexOf ( contractName ) == - 1 ) {
55
- if ( ! toSubmit . contracts [ filename ] ) {
55
+ if ( ! toSubmit . contracts [ filename ] ) {
56
56
toSubmit . contracts [ filename ] = { }
57
57
}
58
58
toSubmit . contracts [ filename ] [ contractName ] = contract ;
59
59
}
60
60
} else {
61
61
if ( cfg . contracts . indexOf ( contractName ) >= 0 && embark . pluginConfig . ignore . indexOf ( contractName ) == - 1 ) {
62
- if ( ! toSubmit . contracts [ filename ] ) {
62
+ if ( ! toSubmit . contracts [ filename ] ) {
63
63
toSubmit . contracts [ filename ] = { }
64
64
}
65
65
toSubmit . contracts [ filename ] [ contractName ] = contract ;
66
66
}
67
67
}
68
68
}
69
69
}
70
-
70
+
71
71
// Stop here if no contracts are left
72
- if ( Object . keys ( toSubmit . contracts ) . length === 0 ) {
72
+ if ( Object . keys ( toSubmit . contracts ) . length === 0 ) {
73
73
embark . logger . info ( "No contracts to submit." ) ;
74
74
return 0 ;
75
75
}
@@ -85,12 +85,12 @@ async function getStatus(uuid, embark) {
85
85
86
86
// Connect to MythX via armlet
87
87
const armletClient = new armlet . Client (
88
- {
89
- clientToolName : "embark-mythx" ,
90
- password : process . env . MYTHX_PASSWORD ,
91
- ethAddress : process . env . MYTHX_USERNAME ,
92
- } )
93
-
88
+ {
89
+ clientToolName : "embark-mythx" ,
90
+ password : process . env . MYTHX_PASSWORD ,
91
+ ethAddress : process . env . MYTHX_USERNAME ,
92
+ } )
93
+
94
94
try {
95
95
const results = await armletClient . getIssues ( uuid ) ;
96
96
return ghettoReport ( embark . logger , results ) ;
@@ -106,7 +106,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
106
106
const initialDelay = ( 'initial-delay' in config ) ? config [ 'initial-delay' ] * 1000 : undefined ;
107
107
108
108
const results = await asyncPool ( limit , contracts , async buildObj => {
109
-
109
+
110
110
const obj = new MythXIssues ( buildObj , config ) ;
111
111
112
112
let analyzeOpts = {
@@ -118,22 +118,22 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
118
118
analyzeOpts . data = mythXUtil . cleanAnalyzeDataEmptyProps ( obj . buildObj , config . debug , config . logger . debug ) ;
119
119
analyzeOpts . data . analysisMode = config . full ? "full" : "quick" ;
120
120
if ( config . debug > 1 ) {
121
- config . logger . debug ( "analyzeOpts: " + `${ util . inspect ( analyzeOpts , { depth : null } ) } ` ) ;
121
+ config . logger . debug ( "analyzeOpts: " + `${ util . inspect ( analyzeOpts , { depth : null } ) } ` ) ;
122
122
}
123
123
124
124
// request analysis to armlet.
125
125
try {
126
126
//TODO: Call analyze/analyzeWithStatus asynchronously
127
127
config . logger . info ( "Submitting '" + obj . contractName + "' for " + analyzeOpts . data . analysisMode + " analysis..." )
128
- const { issues, status} = await armletClient . analyzeWithStatus ( analyzeOpts ) ;
128
+ const { issues, status } = await armletClient . analyzeWithStatus ( analyzeOpts ) ;
129
129
obj . uuid = status . uuid ;
130
130
131
131
if ( status . status === 'Error' ) {
132
132
return [ status , null ] ;
133
133
} else {
134
134
obj . setIssues ( issues ) ;
135
135
}
136
-
136
+
137
137
return [ null , obj ] ;
138
138
} catch ( err ) {
139
139
//console.log("catch", JSON.stringify(err));
@@ -147,7 +147,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
147
147
}
148
148
149
149
if ( errStr . includes ( 'User or default timeout reached after' )
150
- || errStr . includes ( 'Timeout reached after' ) ) {
150
+ || errStr . includes ( 'Timeout reached after' ) ) {
151
151
return [ ( buildObj . contractName + ": " ) . yellow + errStr , null ] ;
152
152
} else {
153
153
return [ ( buildObj . contractName + ": " ) . red + errStr , null ] ;
@@ -157,7 +157,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
157
157
} ) ;
158
158
159
159
return results . reduce ( ( accum , curr ) => {
160
- const [ err , obj ] = curr ;
160
+ const [ err , obj ] = curr ;
161
161
if ( err ) {
162
162
accum . errors . push ( err ) ;
163
163
} else if ( obj ) {
@@ -172,15 +172,15 @@ function ghettoReport(logger, results) {
172
172
results . forEach ( ele => {
173
173
issuesCount += ele . issues . length ;
174
174
} ) ;
175
-
175
+
176
176
if ( issuesCount === 0 ) {
177
177
logger . info ( 'No issues found' ) ;
178
178
return 0 ;
179
179
}
180
180
for ( const group of results ) {
181
181
logger . info ( group . sourceList . join ( ', ' ) . underline ) ;
182
182
for ( const issue of group . issues ) {
183
- logger . info ( yaml . safeDump ( issue , { 'skipInvalid' : true } ) ) ;
183
+ logger . info ( yaml . safeDump ( issue , { 'skipInvalid' : true } ) ) ;
184
184
}
185
185
}
186
186
return 1 ;
0 commit comments