Commit 1c6facc3 authored by aniket-engg's avatar aniket-engg Committed by Aniket

analyze, transform and return to IDE

parent 80f8d503
import * as WS from 'ws' // eslint-disable-line import * as WS from 'ws' // eslint-disable-line
import { PluginClient } from '@remixproject/plugin' import { PluginClient } from '@remixproject/plugin'
import { existsSync, readFileSync } from 'fs' import { existsSync, readFileSync } from 'fs'
import { OutputStandard } from '../types' // eslint-disable-line
const { spawn, execSync } = require('child_process') const { spawn, execSync } = require('child_process')
export class SlitherClient extends PluginClient { export class SlitherClient extends PluginClient {
...@@ -22,14 +23,21 @@ export class SlitherClient extends PluginClient { ...@@ -22,14 +23,21 @@ export class SlitherClient extends PluginClient {
} }
transform (detectors) { transform (detectors) {
// detectors const standardReport = []
// I/O standard mapping for (let e of detectors) {
// Analysis Description -> description let obj = {}
// Analysis Short title -> check obj['description'] = e['description']
// Confidence -> confidence obj['title'] = e.check
// Severity -> impact obj['confidence'] = e.confidence
// Source Map -> elements[i].source_mapping (remove filename_used, filename_absolute) obj['severity'] = e.impact
obj['sourceMap'] = e.elements.map((element) => {
delete element.source_mapping['filename_used']
delete element.source_mapping['filename_absolute']
return element
})
standardReport.push(obj)
}
return standardReport
} }
analyse (filePath: string, compilerConfig) { analyse (filePath: string, compilerConfig) {
...@@ -72,8 +80,8 @@ export class SlitherClient extends PluginClient { ...@@ -72,8 +80,8 @@ export class SlitherClient extends PluginClient {
child.on('close', () => { child.on('close', () => {
const outputFileAbsPath = `${this.currentSharedFolder}/${outputFile}` const outputFileAbsPath = `${this.currentSharedFolder}/${outputFile}`
if (existsSync (outputFileAbsPath)) { if (existsSync (outputFileAbsPath)) {
const report = readFileSync(outputFileAbsPath, 'utf8') let report = readFileSync(outputFileAbsPath, 'utf8')
console.log('report--->', report) report = JSON.parse(report)
if (report['success']) { if (report['success']) {
response['status'] = true response['status'] = true
if (!report['results'] || !report['results'].detectors || !report['results'].detectors.length) { if (!report['results'] || !report['results'].detectors || !report['results'].detectors.length) {
...@@ -90,8 +98,6 @@ export class SlitherClient extends PluginClient { ...@@ -90,8 +98,6 @@ export class SlitherClient extends PluginClient {
reject(new Error('Error in running Slither Analysis. See remixd console.')) reject(new Error('Error in running Slither Analysis. See remixd console.'))
} }
} else reject(new Error('Error in generating Slither Analysis Report. See remixd console.')) } else reject(new Error('Error in generating Slither Analysis Report. See remixd console.'))
// if (error) reject(error)
// else resolve(result)
}) })
}) })
} }
......
import * as ServiceList from '../serviceList' import * as ServiceList from '../serviceList'
import * as Websocket from 'ws' import * as Websocket from 'ws'
export type OutputStandard = { export interface OutputStandard {
description: string description: string
title: string title: string
confidence: string confidence: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment