From bc4b5172091612f69c3bfb09a415bc4856d824e3 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 5 Jul 2023 23:15:17 +0100 Subject: [PATCH] fix analysis running based on enabled tools --- .../src/lib/actions/staticAnalysisActions.ts | 128 ++++++++++-------- 1 file changed, 69 insertions(+), 59 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts index f82f6452b6..c8bea4b432 100644 --- a/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts +++ b/libs/remix-ui/static-analyser/src/lib/actions/staticAnalysisActions.ts @@ -56,73 +56,82 @@ slitherEnabled: boolean, setStartAnalysis: React.Dispatch { - groupedModules[key].forEach(el => { - if (el.name === result.name) { - moduleName = groupedModules[key][0].categoryDisplayName - } + if (basicEnabled) { + _paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyze', 'remixAnalyzer']) + const results = runner.run(lastCompilationResult, categoryIndex) + for (const result of results) { + let moduleName + Object.keys(groupedModules).map(key => { + groupedModules[key].forEach(el => { + if (el.name === result.name) { + moduleName = groupedModules[key][0].categoryDisplayName + } + }) }) - }) - // iterate over the warnings and create an object - for (const item of result.report) { - let location: any = {} - let locationString = 'not available' - let column = 0 - let row = 0 - let fileName = currentFile - let isLibrary = false + // iterate over the warnings and create an object + for (const item of result.report) { + let location: any = {} + let locationString = 'not available' + let column = 0 + let row = 0 + let fileName = currentFile + let isLibrary = false - if (item.location) { - const split = item.location.split(':') - const file = split[2] - location = { - start: parseInt(split[0]), - length: parseInt(split[1]) + if (item.location) { + const split = item.location.split(':') + const file = split[2] + location = { + start: parseInt(split[0]), + length: parseInt(split[1]) + } + location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn( + location, + parseInt(file), + lastCompilationSource.sources, + lastCompilationResult.sources + ) + row = location.start.line + column = location.start.column + locationString = row + 1 + ':' + column + ':' + fileName = Object.keys(lastCompilationResult.sources)[file] } - location = props.analysisModule._deps.offsetToLineColumnConverter.offsetToLineColumn( - location, - parseInt(file), - lastCompilationSource.sources, - lastCompilationResult.sources - ) - row = location.start.line - column = location.start.column - locationString = row + 1 + ':' + column + ':' - fileName = Object.keys(lastCompilationResult.sources)[file] - } - if(fileName !== currentFile) { - const {file, provider} = await props.analysisModule.call('fileManager', 'getPathFromUrl', fileName) - if (file.startsWith('.deps') || (provider.type === 'localhost' && file.startsWith('localhost/node_modules'))) isLibrary = true - } - const msg = message(result.name, item.warning, item.more, state.file, locationString) - const options = { - type: 'warning', - useSpan: true, - errFile: state.file, - fileName, - isLibrary, - errLine: row, - errCol: column, - item: item, - name: result.name, - locationString, - more: item.more, - location: location + if (fileName !== currentFile) { + const { file, provider } = await props.analysisModule.call('fileManager', 'getPathFromUrl', fileName) + if (file.startsWith('.deps') || (provider.type === 'localhost' && file.startsWith('localhost/node_modules'))) isLibrary = true + } + const msg = message(result.name, item.warning, item.more, state.file, locationString) + const options = { + type: 'warning', + useSpan: true, + errFile: state.file, + fileName, + isLibrary, + errLine: row, + errCol: column, + item: item, + name: result.name, + locationString, + more: item.more, + location: location + } + warningErrors.push(options) + warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) + setSsaWarnings(warningMessage) } - warningErrors.push(options) - warningMessage.push({ msg, options, hasWarning: true, warningModuleName: moduleName }) - setSsaWarnings(warningMessage) } - } + } else { + setSsaWarnings([]) + } // Slither Analysis if (showSlither && slitherEnabled) { setSlitherWarnings([]) @@ -198,12 +207,13 @@ slitherEnabled: boolean, setStartAnalysis: React.Dispatch