internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: crytic/slither

Issue:
AssertionError when obtaining address of library
```solidity
library UnsafeMath {
    function add(uint a, uint b) external returns (uint) {
        return a + b;
    }
}

contract Test {
    function getUnsafeMathAddr() public view returns (address) {
        return address(UnsafeMath);
    }
}
```

https://solidity.readthedocs.io/en/latest/contracts.html#libraries:~:text=It%20is%20possible%20to%20obtain%20the%20address%20of%20a%20library


Discussion:

Resolving patch:
diff --git a/slither/slithir/operations/type_conversion.py b/slither/slithir/operations/type_conversion.py
--- a/slither/slithir/operations/type_conversion.py
+++ b/slither/slithir/operations/type_conversion.py
@@ -1,3 +1,4 @@
+from slither.core.declarations import Contract
 from slither.core.solidity_types.type import Type
 from slither.slithir.operations.lvalue import OperationWithLValue
 from slither.slithir.utils.utils import is_valid_lvalue, is_valid_rvalue
@@ -7,7 +8,7 @@ class TypeConversion(OperationWithLValue):
 
     def __init__(self, result, variable, variable_type):
         super().__init__()
-        assert is_valid_rvalue(variable)
+        assert is_valid_rvalue(variable) or isinstance(variable, Contract)
         assert is_valid_lvalue(result)
         assert isinstance(variable_type, Type)
 


Test patch:
Repository: crytic/slither

Issue:
Incorrect type(Proxy).creationCode support
This:

https://github.com/argentlabs/argent-contracts/blob/157d9dd287ef20a5b08e4eda39dcf96385ce0229/contracts/infrastructure/WalletFactory.sol#L139

result in 
`ERROR:ContractSolcParsing:Missing function Variable not found: type() (context <slither.solc_parsing.declarations.function.FunctionSolc object at X>)`

Slither supports `type(Proxy).creationCode`, but it looks this specific case is not correctly handled 
Incorrect type(Proxy).creationCode support
This:

https://github.com/argentlabs/argent-contracts/blob/157d9dd287ef20a5b08e4eda39dcf96385ce0229/contracts/infrastructure/WalletFactory.sol#L139

result in 
`ERROR:ContractSolcParsing:Missing function Variable not found: type() (context <slither.solc_parsing.declarations.function.FunctionSolc object at X>)`

Slither supports `type(Proxy).creationCode`, but it looks this specific case is not correctly handled 


Discussion:

Resolving patch:
diff --git a/slither/core/declarations/solidity_variables.py b/slither/core/declarations/solidity_variables.py
--- a/slither/core/declarations/solidity_variables.py
+++ b/slither/core/declarations/solidity_variables.py
@@ -66,6 +66,7 @@
     # abi.decode returns an a list arbitrary types
     "abi.decode()": [],
     "type(address)": [],
+    "type()": [], # 0.6.8 changed type(address) to type()
 }
 
 
diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py
--- a/slither/slithir/convert.py
+++ b/slither/slithir/convert.py
@@ -581,7 +581,7 @@ def propagate_types(ir, node):
             elif isinstance(ir, Send):
                 ir.lvalue.set_type(ElementaryType('bool'))
             elif isinstance(ir, SolidityCall):
-                if ir.function.name == 'type(address)':
+                if ir.function.name in ['type(address)', 'type()']:
                     ir.function.return_type = [TypeInformation(ir.arguments[0])]
                 return_type = ir.function.return_type
                 if len(return_type) == 1:


Test patch:
Repository: crytic/slither

Issue:
AttributeError: 'StructureTopLevel' object has no attribute 'contract'
On 0x0cf55d57d241161e0ec68e72cbb175dbfe84173a

Here there should be a different case for top-level elements and non-top-level:

