eth int overflow: tests, mul support (#656)
* Move algorithm into ManticoreEVM * Rm buggy unused line * Initial eth testing setup * Check for overflow in mul also * clarifying comment * Install solc for travis * Add sudo * x * Rm travis_retry, since we rarely actually use it, and it's not available in this script for some reason * Check for specific findings * Fix test * Clean up transaction firing logic * Use less strict check, better for floating point
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
contract IntOverflowUnderflow {
|
||||
function intoverflow_add(uint input) {
|
||||
uint local = input + 1;
|
||||
}
|
||||
|
||||
function intoverflow_mul(uint input) {
|
||||
uint local = input * 2;
|
||||
}
|
||||
|
||||
function intunderflow(uint input) {
|
||||
uint local = input - 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import unittest
|
||||
import os
|
||||
|
||||
from manticore.seth import ManticoreEVM, IntegerOverflow
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# FIXME(mark): Remove these two lines when logging works for ManticoreEVM
|
||||
from manticore.utils.log import init_logging
|
||||
init_logging()
|
||||
|
||||
class EthDetectors(unittest.TestCase):
|
||||
def test_int_ovf(self):
|
||||
mevm = ManticoreEVM()
|
||||
mevm.register_detector(IntegerOverflow())
|
||||
filename = os.path.join(THIS_DIR, 'binaries/int_overflow.sol')
|
||||
mevm.multi_tx_analysis(filename)
|
||||
self.assertEqual(len(mevm.global_findings), 3)
|
||||
all_findings = ''.join(map(lambda x: x[2], mevm.global_findings))
|
||||
self.assertIn('underflow at SUB', all_findings)
|
||||
self.assertIn('overflow at ADD', all_findings)
|
||||
self.assertIn('overflow at MUL', all_findings)
|
||||
Reference in New Issue
Block a user