Merge pull request #718 from crytic/dev-deterministic-output

Fix deterministic output for multiple detectors
pull/719/head
Feist Josselin 4 years ago committed by GitHub
commit 21c9279ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      slither/detectors/functions/arbitrary_send.py
  2. 3
      slither/detectors/functions/external_function.py
  3. 4
      slither/detectors/operations/block_timestamp.py
  4. 3
      slither/detectors/operations/low_level_calls.py
  5. 3
      slither/detectors/statements/assembly.py
  6. 3
      slither/detectors/statements/divide_before_multiply.py

@ -117,6 +117,10 @@ Bob calls `setDestination` and `withdraw`. As a result he withdraws the contract
info = [func, " sends eth to arbitrary user\n"]
info += ["\tDangerous calls:\n"]
# sort the nodes to get deterministic results
nodes.sort(key=lambda x: x.node_id)
for node in nodes:
info += ["\t- ", node, "\n"]

@ -195,6 +195,9 @@ class ExternalFunction(AbstractDetector):
if f.visibility == "public" and f.contract == f.contract_declarer
]
if all_function_definitions:
all_function_definitions = sorted(
all_function_definitions, key=lambda x: x.canonical_name
)
function_definition = all_function_definitions[0]
all_function_definitions = all_function_definitions[1:]

@ -78,6 +78,10 @@ class Timestamp(AbstractDetector):
info = [func, " uses timestamp for comparisons\n"]
info += ["\tDangerous comparisons:\n"]
# sort the nodes to get deterministic results
nodes.sort(key=lambda x: x.node_id)
for node in nodes:
info += ["\t- ", node, "\n"]

@ -48,6 +48,9 @@ class LowLevelCalls(AbstractDetector):
for func, nodes in values:
info = ["Low level call in ", func, ":\n"]
# sort the nodes to get deterministic results
nodes.sort(key=lambda x: x.node_id)
for node in nodes:
info += ["\t- ", node, "\n"]

@ -50,6 +50,9 @@ class Assembly(AbstractDetector):
for func, nodes in values:
info = [func, " uses assembly\n"]
# sort the nodes to get deterministic results
nodes.sort(key=lambda x: x.node_id)
for node in nodes:
info += ["\t- ", node, "\n"]

@ -182,6 +182,9 @@ In general, it's usually a good idea to re-arrange arithmetic to perform multipl
" performs a multiplication on the result of a division:\n",
]
# sort the nodes to get deterministic results
nodes.sort(key=lambda x: x.node_id)
for node in nodes:
info += ["\t-", node, "\n"]

Loading…
Cancel
Save