https://github.com/crytic/slither/blob/c0c581b3ba830b6ce8dc3f4be82592a7a42e9752/slither/core/solidity_types/user_defined_type.py#L65-L66
AttributeError: 'StructureTopLevel' object has no attribute 'contract'
On 0x0cf55d57d241161e0ec68e72cbb175dbfe84173a

Here there should be a different case for top-level elements and non-top-level:

https://github.com/crytic/slither/blob/c0c581b3ba830b6ce8dc3f4be82592a7a42e9752/slither/core/solidity_types/user_defined_type.py#L65-L66


Discussion:
@montyly so if we have some `struct` defined out of any `contract` or `interface` then slither would throw this `AttributeError`?
I am running into the same error on this repo: https://github.com/sushiswap/bentobox
@montyly so if we have some `struct` defined out of any `contract` or `interface` then slither would throw this `AttributeError`?
I am running into the same error on this repo: https://github.com/sushiswap/bentobox

Resolving patch:
diff --git a/slither/core/solidity_types/user_defined_type.py b/slither/core/solidity_types/user_defined_type.py
--- a/slither/core/solidity_types/user_defined_type.py
+++ b/slither/core/solidity_types/user_defined_type.py
@@ -59,12 +59,13 @@ def storage_size(self) -> Tuple[int, bool]:
         raise SlitherException(to_log)
 
     def __str__(self):
-        from slither.core.declarations.structure import Structure
-        from slither.core.declarations.enum import Enum
+        from slither.core.declarations.structure_contract import StructureContract
+        from slither.core.declarations.enum_contract import EnumContract
 
-        if isinstance(self.type, (Enum, Structure)):
-            return str(self.type.contract) + "." + str(self.type.name)
-        return str(self.type.name)
+        type_used = self.type
+        if isinstance(type_used, (EnumContract, StructureContract)):
+            return str(type_used.contract) + "." + str(type_used.name)
+        return str(type_used.name)
 
     def __eq__(self, other):
         if not isinstance(other, UserDefinedType):


Test patch:
Repository: crytic/slither

Issue:
`slither-flat` crashes for installed package
When run from an installed `slither-analyzer` package, `slither-flat` crashes with the following exception:

```
File "//path/to//venv/lib/python3.9/site-packages/slither/tools/flattening/flattening.py", line 15, in <module>
    from slither.tools.flattening.export.export import (
ModuleNotFoundError: No module named 'slither.tools.flattening.export'
```
Further inspection shows that the `slither.tools.flattening.export` package/directory is not actually included in the PYPI package (at least for v0.7.0), and is similarly missing when installing from a cloned repo via `pip install .`


Discussion:

Resolving patch:
diff --git a/slither/tools/flattening/export/__init__.py b/slither/tools/flattening/export/__init__.py
new file mode 100644
--- /dev/null
+++ b/slither/tools/flattening/export/__init__.py
@@ -0,0 +1 @@
+
diff --git a/slither/tools/flattening/export/__init__.y.py b/slither/tools/flattening/export/__init__.y.py
deleted file mode 100644


Test patch:
Repository: crytic/slither

Issue:
stop() function in Inline assembly calls is treated as solidity functions
When trying to analyze contract that contains code like this

```
assembly {
  ...
  stop()
  ...
}
```
I'm getting the following error when `name` = `stop()`.
```  
File "/home/ethsec/.local/lib/python3.6/site-packages/slither/core/declarations/solidity_variables.py", line 154, in __init__
    assert name in SOLIDITY_FUNCTIONS
```

Maybe `stop` should be added to `evm_functions.py` list?
stop() function in Inline assembly calls is treated as solidity functions
When trying to analyze contract that contains code like this

```
assembly {
  ...
  stop()
  ...
}
```
I'm getting the following error when `name` = `stop()`.
```  
File "/home/ethsec/.local/lib/python3.6/site-packages/slither/core/declarations/solidity_variables.py", line 154, in __init__
    assert name in SOLIDITY_FUNCTIONS
```

Maybe `stop` should be added to `evm_functions.py` list?


