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
040a8a91
Commit
040a8a91
authored
Jun 17, 2021
by
aniket-engg
Committed by
Aniket
Jul 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
types
parent
c9c9f6da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
22 deletions
+22
-22
slitherClient.ts
libs/remixd/src/services/slitherClient.ts
+22
-22
No files found.
libs/remixd/src/services/slitherClient.ts
View file @
040a8a91
...
@@ -24,17 +24,17 @@ export class SlitherClient extends PluginClient {
...
@@ -24,17 +24,17 @@ export class SlitherClient extends PluginClient {
this
.
currentSharedFolder
=
currentSharedFolder
this
.
currentSharedFolder
=
currentSharedFolder
}
}
transform
(
detectors
)
{
transform
(
detectors
:
Record
<
string
,
any
>
[]):
OutputStandard
[]
{
const
standardReport
=
[]
const
standardReport
:
OutputStandard
[]
=
[]
for
(
const
e
of
detectors
)
{
for
(
const
e
of
detectors
)
{
const
obj
=
{}
const
obj
=
{}
as
OutputStandard
obj
[
'description'
]
=
e
[
'description'
]
obj
.
description
=
e
.
description
obj
[
'title'
]
=
e
.
check
obj
.
title
=
e
.
check
obj
[
'confidence'
]
=
e
.
confidence
obj
.
confidence
=
e
.
confidence
obj
[
'severity'
]
=
e
.
impact
obj
.
severity
=
e
.
impact
obj
[
'sourceMap'
]
=
e
.
elements
.
map
((
element
)
=>
{
obj
.
sourceMap
=
e
.
elements
.
map
((
element
)
=>
{
delete
element
.
source_mapping
[
'filename_used'
]
delete
element
.
source_mapping
.
filename_used
delete
element
.
source_mapping
[
'filename_absolute'
]
delete
element
.
source_mapping
.
filename_absolute
return
element
return
element
})
})
standardReport
.
push
(
obj
)
standardReport
.
push
(
obj
)
...
@@ -42,35 +42,35 @@ export class SlitherClient extends PluginClient {
...
@@ -42,35 +42,35 @@ export class SlitherClient extends PluginClient {
return
standardReport
return
standardReport
}
}
analyse
(
filePath
:
string
,
compilerConfig
)
{
analyse
(
filePath
:
string
,
compilerConfig
:
Record
<
string
,
any
>
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
readOnly
)
{
if
(
this
.
readOnly
)
{
const
errMsg
=
'[Slither Analysis]: Cannot analyse in read-only mode'
const
errMsg
:
string
=
'[Slither Analysis]: Cannot analyse in read-only mode'
return
reject
(
new
Error
(
errMsg
))
return
reject
(
new
Error
(
errMsg
))
}
}
const
options
=
{
cwd
:
this
.
currentSharedFolder
,
shell
:
true
}
const
options
=
{
cwd
:
this
.
currentSharedFolder
,
shell
:
true
}
const
{
currentVersion
,
optimize
,
evmVersion
}
=
compilerConfig
const
{
currentVersion
,
optimize
,
evmVersion
}
=
compilerConfig
if
(
currentVersion
)
{
if
(
currentVersion
)
{
const
versionString
=
currentVersion
.
substring
(
0
,
currentVersion
.
indexOf
(
'+commit'
)
+
16
)
const
versionString
:
string
=
currentVersion
.
substring
(
0
,
currentVersion
.
indexOf
(
'+commit'
)
+
16
)
const
solcOutput
=
execSync
(
'solc --version'
,
options
)
const
solcOutput
:
Buffer
=
execSync
(
'solc --version'
,
options
)
if
(
!
solcOutput
.
toString
().
includes
(
versionString
))
{
if
(
!
solcOutput
.
toString
().
includes
(
versionString
))
{
const
version
=
versionString
.
substring
(
0
,
versionString
.
indexOf
(
'+commit'
))
const
version
:
string
=
versionString
.
substring
(
0
,
versionString
.
indexOf
(
'+commit'
))
const
solcSelectInstalledVersions
=
execSync
(
'solc-select versions'
,
options
)
const
solcSelectInstalledVersions
:
Buffer
=
execSync
(
'solc-select versions'
,
options
)
if
(
!
solcSelectInstalledVersions
.
toString
().
includes
(
version
))
{
if
(
!
solcSelectInstalledVersions
.
toString
().
includes
(
version
))
{
execSync
(
`solc-select install
${
version
}
`
,
options
)
execSync
(
`solc-select install
${
version
}
`
,
options
)
}
}
execSync
(
`solc-select use
${
version
}
`
,
options
)
execSync
(
`solc-select use
${
version
}
`
,
options
)
}
}
}
}
const
outputFile
=
'remix-slitherReport_'
+
Date
.
now
()
+
'.json'
const
outputFile
:
string
=
'remix-slitherReport_'
+
Date
.
now
()
+
'.json'
const
optimizeOption
=
optimize
?
'--optimize '
:
''
const
optimizeOption
:
string
=
optimize
?
'--optimize '
:
''
const
evmOption
=
evmVersion
?
`--evm-version
${
evmVersion
}
`
:
''
const
evmOption
:
string
=
evmVersion
?
`--evm-version
${
evmVersion
}
`
:
''
const
solcArgs
=
optimizeOption
||
evmOption
?
`--solc-args '
${
optimizeOption
}${
evmOption
}
'`
:
''
const
solcArgs
:
string
=
optimizeOption
||
evmOption
?
`--solc-args '
${
optimizeOption
}${
evmOption
}
'`
:
''
const
cmd
=
`slither
${
filePath
}
${
solcArgs
}
--json
${
outputFile
}
`
const
cmd
:
string
=
`slither
${
filePath
}
${
solcArgs
}
--json
${
outputFile
}
`
const
child
=
spawn
(
cmd
,
options
)
const
child
=
spawn
(
cmd
,
options
)
const
response
=
{}
const
response
=
{}
child
.
on
(
'close'
,
()
=>
{
child
.
on
(
'close'
,
()
=>
{
const
outputFileAbsPath
=
`
${
this
.
currentSharedFolder
}
/
${
outputFile
}
`
const
outputFileAbsPath
:
string
=
`
${
this
.
currentSharedFolder
}
/
${
outputFile
}
`
if
(
existsSync
(
outputFileAbsPath
))
{
if
(
existsSync
(
outputFileAbsPath
))
{
let
report
=
readFileSync
(
outputFileAbsPath
,
'utf8'
)
let
report
=
readFileSync
(
outputFileAbsPath
,
'utf8'
)
report
=
JSON
.
parse
(
report
)
report
=
JSON
.
parse
(
report
)
...
...
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