sbip-sg / solc-json-parser

A Powerful AST Parser for Solidity
12 stars 1 forks source link

wrong line mapping #48

Closed minhhn2910 closed 1 year ago

minhhn2910 commented 1 year ago
pragma solidity ^0.8.0;
contract Test {
    int a;
    mapping (address => bool) test;
    function bug(address[10] memory input) public {
        for(uint i=0; i<input.length; i++){
            test[input[i]] = true;
        }
        //bug is hidden if we dont control input length
        uint temp = block.timestamp;
        temp = block.number;
        payable(msg.sender).transfer(1234);
    }
 }
Test 2 bugs found
sample_contracts/test_false_negative.sol BlockNumberDependency 67 189
9         //bug is hidden if we dont control input length
--------------------------------------------------------------------------------
sample_contracts/test_false_negative.sol UnauthorizedSend CALL 207
10         uint temp = block.timestamp;
--------------------------------------------------------------------------------
********************************************************************************
0 Total Revert TXs, Percentage: 0.0
{'-0x5a00f655ef7caae9': {'bug_type': 'BlockNumberDependency',
                         'bytecode_location': 189,
                         'contract': 'Test',
                         'deploy': False,
                         'function': 'bug',
                         'input': ['0x0000000000000000000000000000000000000000'],
                         'is_yul': False,
                         'line_number': [9, 9],
                         'opcode': 67},
 '0xc674552d928a9b9': {'bug_type': 'UnauthorizedSend',
                       'bytecode_location': 207,
                       'contract': 'Test',
                       'deploy': False,
                       'function': 'bug',
                       'input': ['0x0000000000000000000000000000000000000000'],
                       'is_yul': False,
                       'line_number': [10, 10],
                       'opcode': 'CALL'}}

The commit long time ago is still working correctly https://github.com/sbip-sg/solc-json-parser/commit/317b44fcef6ecc46a92cf892ba0362a022a19b4e. I will switch back to the old one for now