Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
ebcccab4
Commit
ebcccab4
authored
Jun 17, 2021
by
aniket-engg
Committed by
Aniket
Jul 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
error and response defined
parent
07130ef0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
slitherClient.ts
libs/remixd/src/services/slitherClient.ts
+35
-2
No files found.
libs/remixd/src/services/slitherClient.ts
View file @
ebcccab4
import
*
as
WS
from
'ws'
// eslint-disable-line
import
{
PluginClient
}
from
'@remixproject/plugin'
import
{
existsSync
,
readFileSync
}
from
'fs'
const
{
spawn
,
execSync
}
=
require
(
'child_process'
)
export
class
SlitherClient
extends
PluginClient
{
...
...
@@ -20,6 +21,17 @@ export class SlitherClient extends PluginClient {
this
.
currentSharedFolder
=
currentSharedFolder
}
transform
(
detectors
)
{
// detectors
// I/O standard mapping
// Analysis Description -> description
// Analysis Short title -> check
// Confidence -> confidence
// Severity -> impact
// Source Map -> elements[i].source_mapping (remove filename_used, filename_absolute)
}
analyse
(
filePath
:
string
,
compilerConfig
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
readOnly
)
{
...
...
@@ -48,6 +60,7 @@ export class SlitherClient extends PluginClient {
const
child
=
spawn
(
cmd
,
options
)
let
result
=
''
let
error
=
''
let
response
=
{}
child
.
stdout
.
on
(
'data'
,
(
data
)
=>
{
const
msg
=
`[Slither Analysis]:
${
data
.
toString
()}
`
console
.
log
(
'
\
x1b[32m%s
\
x1b[0m'
,
msg
)
...
...
@@ -57,8 +70,28 @@ export class SlitherClient extends PluginClient {
error
+=
`[Slither Analysis]:
${
err
.
toString
()}
`
})
child
.
on
(
'close'
,
()
=>
{
if
(
error
)
reject
(
error
)
else
resolve
(
result
)
const
outputFileAbsPath
=
`
${
this
.
currentSharedFolder
}
/
${
outputFile
}
`
if
(
existsSync
(
outputFileAbsPath
))
{
const
report
=
readFileSync
(
outputFileAbsPath
,
'utf8'
)
console
.
log
(
'report--->'
,
report
)
if
(
report
[
'success'
])
{
response
[
'status'
]
=
true
if
(
!
report
[
'results'
]
||
!
report
[
'results'
].
detectors
||
!
report
[
'results'
].
detectors
.
length
)
{
response
[
'count'
]
=
0
}
else
{
const
{
detectors
}
=
report
[
'results'
]
response
[
'count'
]
=
detectors
.
length
response
[
'data'
]
=
this
.
transform
(
detectors
)
}
resolve
(
response
)
}
else
{
console
.
log
(
'[Slither Analysis]: Error in running Slither Analysis'
)
console
.
log
(
report
[
'error'
])
reject
(
new
Error
(
'Error in running Slither Analysis. See remixd console.'
))
}
}
else
reject
(
new
Error
(
'Error in generating Slither Analysis Report. See remixd console.'
))
// if (error) reject(error)
// else resolve(result)
})
})
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment