Giter Club home page Giter Club logo

Comments (7)

norhh avatar norhh commented on September 27, 2024 2

Thanks for the contract, the PR #1812 will fix this

from mythril.

abhinandanudupa avatar abhinandanudupa commented on September 27, 2024

Looks like making this small change in the function extract_address_variable present in the file features.py:226-231 fixes this temporarily:

            elif isinstance(value, list):
                for item in value:
                    if item != None:
                        transfer_vars.update(self.extract_address_variable(item))

        return transfer_vars

(checking if item is not None instance and then updating)

from mythril.

abhinandanudupa avatar abhinandanudupa commented on September 27, 2024

It turns out that objects likestrs (and ints) are also passed to the the function leading to the same issue. Is it due to some changes in an upstream package?

With:

/*
 * @author: Bernhard Mueller (ConsenSys / MythX)
 */

pragma solidity 0.6.4;

interface ICallable {
    function callMe() external;
}

contract HardcodedNotGood {

    address payable _callable = 0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa;
    ICallable callable = ICallable(_callable);

    constructor() public payable {
    }

    function doTransfer(uint256 amount) public {
        _callable.transfer(amount);
    }

    function doSend(uint256 amount) public {
        _callable.send(amount);
    }

     function callLowLevel() public {
         _callable.call.value(0).gas(10000)("");
     }

     function callWithArgs() public {
         callable.callMe{gas: 10000}();
     }
}

I get:

mythril.interfaces.cli [ERROR]: Traceback (most recent call last):
  File "~/venv/lib/python3.10/site-packages/mythril/interfaces/cli.py", line 966, in parse_args_and_execute
    address = load_code(disassembler, args)
  File "~/venv/lib/python3.10/site-packages/mythril/interfaces/cli.py", line 717, in load_code
    address, _ = disassembler.load_from_solidity(
  File "~/venv/lib/python3.10/site-packages/mythril/mythril/mythril_disassembler.py", line 291, in load_from_solidity
    for contract in get_contracts_from_file(
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/soliditycontract.py", line 132, in get_contracts_from_file
    yield SolidityContract(
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/soliditycontract.py", line 197, in __init__
    ).extract_features()
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 28, in extract_features
    ether_vars = self.extract_address_variable(node)
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 224, in extract_address_variable
    transfer_vars.update(self.extract_address_variable(value))
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 228, in extract_address_variable
    transfer_vars.update(self.extract_address_variable(item))
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 224, in extract_address_variable
    transfer_vars.update(self.extract_address_variable(value))
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 224, in extract_address_variable
    transfer_vars.update(self.extract_address_variable(value))
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 228, in extract_address_variable
    transfer_vars.update(self.extract_address_variable(item))
  File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 210, in extract_address_variable
    node.get("nodeType", "") == "ExpressionStatement"
AttributeError: 'str' object has no attribute 'get'

Sorry for the delay in reporting this.

from mythril.

norhh avatar norhh commented on September 27, 2024

Does the current develop work for you? This example works for me on the develop.
Clone the develop and you can directly execute it using ./myth analyze <file_path>

from mythril.

abhinandanudupa avatar abhinandanudupa commented on September 27, 2024

Yes, surprisingly it did fix that issue. But I found a new one in a different file:

mythril.interfaces.cli [ERROR]: Traceback (most recent call last):
  File "/home/parakeet/tests/mythril/mythril/interfaces/cli.py", line 966, in parse_args_and_execute
    address = load_code(disassembler, args)
  File "/home/parakeet/tests/mythril/mythril/interfaces/cli.py", line 717, in load_code
    address, _ = disassembler.load_from_solidity(
  File "/home/parakeet/tests/mythril/mythril/mythril/mythril_disassembler.py", line 272, in load_from_solidity
    if self.check_run_integer_module(file) is False:
  File "/home/parakeet/tests/mythril/mythril/mythril/mythril_disassembler.py", line 236, in check_run_integer_module
    normalized_version = self.solc_version.lstrip("v")
AttributeError: 'NoneType' object has no attribute 'lstrip'

The contract in question does not specify the solidity version (which is wrong) but when I tested it with Mythril v0.23.19 the compilation works fine.

Looks like the source is this recent change:
a28d600

from mythril.

norhh avatar norhh commented on September 27, 2024

This mythril version tries to autofind the solidity version, Can you try to paste the first few lines at the top of the file (till contract <ContractName>)? I'll try fixing this issue

from mythril.

abhinandanudupa avatar abhinandanudupa commented on September 27, 2024

Here is the contract:

contract MarketPlace {
    address owner;
    uint256 private cost = 100;
    uint256 private inventory = 20;
    event Purchase(address _buyer, uint256 _amt);

    function increasePrice (uint256 increaseCost) public {
        require(msg.sender == owner);
        cost += increaseCost;
    }

    function buy() public payable returns (uint256) {
        uint256 amt = msg.value / cost;
        require(inventory > amt);
        inventory -= amt;
        emit Purchase(msg.sender, amt);
    }
}

from mythril.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.