@@ -40,40 +40,40 @@ async function analyse(contracts, cfg, embark) {
40
40
checkEnvVariables ( embark ) ;
41
41
42
42
const armletClient = new armlet . Client (
43
- {
44
- clientToolName : "embark-mythx" ,
45
- password : process . env . MYTHX_PASSWORD ,
46
- ethAddress : process . env . MYTHX_USERNAME ,
47
- } )
48
-
43
+ {
44
+ clientToolName : "embark-mythx" ,
45
+ password : process . env . MYTHX_PASSWORD ,
46
+ ethAddress : process . env . MYTHX_USERNAME ,
47
+ } )
48
+
49
49
// Filter contracts based on parameter choice
50
50
let toSubmit = { "contracts" : { } , "sources" : contracts . sources } ;
51
- if ( ! ( "ignore" in embark . pluginConfig ) ) {
51
+ if ( ! ( "ignore" in embark . pluginConfig ) ) {
52
52
embark . pluginConfig . ignore = [ ]
53
53
}
54
54
55
55
for ( let [ filename , contractObjects ] of Object . entries ( contracts . contracts ) ) {
56
56
for ( let [ contractName , contract ] of Object . entries ( contractObjects ) ) {
57
- if ( ! ( "contracts" in cfg ) ) {
57
+ if ( ! ( "contracts" in cfg ) ) {
58
58
if ( embark . pluginConfig . ignore . indexOf ( contractName ) == - 1 ) {
59
- if ( ! toSubmit . contracts [ filename ] ) {
59
+ if ( ! toSubmit . contracts [ filename ] ) {
60
60
toSubmit . contracts [ filename ] = { }
61
61
}
62
62
toSubmit . contracts [ filename ] [ contractName ] = contract ;
63
63
}
64
64
} else {
65
65
if ( cfg . contracts . indexOf ( contractName ) >= 0 && embark . pluginConfig . ignore . indexOf ( contractName ) == - 1 ) {
66
- if ( ! toSubmit . contracts [ filename ] ) {
66
+ if ( ! toSubmit . contracts [ filename ] ) {
67
67
toSubmit . contracts [ filename ] = { }
68
68
}
69
69
toSubmit . contracts [ filename ] [ contractName ] = contract ;
70
70
}
71
71
}
72
72
}
73
73
}
74
-
74
+
75
75
// Stop here if no contracts are left
76
- if ( Object . keys ( toSubmit . contracts ) . length === 0 ) {
76
+ if ( Object . keys ( toSubmit . contracts ) . length === 0 ) {
77
77
embark . logger . info ( "No contracts to submit." ) ;
78
78
return 0 ;
79
79
}
@@ -114,7 +114,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
114
114
const initialDelay = ( 'initial-delay' in config ) ? config [ 'initial-delay' ] * 1000 : undefined ;
115
115
116
116
const results = await asyncPool ( limit , contracts , async buildObj => {
117
-
117
+
118
118
const obj = new MythXIssues ( buildObj , config ) ;
119
119
120
120
let analyzeOpts = {
@@ -123,25 +123,25 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
123
123
initialDelay
124
124
} ;
125
125
126
- analyzeOpts . data = mythXUtil . cleanAnalyzeDataEmptyProps ( obj . buildObj , config . debug , config . logger . debug ) ;
126
+ analyzeOpts . data = mythXUtil . cleanAnalyzeDataEmptyProps ( obj . buildObj , config . debug , config . logger ) ;
127
127
analyzeOpts . data . analysisMode = config . full ? "full" : "quick" ;
128
128
if ( config . debug > 1 ) {
129
- config . logger . debug ( "analyzeOpts: " + `${ util . inspect ( analyzeOpts , { depth : null } ) } ` ) ;
129
+ config . logger . debug ( "analyzeOpts: " + `${ util . inspect ( analyzeOpts , { depth : null } ) } ` ) ;
130
130
}
131
131
132
132
// request analysis to armlet.
133
133
try {
134
134
//TODO: Call analyze/analyzeWithStatus asynchronously
135
135
config . logger . info ( "Submitting '" + obj . contractName + "' for " + analyzeOpts . data . analysisMode + " analysis..." )
136
- const { issues, status} = await armletClient . analyzeWithStatus ( analyzeOpts ) ;
136
+ const { issues, status } = await armletClient . analyzeWithStatus ( analyzeOpts ) ;
137
137
obj . uuid = status . uuid ;
138
138
139
139
if ( status . status === 'Error' ) {
140
140
return [ status , null ] ;
141
141
} else {
142
142
obj . setIssues ( issues ) ;
143
143
}
144
-
144
+
145
145
return [ null , obj ] ;
146
146
} catch ( err ) {
147
147
//console.log("catch", JSON.stringify(err));
@@ -155,7 +155,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
155
155
}
156
156
157
157
if ( errStr . includes ( 'User or default timeout reached after' )
158
- || errStr . includes ( 'Timeout reached after' ) ) {
158
+ || errStr . includes ( 'Timeout reached after' ) ) {
159
159
return [ ( buildObj . contractName + ": " ) . yellow + errStr , null ] ;
160
160
} else {
161
161
return [ ( buildObj . contractName + ": " ) . red + errStr , null ] ;
@@ -165,7 +165,7 @@ const doAnalysis = async (armletClient, config, contracts, contractNames = null,
165
165
} ) ;
166
166
167
167
return results . reduce ( ( accum , curr ) => {
168
- const [ err , obj ] = curr ;
168
+ const [ err , obj ] = curr ;
169
169
if ( err ) {
170
170
accum . errors . push ( err ) ;
171
171
} else if ( obj ) {
@@ -180,15 +180,15 @@ function ghettoReport(logger, results) {
180
180
results . forEach ( ele => {
181
181
issuesCount += ele . issues . length ;
182
182
} ) ;
183
-
183
+
184
184
if ( issuesCount === 0 ) {
185
185
logger . info ( 'No issues found' ) ;
186
186
return 0 ;
187
187
}
188
188
for ( const group of results ) {
189
189
logger . info ( group . sourceList . join ( ', ' ) . underline ) ;
190
190
for ( const issue of group . issues ) {
191
- logger . info ( yaml . safeDump ( issue , { 'skipInvalid' : true } ) ) ;
191
+ logger . info ( yaml . safeDump ( issue , { 'skipInvalid' : true } ) ) ;
192
192
}
193
193
}
194
194
return 1 ;
0 commit comments