Browse Source

Merge pull request #646 from crytic/feature/skip-assembly

feature to skip assembly
Feist Josselin 3 months ago
parent
commit
6aee221c39

+ 7 - 0
slither/__main__.py

@@ -481,6 +481,13 @@ def parse_args(detector_classes, printer_classes):
         default=defaults_flag_in_config["legacy_ast"],
     )
 
+    parser.add_argument(
+        "--skip-assembly",
+        help=argparse.SUPPRESS,
+        action="store_true",
+        default=defaults_flag_in_config["skip_assembly"],
+    )
+
     parser.add_argument(
         "--ignore-return-value",
         help=argparse.SUPPRESS,

+ 5 - 0
slither/core/slither_core.py

@@ -76,6 +76,7 @@ class SlitherCore(Context):  # pylint: disable=too-many-instance-attributes,too-
 
         # If set to true, slither will not catch errors during parsing
         self._disallow_partial: bool = False
+        self._skip_assembly: bool = False
 
     ###################################################################################
     ###################################################################################
@@ -390,6 +391,10 @@ class SlitherCore(Context):  # pylint: disable=too-many-instance-attributes,too-
         """
         return self._disallow_partial
 
+    @property
+    def skip_assembly(self) -> bool:
+        return self._skip_assembly
+
     # endregion
     ###################################################################################
     ###################################################################################

+ 1 - 0
slither/slither.py

@@ -59,6 +59,7 @@ class Slither(SlitherCore):  # pylint: disable=too-many-instance-attributes
         self._parser: SlitherSolc  #  This could be another parser, like SlitherVyper, interface needs to be determined
 
         self._disallow_partial: bool = kwargs.get("disallow_partial", False)
+        self._skip_assembly: bool = kwargs.get("skip_assembly", False)
 
         # list of files provided (see --splitted option)
         if isinstance(target, list):

+ 1 - 1
slither/solc_parsing/declarations/function.py

@@ -835,7 +835,7 @@ class FunctionSolc:
             node = self._parse_block(statement, node)
         elif name == "InlineAssembly":
             # Added with solc 0.6 - the yul code is an AST
-            if "AST" in statement:
+            if "AST" in statement and not self.slither.skip_assembly:
                 self._function.contains_assembly = True
                 yul_object = self._new_yul_block(statement["src"])
                 entrypoint = yul_object.entrypoint

+ 1 - 0
slither/utils/command_line.py

@@ -39,6 +39,7 @@ defaults_flag_in_config = {
     "filter_paths": None,
     "generate_patches": False,
     # debug command
+    "skip_assembly": False,
     "legacy_ast": False,
     "ignore_return_value": False,
     "zip": None,