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

sync master <> dev #2475

Merged
merged 72 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
4a241c5
Write file on each save
utx0 Aug 1, 2023
e38966c
detect reinitializer in unprotected_upgrade detector
vovikhangcdv Oct 25, 2023
314ceeb
remove ambiguous relation between _is_upgradeable and _is_upgradeable…
vovikhangcdv Oct 26, 2023
2b81c02
make lint
vovikhangcdv Oct 30, 2023
ca851e2
make lint
vovikhangcdv Oct 30, 2023
4c90475
Merge branch 'dev' into dev
vovikhangcdv Oct 30, 2023
eba14c9
Add more academic references
montyly Jan 2, 2024
d54728c
Update README.md
montyly Mar 13, 2024
f10759c
Update README.md
montyly Mar 13, 2024
3905158
Update README.md
montyly Mar 13, 2024
2bd6cbe
Remove deprecated flags and their migration.
DarkaMaul Apr 8, 2024
41f599b
Remove libraries, mock contract, option interfaces
smonicas Aug 22, 2022
ea01702
Fix remove interfaces inherited
smonicas Aug 22, 2022
4164039
Fix
smonicas Aug 22, 2022
20fa97c
Remove interface from inheritance graph.
DarkaMaul Apr 9, 2024
dcec99b
Reduce verbosity for InvalidCompilation errors
DarkaMaul Apr 10, 2024
0ecf6b4
fix: unused state var detector for abstract/library
0xalpharush Apr 11, 2024
57743a4
Merge pull request #2419 from crytic/fix/fp-unused-state-var
0xalpharush Apr 14, 2024
ae0cb5b
Merge pull request #2410 from DarkaMaul/feature/remove-flags-2351
0xalpharush Apr 15, 2024
9413e1e
Fix #2430
DarkaMaul Apr 18, 2024
bb8ad18
chore: fix some typos in comments
careworry Apr 18, 2024
0fad849
Merge pull request #2431 from crytic/fix/evm-printer
0xalpharush Apr 18, 2024
ec06304
Merge pull request #2433 from careworry/master
0xalpharush Apr 18, 2024
6074ab1
Remove calls to isinstance to improve performances.
DarkaMaul Apr 19, 2024
6afe440
Memoize calls to __str__
DarkaMaul Apr 19, 2024
ae6fc40
Remove unneeded metaclass
DarkaMaul Apr 19, 2024
bb84278
Prevent a call to isinstance in _filter_state_variables_written
DarkaMaul Apr 19, 2024
59caf4b
Revert "Memoize calls to __str__"
DarkaMaul Apr 19, 2024
85b39ea
Add missing expression types
DarkaMaul Apr 19, 2024
91e9ff5
Merge branch 'dev' into features/perf-improvment
DarkaMaul Apr 19, 2024
74d8837
Fix bugs in the EVM printer
DarkaMaul Apr 19, 2024
2979cb8
Restore plugin example to working state
elopez Apr 19, 2024
7f82f4a
Merge pull request #2436 from crytic/dev-slither-plugin
0xalpharush Apr 19, 2024
68adb6e
Continue performance improvments
DarkaMaul Apr 22, 2024
950a49c
Merge branch 'dev' into features/perf-improvment
DarkaMaul Apr 22, 2024
82f295f
Replace cache with lru_cache to keep Py3.8 compatibility
DarkaMaul Apr 22, 2024
8c46b9e
Configure coderabbit review to also consider PR on dev branch.
DarkaMaul Apr 23, 2024
7fff11b
chore: fix some typos in comments
alwayshang Apr 24, 2024
5636dff
Merge pull request #2444 from alwayshang/master
0xalpharush Apr 24, 2024
fb23f27
Merge pull request #2417 from crytic/invalid-compilations-errors
0xalpharush Apr 24, 2024
ded705d
Merge pull request #2441 from crytic/features/code-rabbit
0xalpharush Apr 24, 2024
e2daa8a
Add detectors_to_include to override exclude args
nsiregar Apr 23, 2024
0dca6a6
chore: fix typos and link update
xiaoxianBoy May 4, 2024
4645ba5
Merge pull request #2453 from xiaoxianBoy/fix-typos
0xalpharush May 5, 2024
1f15416
Merge branch 'dev' into dev
vovikhangcdv May 9, 2024
08d631f
fix: support array of structs in abi.decode
0xalpharush May 15, 2024
5793b0d
Merge pull request #2438 from crytic/features/perf-improvment
0xalpharush May 17, 2024
22b9cfc
fix: use contract declarer's scope for name resolution
0xalpharush May 17, 2024
4f661e4
add test for 08d631f
0xalpharush May 17, 2024
bfa99eb
Merge pull request #2459 from crytic/fix/identifier-resolve-with-rena…
0xalpharush May 17, 2024
aed5927
Merge pull request #2460 from crytic/test/abi-decode-array-of-structs
0xalpharush May 17, 2024
40578ae
dependabot[bot] May 20, 2024
599edf7
dependabot[bot] May 20, 2024
f0b592e
Merge pull request #2463 from crytic/dependabot/github_actions/dev/ca…
0xalpharush May 28, 2024
9ee2ae0
Merge pull request #2461 from crytic/dependabot/github_actions/dev/ca…
0xalpharush May 28, 2024
221cfc6
chore: remove unused scripts
0xalpharush Jun 3, 2024
a46835b
Merge pull request #2435 from crytic/fix/evm-printer
0xalpharush Jun 4, 2024
7d3b73c
Merge pull request #2440 from nsiregar/add-detectors-to-include-overr…
0xalpharush Jun 4, 2024
dc767b1
Merge pull request #2468 from crytic/chore/remove-unused-scripts
0xalpharush Jun 4, 2024
ecf8b24
lint
0xalpharush Jun 4, 2024
8615b19
Merge branch 'dev' into fix-inheritance-printer-rebase
0xalpharush Jun 4, 2024
5d78357
Merge branch 'dev' into update-readme
0xalpharush Jun 4, 2024
ee7023c
Merge pull request #2153 from crytic/fix-inheritance-printer-rebase
0xalpharush Jun 4, 2024
4a3a2f6
Merge pull request #2270 from crytic/update-readme
0xalpharush Jun 4, 2024
dde3378
Merge pull request #2203 from vovikhangcdv/dev
0xalpharush Jun 4, 2024
23006f5
Merge pull request #2071 from utx0/master
0xalpharush Jun 4, 2024
b9a3ea6
remove similar-names bc it's slow (#2469)
0xalpharush Jun 4, 2024
4d09e59
Improve message error for when Crytic throws a KeyError. (#2418)
DarkaMaul Jun 5, 2024
57842b0
Fix regex patterns (#2442)
DarkaMaul Jun 5, 2024
5443292
fix: do not flag imports from import container as unused (#2471)
0xalpharush Jun 5, 2024
a0afa25
fix: filtering of unused-import,incorrect-solc, pragma (#2472)
0xalpharush Jun 5, 2024
02df0dc
prepare 0.10.3 release (#2474)
0xalpharush Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en"
early_access: false
knowledge_base:
learnings:
scope: auto
issues:
scope: global
reviews:
profile: "chill"
request_changes_workflow: false
high_level_summary: true
poem: false
review_status: true
collapse_walkthrough: true
auto_review:
enabled: true
ignore_title_keywords:
- "WIP"
- "DO NOT MERGE"
drafts: false
base_branches:
- dev
chat:
auto_reply: true
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ jobs:

- name: Set up nix
if: matrix.type == 'dapp'
uses: cachix/install-nix-action@v26
uses: cachix/install-nix-action@V27

- name: Set up cachix
if: matrix.type == 'dapp'
uses: cachix/cachix-action@v14
uses: cachix/cachix-action@v15
with:
name: dapp

Expand Down
4 changes: 2 additions & 2 deletions plugin_example/setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from setuptools import setup, find_packages

setup(
name="slither-my-plugins",
name="slither_my_plugin",
description="This is an example of detectors and printers to Slither.",
url="https://github.com/trailofbits/slither-plugins",
author="Trail of Bits",
version="0.0",
packages=find_packages(),
python_requires=">=3.8",
install_requires=["slither-analyzer==0.1"],
install_requires=["slither-analyzer>=0.6.0"],
entry_points={
"slither_analyzer.plugin": "slither my-plugin=slither_my_plugin:make_plugin",
},
Expand Down
Empty file.
10 changes: 5 additions & 5 deletions plugin_example/slither_my_plugin/detectors/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class Example(AbstractDetector): # pylint: disable=too-few-public-methods
IMPACT = DetectorClassification.HIGH
CONFIDENCE = DetectorClassification.HIGH

WIKI = ""
WIKI = "https://www.example.com/#example-detector"

WIKI_TITLE = ""
WIKI_DESCRIPTION = ""
WIKI_EXPLOIT_SCENARIO = ""
WIKI_RECOMMENDATION = ""
WIKI_TITLE = "example detector"
WIKI_DESCRIPTION = "This is an example detector that always generates a finding"
WIKI_EXPLOIT_SCENARIO = "Scenario goes here"
WIKI_RECOMMENDATION = "Customize the detector"

def _detect(self):

Expand Down
84 changes: 0 additions & 84 deletions scripts/ci_test.sh

This file was deleted.

27 changes: 0 additions & 27 deletions scripts/json_diff.py

This file was deleted.

83 changes: 52 additions & 31 deletions slither/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import sys
import traceback
from importlib import metadata
from typing import Tuple, Optional, List, Dict, Type, Union, Any, Sequence
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Type, Union


from crytic_compile import cryticparser, CryticCompile
from crytic_compile import cryticparser, CryticCompile, InvalidCompilation
from crytic_compile.platform.standard import generate_standard_export
from crytic_compile.platform.etherscan import SUPPORTED_NETWORK
from crytic_compile import compile_all, is_supported
Expand Down Expand Up @@ -93,7 +93,13 @@ def process_all(
detector_classes: List[Type[AbstractDetector]],
printer_classes: List[Type[AbstractPrinter]],
) -> Tuple[List[Slither], List[Dict], List[Output], int]:
compilations = compile_all(target, **vars(args))

try:
compilations = compile_all(target, **vars(args))
except InvalidCompilation:
logger.error("Unable to compile all targets.")
sys.exit(2)

slither_instances = []
results_detectors = []
results_printers = []
Expand Down Expand Up @@ -205,47 +211,54 @@ def choose_detectors(

if args.detectors_to_run == "all":
detectors_to_run = all_detector_classes
if args.detectors_to_exclude:
detectors_excluded = args.detectors_to_exclude.split(",")
for detector in detectors:
if detector in detectors_excluded:
detectors_to_run.remove(detectors[detector])
else:
for detector in args.detectors_to_run.split(","):
if detector in detectors:
detectors_to_run.append(detectors[detector])
else:
raise ValueError(f"Error: {detector} is not a detector")
detectors_to_run = sorted(detectors_to_run, key=lambda x: x.IMPACT)
detectors_to_run = __include_detectors(
set(detectors_to_run), args.detectors_to_run, detectors
)
return detectors_to_run

if args.exclude_optimization:
detectors_to_run = [
d for d in detectors_to_run if d.IMPACT != DetectorClassification.OPTIMIZATION
]
classification_map = {
DetectorClassification.HIGH: args.exclude_high,
DetectorClassification.MEDIUM: args.exclude_medium,
DetectorClassification.LOW: args.exclude_low,
DetectorClassification.INFORMATIONAL: args.exclude_informational,
DetectorClassification.OPTIMIZATION: args.exclude_optimization,
}
excluded_classification = [
classification for classification, included in classification_map.items() if included
]
detectors_to_run = [d for d in detectors_to_run if d.IMPACT not in excluded_classification]

if args.exclude_informational:
detectors_to_run = [
d for d in detectors_to_run if d.IMPACT != DetectorClassification.INFORMATIONAL
]
if args.exclude_low:
detectors_to_run = [d for d in detectors_to_run if d.IMPACT != DetectorClassification.LOW]
if args.exclude_medium:
detectors_to_run = [
d for d in detectors_to_run if d.IMPACT != DetectorClassification.MEDIUM
]
if args.exclude_high:
detectors_to_run = [d for d in detectors_to_run if d.IMPACT != DetectorClassification.HIGH]
if args.detectors_to_exclude:
detectors_to_run = [
d for d in detectors_to_run if d.ARGUMENT not in args.detectors_to_exclude
]

detectors_to_run = sorted(detectors_to_run, key=lambda x: x.IMPACT)
if args.detectors_to_include:
detectors_to_run = __include_detectors(
set(detectors_to_run), args.detectors_to_include, detectors
)

return detectors_to_run


def __include_detectors(
detectors_to_run: Set[Type[AbstractDetector]],
detectors_to_include: str,
detectors: Dict[str, Type[AbstractDetector]],
) -> List[Type[AbstractDetector]]:
include_detectors = detectors_to_include.split(",")

for detector in include_detectors:
if detector in detectors:
detectors_to_run.add(detectors[detector])
else:
raise ValueError(f"Error: {detector} is not a detector")

detectors_to_run = sorted(detectors_to_run, key=lambda x: x.IMPACT)
return detectors_to_run


def choose_printers(
args: argparse.Namespace, all_printer_classes: List[Type[AbstractPrinter]]
) -> List[Type[AbstractPrinter]]:
Expand Down Expand Up @@ -409,6 +422,14 @@ def parse_args(
default=defaults_flag_in_config["exclude_high"],
)

group_detector.add_argument(
"--include-detectors",
help="Comma-separated list of detectors that should be included",
action="store",
dest="detectors_to_include",
default=defaults_flag_in_config["detectors_to_include"],
)

fail_on_group = group_detector.add_mutually_exclusive_group()
fail_on_group.add_argument(
"--fail-pedantic",
Expand Down
8 changes: 3 additions & 5 deletions slither/analyses/evm/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,22 @@ def generate_source_to_evm_ins_mapping(evm_instructions, srcmap_runtime, slither
# In order to compress these source mappings especially for bytecode, the following rules are used:
# If a field is empty, the value of the preceding element is used.
# If a : is missing, all following fields are considered empty.

mapping_item = mapping.split(":")
mapping_item += prev_mapping[len(mapping_item) :]

for i, _ in enumerate(mapping_item):
if mapping_item[i] == "":
mapping_item[i] = int(prev_mapping[i])
mapping_item[i] = prev_mapping[i]

offset, _length, file_id, *_ = mapping_item
offset, _, file_id, *_ = mapping_item
prev_mapping = mapping_item

if file_id == "-1":
# Internal compiler-generated code snippets to be ignored
# See https://github.com/ethereum/solidity/issues/6119#issuecomment-467797635
continue

offset = int(offset)
line_number = file_source[0:offset].count("\n".encode("utf-8")) + 1
line_number = file_source[0 : int(offset)].count("\n".encode("utf-8")) + 1

# Append evm instructions to the corresponding source line number
# Note: Some evm instructions in mapping are not necessarily in program execution order
Expand Down
1 change: 1 addition & 0 deletions slither/core/declarations/custom_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, compilation_unit: "SlitherCompilationUnit") -> None:

self._solidity_signature: Optional[str] = None
self._full_name: Optional[str] = None
self._pattern = "error"

@property
def name(self) -> str:
Expand Down
Loading