Discussion:
Hi @vanruch, thank you for reporting this. We will fix it
Hi @vanruch, thank you for reporting this. We will fix it

Resolving patch:
diff --git a/slither/solc_parsing/yul/parse_yul.py b/slither/solc_parsing/yul/parse_yul.py
--- a/slither/solc_parsing/yul/parse_yul.py
+++ b/slither/solc_parsing/yul/parse_yul.py
@@ -647,7 +647,16 @@ def parse_yul_function_call(root: YulScope, node: YulNode, ast: Dict) -> Optiona
         if name in unary_ops:
             return UnaryOperation(args[0], unary_ops[name])
 
-        ident = Identifier(SolidityFunction(format_function_descriptor(ident.value.name)))
+        if name == "stop":
+            name = "return"
+            ident = Identifier(SolidityFunction(format_function_descriptor(name)))
+            args = [
+                Literal("0", ElementaryType("uint256")),
+                Literal("0", ElementaryType("uint256")),
+            ]
+
+        else:
+            ident = Identifier(SolidityFunction(format_function_descriptor(ident.value.name)))
 
     if isinstance(ident.value, Function):
         return CallExpression(ident, args, vars_to_typestr(ident.value.returns))


Test patch:
Repository: crytic/slither

Issue:
Update solc-version detector with Solidity 0.7
Currently, the recommended versions are:
```
- 0.5.11 - 0.5.13,
- 0.5.15 - 0.5.17,
- 0.6.8,
- 0.6.10 - 0.6.11. Use a simple pragma version that allows any of these versions. 
```

We need to review the 0.7.x branch and update the detector (including 0.6/0.8)


Discussion:

Resolving patch:
diff --git a/slither/detectors/attributes/incorrect_solc.py b/slither/detectors/attributes/incorrect_solc.py
--- a/slither/detectors/attributes/incorrect_solc.py
+++ b/slither/detectors/attributes/incorrect_solc.py
@@ -35,10 +35,9 @@ class IncorrectSolc(AbstractDetector):
 We also recommend avoiding complex `pragma` statement."""
     WIKI_RECOMMENDATION = """
 Deploy with any of the following Solidity versions:
-- 0.5.11 - 0.5.13,
-- 0.5.15 - 0.5.17,
-- 0.6.8,
-- 0.6.10 - 0.6.11.
+- 0.5.16 - 0.5.17
+- 0.6.11 - 0.6.12
+- 0.7.5 - 0.7.6
 Use a simple pragma version that allows any of these versions.
 Consider using the latest version of Solidity for testing."""
 
@@ -47,7 +46,7 @@ class IncorrectSolc(AbstractDetector):
     LESS_THAN_TXT = "uses lesser than"
 
     TOO_RECENT_VERSION_TXT = (
-        "necessitates a version too recent to be trusted. Consider deploying with 0.6.11"
+        "necessitates a version too recent to be trusted. Consider deploying with 0.6.12/0.7.6"
     )
     BUGGY_VERSION_TXT = (
         "is known to contain severe issues (https://solidity.readthedocs.io/en/latest/bugs.html)"
@@ -55,15 +54,12 @@ class IncorrectSolc(AbstractDetector):
 
     # Indicates the allowed versions. Must be formatted in increasing order.
     ALLOWED_VERSIONS = [
-        "0.5.11",
-        "0.5.12",
-        "0.5.13",
-        "0.5.15",
         "0.5.16",
         "0.5.17",
-        "0.6.8",
-        "0.6.10",
         "0.6.11",
+        "0.6.12",
+        "0.7.5",
+        "0.7.6",
     ]
 
     # Indicates the versions that should not be used.


Test patch:
Repository: crytic/slither

Issue:
Update solc-version detector with Solidity 0.7
Currently, the recommended versions are:
```
- 0.5.11 - 0.5.13,
- 0.5.15 - 0.5.17,
- 0.6.8,
- 0.6.10 - 0.6.11. Use a simple pragma version that allows any of these versions. 
```

We need to review the 0.7.x branch and update the detector (including 0.6/0.8)


Discussion:

Resolving patch:
diff --git a/slither/detectors/attributes/incorrect_solc.py b/slither/detectors/attributes/incorrect_solc.py
--- a/slither/detectors/attributes/incorrect_solc.py
+++ b/slither/detectors/attributes/incorrect_solc.py
@@ -35,10 +35,9 @@ class IncorrectSolc(AbstractDetector):
 We also recommend avoiding complex `pragma` statement."""
     WIKI_RECOMMENDATION = """
 Deploy with any of the following Solidity versions:
-- 0.5.11 - 0.5.13,
-- 0.5.15 - 0.5.17,
-- 0.6.8,
-- 0.6.10 - 0.6.11.
+- 0.5.16 - 0.5.17
+- 0.6.11 - 0.6.12
+- 0.7.5 - 0.7.6
 Use a simple pragma version that allows any of these versions.
 Consider using the latest version of Solidity for testing."""
 
