Consensys / truffle-security

MythX smart contract security verification plugin for Truffle Framework
https://mythx.io
124 stars 28 forks source link

Refactor reading json files and sources keys #201

Closed nbanmp closed 5 years ago

nbanmp commented 5 years ago

This changes usage from

truffle run verify Contract1

to either

truffle run verify contracts/file.sol

or

truffle run verify contracts/file.sol:Contract1

Previously, the chosen buildObj (from a json file) might have had way too much extraneous information, as we were choosing the first one we saw, which could very easily have been a very large contract that imported the one we desire to analyze 3 imports in. This change ensures that the correct buildObj is analyzed; the one directly from the compilation of the file in which the contract was declared in.

The other change this PR makes is fixing the mismatch between the sourceList and the keys of sources. They should be the same, but we had previously used the basepath (contract.sol) for the keys of sources, and the full path (/home/user/truffleproject/contracts/contract.sol) for the sourceList. This switches everything over to the full path. This also fixes potential issues with different subdirectories that contain files with the same name.

Things that still need to happen:

daniyarchambylov commented 5 years ago

LGTM :+1: