diff --git a/remix-analyzer/src/solidity-analyzer/modules/algorithmCategories.js b/remix-analyzer/src/solidity-analyzer/modules/algorithmCategories.js new file mode 100644 index 0000000000..f7d5607a4f --- /dev/null +++ b/remix-analyzer/src/solidity-analyzer/modules/algorithmCategories.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' } +} diff --git a/remix-analyzer/src/solidity-analyzer/modules/assignAndCompare.js b/remix-analyzer/src/solidity-analyzer/modules/assignAndCompare.js index c9ec2e7820..1b827cf6a9 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/assignAndCompare.js +++ b/remix-analyzer/src/solidity-analyzer/modules/assignAndCompare.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/blockBlockhash.js b/remix-analyzer/src/solidity-analyzer/modules/blockBlockhash.js index 094c2d33d4..01854ba325 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/blockBlockhash.js +++ b/remix-analyzer/src/solidity-analyzer/modules/blockBlockhash.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/blockTimestamp.js b/remix-analyzer/src/solidity-analyzer/modules/blockTimestamp.js index a91d77ff81..805505ca38 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/blockTimestamp.js +++ b/remix-analyzer/src/solidity-analyzer/modules/blockTimestamp.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/checksEffectsInteraction.js b/remix-analyzer/src/solidity-analyzer/modules/checksEffectsInteraction.js index 54a1dd051b..190a6e907b 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/checksEffectsInteraction.js +++ b/remix-analyzer/src/solidity-analyzer/modules/checksEffectsInteraction.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/constantFunctions.js b/remix-analyzer/src/solidity-analyzer/modules/constantFunctions.js index 5da3562eb6..ec59246fbc 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/constantFunctions.js +++ b/remix-analyzer/src/solidity-analyzer/modules/constantFunctions.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/deleteDynamicArrays.js b/remix-analyzer/src/solidity-analyzer/modules/deleteDynamicArrays.js index b1143d179e..c41dc95d8f 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/deleteDynamicArrays.js +++ b/remix-analyzer/src/solidity-analyzer/modules/deleteDynamicArrays.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/gasCosts.js b/remix-analyzer/src/solidity-analyzer/modules/gasCosts.js index d9d09cfa4c..2d2c1a7a40 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/gasCosts.js +++ b/remix-analyzer/src/solidity-analyzer/modules/gasCosts.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/guardConditions.js b/remix-analyzer/src/solidity-analyzer/modules/guardConditions.js index a9d877c57c..8459737213 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/guardConditions.js +++ b/remix-analyzer/src/solidity-analyzer/modules/guardConditions.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/inlineAssembly.js b/remix-analyzer/src/solidity-analyzer/modules/inlineAssembly.js index ab9b6e1d03..c2a597f44d 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/inlineAssembly.js +++ b/remix-analyzer/src/solidity-analyzer/modules/inlineAssembly.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/intDivisionTruncate.js b/remix-analyzer/src/solidity-analyzer/modules/intDivisionTruncate.js index 51a3199a99..f18bbafeb3 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/intDivisionTruncate.js +++ b/remix-analyzer/src/solidity-analyzer/modules/intDivisionTruncate.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/lowLevelCalls.js b/remix-analyzer/src/solidity-analyzer/modules/lowLevelCalls.js index 6e8dd0a352..3c70ad2859 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/lowLevelCalls.js +++ b/remix-analyzer/src/solidity-analyzer/modules/lowLevelCalls.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/noReturn.js b/remix-analyzer/src/solidity-analyzer/modules/noReturn.js index dbd212ead5..54187d0d64 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/noReturn.js +++ b/remix-analyzer/src/solidity-analyzer/modules/noReturn.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/selfdestruct.js b/remix-analyzer/src/solidity-analyzer/modules/selfdestruct.js index e9ac8557a1..644a228b84 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/selfdestruct.js +++ b/remix-analyzer/src/solidity-analyzer/modules/selfdestruct.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/similarVariableNames.js b/remix-analyzer/src/solidity-analyzer/modules/similarVariableNames.js index 903fbab20d..7734c091fe 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/similarVariableNames.js +++ b/remix-analyzer/src/solidity-analyzer/modules/similarVariableNames.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/thisLocal.js b/remix-analyzer/src/solidity-analyzer/modules/thisLocal.js index 2ca7a5975c..cdf2aa468f 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/thisLocal.js +++ b/remix-analyzer/src/solidity-analyzer/modules/thisLocal.js @@ -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 } diff --git a/remix-analyzer/src/solidity-analyzer/modules/txOrigin.js b/remix-analyzer/src/solidity-analyzer/modules/txOrigin.js index 46834e4f8e..512fe579f7 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/txOrigin.js +++ b/remix-analyzer/src/solidity-analyzer/modules/txOrigin.js @@ -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 }