@@ -47,7 +46,7 @@ class IncorrectSolc(AbstractDetector):
     LESS_THAN_TXT = "uses lesser than"
 
     TOO_RECENT_VERSION_TXT = (
-        "necessitates a version too recent to be trusted. Consider deploying with 0.6.11"
+        "necessitates a version too recent to be trusted. Consider deploying with 0.6.12/0.7.6"
     )
     BUGGY_VERSION_TXT = (
         "is known to contain severe issues (https://solidity.readthedocs.io/en/latest/bugs.html)"
@@ -55,15 +54,12 @@ class IncorrectSolc(AbstractDetector):
 
     # Indicates the allowed versions. Must be formatted in increasing order.
     ALLOWED_VERSIONS = [
-        "0.5.11",
-        "0.5.12",
-        "0.5.13",
-        "0.5.15",
         "0.5.16",
         "0.5.17",
-        "0.6.8",
-        "0.6.10",
         "0.6.11",
+        "0.6.12",
+        "0.7.5",
+        "0.7.6",
     ]
 
     # Indicates the versions that should not be used.
diff --git a/slither/detectors/statements/array_length_assignment.py b/slither/detectors/statements/array_length_assignment.py
--- a/slither/detectors/statements/array_length_assignment.py
+++ b/slither/detectors/statements/array_length_assignment.py
@@ -103,6 +103,9 @@ def _detect(self):
         Detect array length assignments
         """
         results = []
+        # Starting from 0.6 .length is read only
+        if self.slither.solc_version >= "0.6.":
+            return results
         for contract in self.contracts:
             array_length_assignments = detect_array_length_assignment(contract)
             if array_length_assignments:


Test patch:
diff --git a/scripts/ci_test_etherlime.sh b/scripts/ci_test_etherlime.sh
--- a/scripts/ci_test_etherlime.sh
+++ b/scripts/ci_test_etherlime.sh
@@ -15,7 +15,7 @@ npm i -g etherlime
 etherlime init
 slither .
 
-if [ $? -eq 8 ]
+if [ $? -eq 7 ]
 then
     exit 0
 fi
Repository: crytic/slither

Issue:
Checklist: add --check-limit-output flag
If enable, generate max `X` findings, and print `Y additional findings, please review [slither_output.txt]`
Checklist: add --check-limit-output flag
If enable, generate max `X` findings, and print `Y additional findings, please review [slither_output.txt]`


Discussion:

Resolving patch:
diff --git a/slither/__main__.py b/slither/__main__.py
--- a/slither/__main__.py
+++ b/slither/__main__.py
@@ -472,6 +472,8 @@ def parse_args(detector_classes, printer_classes):  # pylint: disable=too-many-s
         "--checklist", help=argparse.SUPPRESS, action="store_true", default=False
     )
 
+    group_misc.add_argument("--checklist-limit", help=argparse.SUPPRESS, action="store", default="")
+
     parser.add_argument(
         "--wiki-detectors", help=argparse.SUPPRESS, action=OutputWiki, default=False
     )
@@ -751,7 +753,7 @@ def main_impl(all_detector_classes, all_printer_classes):
 
         # Output our results to markdown if we wish to compile a checklist.
         if args.checklist:
-            output_results_to_markdown(results_detectors)
+            output_results_to_markdown(results_detectors, args.checklist_limit)
 
         # Dont print the number of result for printers
         if number_contracts == 0:
diff --git a/slither/utils/command_line.py b/slither/utils/command_line.py
--- a/slither/utils/command_line.py
+++ b/slither/utils/command_line.py
@@ -145,7 +145,7 @@ def convert_result_to_markdown(txt):
     return "".join(ret)
 
 
-def output_results_to_markdown(all_results):
+def output_results_to_markdown(all_results, checklistlimit: str):
     checks = defaultdict(list)
     info = defaultdict(dict)
     for results in all_results:
@@ -154,13 +154,17 @@ def output_results_to_markdown(all_results):
 
     print("Summary")
     for check in checks:
-        print(f" - [{check}](#{check}) ({len(checks[check])} results)")
+        print(f" - [{check}](#{check}) ({len(checks[check])} results) ({info[check]['impact']})")
 
     counter = 0
     for (check, results) in checks.items():
         print(f"## {check}")
         print(f'Impact: {info[check]["impact"]}')
         print(f'Confidence: {info[check]["confidence"]}')
+        additional = False
+        if checklistlimit and len(results) > 5:
+            results = results[0:5]
+            additional = True
         for result in results:
             print(" - [ ] ID-" + f"{counter}")
             counter = counter + 1
@@ -168,6 +172,8 @@ def output_results_to_markdown(all_results):
             if result["first_markdown_element"]:
                 print(result["first_markdown_element"])
                 print("\n")
+        if additional:
+            print(f"**More results were found, check [{checklistlimit}]({checklistlimit})**")
 
 
 def output_wiki(detector_classes, filter_wiki):


Test patch:
Repository: crytic/slither

Issue:
function.is_protected: Improve heuristic
`function.is_protected` is heavily used by the inbuilt-analyses and many detectors:
https://github.com/crytic/slither/blob/1b15a401c93357bddeae4a99d4c15c14537c04d3/slither/core/declarations/function.py#L1133-L1149

This function was introduced ~1,5 year ago, and gives too many false positives and false negatives (ex: `require(msg.sender == tx.origin)`, https://github.com/crytic/slither/issues/399). We need to improve it. some ideas:
- Use all_slithir_operations, and check for direct comparison with msg.sender
- Find a way to capture correctly `msg.sender` that are used in a call/modifier. The data dependency can't be used here, as it relies on `is_protected`. An alternative would be to compute first the data dependency without the protected information, and recompute it a second time. This would give better results but will require some refactoring. 
- We should make it a property and memoize it



Discussion:

Resolving patch:
diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py
--- a/slither/core/declarations/function.py
+++ b/slither/core/declarations/function.py
@@ -1405,7 +1405,11 @@ def is_protected(self) -> bool:
         """
             Determine if the function is protected using a check on msg.sender
 
-            Only detects if msg.sender is directly used in a condition
+            Consider onlyOwner as a safe modifier.
+            If the owner functionality is incorrectly implemented, this will lead to incorrectly
+            classify the function as protected
+
+            Otherwise only detects if msg.sender is directly used in a condition
             For example, it wont work for:
                 address a = msg.sender
                 require(a == owner)
@@ -1417,6 +1421,9 @@ def is_protected(self) -> bool:
             if self.is_constructor:
                 self._is_protected = True
                 return True
+            if "onlyOwner" in [m.name for m in self.modifiers]:
+                self._is_protected = True
+                return True
             conditional_vars = self.all_conditional_solidity_variables_read(include_loop=False)
             args_vars = self.all_solidity_variables_used_as_args()
             self._is_protected = (


Test patch:
Repository: crytic/slither

Issue:
Broken link in Slither recommendation due to typo in Wiki
Hi, there is a typo (oarameters instead of parameters) in the first-level header "Unindexed ERC20 event oarameters" of the wiki: 
https://github.com/crytic/slither/wiki/Detector-Documentation#unindexed-erc20-event-oarameters

On [L. 19](https://github.com/crytic/slither/blob/3bc22a9b143828edec956f170bdef7234d6707d6/slither/detectors/erc/unindexed_event_parameters.py#L19) of the detector there is also the same typo on `WIKI_TITLE`.



Discussion:

Resolving patch:
diff --git a/slither/detectors/erc/unindexed_event_parameters.py b/slither/detectors/erc/unindexed_event_parameters.py
--- a/slither/detectors/erc/unindexed_event_parameters.py
+++ b/slither/detectors/erc/unindexed_event_parameters.py
@@ -16,7 +16,7 @@ class UnindexedERC20EventParameters(AbstractDetector):
 
     WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#unindexed-erc20-event-parameters"
 
-    WIKI_TITLE = "Unindexed ERC20 event oarameters"
+    WIKI_TITLE = "Unindexed ERC20 event parameters"
     WIKI_DESCRIPTION = "Detects whether events defined by the `ERC20` specification that should have some parameters as `indexed` are missing the `indexed` keyword."
 
     # region wiki_exploit_scenario


Test patch:
Repository: crytic/slither

Issue:
[Bug-Candidate]: Phi-node print missing 'f' in f-string
### Describe the issue:

When printing a Phi-node the string is not formatted.
There seems to be a 'f' missing ahead of the str in https://github.com/crytic/slither/blob/dev/slither/slithir/operations/phi.py#L36

### Code example to reproduce the issue:

slither tests/complex_func.sol --print slithir-ssa

### Version:

dev-branch dd91f770f61eaadc286e2af3c72fb5798e376c16

### Relevant log output:

```
Contract Increment
        Function Increment.increaseBy1()
                IRs:
                        {self.lvalue}({self.lvalue.type}) := ϕ({[str(v) for v in self._rvalues]})
                Expression: i += 1
```


Discussion:

Resolving patch:
diff --git a/slither/slithir/operations/phi.py b/slither/slithir/operations/phi.py
--- a/slither/slithir/operations/phi.py
+++ b/slither/slithir/operations/phi.py
@@ -33,4 +33,4 @@ def nodes(self):
         return self._nodes
 
     def __str__(self):
-        return "{self.lvalue}({self.lvalue.type}) := \u03D5({[str(v) for v in self._rvalues]})"
+        return f"{self.lvalue}({self.lvalue.type}) := \u03D5({[str(v) for v in self._rvalues]})"


Test patch:
Repository: crytic/slither

Issue:
Function.__str__ can raise a TypeError on special FunctionTypes
### Describe the issue:

For special function types like `FunctionType.CONSTRUCTOR_VARIABLES`, the `Function._name` member variable will be `None`, yet the `Function.name` property will return a string as expected (`"slitherConstructorVariables"`). `Function.__str__`, however, returns `self._name` rather than `self.name`. Returning `None` from `__str__` raises a `TypeError` at runtime.

### Code example to reproduce the issue:

Every function for which `Function._function_type == FunctionType.CONSTRUCTOR_VARIABLES` seems to have this problem.

### Version:

0.8.2

### Relevant log output:

_No response_


Discussion:

Resolving patch:
diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py
--- a/slither/core/declarations/function.py
+++ b/slither/core/declarations/function.py
@@ -1724,6 +1724,6 @@ def update_read_write_using_ssa(self):
     ###################################################################################
 
     def __str__(self):
-        return self._name
+        return self.name
 
     # endregion


Test patch: