Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shadowing-function detector does not work as expected #165

Closed
Xenomega opened this issue Feb 6, 2019 · 0 comments
Closed

shadowing-function detector does not work as expected #165

Xenomega opened this issue Feb 6, 2019 · 0 comments
Assignees

Comments

@Xenomega
Copy link
Member

Xenomega commented Feb 6, 2019

The shadowing-function detector (used internally for the inheritance-graph printer) does not return correct results. It relies on checking that an inheriting contract has a function definition with the same full_name, but does this by using the functions property of a contract. The functions property returns functions from contracts inherited from as well. This causes this detector to return every function for any inherited contract as if it is being shadowed (which the printer later filters out, making it seem as if this detector is behaving as intended).

Example:

contract A {
    function notShadowed() public {

    }
}

contract B is A {

}

This contract will produce the following results from the detector:

[{'vuln': 'ShadowingFunctionContract', 'filename': '.\\tests\\c3_shadowing.sol', 'contractShadower': 'B', 'contract': 'A', 'functions': ['notShadowed()']}]

Obviously notShadowed is not shadowed and should not be returned as a result.

Furthermore, this could be extended to include modifiers so that the printer can highlight shadowed modifiers as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants