StaticAnalysis: Add Exact and heuristic classification for module

pull/5370/head
soad003 6 years ago
parent a4bac990d9
commit 80933f8715
  1. 9
      remix-analyzer/src/solidity-analyzer/modules/algorithmCategories.js
  2. 2
      remix-analyzer/src/solidity-analyzer/modules/assignAndCompare.js
  3. 2
      remix-analyzer/src/solidity-analyzer/modules/blockBlockhash.js
  4. 2
      remix-analyzer/src/solidity-analyzer/modules/blockTimestamp.js
  5. 2
      remix-analyzer/src/solidity-analyzer/modules/checksEffectsInteraction.js
  6. 2
      remix-analyzer/src/solidity-analyzer/modules/constantFunctions.js
  7. 2
      remix-analyzer/src/solidity-analyzer/modules/deleteDynamicArrays.js
  8. 2
      remix-analyzer/src/solidity-analyzer/modules/gasCosts.js
  9. 2
      remix-analyzer/src/solidity-analyzer/modules/guardConditions.js
  10. 2
      remix-analyzer/src/solidity-analyzer/modules/inlineAssembly.js
  11. 4
      remix-analyzer/src/solidity-analyzer/modules/intDivisionTruncate.js
  12. 2
      remix-analyzer/src/solidity-analyzer/modules/lowLevelCalls.js
  13. 2
      remix-analyzer/src/solidity-analyzer/modules/noReturn.js
  14. 6
      remix-analyzer/src/solidity-analyzer/modules/selfdestruct.js
  15. 2
      remix-analyzer/src/solidity-analyzer/modules/similarVariableNames.js
  16. 2
      remix-analyzer/src/solidity-analyzer/modules/thisLocal.js
  17. 2
      remix-analyzer/src/solidity-analyzer/modules/txOrigin.js

@ -0,0 +1,9 @@
/**
* Should be used to categorize different modules, main reason is to give users feedback if the modules
* Produce exact results or have false positives and negatives in them
* A further category could be approximate if some form of approximation is used
*/
module.exports = {
EXACT: { hasFalsePositives: false, hasFalseNegatives: false, id: 'EXACT' },
HEURISTIC: { hasFalsePositives: true, hasFalseNegatives: true, id: 'HEURI' }
}

@ -2,6 +2,7 @@ var name = 'Result not used: '
var desc = 'The result of an operation was not used.'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function assignAndCompare () {
this.warningNodes = []
@ -24,5 +25,6 @@ module.exports = {
name: name,
description: desc,
category: categories.MISC,
algorithm: algo.EXACT,
Module: assignAndCompare
}

@ -2,6 +2,7 @@ var name = 'Block.blockhash usage: '
var desc = 'Semantics maybe unclear'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function blockBlockhash () {
this.warningNodes = []
@ -27,6 +28,7 @@ module.exports = {
name: name,
description: desc,
category: categories.SECURITY,
algorithm: algo.EXACT,
Module: blockBlockhash
}

@ -2,6 +2,7 @@ var name = 'Block timestamp: '
var desc = 'Semantics maybe unclear'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function blockTimestamp () {
this.warningNowNodes = []
@ -35,6 +36,7 @@ module.exports = {
name: name,
description: desc,
category: categories.SECURITY,
algorithm: algo.EXACT,
Module: blockTimestamp
}

@ -4,6 +4,7 @@ var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var fcallGraph = require('./functionCallGraph')
var AbstractAst = require('./abstractAstView')
var algo = require('./algorithmCategories')
function checksEffectsInteraction () {
this.abstractAst = new AbstractAst()
@ -84,5 +85,6 @@ module.exports = {
name: name,
description: desc,
category: categories.SECURITY,
algorithm: algo.HEURISTIC,
Module: checksEffectsInteraction
}

@ -4,6 +4,7 @@ var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var fcallGraph = require('./functionCallGraph')
var AbstractAst = require('./abstractAstView')
var algo = require('./algorithmCategories')
function constantFunctions () {
this.abstractAst = new AbstractAst()
@ -104,5 +105,6 @@ module.exports = {
name: name,
description: desc,
category: categories.MISC,
algorithm: algo.HEURISTIC,
Module: constantFunctions
}

@ -2,6 +2,7 @@ var name = 'Delete on dynamic Array: '
var desc = 'Use require and appropriately'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function deleteDynamicArrays () {
this.rel = []
@ -25,5 +26,6 @@ module.exports = {
name: name,
description: desc,
category: categories.GAS,
algorithm: algo.EXACT,
Module: deleteDynamicArrays
}

@ -1,6 +1,7 @@
var name = 'Gas costs: '
var desc = 'Warn if the gas requirements of functions are too high.'
var categories = require('./categories')
var algo = require('./algorithmCategories')
function gasCosts () {
}
@ -61,5 +62,6 @@ module.exports = {
name: name,
description: desc,
category: categories.GAS,
algorithm: algo.EXACT,
Module: gasCosts
}

@ -2,6 +2,7 @@ var name = 'Guard Conditions: '
var desc = 'Use require and appropriately'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function guardConditions () {
this.guards = []
@ -25,5 +26,6 @@ module.exports = {
name: name,
description: desc,
category: categories.MISC,
algorithm: algo.EXACT,
Module: guardConditions
}

@ -2,6 +2,7 @@ var name = 'Inline assembly: '
var desc = 'Use of Inline Assembly'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function inlineAssembly () {
this.inlineAssNodes = []
@ -26,5 +27,6 @@ module.exports = {
name: name,
description: desc,
category: categories.SECURITY,
algorithm: algo.EXACT,
Module: inlineAssembly
}

@ -2,6 +2,7 @@ var name = 'Data Trucated: '
var desc = 'Division on int/uint values truncates the result.'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function intDivitionTruncate () {
this.warningNodes = []
@ -14,7 +15,7 @@ intDivitionTruncate.prototype.visit = function (node) {
intDivitionTruncate.prototype.report = function (compilationResults) {
return this.warningNodes.map(function (item, i) {
return {
warning: 'Division of integer values yields an integer value again. That means eg. a / 100 = 0 instead of 0.a since the result is an integer again. This does not hold for division of (only) literal values since those yield rational constants.',
warning: 'Division of integer values yields an integer value again. That means e.g. 10 / 100 = 0 instead of 0.1 since the result is an integer again. This does not hold for division of (only) literal values since those yield rational constants.',
location: item.src
}
})
@ -24,5 +25,6 @@ module.exports = {
name: name,
description: desc,
category: categories.MISC,
algorithm: algo.EXACT,
Module: intDivitionTruncate
}

@ -2,6 +2,7 @@ var name = 'Low level calls: '
var desc = 'Semantics maybe unclear'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function lowLevelCalls () {
this.llcNodes = []
@ -59,6 +60,7 @@ module.exports = {
name: name,
description: desc,
category: categories.SECURITY,
algorithm: algo.EXACT,
Module: lowLevelCalls
}

@ -3,6 +3,7 @@ var desc = 'Function with return type is not returning'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var AbstractAst = require('./abstractAstView')
var algo = require('./algorithmCategories')
function noReturn () {
this.abstractAst = new AbstractAst()
@ -69,5 +70,6 @@ module.exports = {
name: name,
description: desc,
category: categories.MISC,
algorithm: algo.EXACT,
Module: noReturn
}

@ -3,6 +3,7 @@ var desc = 'Be aware of caller contracts.'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var AbstractAst = require('./abstractAstView')
var algo = require('./algorithmCategories')
function selfdestruct () {
this.abstractAst = new AbstractAst()
@ -15,9 +16,9 @@ function selfdestruct () {
this.report = this.abstractAst.build_report(report)
}
selfdestruct.prototype.visit = function () { throw new Error('constantFunctions.js no visit function set upon construction') }
selfdestruct.prototype.visit = function () { throw new Error('selfdestruct.js no visit function set upon construction') }
selfdestruct.prototype.report = function () { throw new Error('constantFunctions.js no report function set upon construction') }
selfdestruct.prototype.report = function () { throw new Error('selfdestruct.js no report function set upon construction') }
function report (contracts, multipleContractsWithSameName) {
var warnings = []
@ -53,5 +54,6 @@ module.exports = {
name: name,
description: desc,
category: categories.SECURITY,
algorithm: algo.HEURISTIC,
Module: selfdestruct
}

@ -6,6 +6,7 @@ var AbstractAst = require('./abstractAstView')
var levenshtein = require('fast-levenshtein')
var remixLib = require('remix-lib')
var util = remixLib.util
var algo = require('./algorithmCategories')
function similarVariableNames () {
this.abstractAst = new AbstractAst()
@ -82,5 +83,6 @@ module.exports = {
name: name,
description: desc,
category: categories.MISC,
algorithm: algo.EXACT,
Module: similarVariableNames
}

@ -2,6 +2,7 @@ var name = 'This on local calls: '
var desc = 'Invocation of local functions via this'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
var algo = require('./algorithmCategories')
function thisLocal () {
this.warningNodes = []
@ -25,5 +26,6 @@ module.exports = {
name: name,
description: desc,
category: categories.GAS,
algorithm: algo.EXACT,
Module: thisLocal
}

@ -1,6 +1,7 @@
var name = 'Transaction origin: '
var desc = 'Warn if tx.origin is used'
var categories = require('./categories')
var algo = require('./algorithmCategories')
function txOrigin () {
this.txOriginNodes = []
@ -31,5 +32,6 @@ module.exports = {
name: name,
description: desc,
category: categories.SECURITY,
algorithm: algo.EXACT,
Module: txOrigin
}

Loading…
Cancel
Save