Skip to content

Commit

Permalink
Black run
Browse files Browse the repository at this point in the history
  • Loading branch information
bart1e committed May 3, 2023
1 parent 4f67630 commit 5a450a0
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions slither/detectors/statements/incorrect_using_for.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class IncorrectUsingFor(AbstractDetector):
WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-using-for-usage"

WIKI_TITLE = "Incorrect usage of using-for statement"
WIKI_DESCRIPTION = "In Solidity, it is possible to use libraries for certain types, by the `using-for` statement " \
"(`using <library> for <type>`). However, the Solidity compiler doesn't check whether a given " \
"library has at least one function matching a given type. If it doesn't, such a statement has " \
"no effect and may be confusing. "
WIKI_DESCRIPTION = (
"In Solidity, it is possible to use libraries for certain types, by the `using-for` statement "
"(`using <library> for <type>`). However, the Solidity compiler doesn't check whether a given "
"library has at least one function matching a given type. If it doesn't, such a statement has "
"no effect and may be confusing. "
)

# region wiki_exploit_scenario
WIKI_EXPLOIT_SCENARIO = """
Expand All @@ -41,8 +43,10 @@ class IncorrectUsingFor(AbstractDetector):
```
Such a code will compile despite the fact that `L` has no function with `uint` as its first argument."""
# endregion wiki_exploit_scenario
WIKI_RECOMMENDATION = "Make sure that the libraries used in `using-for` statements have at least one function " \
"matching a type used in these statements. "
WIKI_RECOMMENDATION = (
"Make sure that the libraries used in `using-for` statements have at least one function "
"matching a type used in these statements. "
)

@staticmethod
def _implicitly_convertible_to_for_contracts(contract1: Contract, contract2: Contract) -> bool:
Expand Down Expand Up @@ -179,8 +183,10 @@ def _is_correctly_used(type_: Type, library: Contract) -> bool:
return False

def _append_result(self, results: list, uf: UsingForTopLevel, type_: Type, library: Contract):
info = f"using-for statement at {uf.source_mapping} is incorrect - no matching function for {type_} found in " \
f"{library}.\n"
info = (
f"using-for statement at {uf.source_mapping} is incorrect - no matching function for {type_} found in "
f"{library}.\n"
)
res = self.generate_result(info)
results.append(res)

Expand Down

0 comments on commit 5a450a0

Please sign in to comment.