minor changes

pull/1398/head
Aniket-Engg 3 years ago committed by Aniket
parent b0873d188e
commit 3e148354ce
  1. 2
      apps/remix-ide/src/app/editor/sourceHighlighter.js
  2. 2
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx
  3. 4
      libs/remixd/src/services/slitherClient.ts

@ -37,7 +37,7 @@ class SourceHighlighter {
this.statementMarker = null
this.fullLineMarker = null
this.source = null
if (lineColumnPos) {
if (lineColumnPos && lineColumnPos.start && lineColumnPos.end) {
this.source = filePath
this.style = style || 'var(--info)'
// if (!this.source) this.source = this._deps.fileManager.currentFile()

@ -191,6 +191,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
if (slitherEnabled) {
props.analysisModule.call('solidity-logic', 'getCompilerState').then((compilerState) => {
const { currentVersion, optimize, evmVersion } = compilerState
props.analysisModule.call('terminal', 'log', { type: 'info', value: '[Slither Analysis]: Running...' })
props.analysisModule.call('slither', 'analyse', state.file, { currentVersion, optimize, evmVersion }).then((result) => {
if (result.status) {
props.analysisModule.call('terminal', 'log', { type: 'info', value: `[Slither Analysis]: Analysis Completed!! ${result.count} warnings found.` })
@ -203,6 +204,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
const fileName = currentFile
// There are issues with location for imported contract
// which stops complete analysis including remix analyzer's
// if (item.sourceMap && item.sourceMap.length) {
// location = {
// start: item.sourceMap[0].source_mapping.start,

@ -111,7 +111,7 @@ export class SlitherClient extends PluginClient {
}
} else console.log('\x1b[32m%s\x1b[0m', '[Slither Analysis]: Compiler version is same as installed solc version')
}
const outputFile: string = 'remix-slitherReport_' + Date.now() + '.json'
// Allow paths and set solc remapping for import URLs
const fileContent = readFileSync(`${this.currentSharedFolder}/${filePath}`, 'utf8')
const importsArr = fileContent.match(/import ['"][^.|..](.+?)['"];/g)
let allowPaths = ''; let remaps = ''
@ -126,11 +126,13 @@ export class SlitherClient extends PluginClient {
const solcArgs: string = optimizeOption || evmOption || allowPathsOption ? `--solc-args '${allowPathsOption}${optimizeOption}${evmOption}'` : ''
const solcRemaps = remaps ? `--solc-remaps "${remaps}"` : ''
const outputFile: string = 'remix-slitherReport_' + Math.floor(Date.now() / 1000) + '.json'
const cmd: string = `slither ${filePath} ${solcArgs} ${solcRemaps} --json ${outputFile}`
console.log('\x1b[32m%s\x1b[0m', '[Slither Analysis]: Running Slither...')
// Added `stdio: 'ignore'` as for contract with NPM imports analysis which is exported in 'stderr'
// get too big and hangs the process. We process analysis from the report file only
const child = spawn(cmd, { cwd: this.currentSharedFolder, shell: true, stdio: 'ignore' })
const response = {}
child.on('close', () => {
const outputFileAbsPath: string = `${this.currentSharedFolder}/${outputFile}`

Loading…
Cancel
Save