|
|
@ -9,7 +9,7 @@ import * as semver from 'semver' |
|
|
|
import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line
|
|
|
|
import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line
|
|
|
|
import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line
|
|
|
|
import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line
|
|
|
|
import ErrorRenderer from './ErrorRenderer' // eslint-disable-line
|
|
|
|
import ErrorRenderer from './ErrorRenderer' // eslint-disable-line
|
|
|
|
import { compilation, runSlitherAnalysis } from './actions/staticAnalysisActions' |
|
|
|
import { compilation, runLinting, runSlitherAnalysis } from './actions/staticAnalysisActions' |
|
|
|
import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' |
|
|
|
import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' |
|
|
|
import { CodeAnalysis } from '@remix-project/remix-analyzer' |
|
|
|
import { CodeAnalysis } from '@remix-project/remix-analyzer' |
|
|
|
import Tab from 'react-bootstrap/Tab' |
|
|
|
import Tab from 'react-bootstrap/Tab' |
|
|
@ -116,6 +116,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
setSlitherWarnings([]) |
|
|
|
setSlitherWarnings([]) |
|
|
|
setSsaWarnings([]) |
|
|
|
setSsaWarnings([]) |
|
|
|
compilation(props.analysisModule, dispatch) |
|
|
|
compilation(props.analysisModule, dispatch) |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [-1]) |
|
|
|
}, [props]) |
|
|
|
}, [props]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
@ -125,9 +126,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
setSlitherWarnings([]) |
|
|
|
setSlitherWarnings([]) |
|
|
|
setSsaWarnings([]) |
|
|
|
setSsaWarnings([]) |
|
|
|
const runAnalysis = async () => { |
|
|
|
const runAnalysis = async () => { |
|
|
|
await run(state.data, state.source, state.file, state, props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, message, showWarnings, allWarnings, warningContainer,calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis) |
|
|
|
await run(state.data, state.source, state.file, state, props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, message, showWarnings, allWarnings, warningContainer,calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis, solhintEnabled, basicEnabled) |
|
|
|
} |
|
|
|
} |
|
|
|
props.event.trigger('staticAnaysisWarning', [0]) |
|
|
|
|
|
|
|
return () => { } |
|
|
|
return () => { } |
|
|
|
}, [state]) |
|
|
|
}, [state]) |
|
|
|
|
|
|
|
|
|
|
@ -146,19 +146,13 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
checkRemixdActive() |
|
|
|
checkRemixdActive() |
|
|
|
}, [props]) |
|
|
|
}, [props]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if(hints.length > 0) { |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', [hints.length]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, [hints.length]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
props.analysisModule.on('filePanel', 'setWorkspace', (currentWorkspace) => { |
|
|
|
props.analysisModule.on('filePanel', 'setWorkspace', (currentWorkspace) => { |
|
|
|
// Reset warning state
|
|
|
|
// Reset warning state
|
|
|
|
allWarnings.current = {} |
|
|
|
allWarnings.current = {} |
|
|
|
setWarningState({}) |
|
|
|
setWarningState({}) |
|
|
|
// Reset badge
|
|
|
|
// Reset badge
|
|
|
|
props.event.trigger('staticAnaysisWarning', [0]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [-1]) |
|
|
|
// Reset state
|
|
|
|
// Reset state
|
|
|
|
dispatch({ type: '', payload: initialState }) |
|
|
|
dispatch({ type: '', payload: initialState }) |
|
|
|
setHints([]) |
|
|
|
setHints([]) |
|
|
@ -184,7 +178,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
setSlitherEnabled(false) |
|
|
|
setSlitherEnabled(false) |
|
|
|
setSsaWarnings([]) |
|
|
|
setSsaWarnings([]) |
|
|
|
// Reset badge
|
|
|
|
// Reset badge
|
|
|
|
props.event.trigger('staticAnaysisWarning', [0]) |
|
|
|
props.event.trigger('staticAnaysisWarning', [-1]) |
|
|
|
// Reset state
|
|
|
|
// Reset state
|
|
|
|
dispatch({ type: '', payload: initialState }) |
|
|
|
dispatch({ type: '', payload: initialState }) |
|
|
|
setShowSlither(false) |
|
|
|
setShowSlither(false) |
|
|
@ -257,6 +251,19 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
}, [ssaWarnings.length]) |
|
|
|
}, [ssaWarnings.length]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if(hints.length === 0) { |
|
|
|
|
|
|
|
props.analysisModule.hints = [] |
|
|
|
|
|
|
|
props.event.trigger('staticAnaysisWarning', []) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, [hints.length]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if(solhintEnabled === false) { |
|
|
|
|
|
|
|
props.analysisModule.hints = [] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, [solhintEnabled]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const showWarnings = (warningMessage, groupByKey) => { |
|
|
|
const showWarnings = (warningMessage, groupByKey) => { |
|
|
@ -326,7 +333,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleLinterEnabled = () => { |
|
|
|
const handleLinterEnabled = async () => { |
|
|
|
if (solhintEnabled) { |
|
|
|
if (solhintEnabled) { |
|
|
|
setSolhintEnabled(false) |
|
|
|
setSolhintEnabled(false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -414,8 +421,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
setHideWarnings(!hideWarnings) |
|
|
|
setHideWarnings(!hideWarnings) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log({ ssaWarnings, remixAnalysisNoLibs, slitherWarnings, hints }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const tabKeys = [ |
|
|
|
const tabKeys = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
tabKey: "linter", |
|
|
|
tabKey: "linter", |
|
|
@ -502,7 +507,6 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
{hint.formattedMessage} |
|
|
|
{hint.formattedMessage} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
<span>{hint.type}</span> |
|
|
|
|
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
<span>{`${hint.column}:${hint.line}`}</span> |
|
|
|
<span>{`${hint.column}:${hint.line}`}</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -516,7 +520,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
), |
|
|
|
), |
|
|
|
title: ( |
|
|
|
title: ( |
|
|
|
<span> |
|
|
|
<span> |
|
|
|
Linter |
|
|
|
Solhint |
|
|
|
{hints.length > 0 ? ( |
|
|
|
{hints.length > 0 ? ( |
|
|
|
hideWarnings ? ( |
|
|
|
hideWarnings ? ( |
|
|
|
<i className={`badge ${hints.filter(x => x.type === 'error').length > 0 |
|
|
|
<i className={`badge ${hints.filter(x => x.type === 'error').length > 0 |
|
|
@ -610,7 +614,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
name={`staticAnalysisModule${warning.warningModuleName}${index}`} |
|
|
|
name={`staticAnalysisModule${warning.warningModuleName}${index}`} |
|
|
|
message={warning.msg} |
|
|
|
message={warning.msg} |
|
|
|
opt={warning.options} |
|
|
|
opt={warning.options} |
|
|
|
warningErrors={warning.warningErrors} |
|
|
|
warningErrors={''} |
|
|
|
editor={props.analysisModule} |
|
|
|
editor={props.analysisModule} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -625,7 +629,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
name={`staticAnalysisModule${warning.warningModuleName}${index}`} |
|
|
|
name={`staticAnalysisModule${warning.warningModuleName}${index}`} |
|
|
|
message={warning.msg} |
|
|
|
message={warning.msg} |
|
|
|
opt={warning.options} |
|
|
|
opt={warning.options} |
|
|
|
warningErrors={warning.warningErrors} |
|
|
|
warningErrors={''} |
|
|
|
editor={props.analysisModule} |
|
|
|
editor={props.analysisModule} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -673,7 +677,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
<RemixUiCheckbox |
|
|
|
<RemixUiCheckbox |
|
|
|
id="solhintstaticanalysis" |
|
|
|
id="solhintstaticanalysis" |
|
|
|
inputType="checkbox" |
|
|
|
inputType="checkbox" |
|
|
|
title="SolHint lints the selected contract." |
|
|
|
title="Solhint lints Solidity code for security and style guide validations." |
|
|
|
onClick={handleLinterEnabled} |
|
|
|
onClick={handleLinterEnabled} |
|
|
|
checked={solhintEnabled } |
|
|
|
checked={solhintEnabled } |
|
|
|
label="Solhint" |
|
|
|
label="Solhint" |
|
|
@ -697,11 +701,11 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{state.data && state.file.length > 0 && state.source ? <Button |
|
|
|
{state.data && state.file.length > 0 && state.source ? <Button |
|
|
|
buttonText={`Analyse ${state.file}`} |
|
|
|
buttonText={`Analyse ${state.file}`} |
|
|
|
title={`${runButtonTitle}`} |
|
|
|
|
|
|
|
classList="btn btn-sm btn-primary btn-block" |
|
|
|
classList="btn btn-sm btn-primary btn-block" |
|
|
|
onClick={async () => { |
|
|
|
onClick={async () => { |
|
|
|
await run(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, |
|
|
|
await run(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, |
|
|
|
message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis) |
|
|
|
message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis, solhintEnabled, basicEnabled) |
|
|
|
|
|
|
|
|
|
|
|
await runSlitherAnalysis(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, |
|
|
|
await runSlitherAnalysis(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, |
|
|
|
message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis) |
|
|
|
message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis) |
|
|
|
} |
|
|
|
} |
|
|
@ -712,7 +716,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { |
|
|
|
title={`${runButtonTitle}`} |
|
|
|
title={`${runButtonTitle}`} |
|
|
|
classList="btn btn-sm btn-primary btn-block" |
|
|
|
classList="btn btn-sm btn-primary btn-block" |
|
|
|
onClick={async () => await run(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, |
|
|
|
onClick={async () => await run(state.data, state.source, state.file, state , props, isSupportedVersion, showSlither, categoryIndex, groupedModules, runner,_paq, |
|
|
|
message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis)} |
|
|
|
message, showWarnings, allWarnings, warningContainer, calculateWarningStateEntries, warningState, setHints, hints, setSlitherWarnings, setSsaWarnings, slitherEnabled, setStartAnalysis, solhintEnabled, basicEnabled)} |
|
|
|
disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } |
|
|
|
disabled={(state.data === null || !isSupportedVersion) || (!solhintEnabled && !basicEnabled) } |
|
|
|
/>} |
|
|
|
/>} |
|
|
|
{state && state.data !== null && state.source !== null && state.file.length > 0 ? (<div className="d-flex border-top flex-column"> |
|
|
|
{state && state.data !== null && state.source !== null && state.file.length > 0 ? (<div className="d-flex border-top flex-column"> |
|
|
|