mirror of https://github.com/crytic/slither
commit
90a5977101
@ -0,0 +1,38 @@ |
||||
--- |
||||
body: |
||||
- |
||||
attributes: |
||||
label: "What operating system are you using?" |
||||
id: os |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
label: "How did you install slither?" |
||||
description: | |
||||
For example, using git or python's pip. |
||||
id: install-method |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- type: dropdown |
||||
id: python |
||||
attributes: |
||||
label: Do you have python added to your $PATH? |
||||
multiple: true |
||||
options: |
||||
- "Yes" |
||||
- "No" |
||||
- "Not sure" |
||||
- |
||||
attributes: |
||||
description: | |
||||
Please copy and paste any relevant log output. This |
||||
will be automatically formatted into code, so no need for backticks. |
||||
render: shell |
||||
label: "Output of running `slither-doctor .`:" |
||||
id: logs |
||||
labels: |
||||
- installation-help |
||||
title: "[Installation-Help]: " |
@ -1,55 +0,0 @@ |
||||
--- |
||||
body: |
||||
- |
||||
attributes: |
||||
value: | |
||||
Please check the issues tab to avoid duplicates. |
||||
Thanks for taking the time to fill out this bug report! |
||||
type: markdown |
||||
- |
||||
attributes: |
||||
label: "What operating system are you using?" |
||||
id: os |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
label: "How did you install slither?" |
||||
description: | |
||||
For example, using git or python's pip. |
||||
id: install-method |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- type: dropdown |
||||
id: python |
||||
attributes: |
||||
label: Do you have python added to your $PATH? |
||||
multiple: true |
||||
options: |
||||
- "Yes" |
||||
- "No" |
||||
- "Not sure" |
||||
- type: dropdown |
||||
id: solc |
||||
attributes: |
||||
label: Do you have solc-select installed? |
||||
multiple: true |
||||
options: |
||||
- "Yes" |
||||
- "No" |
||||
- |
||||
attributes: |
||||
description: | |
||||
Please copy and paste any relevant log output. This |
||||
will be automatically formatted into code, so no need for backticks. |
||||
render: shell |
||||
label: "Output of running `slither-doctor .`:" |
||||
id: logs |
||||
type: textarea |
||||
description: "Get help troubleshooting slither installation" |
||||
labels: |
||||
- installation-help |
||||
name: "Trouble with Installing Slither" |
||||
title: "[Installation-Help]: " |
@ -0,0 +1,30 @@ |
||||
# Derived from <https://github.com/pyca/cryptography/blob/SOME_REF/.github/actions/upload-coverage/action.yml> |
||||
# Originally authored by the PyCA Cryptography maintainers, and licensed under |
||||
# the terms of the BSD license: |
||||
# <https://github.com/pyca/cryptography/blob/main/LICENSE.BSD> |
||||
|
||||
name: Upload Coverage |
||||
description: Upload coverage files |
||||
|
||||
runs: |
||||
using: "composite" |
||||
|
||||
steps: |
||||
# FIXME(jl): codecov has the option of including machine information in filename that would solve this unique naming |
||||
# issue more completely. |
||||
# This method has the limitation of 1 coverage file per run, limiting some coverage between online/offline tests. |
||||
- run: | |
||||
COVERAGE_UUID=$(python3 -c "import uuid; print(uuid.uuid4())") |
||||
echo "COVERAGE_UUID=${COVERAGE_UUID}" >> $GITHUB_OUTPUT |
||||
if [ -f .coverage ]; then |
||||
mv .coverage .coverage.${COVERAGE_UUID} |
||||
fi |
||||
id: coverage-uuid |
||||
shell: bash |
||||
- uses: actions/upload-artifact@v3.1.0 |
||||
with: |
||||
name: coverage-data |
||||
path: | |
||||
.coverage.* |
||||
*.lcov |
||||
if-no-files-found: ignore |
@ -0,0 +1,13 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
# used to pass --cov=$path and --cov-append to pytest |
||||
if [ "$1" != "" ]; then |
||||
pytest "$1" tests/e2e/ -n auto |
||||
status_code=$? |
||||
python -m coverage report |
||||
else |
||||
pytest tests/e2e/ -n auto |
||||
status_code=$? |
||||
fi |
||||
|
||||
exit "$status_code" |
@ -0,0 +1,13 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
# used to pass --cov=$path and --cov-append to pytest |
||||
if [ "$1" != "" ]; then |
||||
pytest "$1" tests/tools/read-storage/test_read_storage.py |
||||
status_code=$? |
||||
python -m coverage report |
||||
else |
||||
pytest tests/tools/read-storage/test_read_storage.py |
||||
status_code=$? |
||||
fi |
||||
|
||||
exit "$status_code" |
@ -0,0 +1,13 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
# used to pass --cov=$path and --cov-append to pytest |
||||
if [ "$1" != "" ]; then |
||||
pytest "$1" tests/unit/ -n auto |
||||
status_code=$? |
||||
python -m coverage report |
||||
else |
||||
pytest tests/unit/ -n auto |
||||
status_code=$? |
||||
fi |
||||
|
||||
exit "$status_code" |
@ -1,51 +0,0 @@ |
||||
--- |
||||
name: IR tests |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: IR tests |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-latest, windows-2022] |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
solc-select install 0.5.0 |
||||
solc-select use 0.8.11 --always-install |
||||
|
||||
- name: Install old solc |
||||
if: matrix.os == 'ubuntu-latest' |
||||
run: solc-select install 0.4.0 |
||||
|
||||
|
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_ssa_generation.py |
@ -1,45 +0,0 @@ |
||||
--- |
||||
name: Detectors tests |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Detectors tests |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-latest, windows-2022] |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
|
||||
solc-select use 0.7.3 --always-install |
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_detectors.py |
@ -1,56 +0,0 @@ |
||||
--- |
||||
name: Features tests |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Features tests |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-latest, windows-2022] |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
|
||||
solc-select use 0.8.0 --always-install |
||||
|
||||
cd tests/test_node_modules/ |
||||
npm install hardhat |
||||
cd ../.. |
||||
|
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_features.py |
||||
pytest tests/test_constant_folding.py |
||||
pytest tests/slithir/test_ternary_expressions.py |
||||
pytest tests/slithir/test_operation_reads.py |
||||
pytest tests/test_functions_ids.py |
||||
pytest tests/test_function.py |
||||
pytest tests/test_source_mapping.py |
@ -1,49 +0,0 @@ |
||||
--- |
||||
name: Parser tests |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Parser tests |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-latest, windows-2022] |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
|
||||
- name: Install solc |
||||
run: | |
||||
solc-select install all |
||||
solc-select use 0.8.0 |
||||
|
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_ast_parsing.py -n auto |
@ -1,53 +0,0 @@ |
||||
--- |
||||
name: Test slither-read-storage |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Test slither-read-storage |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
- name: Setup node |
||||
uses: actions/setup-node@v2 |
||||
with: |
||||
node-version: '14' |
||||
|
||||
- name: Install ganache |
||||
run: npm install --global ganache |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v2 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install python dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
solc-select install 0.8.1 |
||||
solc-select install 0.8.10 |
||||
solc-select use 0.8.1 |
||||
|
||||
- name: Run slither-read-storage |
||||
run: | |
||||
pytest tests/test_read_storage.py |
||||
|
||||
- name: Run storage layout tests |
||||
run: | |
||||
pytest tests/test_storage_layout.py |
@ -0,0 +1,105 @@ |
||||
--- |
||||
name: Pytest |
||||
|
||||
defaults: |
||||
run: |
||||
shell: bash |
||||
|
||||
on: |
||||
push: |
||||
branches: [master, dev] |
||||
pull_request: |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
tests: |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: ["ubuntu-latest", "windows-2022"] |
||||
type: ["unit", "integration", "tool"] |
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v4 |
||||
with: |
||||
python-version: 3.8 |
||||
cache: "pip" |
||||
cache-dependency-path: setup.py |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[test]" |
||||
|
||||
- name: Setup node |
||||
uses: actions/setup-node@v3 |
||||
with: |
||||
node-version: '16' |
||||
cache: 'npm' |
||||
cache-dependency-path: '**/package-lock.json' |
||||
|
||||
- name: Install test dependencies |
||||
run: | |
||||
if [ ${{ matrix.type }} = "tool" ]; then |
||||
# Setup Ganache for slither-read-storage tests. |
||||
npm install --global ganache |
||||
elif [ ${{ matrix.type }} = "integration" ]; then |
||||
# Setup Hardhat for compilation tests. |
||||
pushd tests/e2e/compilation/test_data/test_node_modules/ || exit |
||||
npm install hardhat |
||||
popd || exit |
||||
fi |
||||
|
||||
- name: Run ${{ matrix.type }} tests |
||||
env: |
||||
TEST_TYPE: ${{ matrix.type }} |
||||
# Only run coverage on ubuntu-latest. |
||||
run: | |
||||
if [ ${{ matrix.os }} = "ubuntu-latest" ]; then |
||||
TEST_ARGS="--cov=slither --cov-append" |
||||
elif [ ${{ matrix.os }} = "windows-2022" ]; then |
||||
TEST_ARGS="" |
||||
fi |
||||
bash "./.github/scripts/${TEST_TYPE}_test_runner.sh" $TEST_ARGS |
||||
|
||||
|
||||
- name: Upload coverage |
||||
uses: ./.github/actions/upload-coverage |
||||
# only aggregate test coverage over linux-based tests to avoid any OS-specific filesystem information stored in |
||||
# coverage metadata. |
||||
if: ${{ matrix.os == 'ubuntu-latest' }} |
||||
|
||||
coverage: |
||||
needs: |
||||
- tests |
||||
|
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v4 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- run: pip install coverage[toml] |
||||
|
||||
- name: download coverage data |
||||
uses: actions/download-artifact@v3.0.2 |
||||
with: |
||||
name: coverage-data |
||||
|
||||
- name: combine coverage data |
||||
id: combinecoverage |
||||
run: | |
||||
set +e |
||||
python -m coverage combine |
||||
echo "## python coverage" >> $GITHUB_STEP_SUMMARY |
||||
python -m coverage report -m --format=markdown >> $GITHUB_STEP_SUMMARY |
@ -0,0 +1,88 @@ |
||||
SHELL := /bin/bash
|
||||
|
||||
PY_MODULE := slither
|
||||
TEST_MODULE := tests
|
||||
|
||||
ALL_PY_SRCS := $(shell find $(PY_MODULE) -name '*.py') \
|
||||
$(shell find test -name '*.py')
|
||||
|
||||
# Optionally overriden by the user, if they're using a virtual environment manager.
|
||||
VENV ?= env
|
||||
|
||||
# On Windows, venv scripts/shims are under `Scripts` instead of `bin`.
|
||||
VENV_BIN := $(VENV)/bin
|
||||
ifeq ($(OS),Windows_NT) |
||||
VENV_BIN := $(VENV)/Scripts
|
||||
endif |
||||
|
||||
# Optionally overridden by the user in the `release` target.
|
||||
BUMP_ARGS :=
|
||||
|
||||
# Optionally overridden by the user in the `test` target.
|
||||
TESTS :=
|
||||
|
||||
# Optionally overridden by the user/CI, to limit the installation to a specific
|
||||
# subset of development dependencies.
|
||||
SLITHER_EXTRA := dev
|
||||
|
||||
# If the user selects a specific test pattern to run, set `pytest` to fail fast
|
||||
# and only run tests that match the pattern.
|
||||
# Otherwise, run all tests and enable coverage assertions, since we expect
|
||||
# complete test coverage.
|
||||
ifneq ($(TESTS),) |
||||
TEST_ARGS := -x -k $(TESTS)
|
||||
COV_ARGS :=
|
||||
else |
||||
TEST_ARGS := -n auto
|
||||
COV_ARGS := # --fail-under 100
|
||||
endif |
||||
|
||||
.PHONY: all |
||||
all: |
||||
@echo "Run my targets individually!"
|
||||
|
||||
.PHONY: dev |
||||
dev: $(VENV)/pyvenv.cfg |
||||
|
||||
.PHONY: run |
||||
run: $(VENV)/pyvenv.cfg |
||||
@. $(VENV_BIN)/activate && slither $(ARGS)
|
||||
|
||||
$(VENV)/pyvenv.cfg: pyproject.toml |
||||
# Create our Python 3 virtual environment
|
||||
python3 -m venv env
|
||||
$(VENV_BIN)/python -m pip install --upgrade pip
|
||||
$(VENV_BIN)/python -m pip install -e .[$(SLITHER_EXTRA)]
|
||||
|
||||
.PHONY: lint |
||||
lint: $(VENV)/pyvenv.cfg |
||||
. $(VENV_BIN)/activate && \
|
||||
black --check . && \
|
||||
pylint $(PY_MODULE) $(TEST_MODULE)
|
||||
# ruff $(ALL_PY_SRCS) && \
|
||||
# mypy $(PY_MODULE) &&
|
||||
|
||||
.PHONY: reformat |
||||
reformat: |
||||
. $(VENV_BIN)/activate && \
|
||||
black .
|
||||
|
||||
.PHONY: test tests |
||||
test tests: $(VENV)/pyvenv.cfg |
||||
. $(VENV_BIN)/activate && \
|
||||
pytest --cov=$(PY_MODULE) $(T) $(TEST_ARGS) && \
|
||||
python -m coverage report -m $(COV_ARGS)
|
||||
|
||||
.PHONY: doc |
||||
doc: $(VENV)/pyvenv.cfg |
||||
. $(VENV_BIN)/activate && \
|
||||
PDOC_ALLOW_EXEC=1 pdoc -o html slither '!slither.tools'
|
||||
|
||||
.PHONY: package |
||||
package: $(VENV)/pyvenv.cfg |
||||
. $(VENV_BIN)/activate && \
|
||||
python3 -m build
|
||||
|
||||
.PHONY: edit |
||||
edit: |
||||
$(EDITOR) $(ALL_PY_SRCS)
|
@ -1 +1,4 @@ |
||||
""" |
||||
.. include:: ../README.md |
||||
""" |
||||
from .slither import Slither |
||||
|
@ -1,19 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
from slither.core.source_mapping.source_mapping import SourceMapping |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
|
||||
class ChildContract(SourceMapping): |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._contract = None |
||||
|
||||
def set_contract(self, contract: "Contract") -> None: |
||||
self._contract = contract |
||||
|
||||
@property |
||||
def contract(self) -> "Contract": |
||||
return self._contract |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Event |
||||
|
||||
|
||||
class ChildEvent: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._event = None |
||||
|
||||
def set_event(self, event: "Event"): |
||||
self._event = event |
||||
|
||||
@property |
||||
def event(self) -> "Event": |
||||
return self._event |
@ -1,18 +0,0 @@ |
||||
from typing import TYPE_CHECKING, Union |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.expressions.expression import Expression |
||||
from slither.slithir.operations import Operation |
||||
|
||||
|
||||
class ChildExpression: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._expression = None |
||||
|
||||
def set_expression(self, expression: Union["Expression", "Operation"]) -> None: |
||||
self._expression = expression |
||||
|
||||
@property |
||||
def expression(self) -> Union["Expression", "Operation"]: |
||||
return self._expression |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Function |
||||
|
||||
|
||||
class ChildFunction: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._function = None |
||||
|
||||
def set_function(self, function: "Function") -> None: |
||||
self._function = function |
||||
|
||||
@property |
||||
def function(self) -> "Function": |
||||
return self._function |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
|
||||
class ChildInheritance: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._contract_declarer = None |
||||
|
||||
def set_contract_declarer(self, contract: "Contract") -> None: |
||||
self._contract_declarer = contract |
||||
|
||||
@property |
||||
def contract_declarer(self) -> "Contract": |
||||
return self._contract_declarer |
@ -1,31 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.compilation_unit import SlitherCompilationUnit |
||||
from slither.core.cfg.node import Node |
||||
from slither.core.declarations import Function, Contract |
||||
|
||||
|
||||
class ChildNode: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._node = None |
||||
|
||||
def set_node(self, node: "Node") -> None: |
||||
self._node = node |
||||
|
||||
@property |
||||
def node(self) -> "Node": |
||||
return self._node |
||||
|
||||
@property |
||||
def function(self) -> "Function": |
||||
return self.node.function |
||||
|
||||
@property |
||||
def contract(self) -> "Contract": |
||||
return self.node.function.contract |
||||
|
||||
@property |
||||
def compilation_unit(self) -> "SlitherCompilationUnit": |
||||
return self.node.compilation_unit |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Structure |
||||
|
||||
|
||||
class ChildStructure: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._structure = None |
||||
|
||||
def set_structure(self, structure: "Structure") -> None: |
||||
self._structure = structure |
||||
|
||||
@property |
||||
def structure(self) -> "Structure": |
||||
return self._structure |
@ -0,0 +1,29 @@ |
||||
from typing import TYPE_CHECKING, Optional |
||||
|
||||
from slither.core.source_mapping.source_mapping import SourceMapping |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
|
||||
class ContractLevel(SourceMapping): |
||||
""" |
||||
This class is used to represent objects that are at the contract level |
||||
The opposite is TopLevel |
||||
|
||||
""" |
||||
|
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
# TODO remove all the setters for the child objects |
||||
# And make it a constructor arguement |
||||
# This will remove the optional |
||||
self._contract: Optional["Contract"] = None |
||||
|
||||
def set_contract(self, contract: "Contract") -> None: |
||||
self._contract = contract |
||||
|
||||
@property |
||||
def contract(self) -> "Contract": |
||||
assert self._contract |
||||
return self._contract |
@ -1,20 +0,0 @@ |
||||
from typing import Optional, TYPE_CHECKING |
||||
|
||||
from slither.core.expressions.expression import Expression |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.solidity_types.type import Type |
||||
|
||||
|
||||
class ExpressionTyped(Expression): # pylint: disable=too-few-public-methods |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._type: Optional["Type"] = None |
||||
|
||||
@property |
||||
def type(self) -> Optional["Type"]: |
||||
return self._type |
||||
|
||||
@type.setter |
||||
def type(self, new_type: "Type"): |
||||
self._type = new_type |
@ -1,6 +1,19 @@ |
||||
from typing import TYPE_CHECKING, Optional |
||||
from slither.core.variables.variable import Variable |
||||
from slither.core.children.child_structure import ChildStructure |
||||
|
||||
|
||||
class StructureVariable(ChildStructure, Variable): |
||||
pass |
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Structure |
||||
|
||||
|
||||
class StructureVariable(Variable): |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._structure: Optional["Structure"] = None |
||||
|
||||
def set_structure(self, structure: "Structure") -> None: |
||||
self._structure = structure |
||||
|
||||
@property |
||||
def structure(self) -> "Structure": |
||||
return self._structure |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue