Commit 4d457a81 authored by soad003's avatar soad003

static analysis: change to new file structure

parent 5a9a733e
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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment