static analysis: change to new file structure

pull/7/head
soad003 6 years ago
parent 5a9a733ef2
commit 4d457a81a2
  1. 34
      remix-analyzer/src/solidity-analyzer/modules/stringBytesLength.js
  2. 4
      remix-analyzer/test/analysis/staticAnalysisIntegration-test.js

@ -0,0 +1,34 @@
var name = 'String Length: '
var desc = 'Bytes length != String length'
var categories = require('./categories')
var common = require('./staticAnalysisCommon')
function stringBytesLength () {
this.stringToBytesConversions = []
this.bytesLengthChecks = []
}
stringBytesLength.prototype.visit = function (node) {
if (common.isStringToBytesConversion(node)) this.stringToBytesConversions.push(node)
else if (common.isBytesLengthCheck(node)) this.bytesLengthChecks.push(node)
}
stringBytesLength.prototype.report = function (compilationResults) {
if (this.stringToBytesConversions.length > 0 && this.bytesLengthChecks.length > 0) {
return [{
warning: 'Bytes and string length are not the same since strings are assumed to be UTF-8 encoded (according to the ABI defintion) therefore one character is not nessesarily encoded in one byte of data.',
location: this.bytesLengthChecks[0],
more: 'https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#argument-encoding'
}]
} else {
return []
}
}
module.exports = {
name: name,
description: desc,
category: categories.MISC,
Module: stringBytesLength
}

@ -487,7 +487,7 @@ test('Integration test selfdestruct.js', function (t) {
'selfdestruct.sol': 3,
'deleteDynamicArray.sol': 0,
'blockLevelCompare.sol': 0,
'intDivisionTruncate.sol': 1, // 5
'intDivisionTruncate.sol': 5,
'stringBytesLength.sol': 0
}
@ -639,7 +639,7 @@ test('Integration test intDivisionTruncate.js', function (t) {
test('Integration test stringBytesLength.js', function (t) {
t.plan(testFiles.length)
var module = require('../../src/analysis/modules/stringBytesLength')
var module = require('../../src/solidity-analyzer/modules/stringBytesLength')
var lengthCheck = {
'KingOfTheEtherThrone.sol': 0,

Loading…
Cancel
Save