mirror of
https://github.com/crytic/slither.git
synced 2026-10-12 02:12:39 +00:00
Initial public commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.sol linguist-language=Solidity
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.DS_Store
|
||||
tags
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache
|
||||
|
||||
*.sw*
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
sudo: required
|
||||
os:
|
||||
- linux
|
||||
language: python
|
||||
python:
|
||||
- 2.7.12
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
install:
|
||||
- scripts/travis_install.sh
|
||||
|
||||
script:
|
||||
- scripts/travis_test.sh
|
||||
|
||||
|
||||
@@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
@@ -0,0 +1,84 @@
|
||||
# Slither, the Solidity source analyzer
|
||||
[](https://travis-ci.com/trailofbits/slither)
|
||||
|
||||
Slither is a Solidity static analyzer framework, it provides an API to manipulate Solidity code easily. In addition to exposing a Solidity contracts AST, Slither provides many APIs to quickly check local and state variable usage.
|
||||
|
||||
With Slither you can:
|
||||
- Detect vulnerabilities.
|
||||
- Speed up your code understanding.
|
||||
- Build custom analyses to answer specific needs.
|
||||
- Quickly prototype a new static analysis technique.
|
||||
|
||||
## How to install
|
||||
|
||||
Use pip to install the dependencies:
|
||||
|
||||
```bash
|
||||
$ sudo -H pip install -U -r requirements.txt
|
||||
```
|
||||
|
||||
You may also want solc, which can be installed using homebrew:
|
||||
|
||||
```bash
|
||||
$ brew update
|
||||
$ brew upgrade
|
||||
$ brew tap ethereum/ethereum
|
||||
$ brew install solidity
|
||||
$ brew linkapps solidity
|
||||
```
|
||||
|
||||
or with aptitude:
|
||||
|
||||
```bash
|
||||
$ sudo add-apt-repository ppa:ethereum/ethereum
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install solc
|
||||
```
|
||||
|
||||
## How to use
|
||||
|
||||
```
|
||||
$ slither.py file.sol
|
||||
```
|
||||
|
||||
```
|
||||
$ slither.py examples/uninitialized.sol
|
||||
[..]
|
||||
INFO:Detectors:Uninitialized state variables in examples/uninitialized.sol, Contract: Uninitialized, Vars: destination, Used in ['transfer']
|
||||
[..]
|
||||
```
|
||||
|
||||
If Slither is applied on a directory, it will run on every `.sol` file of the directory.
|
||||
|
||||
## Options
|
||||
|
||||
### Configuration
|
||||
* `--solc` SOLC: Path to `solc` (default 'solc')
|
||||
* `--disable-solc-warnings`: Do not print solc warnings
|
||||
* `--solc-ast`: Use the solc AST file as input (`solc file.sol --ast-json > file.ast.json`)
|
||||
* `--json` FILE: Export results as JSON
|
||||
* `--solc-args` SOLC_ARGS: Add custom solc arguments. SOLC_ARGS can contain multiple arguments.
|
||||
|
||||
### Analyses
|
||||
* `--high`: Run only medium/high severity checks with high confidence
|
||||
* `--medium`: Run only medium/high severity checks with medium confidence
|
||||
* `--low`: Run only low severity checks
|
||||
|
||||
### Printers
|
||||
* `--print-summary`: Print a summary of the contracts
|
||||
* `--print-quick-summary`: Print a quick summary of the contracts
|
||||
* `--print-inheritance`: Print the inheritance graph
|
||||
|
||||
For more information about printers, see the [Printers documentation](docs/PRINTERS.md)
|
||||
|
||||
## Checks available
|
||||
|
||||
Check | Purpose | Severity | Confidence
|
||||
--- | --- | --- | ---
|
||||
`--uninitialized`| Detect uninitialized variables | High | High
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Slither is licensed and distributed under the AGPLv3 license. [Contact us](mailto:[email protected]) if you're looking for an exception to the terms.ontact us if you're looking for an exception to the terms.
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
# Slither Printers
|
||||
|
||||
Slither allows printing contracts information through its printers.
|
||||
|
||||
## Quick Summary
|
||||
`slither.py file.sol --print-quick-summary`
|
||||
|
||||
Output a quick summary of the contract.
|
||||
Example:
|
||||
```
|
||||
$ slither.py vulns/0x01293cd77f68341635814c35299ed30ae212789e.sol --print-quick-summary
|
||||
```
|
||||
<img src="imgs/quick-summary.png" width="300">
|
||||
|
||||
## Summary
|
||||
`slither.py file.sol --print-summary`
|
||||
|
||||
Output a summary of the contract showing for each function:
|
||||
- What are the visibility and the modifiers
|
||||
- What are the state variables read or written
|
||||
- What are the calls
|
||||
|
||||
Example:
|
||||
```
|
||||
$ slither.py vulns/0x01293cd77f68341635814c35299ed30ae212789e.sol --print-summary
|
||||
```
|
||||
```
|
||||
[...]
|
||||
|
||||
INFO:Slither:Contract NBACrypto
|
||||
Contract vars: [u'ceoAddress', u'cfoAddress', u'teams', u'players', u'teamsAreInitiated', u'playersAreInitiated', u'isPaused']
|
||||
+--------------------+------------+--------------+------------------------+---------------+----------------------------------------------+
|
||||
| Function | Visibility | Modifiers | Read | Write | Calls |
|
||||
+--------------------+------------+--------------+------------------------+---------------+----------------------------------------------+
|
||||
| pauseGame | public | [u'onlyCeo'] | [] | [u'isPaused'] | [] |
|
||||
| unPauseGame | public | [u'onlyCeo'] | [] | [u'isPaused'] | [] |
|
||||
| GetIsPauded | public | [] | [u'isPaused'] | [] | [] |
|
||||
| purchaseCountry | public | [] | [u'isPaused'] | [u'teams'] | [u'cfoAddress.transfer', u'mul'] |
|
||||
| | | | | | [u'require', u'teams.ownerAddress.transfer'] |
|
||||
| purchasePlayer | public | [] | [u'isPaused'] | [u'players'] | [u'cfoAddress.transfer', u'mul'] |
|
||||
| | | | | | [u'require', u'teams.ownerAddress.transfer'] |
|
||||
| | | | | | [u'players.ownerAddress.transfer'] |
|
||||
| modifyPriceCountry | public | [] | [] | [u'teams'] | [u'require'] |
|
||||
| getTeam | public | [] | [u'teams'] | [] | [] |
|
||||
| getPlayer | public | [] | [u'players'] | [] | [] |
|
||||
| getTeamPrice | public | [] | [] | [] | [] |
|
||||
| getPlayerPrice | public | [] | [] | [] | [] |
|
||||
| getTeamOwner | public | [] | [] | [] | [] |
|
||||
| getPlayerOwner | public | [] | [] | [] | [] |
|
||||
| mul | internal | [] | [] | [] | [u'assert'] |
|
||||
| div | internal | [] | [] | [] | [] |
|
||||
| InitiateTeams | public | [u'onlyCeo'] | [u'teamsAreInitiated'] | [] | [u'require', u'teams.push'] |
|
||||
| addPlayer | public | [u'onlyCeo'] | [] | [] | [u'players.push'] |
|
||||
+--------------------+------------+--------------+------------------------+---------------+----------------------------------------------+
|
||||
```
|
||||
|
||||
## Inheritance Graph
|
||||
`slither.py file.sol --print-inheritance`
|
||||
|
||||
Output a graph showing the inheritance interaction between the contracts.
|
||||
Example:
|
||||
```
|
||||
$ slither examples/DAO.sol --print-inheritance
|
||||
[...]
|
||||
INFO:PrinterInheritance:Inheritance Graph: examples/DAO.sol.dot
|
||||
```
|
||||
|
||||
The output format is [dot](https://www.graphviz.org/) and can be converted to svg using:
|
||||
```
|
||||
dot examples/DAO.sol.dot -Tsvg -o examples/DAO.svg
|
||||
```
|
||||
|
||||
Functions in orange override a parent's functions. If a variable points to another contract, the contract type is written in blue.
|
||||
|
||||
<img src="imgs/DAO.svg" width="700">
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
|
||||
-->
|
||||
<!-- Title: %3 Pages: 1 -->
|
||||
<svg width="789pt" height="2361pt"
|
||||
viewBox="0.00 0.00 788.50 2361.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 2357)">
|
||||
<title>%3</title>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-2357 784.5,-2357 784.5,4 -4,4"/>
|
||||
<!-- TokenInterface -->
|
||||
<g id="node1" class="node"><title>TokenInterface</title>
|
||||
<polygon fill="none" stroke="black" points="125,-262 7.10543e-15,-262 7.10543e-15,-0 125,-0 125,-262"/>
|
||||
<text text-anchor="start" x="18" y="-243.8" font-family="Times,serif" font-weight="bold" font-size="14.00">TokenInterface</text>
|
||||
<text text-anchor="start" x="12.5" y="-222.8" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="12.5" y="-200.8" font-family="Times,serif" font-size="14.00">    balanceOf</text>
|
||||
<text text-anchor="start" x="12.5" y="-179.8" font-family="Times,serif" font-size="14.00">    transfer</text>
|
||||
<text text-anchor="start" x="12.5" y="-158.8" font-family="Times,serif" font-size="14.00">    transferFrom</text>
|
||||
<text text-anchor="start" x="12.5" y="-137.8" font-family="Times,serif" font-size="14.00">    approve</text>
|
||||
<text text-anchor="start" x="12.5" y="-116.8" font-family="Times,serif" font-size="14.00">    allowance</text>
|
||||
<text text-anchor="start" x="12.5" y="-96.8" font-family="Times,serif" font-style="italic" font-size="14.00">Public Variables:</text>
|
||||
<text text-anchor="start" x="12.5" y="-74.8" font-family="Times,serif" font-size="14.00">    totalSupply</text>
|
||||
<text text-anchor="start" x="12.5" y="-54.8" font-family="Times,serif" font-style="italic" font-size="14.00">Private Variables:</text>
|
||||
<text text-anchor="start" x="12.5" y="-32.8" font-family="Times,serif" font-size="14.00">    balances</text>
|
||||
<text text-anchor="start" x="12.5" y="-11.8" font-family="Times,serif" font-size="14.00">    allowed</text>
|
||||
</g>
|
||||
<!-- Token -->
|
||||
<g id="node2" class="node"><title>Token</title>
|
||||
<polygon fill="none" stroke="black" points="118,-539 7,-539 7,-340 118,-340 118,-539"/>
|
||||
<text text-anchor="start" x="44.5" y="-520.3" font-family="Times,serif" font-weight="bold" font-size="14.00">Token</text>
|
||||
<text text-anchor="start" x="19.5" y="-499.3" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="19.5" y="-477.3" font-family="Times,serif" font-size="14.00" fill="#ffa500">    balanceOf</text>
|
||||
<text text-anchor="start" x="19.5" y="-456.3" font-family="Times,serif" font-size="14.00" fill="#ffa500">    transfer</text>
|
||||
<text text-anchor="start" x="19.5" y="-435.3" font-family="Times,serif" font-size="14.00" fill="#ffa500">    transferFrom</text>
|
||||
<text text-anchor="start" x="19.5" y="-414.3" font-family="Times,serif" font-size="14.00" fill="#ffa500">    approve</text>
|
||||
<text text-anchor="start" x="19.5" y="-393.3" font-family="Times,serif" font-size="14.00" fill="#ffa500">    allowance</text>
|
||||
<text text-anchor="start" x="19.5" y="-373.3" font-family="Times,serif" font-style="italic" font-size="14.00">Modifiers:</text>
|
||||
<text text-anchor="start" x="19.5" y="-351.3" font-family="Times,serif" font-size="14.00">    noEther</text>
|
||||
</g>
|
||||
<!-- Token->TokenInterface -->
|
||||
<g id="edge1" class="edge"><title>Token->TokenInterface</title>
|
||||
<path fill="none" stroke="black" d="M62.5,-339.834C62.5,-318.264 62.5,-295.034 62.5,-272.194"/>
|
||||
<polygon fill="black" stroke="black" points="66.0001,-272.086 62.5,-262.086 59.0001,-272.086 66.0001,-272.086"/>
|
||||
</g>
|
||||
<!-- ManagedAccountInterface -->
|
||||
<g id="node3" class="node"><title>ManagedAccountInterface</title>
|
||||
<polygon fill="none" stroke="black" points="680.5,-1204.5 500.5,-1204.5 500.5,-1047.5 680.5,-1047.5 680.5,-1204.5"/>
|
||||
<text text-anchor="start" x="512.5" y="-1185.8" font-family="Times,serif" font-weight="bold" font-size="14.00">ManagedAccountInterface</text>
|
||||
<text text-anchor="start" x="512.5" y="-1164.8" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="512.5" y="-1142.8" font-family="Times,serif" font-size="14.00">    payOut</text>
|
||||
<text text-anchor="start" x="512.5" y="-1122.8" font-family="Times,serif" font-style="italic" font-size="14.00">Public Variables:</text>
|
||||
<text text-anchor="start" x="512.5" y="-1100.8" font-family="Times,serif" font-size="14.00">    owner</text>
|
||||
<text text-anchor="start" x="512.5" y="-1079.8" font-family="Times,serif" font-size="14.00">    payOwnerOnly</text>
|
||||
<text text-anchor="start" x="512.5" y="-1058.8" font-family="Times,serif" font-size="14.00">    accumulatedInput</text>
|
||||
</g>
|
||||
<!-- ManagedAccount -->
|
||||
<g id="node4" class="node"><title>ManagedAccount</title>
|
||||
<polygon fill="none" stroke="black" points="654,-2059 527,-2059 527,-1965 654,-1965 654,-2059"/>
|
||||
<text text-anchor="start" x="539.5" y="-2040.8" font-family="Times,serif" font-weight="bold" font-size="14.00">ManagedAccount</text>
|
||||
<text text-anchor="start" x="539.5" y="-2019.8" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="539.5" y="-1997.8" font-family="Times,serif" font-size="14.00">    fallback</text>
|
||||
<text text-anchor="start" x="539.5" y="-1976.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    payOut</text>
|
||||
</g>
|
||||
<!-- ManagedAccount->ManagedAccountInterface -->
|
||||
<g id="edge2" class="edge"><title>ManagedAccount->ManagedAccountInterface</title>
|
||||
<path fill="none" stroke="black" d="M590.5,-1964.72C590.5,-1824.03 590.5,-1399.82 590.5,-1214.83"/>
|
||||
<polygon fill="black" stroke="black" points="594,-1214.6 590.5,-1204.6 587,-1214.6 594,-1214.6"/>
|
||||
</g>
|
||||
<!-- TokenCreationInterface -->
|
||||
<g id="node5" class="node"><title>TokenCreationInterface</title>
|
||||
<polygon fill="none" stroke="black" points="328.5,-581 136.5,-581 136.5,-298 328.5,-298 328.5,-581"/>
|
||||
<text text-anchor="start" x="162" y="-562.3" font-family="Times,serif" font-weight="bold" font-size="14.00">TokenCreationInterface</text>
|
||||
<text text-anchor="start" x="148.5" y="-541.3" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="148.5" y="-519.3" font-family="Times,serif" font-size="14.00">    createTokenProxy</text>
|
||||
<text text-anchor="start" x="148.5" y="-498.3" font-family="Times,serif" font-size="14.00">    refund</text>
|
||||
<text text-anchor="start" x="148.5" y="-477.3" font-family="Times,serif" font-size="14.00">    divisor</text>
|
||||
<text text-anchor="start" x="148.5" y="-457.3" font-family="Times,serif" font-style="italic" font-size="14.00">Public Variables:</text>
|
||||
<text text-anchor="start" x="148.5" y="-435.3" font-family="Times,serif" font-size="14.00">    closingTime</text>
|
||||
<text text-anchor="start" x="148.5" y="-414.3" font-family="Times,serif" font-size="14.00">    minTokensToCreate</text>
|
||||
<text text-anchor="start" x="148.5" y="-393.3" font-family="Times,serif" font-size="14.00">    isFueled</text>
|
||||
<text text-anchor="start" x="148.5" y="-372.3" font-family="Times,serif" font-size="14.00">    privateCreation</text>
|
||||
<text text-anchor="start" x="148.5" y="-352.3" font-family="Times,serif" font-size="14.00">    extraBalance</text>
|
||||
<text text-anchor="start" x="234.5" y="-352.3" font-family="Times,serif" font-size="10.00" fill="blue"> (ManagedAccount)</text>
|
||||
<text text-anchor="start" x="148.5" y="-331.3" font-family="Times,serif" font-style="italic" font-size="14.00">Private Variables:</text>
|
||||
<text text-anchor="start" x="148.5" y="-309.3" font-family="Times,serif" font-size="14.00">    weiGiven</text>
|
||||
</g>
|
||||
<!-- TokenCreation -->
|
||||
<g id="node6" class="node"><title>TokenCreation</title>
|
||||
<polygon fill="none" stroke="black" points="230,-1183.5 91,-1183.5 91,-1068.5 230,-1068.5 230,-1183.5"/>
|
||||
<text text-anchor="start" x="117" y="-1164.8" font-family="Times,serif" font-weight="bold" font-size="14.00">TokenCreation</text>
|
||||
<text text-anchor="start" x="103.5" y="-1143.8" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="103.5" y="-1121.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    createTokenProxy</text>
|
||||
<text text-anchor="start" x="103.5" y="-1100.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    refund</text>
|
||||
<text text-anchor="start" x="103.5" y="-1079.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    divisor</text>
|
||||
</g>
|
||||
<!-- TokenCreation->Token -->
|
||||
<g id="edge4" class="edge"><title>TokenCreation->Token</title>
|
||||
<path fill="none" stroke="black" d="M152.397,-1068.4C136.113,-954.664 99.1762,-696.672 78.0661,-549.224"/>
|
||||
<polygon fill="black" stroke="black" points="81.5185,-548.642 76.6365,-539.239 74.5891,-549.634 81.5185,-548.642"/>
|
||||
</g>
|
||||
<!-- TokenCreation->TokenCreationInterface -->
|
||||
<g id="edge3" class="edge"><title>TokenCreation->TokenCreationInterface</title>
|
||||
<path fill="none" stroke="black" d="M166.453,-1068.4C177.347,-964.84 200.82,-741.682 216.641,-591.273"/>
|
||||
<polygon fill="black" stroke="black" points="220.154,-591.334 217.719,-581.023 213.192,-590.602 220.154,-591.334"/>
|
||||
</g>
|
||||
<!-- DAOInterface -->
|
||||
<g id="node7" class="node"><title>DAOInterface</title>
|
||||
<polygon fill="none" stroke="black" points="482.5,-1635 248.5,-1635 248.5,-617 482.5,-617 482.5,-1635"/>
|
||||
<text text-anchor="start" x="323.5" y="-1616.8" font-family="Times,serif" font-weight="bold" font-size="14.00">DAOInterface</text>
|
||||
<text text-anchor="start" x="260.5" y="-1595.8" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="260.5" y="-1573.8" font-family="Times,serif" font-size="14.00">    fallback</text>
|
||||
<text text-anchor="start" x="260.5" y="-1552.8" font-family="Times,serif" font-size="14.00">    receiveEther</text>
|
||||
<text text-anchor="start" x="260.5" y="-1531.8" font-family="Times,serif" font-size="14.00">    newProposal</text>
|
||||
<text text-anchor="start" x="260.5" y="-1510.8" font-family="Times,serif" font-size="14.00">    checkProposalCode</text>
|
||||
<text text-anchor="start" x="260.5" y="-1489.8" font-family="Times,serif" font-size="14.00">    vote</text>
|
||||
<text text-anchor="start" x="260.5" y="-1468.8" font-family="Times,serif" font-size="14.00">    executeProposal</text>
|
||||
<text text-anchor="start" x="260.5" y="-1447.8" font-family="Times,serif" font-size="14.00">    splitDAO</text>
|
||||
<text text-anchor="start" x="260.5" y="-1426.8" font-family="Times,serif" font-size="14.00">    newContract</text>
|
||||
<text text-anchor="start" x="260.5" y="-1405.8" font-family="Times,serif" font-size="14.00">    changeAllowedRecipients</text>
|
||||
<text text-anchor="start" x="260.5" y="-1384.8" font-family="Times,serif" font-size="14.00">    changeProposalDeposit</text>
|
||||
<text text-anchor="start" x="260.5" y="-1363.8" font-family="Times,serif" font-size="14.00">    retrieveDAOReward</text>
|
||||
<text text-anchor="start" x="260.5" y="-1342.8" font-family="Times,serif" font-size="14.00">    getMyReward</text>
|
||||
<text text-anchor="start" x="260.5" y="-1321.8" font-family="Times,serif" font-size="14.00">    withdrawRewardFor</text>
|
||||
<text text-anchor="start" x="260.5" y="-1300.8" font-family="Times,serif" font-size="14.00">    transferWithoutReward</text>
|
||||
<text text-anchor="start" x="260.5" y="-1279.8" font-family="Times,serif" font-size="14.00">    transferFromWithoutReward</text>
|
||||
<text text-anchor="start" x="260.5" y="-1258.8" font-family="Times,serif" font-size="14.00">    halveMinQuorum</text>
|
||||
<text text-anchor="start" x="260.5" y="-1237.8" font-family="Times,serif" font-size="14.00">    numberOfProposals</text>
|
||||
<text text-anchor="start" x="260.5" y="-1216.8" font-family="Times,serif" font-size="14.00">    getNewDAOAddress</text>
|
||||
<text text-anchor="start" x="260.5" y="-1195.8" font-family="Times,serif" font-size="14.00">    isBlocked</text>
|
||||
<text text-anchor="start" x="260.5" y="-1174.8" font-family="Times,serif" font-size="14.00">    unblockMe</text>
|
||||
<text text-anchor="start" x="260.5" y="-1154.8" font-family="Times,serif" font-style="italic" font-size="14.00">Modifiers:</text>
|
||||
<text text-anchor="start" x="260.5" y="-1132.8" font-family="Times,serif" font-size="14.00">    onlyTokenholders</text>
|
||||
<text text-anchor="start" x="260.5" y="-1112.8" font-family="Times,serif" font-style="italic" font-size="14.00">Public Variables:</text>
|
||||
<text text-anchor="start" x="260.5" y="-1090.8" font-family="Times,serif" font-size="14.00">    proposals</text>
|
||||
<text text-anchor="start" x="260.5" y="-1069.8" font-family="Times,serif" font-size="14.00">    minQuorumDivisor</text>
|
||||
<text text-anchor="start" x="260.5" y="-1048.8" font-family="Times,serif" font-size="14.00">    lastTimeMinQuorumMet</text>
|
||||
<text text-anchor="start" x="260.5" y="-1027.8" font-family="Times,serif" font-size="14.00">    curator</text>
|
||||
<text text-anchor="start" x="260.5" y="-1006.8" font-family="Times,serif" font-size="14.00">    allowedRecipients</text>
|
||||
<text text-anchor="start" x="260.5" y="-985.8" font-family="Times,serif" font-size="14.00">    rewardToken</text>
|
||||
<text text-anchor="start" x="260.5" y="-964.8" font-family="Times,serif" font-size="14.00">    totalRewardToken</text>
|
||||
<text text-anchor="start" x="260.5" y="-944.8" font-family="Times,serif" font-size="14.00">    rewardAccount</text>
|
||||
<text text-anchor="start" x="359.5" y="-944.8" font-family="Times,serif" font-size="10.00" fill="blue"> (ManagedAccount)</text>
|
||||
<text text-anchor="start" x="260.5" y="-923.8" font-family="Times,serif" font-size="14.00">    DAOrewardAccount</text>
|
||||
<text text-anchor="start" x="388.5" y="-923.8" font-family="Times,serif" font-size="10.00" fill="blue"> (ManagedAccount)</text>
|
||||
<text text-anchor="start" x="260.5" y="-901.8" font-family="Times,serif" font-size="14.00">    DAOpaidOut</text>
|
||||
<text text-anchor="start" x="260.5" y="-880.8" font-family="Times,serif" font-size="14.00">    paidOut</text>
|
||||
<text text-anchor="start" x="260.5" y="-859.8" font-family="Times,serif" font-size="14.00">    blocked</text>
|
||||
<text text-anchor="start" x="260.5" y="-838.8" font-family="Times,serif" font-size="14.00">    proposalDeposit</text>
|
||||
<text text-anchor="start" x="260.5" y="-818.8" font-family="Times,serif" font-size="14.00">    daoCreator</text>
|
||||
<text text-anchor="start" x="336.5" y="-818.8" font-family="Times,serif" font-size="10.00" fill="blue"> (DAO_Creator)</text>
|
||||
<text text-anchor="start" x="260.5" y="-797.8" font-family="Times,serif" font-style="italic" font-size="14.00">Private Variables:</text>
|
||||
<text text-anchor="start" x="260.5" y="-775.8" font-family="Times,serif" font-size="14.00">    creationGracePeriod</text>
|
||||
<text text-anchor="start" x="260.5" y="-754.8" font-family="Times,serif" font-size="14.00">    minProposalDebatePeriod</text>
|
||||
<text text-anchor="start" x="260.5" y="-733.8" font-family="Times,serif" font-size="14.00">    minSplitDebatePeriod</text>
|
||||
<text text-anchor="start" x="260.5" y="-712.8" font-family="Times,serif" font-size="14.00">    splitExecutionPeriod</text>
|
||||
<text text-anchor="start" x="260.5" y="-691.8" font-family="Times,serif" font-size="14.00">    quorumHalvingPeriod</text>
|
||||
<text text-anchor="start" x="260.5" y="-670.8" font-family="Times,serif" font-size="14.00">    executeProposalPeriod</text>
|
||||
<text text-anchor="start" x="260.5" y="-649.8" font-family="Times,serif" font-size="14.00">    maxDepositDivisor</text>
|
||||
<text text-anchor="start" x="260.5" y="-628.8" font-family="Times,serif" font-size="14.00">    sumOfProposalDeposits</text>
|
||||
</g>
|
||||
<!-- DAO -->
|
||||
<g id="node8" class="node"><title>DAO</title>
|
||||
<polygon fill="none" stroke="black" points="259.5,-2353 61.5,-2353 61.5,-1671 259.5,-1671 259.5,-2353"/>
|
||||
<text text-anchor="start" x="145" y="-2334.8" font-family="Times,serif" font-weight="bold" font-size="14.00">DAO</text>
|
||||
<text text-anchor="start" x="73.5" y="-2313.8" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="73.5" y="-2291.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    fallback</text>
|
||||
<text text-anchor="start" x="73.5" y="-2270.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    receiveEther</text>
|
||||
<text text-anchor="start" x="73.5" y="-2249.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    newProposal</text>
|
||||
<text text-anchor="start" x="73.5" y="-2228.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    checkProposalCode</text>
|
||||
<text text-anchor="start" x="73.5" y="-2207.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    vote</text>
|
||||
<text text-anchor="start" x="73.5" y="-2186.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    executeProposal</text>
|
||||
<text text-anchor="start" x="73.5" y="-2165.8" font-family="Times,serif" font-size="14.00">    closeProposal</text>
|
||||
<text text-anchor="start" x="73.5" y="-2144.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    splitDAO</text>
|
||||
<text text-anchor="start" x="73.5" y="-2123.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    newContract</text>
|
||||
<text text-anchor="start" x="73.5" y="-2102.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    retrieveDAOReward</text>
|
||||
<text text-anchor="start" x="73.5" y="-2081.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    getMyReward</text>
|
||||
<text text-anchor="start" x="73.5" y="-2060.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    withdrawRewardFor</text>
|
||||
<text text-anchor="start" x="73.5" y="-2039.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    transfer</text>
|
||||
<text text-anchor="start" x="73.5" y="-2018.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    transferWithoutReward</text>
|
||||
<text text-anchor="start" x="73.5" y="-1997.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    transferFrom</text>
|
||||
<text text-anchor="start" x="73.5" y="-1976.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    transferFromWithoutReward</text>
|
||||
<text text-anchor="start" x="73.5" y="-1955.8" font-family="Times,serif" font-size="14.00">    transferPaidOut</text>
|
||||
<text text-anchor="start" x="73.5" y="-1934.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    changeProposalDeposit</text>
|
||||
<text text-anchor="start" x="73.5" y="-1913.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    changeAllowedRecipients</text>
|
||||
<text text-anchor="start" x="73.5" y="-1892.8" font-family="Times,serif" font-size="14.00">    isRecipientAllowed</text>
|
||||
<text text-anchor="start" x="73.5" y="-1871.8" font-family="Times,serif" font-size="14.00">    actualBalance</text>
|
||||
<text text-anchor="start" x="73.5" y="-1850.8" font-family="Times,serif" font-size="14.00">    minQuorum</text>
|
||||
<text text-anchor="start" x="73.5" y="-1829.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    halveMinQuorum</text>
|
||||
<text text-anchor="start" x="73.5" y="-1808.8" font-family="Times,serif" font-size="14.00">    createNewDAO</text>
|
||||
<text text-anchor="start" x="73.5" y="-1787.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    numberOfProposals</text>
|
||||
<text text-anchor="start" x="73.5" y="-1766.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    getNewDAOAddress</text>
|
||||
<text text-anchor="start" x="73.5" y="-1745.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    isBlocked</text>
|
||||
<text text-anchor="start" x="73.5" y="-1724.8" font-family="Times,serif" font-size="14.00" fill="#ffa500">    unblockMe</text>
|
||||
<text text-anchor="start" x="73.5" y="-1704.8" font-family="Times,serif" font-style="italic" font-size="14.00">Modifiers:</text>
|
||||
<text text-anchor="start" x="73.5" y="-1682.8" font-family="Times,serif" font-size="14.00">    onlyTokenholders</text>
|
||||
</g>
|
||||
<!-- DAO->Token -->
|
||||
<g id="edge6" class="edge"><title>DAO->Token</title>
|
||||
<path fill="none" stroke="black" d="M86.0098,-1670.75C84.3319,-1658.71 82.8174,-1646.77 81.5,-1635 36.9399,-1237.01 48.7897,-759.848 57.305,-549.356"/>
|
||||
<polygon fill="black" stroke="black" points="60.8075,-549.365 57.7204,-539.23 53.8134,-549.078 60.8075,-549.365"/>
|
||||
</g>
|
||||
<!-- DAO->TokenCreation -->
|
||||
<g id="edge7" class="edge"><title>DAO->TokenCreation</title>
|
||||
<path fill="none" stroke="black" d="M160.5,-1670.8C160.5,-1494.42 160.5,-1295.16 160.5,-1193.87"/>
|
||||
<polygon fill="black" stroke="black" points="164,-1193.78 160.5,-1183.78 157,-1193.78 164,-1193.78"/>
|
||||
</g>
|
||||
<!-- DAO->DAOInterface -->
|
||||
<g id="edge5" class="edge"><title>DAO->DAOInterface</title>
|
||||
<path fill="none" stroke="black" d="M239.392,-1670.8C241.634,-1661.13 243.892,-1651.4 246.162,-1641.61"/>
|
||||
<polygon fill="black" stroke="black" points="249.586,-1642.34 248.435,-1631.81 242.767,-1640.76 249.586,-1642.34"/>
|
||||
</g>
|
||||
<!-- DAO_Creator -->
|
||||
<g id="node9" class="node"><title>DAO_Creator</title>
|
||||
<polygon fill="none" stroke="black" points="780.5,-2048.5 672.5,-2048.5 672.5,-1975.5 780.5,-1975.5 780.5,-2048.5"/>
|
||||
<text text-anchor="start" x="684.5" y="-2029.8" font-family="Times,serif" font-weight="bold" font-size="14.00">DAO_Creator</text>
|
||||
<text text-anchor="start" x="684.5" y="-2008.8" font-family="Times,serif" font-style="italic" font-size="14.00">Functions:</text>
|
||||
<text text-anchor="start" x="684.5" y="-1986.8" font-family="Times,serif" font-size="14.00">    createDAO</text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
@@ -0,0 +1,9 @@
|
||||
pragma solidity 0.4.24;
|
||||
|
||||
contract C{
|
||||
|
||||
function i_am_a_backdoor() public{
|
||||
selfdestruct(msg.sender);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
contract Uninitialized{
|
||||
|
||||
|
||||
address destination;
|
||||
|
||||
function transfer() payable{
|
||||
|
||||
destination.transfer(msg.value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
contract Contract1{
|
||||
|
||||
uint myvar;
|
||||
|
||||
function myfunc() public{}
|
||||
}
|
||||
|
||||
contract Contract2{
|
||||
|
||||
uint public myvar2;
|
||||
|
||||
function myfunc2() public{}
|
||||
|
||||
function privatefunc() private{}
|
||||
}
|
||||
|
||||
contract Contract3 is Contract1, Contract2{
|
||||
|
||||
function myfunc() public{} // override myfunc
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
digraph{
|
||||
Contract3 -> Contract2;
|
||||
Contract3 -> Contract1;
|
||||
Contract3[shape="box"label=< <TABLE border="0"><TR><TD align="center"><B>Contract3</B></TD></TR><TR><TD align="left"><I>Public Functions:</I></TD></TR><TR><TD align="left"><font color="#FFA500"> myfunc()</font></TD></TR><TR><TD align="left"><I>Public Variables:</I></TD></TR><TR><TD align="left"> myvar2</TD></TR><TR><TD align="left"><I>Private Variables:</I></TD></TR><TR><TD align="left"> myvar</TD></TR></TABLE> >];
|
||||
Contract2[shape="box"label=< <TABLE border="0"><TR><TD align="center"><B>Contract2</B></TD></TR><TR><TD align="left"><I>Public Functions:</I></TD></TR><TR><TD align="left"> myfunc2()</TD></TR><TR><TD align="left"><I>Private Functions:</I></TD></TR><TR><TD align="left"> privatefunc()</TD></TR><TR><TD align="left"><I>Public Variables:</I></TD></TR><TR><TD align="left"> myvar2</TD></TR></TABLE> >];
|
||||
Contract1[shape="box"label=< <TABLE border="0"><TR><TD align="center"><B>Contract1</B></TD></TR><TR><TD align="left"><I>Public Functions:</I></TD></TR><TR><TD align="left"> myfunc()</TD></TR><TR><TD align="left"><I>Private Variables:</I></TD></TR><TR><TD align="left"> myvar</TD></TR></TABLE> >];
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
from slither.slither import Slither
|
||||
|
||||
# Init slither
|
||||
slither = Slither('functions_called.sol')
|
||||
|
||||
# Get the contract
|
||||
contract = slither.get_contract_from_name('Contract')
|
||||
|
||||
# Get the variable
|
||||
entry_point = contract.get_function_from_signature('entry_point()')
|
||||
|
||||
all_calls = entry_point.all_calls()
|
||||
|
||||
all_calls_formated = [f.contract.name + '.' + f.name for f in all_calls]
|
||||
|
||||
# Print the result
|
||||
print 'From entry_point the functions reached are {}'.format(all_calls_formated)
|
||||
@@ -0,0 +1,29 @@
|
||||
contract BaseContract{
|
||||
|
||||
function f1(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
contract Contract is BaseContract{
|
||||
|
||||
uint a;
|
||||
|
||||
function entry_point(){
|
||||
f1();
|
||||
f2();
|
||||
}
|
||||
|
||||
function f1(){
|
||||
super.f1();
|
||||
}
|
||||
|
||||
function f2(){
|
||||
|
||||
}
|
||||
|
||||
// not reached from entry_point
|
||||
function f3(){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
from slither.slither import Slither
|
||||
|
||||
# Init slither
|
||||
slither = Slither('function_writing.sol')
|
||||
|
||||
# Get the contract
|
||||
contract = slither.get_contract_from_name('Contract')
|
||||
|
||||
# Get the variable
|
||||
var_a = contract.get_state_variable_from_name('a')
|
||||
|
||||
# Get the functions writing the variable
|
||||
functions_writing_a = contract.get_functions_writing_variable(var_a)
|
||||
|
||||
# Print the result
|
||||
print 'The function writing "a" are {}'.format([f.name for f in functions_writing_a])
|
||||
@@ -0,0 +1,14 @@
|
||||
contract Contract{
|
||||
|
||||
uint a;
|
||||
|
||||
function write(){
|
||||
a++;
|
||||
}
|
||||
|
||||
// shadowing of a
|
||||
function dont_write(uint a){
|
||||
a = a +1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
from slither.slither import Slither
|
||||
|
||||
# Init slither
|
||||
slither = Slither('variable_in_condition.sol')
|
||||
|
||||
# Get the contract
|
||||
contract = slither.get_contract_from_name('Contract')
|
||||
|
||||
# Get the variable
|
||||
var_a = contract.get_state_variable_from_name('a')
|
||||
|
||||
# Get the functions reading the variable
|
||||
functions_reading_a = contract.get_functions_reading_variable(var_a)
|
||||
|
||||
function_using_a_as_condition = [f for f in functions_reading_a if\
|
||||
f.is_reading_in_conditional_node(var_a) or\
|
||||
f.is_reading_in_require_or_assert(var_a)]
|
||||
|
||||
# Print the result
|
||||
print 'The function using "a" in condition are {}'.format([f.name for f in function_using_a_as_condition])
|
||||
@@ -0,0 +1,19 @@
|
||||
contract Contract{
|
||||
|
||||
uint a;
|
||||
|
||||
function condition(){
|
||||
if(a==0){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function call_require(){
|
||||
require(a==0);
|
||||
}
|
||||
|
||||
function read_and_write(){
|
||||
a = a + 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
prettytable
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
pip install -r requirements.txt
|
||||
|
||||
function install_solc {
|
||||
sudo wget -O /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.4.23/solc-static-linux
|
||||
sudo chmod +x /usr/bin/solc
|
||||
}
|
||||
|
||||
install_solc
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
./slither.py examples/bugs --disable-solc-warnings
|
||||
if [ $? -ne 2 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Executable
+288
@@ -0,0 +1,288 @@
|
||||
#!/usr/bin/env python2
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import logging
|
||||
import subprocess
|
||||
import traceback
|
||||
import os
|
||||
import glob
|
||||
import json
|
||||
|
||||
from slither.slither import Slither
|
||||
from slither.utils.colors import red
|
||||
from slither.detectors.detectors import Detectors
|
||||
from slither.printers.printers import Printers
|
||||
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger("Slither")
|
||||
|
||||
def determineChecks(detectors, args):
|
||||
if args.medium:
|
||||
return detectors.medium + detectors.high
|
||||
elif args.high:
|
||||
return detectors.high
|
||||
elif args.detectors_to_run:
|
||||
return args.detectors_to_run
|
||||
else:
|
||||
return detectors.high + detectors.medium + detectors.low
|
||||
|
||||
|
||||
def process(filename, args, detectors, printers):
|
||||
slither = Slither(filename, args.solc, args.disable_solc_warnings, args.solc_args)
|
||||
if args.printers_to_run:
|
||||
[printers.run_printer(slither, p) for p in args.printers_to_run]
|
||||
return []
|
||||
else:
|
||||
checks = determineChecks(detectors, args)
|
||||
results = [detectors.run_detector(slither, c) for c in checks]
|
||||
results = [x for x in results if x] # remove empty results
|
||||
results = [item for sublist in results for item in sublist] #flatten
|
||||
return results
|
||||
|
||||
def output_json(results, filename):
|
||||
with open(filename, 'w') as f:
|
||||
json.dump(results, f)
|
||||
|
||||
def exit(results):
|
||||
if not results:
|
||||
sys.exit(0)
|
||||
sys.exit(len(results))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
detectors = Detectors()
|
||||
printers = Printers()
|
||||
|
||||
parser = argparse.ArgumentParser(description='Slither',
|
||||
usage="slither.py contract.sol")
|
||||
|
||||
parser.add_argument('filename',
|
||||
help='contract.sol file')
|
||||
|
||||
parser.add_argument('--solc',
|
||||
help='solc path',
|
||||
action='store',
|
||||
default='solc')
|
||||
|
||||
parser.add_argument('--solc-args',
|
||||
help='Add custom solc arguments. Example: --solc-args "--allow-path /tmp --evm-version byzantium".',
|
||||
action='store',
|
||||
default=None)
|
||||
|
||||
parser.add_argument('--disable-solc-warnings',
|
||||
help='Disable solc warnings',
|
||||
action='store_true',
|
||||
default=False)
|
||||
|
||||
parser.add_argument('--solc-ast',
|
||||
help='Provide the ast solc file',
|
||||
action='store_true',
|
||||
default=False)
|
||||
|
||||
parser.add_argument('--medium',
|
||||
help='Only medium and high analyses',
|
||||
action='store_true',
|
||||
default=False)
|
||||
|
||||
parser.add_argument('--high',
|
||||
help='Only high analyses',
|
||||
action='store_true',
|
||||
default=False)
|
||||
|
||||
parser.add_argument('--json',
|
||||
help='Export results as JSON',
|
||||
action='store',
|
||||
default=None)
|
||||
|
||||
# Analyses available
|
||||
|
||||
# parser.add_argument('--reentrancy',
|
||||
# help='Re-entrancy detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_reentrancy')
|
||||
#
|
||||
# parser.add_argument('--sim',
|
||||
# help='Variable name similitude detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_sim')
|
||||
#
|
||||
# parser.add_argument('--const-func',
|
||||
# help='Incorrect constant functions',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_constant_function')
|
||||
#
|
||||
# parser.add_argument('--missing-cons',
|
||||
# help='Missing constructor detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_no_constructor')
|
||||
#
|
||||
# parser.add_argument('--unprotected-func',
|
||||
# help='Unprotected function detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_unprotected_func')
|
||||
#
|
||||
# parser.add_argument('--unprotected-erc20',
|
||||
# help='Unprotected function detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_unprotected_erc20')
|
||||
#
|
||||
# parser.add_argument('--event-name',
|
||||
# help='Incorrect event name detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_incorrect_events_prefix')
|
||||
#
|
||||
# parser.add_argument('--erc20-interface',
|
||||
# help='Incorrect ERC20 interface',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_incorrect_erc20_interface')
|
||||
#
|
||||
# parser.add_argument('--uninitialized',
|
||||
# help='Uninitialized state vars detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_uninitialized')
|
||||
#
|
||||
# parser.add_argument('--unused',
|
||||
# help='Unused state vars detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_unused')
|
||||
#
|
||||
# parser.add_argument('--mapping-deletion',
|
||||
# help='Mapping deletion detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_mapping_deletion')
|
||||
#
|
||||
# parser.add_argument('--shadowing',
|
||||
# help='State variables shadowing detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_state_shadowing')
|
||||
#
|
||||
# parser.add_argument('--shadowing-abstract',
|
||||
# help='State variables shadowing detection from abstract contracts',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_state_shadowing_abstract')
|
||||
#
|
||||
# parser.add_argument('--unimplemented-func',
|
||||
# help='Unimplemented function detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_unimplemented_function')
|
||||
#
|
||||
# parser.add_argument('--tx-origin',
|
||||
# help='tx.origin usage detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_tx_origin')
|
||||
#
|
||||
# parser.add_argument('--suicidal-func',
|
||||
# help='Suicidal functions detection',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_suicidal_function')
|
||||
#
|
||||
# parser.add_argument('--msgValue',
|
||||
# help='Non payable function using msg.value detection (solidity >= 0.4)',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='detect_msgValue_non_payable')
|
||||
#
|
||||
# parser.add_argument('--print-summary',
|
||||
# help='Print the summary of the contract',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='print_summary')
|
||||
#
|
||||
# parser.add_argument('--print-quick-summary',
|
||||
# help='Print a quick summary of the contract',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='print_quick_summary')
|
||||
#
|
||||
# parser.add_argument('--print-inheritance',
|
||||
# help='Print the inheritance graph',
|
||||
# action="append_const",
|
||||
# dest="detectors_to_run",
|
||||
# const='print_inheritance')
|
||||
#
|
||||
|
||||
for detector_name, Detector in detectors.detectors.iteritems():
|
||||
detector_arg = '--{}'.format(Detector.ARGUMENT)
|
||||
detector_help = 'Detection of ' + Detector.HELP
|
||||
parser.add_argument(detector_arg,
|
||||
help=detector_help,
|
||||
action="append_const",
|
||||
dest="detectors_to_run",
|
||||
const=detector_name)
|
||||
|
||||
for printer_name, Printer in printers.printers.iteritems():
|
||||
printer_arg = '--{}'.format(Printer.ARGUMENT)
|
||||
printer_help = Printer.HELP
|
||||
parser.add_argument(printer_arg,
|
||||
help=printer_help,
|
||||
action="append_const",
|
||||
dest="printers_to_run",
|
||||
const=printer_name)
|
||||
|
||||
# Debug
|
||||
parser.add_argument('--debug',
|
||||
help='Debug mode',
|
||||
action="store_true",
|
||||
default=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
default_log = logging.INFO
|
||||
if args.debug:
|
||||
default_log = logging.DEBUG
|
||||
|
||||
for (l_name, l_level) in [('Slither', default_log),
|
||||
('Contract', default_log),
|
||||
('Function', default_log),
|
||||
('Node', default_log),
|
||||
('Parsing', default_log),
|
||||
('Detectors', default_log),
|
||||
('FunctionSolc', default_log),
|
||||
('ExpressionParsing', default_log),
|
||||
('TypeParsing', default_log),
|
||||
('Printers', default_log)]:
|
||||
l = logging.getLogger(l_name)
|
||||
l.setLevel(l_level)
|
||||
|
||||
try:
|
||||
filename = sys.argv[1]
|
||||
|
||||
if os.path.isfile(filename):
|
||||
results = process(filename, args, detectors, printers)
|
||||
elif os.path.isdir(filename):
|
||||
extension = "*.sol" if not args.solc_ast else "*.json"
|
||||
filenames = glob.glob(os.path.join(filename, extension))
|
||||
results = [process(filename, args, detectors, printers) for filename in filenames]
|
||||
results = [item for sublist in results for item in sublist] #flatten
|
||||
#if args.json:
|
||||
# output_json(results, args.json)
|
||||
#exit(results)
|
||||
else:
|
||||
raise Exception("Unrecognised file/dir path: '#{filename}'".format(filename=filename))
|
||||
|
||||
if args.json:
|
||||
output_json(results, args.json)
|
||||
logger.info('%s analyzed, %d result(s) found', filename, len(results))
|
||||
exit(results)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logging.error('Error in %s'%sys.argv[1])
|
||||
logging.error(traceback.format_exc())
|
||||
sys.exit(-1)
|
||||
@@ -0,0 +1,212 @@
|
||||
"""
|
||||
Node module
|
||||
"""
|
||||
import logging
|
||||
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
from slither.core.cfg.nodeType import NodeType
|
||||
from slither.core.variables.variable import Variable
|
||||
|
||||
from slither.visitors.expression.expressionPrinter import ExpressionPrinter
|
||||
from slither.visitors.expression.readVar import ReadVar
|
||||
from slither.visitors.expression.writeVar import WriteVar
|
||||
|
||||
from slither.core.children.childFunction import ChildFunction
|
||||
|
||||
from slither.core.declarations.solidityVariables import SolidityFunction
|
||||
logger = logging.getLogger("Node")
|
||||
|
||||
def link_nodes(n1, n2):
|
||||
n1.add_son(n2)
|
||||
n2.add_father(n1)
|
||||
|
||||
class Node(SourceMapping, ChildFunction):
|
||||
"""
|
||||
Node class
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, node_type, node_id):
|
||||
super(Node, self).__init__()
|
||||
self._node_type = node_type
|
||||
self._sons = []
|
||||
self._fathers = []
|
||||
self._expression = None
|
||||
self._variable_declaration = None
|
||||
self._node_id = node_id
|
||||
self._vars_written = []
|
||||
self._vars_read = []
|
||||
self._calls = []
|
||||
|
||||
self._state_vars_written = []
|
||||
self._state_vars_read = []
|
||||
self._solidity_vars_read = []
|
||||
|
||||
self._expression_vars_written = []
|
||||
self._expression_vars_read = []
|
||||
self._expression_calls = []
|
||||
|
||||
@property
|
||||
def node_id(self):
|
||||
"""Unique node id."""
|
||||
return self._node_id
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
"""
|
||||
NodeType: type of the node
|
||||
"""
|
||||
return self._node_type
|
||||
|
||||
@property
|
||||
def variables_read(self):
|
||||
"""
|
||||
list(Variable): Variables read (local/state/solidity)
|
||||
"""
|
||||
return self._vars_read
|
||||
|
||||
@property
|
||||
def state_variables_read(self):
|
||||
"""
|
||||
list(StateVariable): State variables read
|
||||
"""
|
||||
return self._state_vars_read
|
||||
|
||||
@property
|
||||
def solidity_variables_read(self):
|
||||
"""
|
||||
list(SolidityVariable): State variables read
|
||||
"""
|
||||
return self._solidity_vars_read
|
||||
|
||||
@property
|
||||
def variables_read_as_expression(self):
|
||||
return self._expression_vars_read
|
||||
|
||||
@property
|
||||
def variables_written(self):
|
||||
"""
|
||||
list(Variable): Variables written (local/state/solidity)
|
||||
"""
|
||||
return self._vars_written
|
||||
|
||||
@property
|
||||
def state_variables_written(self):
|
||||
"""
|
||||
list(StateVariable): State variables written
|
||||
"""
|
||||
return self._state_vars_written
|
||||
|
||||
@property
|
||||
def variables_written_as_expression(self):
|
||||
return self._expression_vars_written
|
||||
|
||||
@property
|
||||
def calls(self):
|
||||
"""
|
||||
list(Function or SolidityFunction): List of calls
|
||||
"""
|
||||
return self._calls
|
||||
|
||||
@property
|
||||
def calls_as_expression(self):
|
||||
return self._expression_calls
|
||||
|
||||
@property
|
||||
def expression(self):
|
||||
"""
|
||||
Expression: Expression of the node
|
||||
"""
|
||||
return self._expression
|
||||
|
||||
def add_expression(self, expression):
|
||||
assert self._expression is None
|
||||
self._expression = expression
|
||||
|
||||
def add_variable_declaration(self, var):
|
||||
assert self._variable_declaration is None
|
||||
self._variable_declaration = var
|
||||
self._expression = var.expression
|
||||
|
||||
def __str__(self):
|
||||
txt = NodeType.str(self._node_type) + ' '+ str(self.expression)
|
||||
return txt
|
||||
|
||||
def contains_require_or_assert(self):
|
||||
"""
|
||||
Check if the node has a require or assert call
|
||||
Returns:
|
||||
bool: True if the node has a require or assert call
|
||||
"""
|
||||
return self.calls and\
|
||||
any(isinstance(c, SolidityFunction) and\
|
||||
(c.name in ['require(bool)', 'require(bool,string)', 'assert(bool)'])\
|
||||
for c in self.calls)
|
||||
|
||||
def contains_if(self):
|
||||
"""
|
||||
Check if the node is a conditional node
|
||||
Returns:
|
||||
bool: True if the node is a conditional node (IF or IFLOOP)
|
||||
"""
|
||||
return self.type in [NodeType.IF, NodeType.IFLOOP]
|
||||
|
||||
def add_father(self, father):
|
||||
""" Add a father node
|
||||
|
||||
Args:
|
||||
father: father to add
|
||||
"""
|
||||
self._fathers.append(father)
|
||||
|
||||
def set_fathers(self, fathers):
|
||||
""" Set the father nodes
|
||||
|
||||
Args:
|
||||
fathers: list of fathers to add
|
||||
"""
|
||||
self._fathers = fathers
|
||||
|
||||
@property
|
||||
def fathers(self):
|
||||
""" Returns the father nodes
|
||||
|
||||
Returns:
|
||||
fathers: list of fathers
|
||||
"""
|
||||
return self._fathers
|
||||
|
||||
def remove_father(self, father):
|
||||
""" Remove the father node. Do nothing if the node is not a father
|
||||
|
||||
Args:
|
||||
fathers: list of fathers to add
|
||||
"""
|
||||
self._fathers = [x for x in self._fathers if x.node_id != father.node_id]
|
||||
|
||||
|
||||
def add_son(self, son):
|
||||
""" Add a son node
|
||||
|
||||
Args:
|
||||
son: son to add
|
||||
"""
|
||||
self._sons.append(son)
|
||||
|
||||
def set_sons(self, sons):
|
||||
""" Set the son nodes
|
||||
|
||||
Args:
|
||||
sons: list of fathers to add
|
||||
"""
|
||||
self._sons = sons
|
||||
|
||||
@property
|
||||
def sons(self):
|
||||
""" Returns the son nodes
|
||||
|
||||
Returns:
|
||||
sons: list of sons
|
||||
"""
|
||||
return self._sons
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
class NodeType(object):
|
||||
|
||||
ENTRYPOINT = 0x0 # no expression
|
||||
|
||||
# Node with expression
|
||||
|
||||
EXPRESSION = 0x10 # normal case
|
||||
RETURN = 0x11 # RETURN may contain an expression
|
||||
IF = 0x12
|
||||
VARIABLE = 0x13 # Declaration of variable
|
||||
ASSEMBLY = 0x14
|
||||
IFLOOP = 0x15
|
||||
|
||||
# Below the nodes have no expression
|
||||
# But are used to expression CFG structure
|
||||
|
||||
# Absorbing node
|
||||
THROW = 0x20
|
||||
|
||||
# Loop related nodes
|
||||
BREAK = 0x31
|
||||
CONTINUE = 0x32
|
||||
|
||||
# Only modifier node
|
||||
PLACEHOLDER = 0x40
|
||||
|
||||
# Merging nodes
|
||||
# Unclear if they will be necessary
|
||||
ENDIF = 0x50
|
||||
STARTLOOP = 0x51
|
||||
ENDLOOP = 0x52
|
||||
|
||||
@staticmethod
|
||||
def str(t):
|
||||
if t == 0x0:
|
||||
return 'EntryPoint'
|
||||
if t == 0x10:
|
||||
return 'Expressions'
|
||||
if t == 0x11:
|
||||
return 'Return'
|
||||
if t == 0x12:
|
||||
return 'If'
|
||||
if t == 0x13:
|
||||
return 'New variable'
|
||||
if t == 0x14:
|
||||
return 'Inline Assembly'
|
||||
if t == 0x15:
|
||||
return 'IfLoop'
|
||||
if t == 0x20:
|
||||
return 'Throw'
|
||||
if t == 0x31:
|
||||
return 'Break'
|
||||
if t == 0x32:
|
||||
return 'Continue'
|
||||
if t == 0x40:
|
||||
return '_'
|
||||
if t == 0x50:
|
||||
return 'EndIf'
|
||||
if t == 0x51:
|
||||
return 'BeginLoop'
|
||||
if t == 0x52:
|
||||
return 'EndLoop'
|
||||
return 'Unknown type {}'.format(hex(t))
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
class ChildContract(object):
|
||||
|
||||
def __init__(self):
|
||||
super(ChildContract, self).__init__()
|
||||
self._contract = None
|
||||
|
||||
def set_contract(self, contract):
|
||||
self._contract = contract
|
||||
|
||||
@property
|
||||
def contract(self):
|
||||
return self._contract
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
class ChildEvent(object):
|
||||
def __init__(self):
|
||||
super(ChildEvent, self).__init__()
|
||||
self._event = None
|
||||
|
||||
def set_event(self, event):
|
||||
self._event = event
|
||||
|
||||
@property
|
||||
def event(self):
|
||||
return self._event
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
class ChildFunction(object):
|
||||
def __init__(self):
|
||||
super(ChildFunction, self).__init__()
|
||||
self._function = None
|
||||
|
||||
def set_function(self, function):
|
||||
self._function = function
|
||||
|
||||
@property
|
||||
def function(self):
|
||||
return self._function
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
class ChildSlither(object):
|
||||
|
||||
def __init__(self):
|
||||
super(ChildSlither, self).__init__()
|
||||
self._slither = None
|
||||
|
||||
def set_slither(self, slither):
|
||||
self._slither = slither
|
||||
|
||||
@property
|
||||
def slither(self):
|
||||
return self._slither
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
class ChildStructure(object):
|
||||
|
||||
def __init__(self):
|
||||
super(ChildStructure, self).__init__()
|
||||
self._structure = None
|
||||
|
||||
def set_structure(self, structure):
|
||||
self._structure = structure
|
||||
|
||||
@property
|
||||
def structure(self):
|
||||
return self._structure
|
||||
@@ -0,0 +1,14 @@
|
||||
class Context(object):
|
||||
|
||||
def __init__(self):
|
||||
super(Context, self).__init__()
|
||||
self._context = {}
|
||||
|
||||
@property
|
||||
def context(self):
|
||||
'''
|
||||
Dict used by analysis
|
||||
'''
|
||||
return self._context
|
||||
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
""""
|
||||
Contract module
|
||||
"""
|
||||
import logging
|
||||
from slither.core.children.childSlither import ChildSlither
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
from slither.core.declarations.function import Function
|
||||
|
||||
logger = logging.getLogger("Contract")
|
||||
|
||||
class Contract(ChildSlither, SourceMapping):
|
||||
"""
|
||||
Contract class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(Contract, self).__init__()
|
||||
self._name = None
|
||||
|
||||
self._name = None
|
||||
self._id = None
|
||||
self._inheritances = []
|
||||
|
||||
self._enums = {}
|
||||
self._structures = {}
|
||||
self._events = {}
|
||||
self._variables = {}
|
||||
self._modifiers = {}
|
||||
self._functions = {}
|
||||
self._using_for = {}
|
||||
self._kind = None
|
||||
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, unicode):
|
||||
return other == self.name
|
||||
return NotImplemented
|
||||
|
||||
def __neq__(self, other):
|
||||
if isinstance(other, unicode):
|
||||
return other != self.name
|
||||
return NotImplemented
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""str: Name of the contract."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""Unique id."""
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def inheritances(self):
|
||||
'''
|
||||
list(Contract): Inheritances list. Order: the first elem is the first father to be executed
|
||||
'''
|
||||
return self._inheritances
|
||||
|
||||
@property
|
||||
def inheritances_reverse(self):
|
||||
'''
|
||||
list(Contract): Inheritances list. Order: the last elem is the first father to be executed
|
||||
'''
|
||||
return reversed(self._inheritances)
|
||||
|
||||
def setInheritances(self, inheritances):
|
||||
self._inheritances = inheritances
|
||||
|
||||
@property
|
||||
def structures(self):
|
||||
'''
|
||||
list(Structure): List of the structures
|
||||
'''
|
||||
return self._structures.values()
|
||||
|
||||
def structures_as_dict(self):
|
||||
return self._structures
|
||||
|
||||
@property
|
||||
def enums(self):
|
||||
return self._enums.values()
|
||||
|
||||
def enums_as_dict(self):
|
||||
return self._enums
|
||||
|
||||
@property
|
||||
def modifiers(self):
|
||||
'''
|
||||
list(Modifier): List of the modifiers
|
||||
'''
|
||||
return self._modifiers.values()
|
||||
|
||||
def modifiers_as_dict(self):
|
||||
return self._modifiers
|
||||
|
||||
@property
|
||||
def functions(self):
|
||||
'''
|
||||
list(Function): List of the functions
|
||||
'''
|
||||
return self._functions.values()
|
||||
|
||||
@property
|
||||
def functions_inherited(self):
|
||||
'''
|
||||
list(Function): List of the inherited functions
|
||||
'''
|
||||
return [f for f in self.functions if f.contract != self]
|
||||
|
||||
@property
|
||||
def functions_all_called(self):
|
||||
'''
|
||||
list(Function): List of functions reachable from the contract (include super)
|
||||
'''
|
||||
all_calls = [f.all_calls() for f in self.functions]
|
||||
all_calls = [item for sublist in all_calls for item in sublist] + self.functions
|
||||
all_calls = list(set(all_calls))
|
||||
return [c for c in all_calls if isinstance(c, Function)]
|
||||
|
||||
|
||||
def functions_as_dict(self):
|
||||
return self._functions
|
||||
|
||||
@property
|
||||
def events(self):
|
||||
'''
|
||||
list(Event): List of the events
|
||||
'''
|
||||
return self._events.values()
|
||||
|
||||
def events_as_dict(self):
|
||||
return self._events
|
||||
|
||||
@property
|
||||
def state_variables(self):
|
||||
'''
|
||||
list(StateVariable): List of the state variables.
|
||||
'''
|
||||
return self._variables.values()
|
||||
|
||||
@property
|
||||
def variables(self):
|
||||
'''
|
||||
list(StateVariable): List of the state variables. Alias to self.state_variables
|
||||
'''
|
||||
return self.state_variables
|
||||
|
||||
def variables_as_dict(self):
|
||||
return self._variables
|
||||
|
||||
@property
|
||||
def using_for(self):
|
||||
return self._using_for
|
||||
|
||||
def reverse_using_for(self, name):
|
||||
return self._using_for[name]
|
||||
|
||||
@property
|
||||
def contract_kind(self):
|
||||
return self._kind
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def get_functions_reading_variable(self, variable):
|
||||
'''
|
||||
Return the functions reading the variable
|
||||
'''
|
||||
return [f for f in self.functions if f.is_reading(variable)]
|
||||
|
||||
def get_functions_writing_variable(self, variable):
|
||||
'''
|
||||
Return the functions writting the variable
|
||||
'''
|
||||
return [f for f in self.functions if f.is_writing(variable)]
|
||||
|
||||
def is_signature_only(self):
|
||||
""" Detect if the contracts is only an interface
|
||||
|
||||
Returns:
|
||||
bool: true if the contract do no read or write
|
||||
"""
|
||||
for f in self.functions:
|
||||
if f.variables_read_or_written:
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_source_var_declaration(self, var):
|
||||
""" Return the source mapping where the variable is declared
|
||||
|
||||
Args:
|
||||
var (str): variable name
|
||||
Returns:
|
||||
(dict): sourceMapping
|
||||
"""
|
||||
return next((x.source_mapping for x in self.variables if x.name == var))
|
||||
|
||||
def get_source_event_declaration(self, event):
|
||||
""" Return the source mapping where the event is declared
|
||||
|
||||
Args:
|
||||
event (str): event name
|
||||
Returns:
|
||||
(dict): sourceMapping
|
||||
"""
|
||||
return next((x.source_mapping for x in self.events if x.name == event))
|
||||
|
||||
def get_function_from_signature(self, function_signature):
|
||||
"""
|
||||
Return a function from a signature
|
||||
Args:
|
||||
function_signature (str): signature of the function (without return statement)
|
||||
Returns:
|
||||
Function
|
||||
"""
|
||||
return next((f for f in self.functions if f.full_name == function_signature), None)
|
||||
|
||||
def get_modifier_from_signature(self, modifier_signature):
|
||||
"""
|
||||
Return a modifier from a signature
|
||||
Args:
|
||||
modifier_name (str): signature of the modifier
|
||||
Returns:
|
||||
Modifier
|
||||
"""
|
||||
return next((m for m in self.modifiers if m.full_name == modifier_signature), None)
|
||||
|
||||
def get_state_variable_from_name(self, variable_name):
|
||||
"""
|
||||
Return a state variable from a name
|
||||
Args:
|
||||
varible_name (str): name of the variable
|
||||
Returns:
|
||||
StateVariable
|
||||
"""
|
||||
return next((v for v in self.state_variables if v.name == variable_name), None)
|
||||
|
||||
def get_structure_from_name(self, structure_name):
|
||||
"""
|
||||
Return a structure from a name
|
||||
Args:
|
||||
structure_name (str): name of the structure
|
||||
Returns:
|
||||
Structure
|
||||
"""
|
||||
return next((st for st in self.structure if st.name == structure_name), None)
|
||||
|
||||
def get_structure_from_canonical_name(self, structure_name):
|
||||
"""
|
||||
Return a structure from a canonical name
|
||||
Args:
|
||||
structure_name (str): canonical name of the structure
|
||||
Returns:
|
||||
Structure
|
||||
"""
|
||||
return next((st for st in self.structure if st.canonical_name == structure_name), None)
|
||||
|
||||
def get_event_from_name(self, event_name):
|
||||
"""
|
||||
Return an event from a name
|
||||
Args:
|
||||
event_name (str): name of the event
|
||||
Returns:
|
||||
Event
|
||||
"""
|
||||
return next((e for e in self.events if e.name == event_name), None)
|
||||
|
||||
def get_enum_from_name(self, enum_name):
|
||||
"""
|
||||
Return an enum from a name
|
||||
Args:
|
||||
enum_name (str): name of the enum
|
||||
Returns:
|
||||
Enum
|
||||
"""
|
||||
return next((e for e in self.enum if e.name == event_name), None)
|
||||
|
||||
def get_enum_from_canonical_name(self, enum_name):
|
||||
"""
|
||||
Return an enum from a canonical name
|
||||
Args:
|
||||
enum_name (str): canonical name of the enum
|
||||
Returns:
|
||||
Enum
|
||||
"""
|
||||
return next((e for e in self.enum if e.canonical_name == event_name), None)
|
||||
|
||||
def get_summary(self):
|
||||
""" Return the function summary
|
||||
|
||||
Returns:
|
||||
(str, list, list, list): (name, variables, fuction summaries, modifier summaries)
|
||||
"""
|
||||
func_summaries = [f.get_summary() for f in self.functions]
|
||||
modif_summaries = [f.get_summary() for f in self.modifiers]
|
||||
return (self.name, [str(x) for x in self.inheritances], [str(x) for x in self.variables], func_summaries, modif_summaries)
|
||||
@@ -0,0 +1,21 @@
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
from slither.core.children.childContract import ChildContract
|
||||
|
||||
class Enum(ChildContract, SourceMapping):
|
||||
def __init__(self, name, canonical_name, values):
|
||||
self._name = name
|
||||
self._canonical_name = canonical_name
|
||||
self._values = values
|
||||
|
||||
@property
|
||||
def canonical_name(self):
|
||||
return self._canonical_name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
return self._values
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
from slither.core.children.childContract import ChildContract
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
|
||||
class Event(ChildContract, SourceMapping):
|
||||
|
||||
def __init__(self):
|
||||
super(Event, self).__init__()
|
||||
self._name = None
|
||||
self._elems = []
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def signature(self):
|
||||
''' Return the function signature
|
||||
Returns:
|
||||
(str, list(str)): name, list parameters type
|
||||
'''
|
||||
return self.name, [str(x.type) for x in self.elems]
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
''' Return the function signature as a str
|
||||
Returns:
|
||||
str: func_name(type1,type2)
|
||||
'''
|
||||
name, parameters = self.signature
|
||||
return name+'('+','.join(parameters)+')'
|
||||
|
||||
@property
|
||||
def elems(self):
|
||||
return self._elems
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -0,0 +1,522 @@
|
||||
"""
|
||||
Function module
|
||||
"""
|
||||
import logging
|
||||
from itertools import groupby
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
from slither.core.children.childContract import ChildContract
|
||||
|
||||
from slither.core.variables.stateVariable import StateVariable
|
||||
from slither.core.expressions.identifier import Identifier
|
||||
from slither.core.expressions.unaryOperation import UnaryOperation
|
||||
from slither.core.expressions.memberAccess import MemberAccess
|
||||
from slither.core.expressions.indexAccess import IndexAccess
|
||||
|
||||
from slither.core.declarations.solidityVariables import SolidityVariable, SolidityFunction
|
||||
|
||||
logger = logging.getLogger("Function")
|
||||
|
||||
class Function(ChildContract, SourceMapping):
|
||||
"""
|
||||
Function class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(Function, self).__init__()
|
||||
self._name = None
|
||||
self._view = None
|
||||
self._pure = None
|
||||
self._payable = None
|
||||
self._visibility = None
|
||||
self._is_constructor = None
|
||||
self._is_implemented = None
|
||||
self._is_empty = None
|
||||
self._entry_point = None
|
||||
self._nodes = []
|
||||
self._variables = {}
|
||||
self._parameters = []
|
||||
self._returns = []
|
||||
self._vars_read = []
|
||||
self._vars_written = []
|
||||
self._state_vars_read = []
|
||||
self._vars_read_or_written = []
|
||||
self._solidity_vars_read = []
|
||||
self._state_vars_written = []
|
||||
self._calls = []
|
||||
self._expression_vars_read = []
|
||||
self._expression_vars_written = []
|
||||
self._expression_calls = []
|
||||
self._expression_modifiers = []
|
||||
self._modifiers = []
|
||||
self._payable = False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
str: function name
|
||||
"""
|
||||
if self._name == '':
|
||||
if self.is_constructor:
|
||||
return 'constructor'
|
||||
else:
|
||||
return 'fallback'
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def nodes(self):
|
||||
"""
|
||||
list(Node): List of the nodes
|
||||
"""
|
||||
return self._nodes
|
||||
|
||||
@property
|
||||
def entry_point(self):
|
||||
"""
|
||||
Node: Entry point of the function
|
||||
"""
|
||||
return self._entry_point
|
||||
|
||||
@property
|
||||
def visibility(self):
|
||||
"""
|
||||
str: Function visibility
|
||||
"""
|
||||
return self._visibility
|
||||
|
||||
@property
|
||||
def payable(self):
|
||||
"""
|
||||
bool: True if the function is payable
|
||||
"""
|
||||
return self._payable
|
||||
|
||||
@property
|
||||
def is_constructor(self):
|
||||
"""
|
||||
bool: True if the function is the constructor
|
||||
"""
|
||||
return self._is_constructor or self._name == self.contract.name
|
||||
|
||||
@property
|
||||
def view(self):
|
||||
"""
|
||||
bool: True if the function is declared as view
|
||||
"""
|
||||
return self._view
|
||||
|
||||
@property
|
||||
def pure(self):
|
||||
"""
|
||||
bool: True if the function is declared as pure
|
||||
"""
|
||||
return self._pure
|
||||
|
||||
@property
|
||||
def is_implemented(self):
|
||||
"""
|
||||
bool: True if the function is implemented
|
||||
"""
|
||||
return self._is_implemented
|
||||
|
||||
@property
|
||||
def is_empty(self):
|
||||
"""
|
||||
bool: True if the function is empty
|
||||
"""
|
||||
return self._is_empty
|
||||
|
||||
@property
|
||||
def parameters(self):
|
||||
"""
|
||||
list(LocalVariable): List of the parameters
|
||||
"""
|
||||
return self._parameters
|
||||
|
||||
@property
|
||||
def returns(self):
|
||||
"""
|
||||
list(LocalVariable): List of the return variables
|
||||
"""
|
||||
return self._returns
|
||||
|
||||
@property
|
||||
def modifiers(self):
|
||||
"""
|
||||
list(Modifier): List of the modifiers
|
||||
"""
|
||||
return self._modifiers
|
||||
|
||||
def __str__(self):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def variables(self):
|
||||
"""
|
||||
Return all local variables
|
||||
Include paramters and return values
|
||||
"""
|
||||
return self._variables.values()
|
||||
|
||||
def variables_as_dict(self):
|
||||
return self._variables
|
||||
|
||||
@property
|
||||
def variables_read(self):
|
||||
"""
|
||||
list(Variable): Variables read (local/state/solidity)
|
||||
"""
|
||||
return self._vars_read
|
||||
|
||||
@property
|
||||
def variables_written(self):
|
||||
"""
|
||||
list(Variable): Variables written (local/state/solidity)
|
||||
"""
|
||||
return self._vars_written
|
||||
|
||||
@property
|
||||
def state_variables_read(self):
|
||||
"""
|
||||
list(StateVariable): State variables read
|
||||
"""
|
||||
return self._state_vars_read
|
||||
|
||||
@property
|
||||
def solidity_variables_read(self):
|
||||
"""
|
||||
list(SolidityVariable): Solidity variables read
|
||||
"""
|
||||
return self._solidity_vars_read
|
||||
|
||||
@property
|
||||
def state_variables_written(self):
|
||||
"""
|
||||
list(StateVariable): State variables written
|
||||
"""
|
||||
return self._state_vars_written
|
||||
|
||||
@property
|
||||
def variables_read_or_written(self):
|
||||
"""
|
||||
list(Variable): Variables read or written (local/state/solidity)
|
||||
"""
|
||||
return self._vars_read_or_written
|
||||
|
||||
@property
|
||||
def variables_read_as_expression(self):
|
||||
return self._expression_vars_read
|
||||
|
||||
@property
|
||||
def variables_written_as_expression(self):
|
||||
return self._expression_vars_written
|
||||
|
||||
@property
|
||||
def calls(self):
|
||||
"""
|
||||
list(Function or SolidityFunction): List of calls
|
||||
"""
|
||||
return self._calls
|
||||
|
||||
@property
|
||||
def calls_as_expression(self):
|
||||
return self._expression_calls
|
||||
|
||||
@property
|
||||
def expressions(self):
|
||||
"""
|
||||
list(Expression): List of the expressions
|
||||
"""
|
||||
expressions = [n.expression for n in self.nodes]
|
||||
expressions = [e for e in expressions if e]
|
||||
return expressions
|
||||
|
||||
@property
|
||||
def signature(self):
|
||||
"""
|
||||
(str, list(str), list(str)): Function signature as (name, list parameters type, list return values type)
|
||||
"""
|
||||
return self.name, [str(x.type) for x in self.parameters], [str(x.type) for x in self.returns]
|
||||
|
||||
@property
|
||||
def signature_str(self):
|
||||
"""
|
||||
str: func_name(type1,type2) returns (type3)
|
||||
Return the function signature as a str (contains the return values)
|
||||
"""
|
||||
name, parameters, returnVars = self.signature
|
||||
return name+'('+','.join(parameters)+') returns('+','.join(returnVars)+')'
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
"""
|
||||
str: func_name(type1,type2)
|
||||
Return the function signature without the return values
|
||||
"""
|
||||
name, parameters, _ = self.signature
|
||||
return name+'('+','.join(parameters)+')'
|
||||
|
||||
|
||||
def _filter_state_variables_written(self, expressions):
|
||||
ret =[]
|
||||
for expression in expressions:
|
||||
if isinstance(expression, Identifier):
|
||||
ret.append(expression)
|
||||
if isinstance(expression, UnaryOperation):
|
||||
ret.append(expression.expression)
|
||||
if isinstance(expression, MemberAccess):
|
||||
ret.append(expression.expression)
|
||||
if isinstance(expression, IndexAccess):
|
||||
ret.append(expression.expression_left)
|
||||
return ret
|
||||
|
||||
def _analyze_read_write(self):
|
||||
""" Compute variables read/written/...
|
||||
|
||||
"""
|
||||
write_var = [x.variables_written_as_expression for x in self.nodes]
|
||||
write_var = [x for x in write_var if x]
|
||||
write_var = [item for sublist in write_var for item in sublist ]
|
||||
write_var = list(set(write_var))
|
||||
# Remove dupplicate if they share the same string representation
|
||||
write_var = [next(obj) for i, obj in groupby(sorted(write_var, key=lambda x: str(x)), lambda x: str(x))]
|
||||
self._expression_vars_written = write_var
|
||||
|
||||
write_var = [x.variables_written for x in self.nodes]
|
||||
write_var = [x for x in write_var if x]
|
||||
write_var = [item for sublist in write_var for item in sublist ]
|
||||
write_var = list(set(write_var))
|
||||
# Remove dupplicate if they share the same string representation
|
||||
write_var = [next(obj) for i, obj in\
|
||||
groupby(sorted(write_var, key=lambda x: str(x)), lambda x: str(x))]
|
||||
self._vars_written = write_var
|
||||
|
||||
read_var = [x.variables_read_as_expression for x in self.nodes]
|
||||
read_var = [x for x in read_var if x]
|
||||
read_var = [item for sublist in read_var for item in sublist]
|
||||
# Remove dupplicate if they share the same string representation
|
||||
read_var = [next(obj) for i, obj in\
|
||||
groupby(sorted(read_var, key=lambda x: str(x)), lambda x: str(x))]
|
||||
self._expression_vars_read = read_var
|
||||
|
||||
read_var = [x.variables_read for x in self.nodes]
|
||||
read_var = [x for x in read_var if x]
|
||||
read_var = [item for sublist in read_var for item in sublist]
|
||||
# Remove dupplicate if they share the same string representation
|
||||
read_var = [next(obj) for i, obj in\
|
||||
groupby(sorted(read_var, key=lambda x: str(x)), lambda x: str(x))]
|
||||
self._vars_read = read_var
|
||||
|
||||
self._state_vars_written = [x for x in self.variables_written if\
|
||||
isinstance(x, StateVariable)]
|
||||
self._state_vars_read = [x for x in self.variables_read if\
|
||||
isinstance(x, (StateVariable))]
|
||||
self._solidity_vars_read = [x for x in self.variables_read if\
|
||||
isinstance(x, (SolidityVariable))]
|
||||
|
||||
self._vars_read_or_written = self._vars_written + self._vars_read
|
||||
|
||||
def _analyze_calls(self):
|
||||
calls = [x.calls_as_expression for x in self.nodes]
|
||||
calls = [x for x in calls if x]
|
||||
calls = [item for sublist in calls for item in sublist]
|
||||
# Remove dupplicate if they share the same string representation
|
||||
calls = [next(obj) for i, obj in\
|
||||
groupby(sorted(calls, key=lambda x: str(x)), lambda x: str(x))]
|
||||
self._expression_calls = calls
|
||||
|
||||
calls = [x.calls for x in self.nodes]
|
||||
calls = [x for x in calls if x]
|
||||
calls = [item for sublist in calls for item in sublist]
|
||||
calls = [next(obj) for i, obj in\
|
||||
groupby(sorted(calls, key=lambda x: str(x)), lambda x: str(x))]
|
||||
self._calls = [c for c in calls if isinstance(c, (Function, SolidityFunction))]
|
||||
|
||||
def all_state_variables_read(self):
|
||||
""" recursive version of variables_read
|
||||
"""
|
||||
variables = self.state_variables_read
|
||||
explored = [self]
|
||||
to_explore = [c for c in self.calls if isinstance(c, Function) and c not in explored]
|
||||
to_explore += [m for m in self.modifiers if m not in explored]
|
||||
|
||||
while to_explore:
|
||||
f = to_explore[0]
|
||||
to_explore = to_explore[1:]
|
||||
if f in explored:
|
||||
continue
|
||||
explored.append(f)
|
||||
variables += f.state_variables_read
|
||||
to_explore += [c for c in f.calls if\
|
||||
isinstance(c, Function) and c not in explored and c not in to_explore]
|
||||
to_explore += [m for m in f.modifiers if m not in explored and m not in to_explore]
|
||||
|
||||
return list(set(variables))
|
||||
|
||||
def all_solidity_variables_read(self):
|
||||
""" recursive version of solidity_read
|
||||
"""
|
||||
variables = self.solidity_variables_read
|
||||
explored = [self]
|
||||
to_explore = [c for c in self.calls if isinstance(c, Function) and c not in explored]
|
||||
to_explore += [m for m in self.modifiers if m not in explored]
|
||||
|
||||
while to_explore:
|
||||
f = to_explore[0]
|
||||
to_explore = to_explore[1:]
|
||||
if f in explored:
|
||||
continue
|
||||
explored.append(f)
|
||||
variables += f.solidity_variables_read
|
||||
to_explore += [c for c in f.calls if\
|
||||
isinstance(c, Function) and c not in explored and c not in to_explore]
|
||||
to_explore += [m for m in f.modifiers if m not in explored and m not in to_explore]
|
||||
|
||||
return list(set(variables))
|
||||
|
||||
def all_expressions(self):
|
||||
""" recursive version of variables_read
|
||||
"""
|
||||
variables = self.expressions
|
||||
explored = [self]
|
||||
to_explore = [c for c in self.calls if isinstance(c, Function) and c not in explored]
|
||||
to_explore += [m for m in self.modifiers if m not in explored]
|
||||
|
||||
while to_explore:
|
||||
f = to_explore[0]
|
||||
to_explore = to_explore[1:]
|
||||
if f in explored:
|
||||
continue
|
||||
explored.append(f)
|
||||
variables += f.expressions
|
||||
to_explore += [c for c in f.calls if\
|
||||
isinstance(c, Function) and c not in explored and c not in to_explore]
|
||||
to_explore += [m for m in f.modifiers if m not in explored and m not in to_explore]
|
||||
|
||||
return list(set(variables))
|
||||
|
||||
def all_variables_written(self):
|
||||
""" recursive version of variables_written
|
||||
"""
|
||||
variables = self.state_variables_written
|
||||
explored = [self]
|
||||
to_explore = [c for c in self.calls if isinstance(c, Function) and c not in explored]
|
||||
to_explore += [m for m in self.modifiers if m not in explored]
|
||||
|
||||
while to_explore:
|
||||
f = to_explore[0]
|
||||
to_explore = to_explore[1:]
|
||||
if f in explored:
|
||||
continue
|
||||
explored.append(f)
|
||||
variables += f.state_variables_written
|
||||
to_explore += [c for c in f.calls if\
|
||||
isinstance(c, Function) and c not in explored and c not in to_explore]
|
||||
to_explore += [m for m in f.modifiers if m not in explored and m not in to_explore]
|
||||
|
||||
return list(set(variables))
|
||||
|
||||
def all_calls(self):
|
||||
""" recursive version of calls
|
||||
"""
|
||||
calls = self.calls
|
||||
explored = [self]
|
||||
to_explore = [c for c in self.calls if isinstance(c, Function) and c not in explored]
|
||||
to_explore += [m for m in self.modifiers if m not in explored]
|
||||
|
||||
while to_explore:
|
||||
f = to_explore[0]
|
||||
to_explore = to_explore[1:]
|
||||
if f in explored:
|
||||
continue
|
||||
explored.append(f)
|
||||
calls += f.calls
|
||||
to_explore += [c for c in f.calls if\
|
||||
isinstance(c, Function) and c not in explored and c not in to_explore]
|
||||
to_explore += [m for m in f.modifiers if m not in explored and m not in to_explore]
|
||||
|
||||
return list(set(calls))
|
||||
|
||||
def is_reading(self, variable):
|
||||
"""
|
||||
Check if the function reads the variable
|
||||
Args:
|
||||
variable (Variable):
|
||||
Returns:
|
||||
bool: True if the variable is read
|
||||
"""
|
||||
return variable in self.variables_read
|
||||
|
||||
def is_reading_in_conditional_node(self, variable):
|
||||
"""
|
||||
Check if the function reads the variable in a IF node
|
||||
Args:
|
||||
variable (Variable):
|
||||
Returns:
|
||||
bool: True if the variable is read
|
||||
"""
|
||||
variables_read = [n.variables_read for n in self.nodes if n.contains_if()]
|
||||
variables_read = [item for sublist in variables_read for item in sublist]
|
||||
return variable in variables_read
|
||||
|
||||
def is_reading_in_require_or_assert(self, variable):
|
||||
"""
|
||||
Check if the function reads the variable in an require or assert
|
||||
Args:
|
||||
variable (Variable):
|
||||
Returns:
|
||||
bool: True if the variable is read
|
||||
"""
|
||||
variables_read = [n.variables_read for n in self.nodes if n.contains_require_or_assert()]
|
||||
variables_read = [item for sublist in variables_read for item in sublist]
|
||||
return variable in variables_read
|
||||
|
||||
def is_writing(self, variable):
|
||||
"""
|
||||
Check if the function writes the variable
|
||||
Args:
|
||||
variable (Variable):
|
||||
Returns:
|
||||
bool: True if the variable is written
|
||||
"""
|
||||
return variable in self.variables_written
|
||||
|
||||
def apply_visitor(self, Visitor):
|
||||
"""
|
||||
Apply a visitor to all the function expressions
|
||||
Args:
|
||||
Visitor: slither.visitors
|
||||
Returns
|
||||
list(): results of the visit
|
||||
"""
|
||||
expressions = self.expressions
|
||||
v = [Visitor(e).result() for e in expressions]
|
||||
return [item for sublist in v for item in sublist]
|
||||
|
||||
|
||||
def cfg_to_dot(self, filename):
|
||||
"""
|
||||
Export the function to a dot file
|
||||
Args:
|
||||
filename (str)
|
||||
"""
|
||||
with open(filename, 'w') as f:
|
||||
f.write('digraph{\n')
|
||||
for node in self.nodes:
|
||||
f.write('{}[label="{}"];\n'.format(node.node_id, str(node)))
|
||||
for son in node.sons:
|
||||
f.write('{}->{};\n'.format(node.node_id, son.node_id))
|
||||
|
||||
f.write("}\n")
|
||||
|
||||
def get_summary(self):
|
||||
"""
|
||||
Return the function summary
|
||||
Returns:
|
||||
(str, str, list(str), list(str), listr(str), list(str);
|
||||
name, visibility, modifiers, variables read, variables written, calls
|
||||
"""
|
||||
return (self.name, self.visibility,
|
||||
[str(x) for x in self.modifiers],
|
||||
[str(x) for x in self.state_variables_read + self.solidity_variables_read],
|
||||
[str(x) for x in self.state_variables_written],
|
||||
[str(x) for x in self.calls])
|
||||
@@ -0,0 +1,7 @@
|
||||
"""
|
||||
Modifier module
|
||||
"""
|
||||
from function import Function
|
||||
|
||||
class Modifier(Function): pass
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# https://solidity.readthedocs.io/en/v0.4.24/units-and-global-variables.html
|
||||
|
||||
|
||||
SOLIDITY_VARIABLES = ["block", "msg", "now", "tx", "this", "super", 'abi']
|
||||
|
||||
SOLIDITY_VARIABLES_COMPOSED = ["block.coinbase", "block.difficulty", "block.gaslimit", "block.number", "block.timestamp", "msg.data", "msg.gas", "msg.sender", "msg.sig", "msg.value", "tx.gasprice", "tx.origin"]
|
||||
|
||||
SOLIDITY_FUNCTIONS = ["gasleft()", "assert(bool)", "require(bool)", "require(bool,string)", "revert()", "revert(string)", "addmod(uint256,uint256,uint256)", "mulmod(uint256,uint256,uint256)", "keccak256()", "sha256()", "sha3()", "ripemd160()", "ecrecover(bytes32,uint8,bytes32,bytes32)", "selfdestruct(address)", "suicide(address)", "log0(bytes32)", "log1(bytes32,bytes32)", "log2(bytes32,bytes32,bytes32)", "log3(bytes32,bytes32,bytes32,bytes32)", "blockhash(uint256)"]
|
||||
|
||||
class SolidityVariable(object):
|
||||
|
||||
def __init__(self, name):
|
||||
assert name in SOLIDITY_VARIABLES
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
def __str__(self):
|
||||
return self._name
|
||||
|
||||
class SolidityVariableComposed(SolidityVariable):
|
||||
def __init__(self, name):
|
||||
assert name in SOLIDITY_VARIABLES_COMPOSED
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
def __str__(self):
|
||||
return self._name
|
||||
|
||||
|
||||
|
||||
class SolidityFunction(object):
|
||||
|
||||
def __init__(self, name):
|
||||
assert name in SOLIDITY_FUNCTIONS
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
def __str__(self):
|
||||
return self._name
|
||||
@@ -0,0 +1,27 @@
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
from slither.core.children.childContract import ChildContract
|
||||
|
||||
from slither.core.variables.variable import Variable
|
||||
|
||||
class Structure(ChildContract, SourceMapping):
|
||||
|
||||
def __init__(self):
|
||||
super(Structure, self).__init__()
|
||||
self._name = None
|
||||
self._canonical_name = None
|
||||
self._elems = None
|
||||
|
||||
@property
|
||||
def canonical_name(self):
|
||||
return self._canonical_name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def elems(self):
|
||||
return self._elems
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -0,0 +1,113 @@
|
||||
import logging
|
||||
from slither.core.expressions.expressionTyped import ExpressionTyped
|
||||
from slither.core.expressions.expression import Expression
|
||||
|
||||
|
||||
logger = logging.getLogger("AssignmentOperation")
|
||||
|
||||
class AssignmentOperationType(object):
|
||||
ASSIGN = 0 # =
|
||||
ASSIGN_OR = 1 # |=
|
||||
ASSIGN_CARET = 2 # ^=
|
||||
ASSIGN_AND = 3 # &=
|
||||
ASSIGN_LEFT_SHIFT = 4 # <<=
|
||||
ASSIGN_RIGHT_SHIFT = 5 # >>=
|
||||
ASSIGN_ADDITION = 6 # +=
|
||||
ASSIGN_SUBSTRACTION = 7 # -=
|
||||
ASSIGN_MULTIPLICATION = 8 # *=
|
||||
ASSIGN_DIVISION = 9 # /=
|
||||
ASSIGN_MODULO = 10 # %=
|
||||
|
||||
@staticmethod
|
||||
def get_type(operation_type):
|
||||
if operation_type == '=':
|
||||
return AssignmentOperationType.ASSIGN
|
||||
if operation_type == '|=':
|
||||
return AssignmentOperationType.ASSIGN_OR
|
||||
if operation_type == '^=':
|
||||
return AssignmentOperationType.ASSIGN_CARET
|
||||
if operation_type == '&=':
|
||||
return AssignmentOperationType.ASSIGN_AND
|
||||
if operation_type == '<<=':
|
||||
return AssignmentOperationType.ASSIGN_LEFT_SHIFT
|
||||
if operation_type == '>>=':
|
||||
return AssignmentOperationType.ASSIGN_RIGHT_SHIFT
|
||||
if operation_type == '+=':
|
||||
return AssignmentOperationType.ASSIGN_ADDITION
|
||||
if operation_type == '-=':
|
||||
return AssignmentOperationType.ASSIGN_SUBSTRACTION
|
||||
if operation_type == '*=':
|
||||
return AssignmentOperationType.ASSIGN_MULTIPLICATION
|
||||
if operation_type == '/=':
|
||||
return AssignmentOperationType.ASSIGN_DIVISION
|
||||
if operation_type == '%=':
|
||||
return AssignmentOperationType.ASSIGN_MODULO
|
||||
|
||||
logger.error('get_type: Unknown operation type {})'.format(operation_type))
|
||||
exit(-1)
|
||||
|
||||
@staticmethod
|
||||
def str(operation_type):
|
||||
if operation_type == AssignmentOperationType.ASSIGN:
|
||||
return '='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_OR:
|
||||
return '|='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_CARET:
|
||||
return '^='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_AND:
|
||||
return '&='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_LEFT_SHIFT:
|
||||
return '<<='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_RIGHT_SHIFT:
|
||||
return '>>='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_ADDITION:
|
||||
return '+='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_SUBSTRACTION:
|
||||
return '-='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_MULTIPLICATION:
|
||||
return '*='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_DIVISION:
|
||||
return '/='
|
||||
if operation_type == AssignmentOperationType.ASSIGN_MODULO:
|
||||
return '%='
|
||||
|
||||
logger.error('str: Unknown operation type {})'.format(operation_type))
|
||||
exit(-1)
|
||||
|
||||
class AssignmentOperation(ExpressionTyped):
|
||||
|
||||
def __init__(self, left_expression, right_expression, expression_type, expression_return_type):
|
||||
assert isinstance(left_expression, Expression)
|
||||
assert isinstance(right_expression, Expression)
|
||||
super(AssignmentOperation, self).__init__()
|
||||
left_expression.set_lvalue()
|
||||
self._expressions = [left_expression, right_expression]
|
||||
self._type = expression_type
|
||||
self._expression_return_type = expression_return_type
|
||||
|
||||
@property
|
||||
def expressions(self):
|
||||
return self._expressions
|
||||
|
||||
@property
|
||||
def expression_return_type(self):
|
||||
return self._expression_return_type
|
||||
|
||||
@property
|
||||
def expression_left(self):
|
||||
return self._expressions[0]
|
||||
|
||||
@property
|
||||
def expression_right(self):
|
||||
return self._expressions[1]
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
@property
|
||||
def type_str(self):
|
||||
return AssignmentOperationType.str(self._type)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.expression_left) + " "+ self.type_str + " " + str(self.expression_right)
|
||||
@@ -0,0 +1,147 @@
|
||||
import logging
|
||||
from slither.core.expressions.expressionTyped import ExpressionTyped
|
||||
from slither.core.expressions.expression import Expression
|
||||
|
||||
|
||||
logger = logging.getLogger("BinaryOperation")
|
||||
|
||||
class BinaryOperationType(object):
|
||||
POWER = 0 # **
|
||||
MULTIPLICATION = 1 # *
|
||||
DIVISION = 2 # /
|
||||
MODULO = 3 # %
|
||||
ADDITION = 4 # +
|
||||
SUBSTRACTION = 5 # -
|
||||
LEFT_SHIFT = 6 # <<
|
||||
RIGHT_SHIT = 7 # >>>
|
||||
AND = 8 # &
|
||||
CARET = 9 # ^
|
||||
OR = 10 # |
|
||||
LESS = 11 # <
|
||||
GREATER = 12 # >
|
||||
LESS_EQUAL = 13 # <=
|
||||
GREATER_EQUAL = 14 # >=
|
||||
EQUAL = 15 # ==
|
||||
NOT_EQUAL = 16 # !=
|
||||
ANDAND = 17 # &&
|
||||
OROR = 18 # ||
|
||||
|
||||
@staticmethod
|
||||
def get_type(operation_type):
|
||||
if operation_type == '**':
|
||||
return BinaryOperationType.POWER
|
||||
if operation_type == '*':
|
||||
return BinaryOperationType.MULTIPLICATION
|
||||
if operation_type == '/':
|
||||
return BinaryOperationType.DIVISION
|
||||
if operation_type == '%':
|
||||
return BinaryOperationType.MODULO
|
||||
if operation_type == '+':
|
||||
return BinaryOperationType.ADDITION
|
||||
if operation_type == '-':
|
||||
return BinaryOperationType.SUBSTRACTION
|
||||
if operation_type == '<<':
|
||||
return BinaryOperationType.LEFT_SHIFT
|
||||
if operation_type == '>>':
|
||||
return BinaryOperationType.RIGHT_SHIT
|
||||
if operation_type == '&':
|
||||
return BinaryOperationType.AND
|
||||
if operation_type == '^':
|
||||
return BinaryOperationType.CARET
|
||||
if operation_type == '|':
|
||||
return BinaryOperationType.OR
|
||||
if operation_type == '<':
|
||||
return BinaryOperationType.LESS
|
||||
if operation_type == '>':
|
||||
return BinaryOperationType.GREATER
|
||||
if operation_type == '<=':
|
||||
return BinaryOperationType.LESS_EQUAL
|
||||
if operation_type == '>=':
|
||||
return BinaryOperationType.GREATER_EQUAL
|
||||
if operation_type == '==':
|
||||
return BinaryOperationType.EQUAL
|
||||
if operation_type == '!=':
|
||||
return BinaryOperationType.NOT_EQUAL
|
||||
if operation_type == '&&':
|
||||
return BinaryOperationType.ANDAND
|
||||
if operation_type == '||':
|
||||
return BinaryOperationType.OROR
|
||||
|
||||
logger.error('get_type: Unknown operation type {})'.format(operation_type))
|
||||
exit(-1)
|
||||
|
||||
@staticmethod
|
||||
def str(operation_type):
|
||||
if operation_type == BinaryOperationType.POWER:
|
||||
return '**'
|
||||
if operation_type == BinaryOperationType.MULTIPLICATION:
|
||||
return '*'
|
||||
if operation_type == BinaryOperationType.DIVISION:
|
||||
return '/'
|
||||
if operation_type == BinaryOperationType.MODULO:
|
||||
return '%'
|
||||
if operation_type == BinaryOperationType.ADDITION:
|
||||
return '+'
|
||||
if operation_type == BinaryOperationType.SUBSTRACTION:
|
||||
return '-'
|
||||
if operation_type == BinaryOperationType.LEFT_SHIFT:
|
||||
return '<<'
|
||||
if operation_type == BinaryOperationType.RIGHT_SHIT:
|
||||
return '>>'
|
||||
if operation_type == BinaryOperationType.AND:
|
||||
return '&'
|
||||
if operation_type == BinaryOperationType.CARET:
|
||||
return '^'
|
||||
if operation_type == BinaryOperationType.OR:
|
||||
return '|'
|
||||
if operation_type == BinaryOperationType.LESS:
|
||||
return '<'
|
||||
if operation_type == BinaryOperationType.GREATER:
|
||||
return '>'
|
||||
if operation_type == BinaryOperationType.LESS_EQUAL:
|
||||
return '<='
|
||||
if operation_type == BinaryOperationType.GREATER_EQUAL:
|
||||
return '>='
|
||||
if operation_type == BinaryOperationType.EQUAL:
|
||||
return '=='
|
||||
if operation_type == BinaryOperationType.NOT_EQUAL:
|
||||
return '!='
|
||||
if operation_type == BinaryOperationType.ANDAND:
|
||||
return '&&'
|
||||
if operation_type == BinaryOperationType.OROR:
|
||||
return '||'
|
||||
logger.error('str: Unknown operation type {})'.format(operation_type))
|
||||
exit(-1)
|
||||
|
||||
class BinaryOperation(ExpressionTyped):
|
||||
|
||||
def __init__(self, left_expression, right_expression, expression_type):
|
||||
assert isinstance(left_expression, Expression)
|
||||
assert isinstance(right_expression, Expression)
|
||||
super(BinaryOperation, self).__init__()
|
||||
self._expressions = [left_expression, right_expression]
|
||||
self._type = expression_type
|
||||
|
||||
@property
|
||||
def get_expression(self):
|
||||
return self._expressions
|
||||
|
||||
@property
|
||||
def expression_left(self):
|
||||
return self._expressions[0]
|
||||
|
||||
@property
|
||||
def expression_right(self):
|
||||
return self._expressions[1]
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
@property
|
||||
def type_str(self):
|
||||
return BinaryOperationType.str(self._type)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.expression_left) + ' ' + self.type_str + ' ' + str(self.expression_right)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from slither.core.expressions.expression import Expression
|
||||
|
||||
class CallExpression(Expression):
|
||||
|
||||
def __init__(self, called, arguments, type_call):
|
||||
assert isinstance(called, Expression)
|
||||
super(CallExpression, self).__init__()
|
||||
self._called = called
|
||||
self._arguments = arguments
|
||||
self._type_call = type_call
|
||||
|
||||
@property
|
||||
def called(self):
|
||||
return self._called
|
||||
|
||||
@property
|
||||
def arguments(self):
|
||||
return self._arguments
|
||||
|
||||
@property
|
||||
def type_call(self):
|
||||
return self._type_call
|
||||
|
||||
def __str__(self):
|
||||
return str(self._called) + '(' + ','.join([str(a) for a in self._arguments]) + ')'
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
from expression import Expression
|
||||
|
||||
class ConditionalExpression(Expression):
|
||||
|
||||
def __init__(self, if_expression, then_expression, else_expression):
|
||||
assert isinstance(if_expression, Expression)
|
||||
assert isinstance(then_expression, Expression)
|
||||
assert isinstance(else_expression, Expression)
|
||||
super(ConditionalExpression, self).__init__()
|
||||
self._if_expression = if_expression
|
||||
self._then_expression = then_expression
|
||||
self._else_expression = else_expression
|
||||
|
||||
@property
|
||||
def expressions(self):
|
||||
return [self._if_expression, self._then_expression, self._else_expression]
|
||||
|
||||
@property
|
||||
def if_expression(self):
|
||||
return self._if_expression
|
||||
|
||||
@property
|
||||
def else_expression(self):
|
||||
return self._else_expression
|
||||
|
||||
@property
|
||||
def then_expression(self):
|
||||
return self._then_expression
|
||||
|
||||
def __str__(self):
|
||||
return 'if ' + str(self._if_expression) + ' then ' + str(self._then_expression) + ' else ' + str(self._else_expression)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
This expression does nothing, if a contract used it, its probably a bug
|
||||
"""
|
||||
from slither.core.expressions.expression import Expression
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
class ElementaryTypeNameExpression(Expression):
|
||||
|
||||
def __init__(self, t):
|
||||
assert isinstance(t, Type)
|
||||
super(ElementaryTypeNameExpression, self).__init__()
|
||||
self._type = t
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
def __str__(self):
|
||||
return str(self._type)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
|
||||
class Expression( SourceMapping):
|
||||
|
||||
def __init__(self):
|
||||
super(Expression, self).__init__()
|
||||
self._is_lvalue = False
|
||||
|
||||
@property
|
||||
def is_lvalue(self):
|
||||
return self._is_lvalue
|
||||
|
||||
def set_lvalue(self):
|
||||
self._is_lvalue = True
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
from expression import Expression
|
||||
|
||||
class ExpressionTyped(Expression):
|
||||
|
||||
def __init__(self):
|
||||
super(ExpressionTyped, self).__init__()
|
||||
self._type = None
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
from slither.core.expressions.expressionTyped import ExpressionTyped
|
||||
|
||||
class Identifier(ExpressionTyped):
|
||||
|
||||
def __init__(self, value):
|
||||
super(Identifier, self).__init__()
|
||||
self._value = value
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
return self._value
|
||||
|
||||
def __str__(self):
|
||||
return str(self._value)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
from slither.core.expressions.expressionTyped import ExpressionTyped
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
|
||||
class IndexAccess(ExpressionTyped):
|
||||
|
||||
def __init__(self, left_expression, right_expression, index_type):
|
||||
super(IndexAccess, self).__init__()
|
||||
self._expressions = [left_expression, right_expression]
|
||||
# TODO type of undexAccess is not always a Type
|
||||
# assert isinstance(index_type, Type)
|
||||
self._type = index_type
|
||||
|
||||
@property
|
||||
def expressions(self):
|
||||
return self._expressions
|
||||
|
||||
@property
|
||||
def expression_left(self):
|
||||
return self._expressions[0]
|
||||
|
||||
@property
|
||||
def expression_right(self):
|
||||
return self._expressions[1]
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
def __str__(self):
|
||||
return str(self.expression_left) + '[' + str(self.expression_right) + ']'
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
from slither.core.expressions.expression import Expression
|
||||
|
||||
class Literal(Expression):
|
||||
|
||||
def __init__(self, value):
|
||||
super(Literal, self).__init__()
|
||||
self._value = value
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
return self._value
|
||||
|
||||
def __str__(self):
|
||||
# be sure to handle any character
|
||||
if isinstance(self._value, unicode):
|
||||
return self._value.encode('utf-8')
|
||||
return str(self._value)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
from slither.core.expressions.expression import Expression
|
||||
from slither.core.expressions.expressionTyped import ExpressionTyped
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
class MemberAccess(ExpressionTyped):
|
||||
|
||||
def __init__(self, member_name, member_type, expression):
|
||||
#assert isinstance(member_type, Type)
|
||||
# TODO member_type is not always a Type
|
||||
assert isinstance(expression, Expression)
|
||||
super(MemberAccess, self).__init__()
|
||||
self._type = member_type
|
||||
self._member_name = member_name
|
||||
self._expression = expression
|
||||
|
||||
@property
|
||||
def expression(self):
|
||||
return self._expression
|
||||
|
||||
@property
|
||||
def member_name(self):
|
||||
return self._member_name
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
def __str__(self):
|
||||
return str(self.expression) + '.' + self.member_name
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import logging
|
||||
from expression import Expression
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
logger = logging.getLogger("NewArray")
|
||||
|
||||
class NewArray(Expression):
|
||||
|
||||
# note: dont conserve the size of the array if provided
|
||||
def __init__(self, depth, array_type):
|
||||
super(NewArray, self).__init__()
|
||||
assert isinstance(array_type, Type)
|
||||
self._depth = depth
|
||||
self._array_type = array_type
|
||||
|
||||
@property
|
||||
def array_type(self):
|
||||
return self._array_type
|
||||
|
||||
@property
|
||||
def depth(self):
|
||||
return self._depth
|
||||
|
||||
def __str__(self):
|
||||
return 'new ' + str(self._array_type) + '[]'* self._depth
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
from expression import Expression
|
||||
|
||||
class NewContract(Expression):
|
||||
|
||||
def __init__(self, contract_name):
|
||||
super(NewContract, self).__init__()
|
||||
self._contract_name = contract_name
|
||||
|
||||
@property
|
||||
def contract_name(self):
|
||||
return self._contract_name
|
||||
|
||||
def __str__(self):
|
||||
return 'new ' + str(self._contract_name)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from slither.core.expressions.expression import Expression
|
||||
from slither.core.solidityTypes.elementaryType import ElementaryType
|
||||
|
||||
class NewElementaryType(Expression):
|
||||
|
||||
def __init__(self, new_type):
|
||||
assert isinstance(new_type, ElementaryType)
|
||||
super(NewElementaryType, self).__init__()
|
||||
self._type = new_type
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
def __str__(self):
|
||||
return 'new ' + str(self._type)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
from slither.core.expressions.expression import Expression
|
||||
from slither.core.expressions.callExpression import CallExpression
|
||||
|
||||
class SuperCallExpression(CallExpression): pass
|
||||
@@ -0,0 +1,8 @@
|
||||
from slither.core.expressions.expressionTyped import ExpressionTyped
|
||||
from slither.core.expressions.identifier import Identifier
|
||||
|
||||
class SuperIdentifier(Identifier):
|
||||
|
||||
def __str__(self):
|
||||
return 'super.' + str(self._value)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from slither.core.expressions.expression import Expression
|
||||
|
||||
class TupleExpression(Expression):
|
||||
|
||||
def __init__(self, expressions):
|
||||
assert all(isinstance(x, Expression) for x in expressions if x)
|
||||
super(TupleExpression, self).__init__()
|
||||
self._expressions = expressions
|
||||
|
||||
@property
|
||||
def expressions(self):
|
||||
return self._expressions
|
||||
|
||||
def __str__(self):
|
||||
expressions_str = [str(e) for e in self.expressions]
|
||||
return '(' + ','.join(expressions_str) + ')'
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
from slither.core.expressions.expressionTyped import ExpressionTyped
|
||||
from slither.core.expressions.expression import Expression
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
|
||||
class TypeConversion(ExpressionTyped):
|
||||
|
||||
def __init__(self, expression, expression_type):
|
||||
super(TypeConversion, self).__init__()
|
||||
assert isinstance(expression, Expression)
|
||||
assert isinstance(expression_type, Type)
|
||||
self._expression = expression
|
||||
self._type = expression_type
|
||||
|
||||
@property
|
||||
def expression(self):
|
||||
return self._expression
|
||||
|
||||
def __str__(self):
|
||||
return str(self.type) + '(' + str(self.expression) + ')'
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import logging
|
||||
from slither.core.expressions.expressionTyped import ExpressionTyped
|
||||
from slither.core.expressions.expression import Expression
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
logger = logging.getLogger("UnaryOperation")
|
||||
|
||||
class UnaryOperationType(object):
|
||||
BANG = 0 # !
|
||||
TILD = 1 # ~
|
||||
DELETE = 2 # delete
|
||||
PLUSPLUS_PRE = 3 # ++
|
||||
MINUSMINUS_PRE = 4 # --
|
||||
PLUSPLUS_POST = 5 # ++
|
||||
MINUSMINUS_POST = 6 # --
|
||||
PLUS_PRE = 7 # for stuff like uint(+1)
|
||||
MINUS_PRE = 8 # for stuff like uint(-1)
|
||||
|
||||
@staticmethod
|
||||
def get_type(operation_type, isprefix):
|
||||
if isprefix:
|
||||
if operation_type == '!':
|
||||
return UnaryOperationType.BANG
|
||||
if operation_type == '~':
|
||||
return UnaryOperationType.TILD
|
||||
if operation_type == 'delete':
|
||||
return UnaryOperationType.DELETE
|
||||
if operation_type == '++':
|
||||
return UnaryOperationType.PLUSPLUS_PRE
|
||||
if operation_type == '--':
|
||||
return UnaryOperationType.MINUSMINUS_PRE
|
||||
if operation_type == '+':
|
||||
return UnaryOperationType.PLUS_PRE
|
||||
if operation_type == '-':
|
||||
return UnaryOperationType.MINUS_PRE
|
||||
else:
|
||||
if operation_type == '++':
|
||||
return UnaryOperationType.PLUSPLUS_POST
|
||||
if operation_type == '--':
|
||||
return UnaryOperationType.MINUSMINUS_POST
|
||||
logger.error('get_type: Unknown operation type {}'.format(operation_type))
|
||||
exit(-1)
|
||||
|
||||
@staticmethod
|
||||
def str(operation_type):
|
||||
if operation_type == UnaryOperationType.BANG:
|
||||
return '!'
|
||||
if operation_type == UnaryOperationType.TILD:
|
||||
return '~'
|
||||
if operation_type == UnaryOperationType.DELETE:
|
||||
return 'delete'
|
||||
if operation_type == UnaryOperationType.PLUS_PRE:
|
||||
return '+'
|
||||
if operation_type == UnaryOperationType.MINUS_PRE:
|
||||
return '-'
|
||||
if operation_type in [UnaryOperationType.PLUSPLUS_PRE, UnaryOperationType.PLUSPLUS_POST]:
|
||||
return '++'
|
||||
if operation_type in [UnaryOperationType.MINUSMINUS_PRE, UnaryOperationType.MINUSMINUS_POST]:
|
||||
return '--'
|
||||
|
||||
logger.error('str: Unknown operation type {}'.format(operation_type))
|
||||
exit(-1)
|
||||
|
||||
@staticmethod
|
||||
def is_prefix(operation_type):
|
||||
if operation_type in [UnaryOperationType.BANG,
|
||||
UnaryOperationType.TILD,
|
||||
UnaryOperationType.DELETE,
|
||||
UnaryOperationType.PLUSPLUS_PRE,
|
||||
UnaryOperationType.MINUSMINUS_PRE,
|
||||
UnaryOperationType.PLUS_PRE,
|
||||
UnaryOperationType.MINUS_PRE]:
|
||||
return True
|
||||
elif operation_type in [UnaryOperationType.PLUSPLUS_POST, UnaryOperationType.MINUSMINUS_POST]:
|
||||
return False
|
||||
|
||||
logger.error('is_prefix: Unknown operation type {}'.format(operation_type))
|
||||
exit(-1)
|
||||
|
||||
class UnaryOperation(ExpressionTyped):
|
||||
|
||||
def __init__(self, expression, expression_type):
|
||||
assert isinstance(expression, Expression)
|
||||
super(UnaryOperation, self).__init__()
|
||||
self._expression = expression
|
||||
self._type = expression_type
|
||||
if expression_type in [UnaryOperationType.DELETE,
|
||||
UnaryOperationType.PLUSPLUS_PRE,
|
||||
UnaryOperationType.MINUSMINUS_PRE,
|
||||
UnaryOperationType.PLUSPLUS_POST,
|
||||
UnaryOperationType.MINUSMINUS_POST,
|
||||
UnaryOperationType.PLUS_PRE,
|
||||
UnaryOperationType.MINUS_PRE]:
|
||||
expression.set_lvalue()
|
||||
|
||||
@property
|
||||
def expression(self):
|
||||
return self._expression
|
||||
|
||||
@property
|
||||
def type_str(self):
|
||||
return UnaryOperationType.str(self._type)
|
||||
|
||||
@property
|
||||
def is_prefix(self):
|
||||
return UnaryOperationType.is_prefix(self._type)
|
||||
|
||||
def __str__(self):
|
||||
if self.is_prefix:
|
||||
return self.type_str + ' ' + str(self._expression)
|
||||
else:
|
||||
return str(self._expression) + ' ' + self.type_str
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
Main module
|
||||
"""
|
||||
import os
|
||||
|
||||
class Slither(object):
|
||||
"""
|
||||
Slither static analyzer
|
||||
"""
|
||||
name_class = 'Slither'
|
||||
|
||||
def __init__(self):
|
||||
self._contracts = {}
|
||||
self._filename = None
|
||||
self._source_units = {}
|
||||
self._solc_version = None # '0.3' or '0.4':!
|
||||
|
||||
@property
|
||||
def contracts(self):
|
||||
"""list(Contract): List of contracts."""
|
||||
return self._contracts.values()
|
||||
|
||||
@property
|
||||
def contracts_derived(self):
|
||||
"""list(Contract): List of contracts that are derived and not inherited."""
|
||||
inheritances = [x.inheritances for x in self.contracts]
|
||||
inheritances = [item for sublist in inheritances for item in sublist]
|
||||
return [c for c in self._contracts.values() if c not in inheritances]
|
||||
|
||||
def contracts_as_dict(self):
|
||||
"""list(dict(str: Contract): List of contracts as dict: name -> Contract."""
|
||||
return self._contracts
|
||||
|
||||
@property
|
||||
def filename(self):
|
||||
"""str: Filename."""
|
||||
return self._filename
|
||||
|
||||
@property
|
||||
def solc_version(self):
|
||||
"""str: Solidity version."""
|
||||
return self._solc_version
|
||||
|
||||
def get_contract_from_name(self, contract_name):
|
||||
"""
|
||||
Return a contract from a name
|
||||
Args:
|
||||
contract_name (str): name of the contract
|
||||
Returns:
|
||||
Contract
|
||||
"""
|
||||
return next((c for c in self.contracts if c.name == contract_name), None)
|
||||
|
||||
def print_functions(self, d):
|
||||
"""
|
||||
Export all the functions to dot files
|
||||
"""
|
||||
for c in self.contracts:
|
||||
for f in c.functions:
|
||||
f.cfg_to_dot(os.path.join(d,'{}.{}.dot'.format(c.name, f.name)))
|
||||
@@ -0,0 +1,26 @@
|
||||
from slither.core.solidityTypes.type import Type
|
||||
from slither.core.expressions.expression import Expression
|
||||
|
||||
class ArrayType(Type):
|
||||
|
||||
def __init__(self, t, length):
|
||||
assert isinstance(t, Type)
|
||||
if length:
|
||||
assert isinstance(length, Expression)
|
||||
super(ArrayType, self).__init__()
|
||||
self._type = t
|
||||
self._length = length
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
@property
|
||||
def length(self):
|
||||
return self._length
|
||||
|
||||
def __str__(self):
|
||||
if self._length:
|
||||
return str(self._type)+'[{}]'.format(str(self._length))
|
||||
return str(self._type)+'[]'
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import itertools
|
||||
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
|
||||
# see https://solidity.readthedocs.io/en/v0.4.24/miscellaneous.html?highlight=grammar
|
||||
|
||||
Int = ['int', 'int8', 'int16', 'int24', 'int32', 'int40', 'int48', 'int56', 'int64', 'int72', 'int80', 'int88', 'int96', 'int104', 'int112', 'int120', 'int128', 'int136', 'int144', 'int152', 'int160', 'int168', 'int176', 'int184', 'int192', 'int200', 'int208', 'int216', 'int224', 'int232', 'int240', 'int248', 'int256']
|
||||
|
||||
Uint = ['uint', 'uint8', 'uint16', 'uint24', 'uint32', 'uint40', 'uint48', 'uint56', 'uint64', 'uint72', 'uint80', 'uint88', 'uint96', 'uint104', 'uint112', 'uint120', 'uint128', 'uint136', 'uint144', 'uint152', 'uint160', 'uint168', 'uint176', 'uint184', 'uint192', 'uint200', 'uint208', 'uint216', 'uint224', 'uint232', 'uint240', 'uint248', 'uint256']
|
||||
|
||||
Byte = ['byte', 'bytes', 'bytes1', 'bytes2', 'bytes3', 'bytes4', 'bytes5', 'bytes6', 'bytes7', 'bytes8', 'bytes9', 'bytes10', 'bytes11', 'bytes12', 'bytes13', 'bytes14', 'bytes15', 'bytes16', 'bytes17', 'bytes18', 'bytes19', 'bytes20', 'bytes21', 'bytes22', 'bytes23', 'bytes24', 'bytes25', 'bytes26', 'bytes27', 'bytes28', 'bytes29', 'bytes30', 'bytes31', 'bytes32']
|
||||
|
||||
# https://solidity.readthedocs.io/en/v0.4.24/types.html#fixed-point-numbers
|
||||
M = range(8, 257, 8)
|
||||
N = range(0, 81)
|
||||
MN = list(itertools.product(M,N))
|
||||
|
||||
Fixed = ['fixed{}x{}'.format(m,n) for (m,n) in MN] + ['fixed']
|
||||
Ufixed = ['ufixed{}x{}'.format(m,n) for (m,n) in MN] + ['ufixed']
|
||||
|
||||
ElementaryTypeName = ['address', 'bool', 'string', 'var'] + Int + Uint + Byte + Fixed + Ufixed
|
||||
|
||||
class NonElementaryType(Exception): pass
|
||||
|
||||
class ElementaryType(Type):
|
||||
|
||||
def __init__(self, t):
|
||||
if t not in ElementaryTypeName:
|
||||
raise NonElementaryType
|
||||
super(ElementaryType, self).__init__()
|
||||
if t == 'uint':
|
||||
t = 'uint256'
|
||||
elif t == 'int':
|
||||
t = 'int256'
|
||||
elif t == 'byte':
|
||||
t = 'bytes1'
|
||||
self._type = t
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.type
|
||||
|
||||
def __str__(self):
|
||||
return self._type
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from slither.core.solidityTypes.type import Type
|
||||
from slither.core.variables.functionTypeVariable import FunctionTypeVariable
|
||||
from slither.core.expressions.expression import Expression
|
||||
|
||||
class FunctionType(Type):
|
||||
|
||||
def __init__(self, params, return_values):
|
||||
assert all(isinstance(x, FunctionTypeVariable) for x in params)
|
||||
assert all(isinstance(x, FunctionTypeVariable) for x in return_values)
|
||||
super(FunctionType, self).__init__()
|
||||
self._params = params
|
||||
self._return_values = return_values
|
||||
|
||||
@property
|
||||
def params(self):
|
||||
return self._params
|
||||
|
||||
@property
|
||||
def return_values(self):
|
||||
return self._return_values
|
||||
|
||||
def __str__(self):
|
||||
params = ".".join([str(x) for x in self._params])
|
||||
return_values = ".".join([str(x) for x in self._return_values])
|
||||
return 'function({}) returns ({})'.format(params, return_values)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
class MappingType(Type):
|
||||
|
||||
def __init__(self, type_from, type_to):
|
||||
assert isinstance(type_from, Type)
|
||||
assert isinstance(type_to, Type)
|
||||
super(MappingType, self).__init__()
|
||||
self._from = type_from
|
||||
self._to = type_to
|
||||
|
||||
@property
|
||||
def type_from(self):
|
||||
return self._from
|
||||
|
||||
@property
|
||||
def type_to(self):
|
||||
return self._to
|
||||
|
||||
def __str__(self):
|
||||
return 'mapping({} => {}'.format(str(self._from), str(self._to))
|
||||
@@ -0,0 +1,3 @@
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
|
||||
class Type(SourceMapping): pass
|
||||
@@ -0,0 +1,23 @@
|
||||
from slither.core.solidityTypes.type import Type
|
||||
|
||||
from slither.core.declarations.structure import Structure
|
||||
from slither.core.declarations.enum import Enum
|
||||
from slither.core.declarations.contract import Contract
|
||||
|
||||
|
||||
class UserDefinedType(Type):
|
||||
|
||||
def __init__(self, t):
|
||||
assert isinstance(t, (Contract, Enum, Structure))
|
||||
super(UserDefinedType, self).__init__()
|
||||
self._type = t
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
def __str__(self):
|
||||
if isinstance(self.type, (Enum, Structure)):
|
||||
return str(self.type.contract)+'.'+str(self.type.name)
|
||||
return str(self.type.name)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
from slither.core.context.context import Context
|
||||
|
||||
class SourceMapping(Context):
|
||||
|
||||
def __init__(self):
|
||||
super(SourceMapping, self).__init__()
|
||||
self._source_mapping = None
|
||||
self._offset = None
|
||||
|
||||
def set_source_mapping(self, source_mapping):
|
||||
self._source_mapping = source_mapping
|
||||
|
||||
@property
|
||||
def source_mapping(self):
|
||||
return self._source_mapping
|
||||
|
||||
def set_offset(self, offset):
|
||||
self._offset = offset
|
||||
@@ -0,0 +1,5 @@
|
||||
from variable import Variable
|
||||
from slither.core.children.childEvent import ChildEvent
|
||||
|
||||
class EventVariable(ChildEvent, Variable): pass
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
"""
|
||||
Variable used with FunctionType
|
||||
ex:
|
||||
struct C{
|
||||
function(uint) my_func;
|
||||
}
|
||||
"""
|
||||
|
||||
from variable import Variable
|
||||
|
||||
class FunctionTypeVariable(Variable): pass
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from variable import Variable
|
||||
from slither.core.children.childFunction import ChildFunction
|
||||
|
||||
class LocalVariable(ChildFunction, Variable): pass
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
from slither.core.variables.localVariable import LocalVariable
|
||||
|
||||
class LocalVariableInitFromTuple(LocalVariable):
|
||||
"""
|
||||
Use on this pattern:
|
||||
var(a,b) = f()
|
||||
|
||||
It is not possible to split the variable declaration in sigleton and keep the init value
|
||||
We init a and b with f(). get_tuple_index ret() returns which returns values of f is to be used
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(LocalVariableInitFromTuple, self).__init__()
|
||||
self._tuple_index = None
|
||||
|
||||
@property
|
||||
def tuple_index(self):
|
||||
return self._tuple_index
|
||||
@@ -0,0 +1,4 @@
|
||||
from variable import Variable
|
||||
from slither.core.children.childContract import ChildContract
|
||||
|
||||
class StateVariable(ChildContract, Variable): pass
|
||||
@@ -0,0 +1,5 @@
|
||||
from variable import Variable
|
||||
from slither.core.children.childStructure import ChildStructure
|
||||
|
||||
class StructureVariable(ChildStructure, Variable): pass
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
"""
|
||||
Variable module
|
||||
"""
|
||||
|
||||
from slither.core.sourceMapping.sourceMapping import SourceMapping
|
||||
|
||||
|
||||
class Variable(SourceMapping):
|
||||
|
||||
def __init__(self):
|
||||
super(Variable, self).__init__()
|
||||
self._name = None
|
||||
self._typeName = None
|
||||
self._arrayDepth = None
|
||||
self._isMapping = None
|
||||
self._mappingFrom = None
|
||||
self._mappingTo = None
|
||||
self._initial_expression = None
|
||||
self._type = None
|
||||
self._expression = None
|
||||
self._initialized = None
|
||||
self._visibility = None
|
||||
|
||||
@property
|
||||
def expression(self):
|
||||
"""
|
||||
Expression: Expression of the node (if initialized)
|
||||
"""
|
||||
return self._expression
|
||||
|
||||
@property
|
||||
def initialized(self):
|
||||
"""
|
||||
boolean: True if the variable is initialized at construction
|
||||
"""
|
||||
return self._initialized
|
||||
|
||||
@property
|
||||
def uninitialized(self):
|
||||
"""
|
||||
boolean: True if the variable is not initialized
|
||||
"""
|
||||
return not self._initialized
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
'''
|
||||
str: variable name
|
||||
'''
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
@property
|
||||
def visibility(self):
|
||||
'''
|
||||
str: variable visibility
|
||||
'''
|
||||
return self._visibility
|
||||
|
||||
def set_type(self, t):
|
||||
self._type = t
|
||||
|
||||
def __str__(self):
|
||||
return self._name
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import abc
|
||||
import re
|
||||
from slither.detectors.detectorClassification import DetectorClassification
|
||||
from slither.utils.colors import green, yellow, red
|
||||
|
||||
class IncorrectDetectorInitialization(Exception):
|
||||
pass
|
||||
|
||||
class AbstractDetector(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
ARGUMENT = '' # run the detector with slither.py --ARGUMENT
|
||||
HELP = '' # help information
|
||||
CLASSIFICATION = None
|
||||
|
||||
HIDDEN_DETECTOR = False # yes if the detector should not be showed
|
||||
|
||||
def __init__(self, slither, logger):
|
||||
self.slither = slither
|
||||
self.contracts = slither.contracts
|
||||
self.filename = slither.filename
|
||||
self.logger = logger
|
||||
if self.HELP == '':
|
||||
raise IncorrectDetectorInitialization('HELP is not initialized')
|
||||
if self.ARGUMENT == '':
|
||||
raise IncorrectDetectorInitialization('ARGUMENT is not initialized')
|
||||
if re.match('^[a-zA-Z0-9_-]*$', self.ARGUMENT) is None:
|
||||
raise IncorrectDetectorInitialization('ARGUMENT has illegal character')
|
||||
if not self.CLASSIFICATION in [DetectorClassification.LOW,
|
||||
DetectorClassification.MEDIUM,
|
||||
DetectorClassification.HIGH]:
|
||||
raise IncorrectDetectorInitialization('CLASSIFICATION is not initialized')
|
||||
|
||||
def log(self, info):
|
||||
if self.logger:
|
||||
self.logger.info(self.color(info))
|
||||
|
||||
@abc.abstractmethod
|
||||
def detect(self):
|
||||
"""TODO Documentation"""
|
||||
return
|
||||
|
||||
@property
|
||||
def color(self):
|
||||
if self.CLASSIFICATION == DetectorClassification.LOW:
|
||||
return green
|
||||
if self.CLASSIFICATION == DetectorClassification.MEDIUM:
|
||||
return yellow
|
||||
if self.CLASSIFICATION == DetectorClassification.HIGH:
|
||||
return red
|
||||
@@ -0,0 +1,4 @@
|
||||
class DetectorClassification(object):
|
||||
LOW = 0
|
||||
MEDIUM = 1
|
||||
HIGH = 2
|
||||
@@ -0,0 +1,47 @@
|
||||
import sys, inspect
|
||||
import os
|
||||
import logging
|
||||
|
||||
from slither.detectors.abstractDetector import AbstractDetector
|
||||
from slither.detectors.detectorClassification import DetectorClassification
|
||||
|
||||
# Detectors must be imported here
|
||||
from slither.detectors.examples.backdoor import Backdoor
|
||||
from slither.detectors.variables.uninitializedStateVarsDetection import UninitializedStateVarsDetection
|
||||
|
||||
###
|
||||
|
||||
logger_detector = logging.getLogger("Detectors")
|
||||
|
||||
class Detectors(object):
|
||||
|
||||
def __init__(self):
|
||||
self.detectors = {}
|
||||
self.low = []
|
||||
self.medium = []
|
||||
self.high = []
|
||||
|
||||
self._load_detectors()
|
||||
|
||||
def _load_detectors(self):
|
||||
for name, obj in inspect.getmembers(sys.modules[__name__]):
|
||||
if inspect.isclass(obj):
|
||||
if issubclass(obj, AbstractDetector) and name != 'AbstractDetector':
|
||||
if obj.HIDDEN_DETECTOR:
|
||||
continue
|
||||
if name in self.detectors:
|
||||
raise Exception('Detector name collision: {}'.format(name))
|
||||
self.detectors[name] = obj
|
||||
if obj.CLASSIFICATION == DetectorClassification.LOW:
|
||||
self.low.append(name)
|
||||
elif obj.CLASSIFICATION == DetectorClassification.MEDIUM:
|
||||
self.medium.append(name)
|
||||
elif obj.CLASSIFICATION == DetectorClassification.HIGH:
|
||||
self.high.append(name)
|
||||
else:
|
||||
raise Exception('Unknown classification')
|
||||
|
||||
def run_detector(self, slither, name):
|
||||
Detector = self.detectors[name]
|
||||
instance = Detector(slither, logger_detector)
|
||||
return instance.detect()
|
||||
@@ -0,0 +1,25 @@
|
||||
from slither.detectors.abstractDetector import AbstractDetector
|
||||
from slither.detectors.detectorClassification import DetectorClassification
|
||||
|
||||
class Backdoor(AbstractDetector):
|
||||
"""
|
||||
Detect function named backdoor
|
||||
"""
|
||||
|
||||
ARGUMENT = 'backdoor' # slither will launch the detector with slither.py --mydetector
|
||||
HELP = 'Function named backdoor'
|
||||
CLASSIFICATION = DetectorClassification.HIGH
|
||||
|
||||
def detect(self):
|
||||
ret = []
|
||||
|
||||
for contract in self.slither.contracts_derived:
|
||||
# Check if a function has 'backdoor' in its name
|
||||
if any('backdoor' in f.name for f in contract.functions):
|
||||
# Info to be printed
|
||||
info = 'Backdoor function found in {}'.format(contract.name)
|
||||
# Print the info
|
||||
self.log(info)
|
||||
# Add the result in ret
|
||||
ret.append({'vuln':'backdoor', 'contract':contract.name})
|
||||
return ret
|
||||
@@ -0,0 +1,51 @@
|
||||
"""
|
||||
Module detecting shadowing of functions
|
||||
It is more useful as summary printer than as vuln detection
|
||||
"""
|
||||
|
||||
from slither.detectors.abstractDetector import AbstractDetector
|
||||
from slither.detectors.detectorClassification import DetectorClassification
|
||||
|
||||
class ShadowingFunctionsDetection(AbstractDetector):
|
||||
"""
|
||||
Functions shadowing detection
|
||||
"""
|
||||
|
||||
vuln_name = "ShadowingFunctionContract"
|
||||
|
||||
ARGUMENT = 'shadowing-function'
|
||||
HELP = 'Function Shadowing'
|
||||
CLASSIFICATION = DetectorClassification.LOW
|
||||
|
||||
HIDDEN_DETECTOR = True
|
||||
|
||||
def detect_shadowing(self, contract):
|
||||
functions_declared = set([x.full_name for x in contract.functions])
|
||||
ret = {}
|
||||
for father in contract.inheritances:
|
||||
functions_declared_father = ([x.full_name for x in father.functions])
|
||||
inter = functions_declared.intersection(functions_declared_father)
|
||||
if inter:
|
||||
ret[father] = inter
|
||||
return ret
|
||||
|
||||
def detect(self):
|
||||
""" detect shadowing
|
||||
|
||||
recursively visit the calls
|
||||
returns:
|
||||
list: {'vuln', 'filename,'contract','func', 'shadow'}
|
||||
|
||||
"""
|
||||
results = []
|
||||
for c in self.contracts:
|
||||
shadowing = self.detect_shadowing(c)
|
||||
if shadowing:
|
||||
for contract, funcs in shadowing.iteritems():
|
||||
results.append({'vuln':self.vuln_name,
|
||||
'filename': self.filename,
|
||||
'contractShadower': c.name,
|
||||
'contract': contract.name,
|
||||
'funcs': list(funcs)})
|
||||
|
||||
return results
|
||||
@@ -0,0 +1,75 @@
|
||||
"""
|
||||
Module detecting state uninitialized variables
|
||||
Recursively check the called functions
|
||||
|
||||
The heuristic chekcs that:
|
||||
- state variables are read or called
|
||||
- the variables does not call push (avoid too many FP)
|
||||
|
||||
Only analyze "leaf" contracts (contracts that are not inherited by another contract)
|
||||
"""
|
||||
|
||||
from slither.detectors.abstractDetector import AbstractDetector
|
||||
from slither.detectors.detectorClassification import DetectorClassification
|
||||
|
||||
from slither.visitors.expression.findPush import FindPush
|
||||
|
||||
class UninitializedStateVarsDetection(AbstractDetector):
|
||||
"""
|
||||
Constant function detector
|
||||
"""
|
||||
|
||||
ARGUMENT = 'uninitialized'
|
||||
HELP = 'Uninitialized state variables'
|
||||
CLASSIFICATION = DetectorClassification.HIGH
|
||||
|
||||
def detect_uninitialized(self, contract):
|
||||
# get all the state variables read by all functions
|
||||
var_read = [f.state_variables_read for f in contract.functions_all_called + contract.modifiers]
|
||||
# flat list
|
||||
var_read = [item for sublist in var_read for item in sublist]
|
||||
# remove state variable that are initiliazed at contract construction
|
||||
var_read = [v for v in var_read if v.uninitialized]
|
||||
|
||||
# get all the state variables written by the functions
|
||||
var_written = [f.state_variables_written for f in contract.functions_all_called + contract.modifiers]
|
||||
# flat list
|
||||
var_written = [item for sublist in var_written for item in sublist]
|
||||
|
||||
all_push = [f.apply_visitor(FindPush) for f in contract.functions]
|
||||
# flat list
|
||||
all_push = [item for sublist in all_push for item in sublist]
|
||||
|
||||
uninitialized_vars = list(set([v for v in var_read if\
|
||||
v not in var_written and\
|
||||
v not in all_push and\
|
||||
str(v.type) not in contract.using_for])) # Note: does not handle using X for *
|
||||
|
||||
return [(v, contract.get_functions_reading_variable(v)) for v in uninitialized_vars]
|
||||
|
||||
|
||||
def detect(self):
|
||||
""" Detect uninitialized state variables
|
||||
|
||||
Recursively visit the calls
|
||||
Returns:
|
||||
dict: [contract name] = set(state variable uninitialized)
|
||||
"""
|
||||
results = []
|
||||
for c in self.slither.contracts_derived:
|
||||
ret = self.detect_uninitialized(c)
|
||||
for variable, functions in ret:
|
||||
info = "Uninitialized state variables in %s, "%self.filename +\
|
||||
"Contract: %s, Vars: %s, Used in %s"%(c.name,
|
||||
str(variable),
|
||||
[str(f) for f in functions])
|
||||
self.log(info)
|
||||
|
||||
results.append({'vuln':'UninitializedStateVars',
|
||||
'sourceMapping': c.source_mapping,
|
||||
'filename': self.filename,
|
||||
'contract': c.name,
|
||||
'functions': [str(f) for f in functions],
|
||||
'variable': str(variable)})
|
||||
|
||||
return results
|
||||
@@ -0,0 +1,29 @@
|
||||
import abc
|
||||
|
||||
class IncorrectPrinterInitialization(Exception):
|
||||
pass
|
||||
|
||||
class AbstractPrinter(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
ARGUMENT = '' # run the printer with slither.py --ARGUMENT
|
||||
HELP = '' # help information
|
||||
|
||||
def __init__(self, slither, logger):
|
||||
self.slither = slither
|
||||
self.contracts = slither.contracts
|
||||
self.filename = slither.filename
|
||||
self.logger = logger
|
||||
if self.HELP == '':
|
||||
raise IncorrectPrinterInitialization('HELP is not initialized')
|
||||
if self.ARGUMENT == '':
|
||||
raise IncorrectPrinterInitialization('ARGUMENT is not initialized')
|
||||
|
||||
def info(self, info):
|
||||
if self.logger:
|
||||
self.logger.info(info)
|
||||
|
||||
@abc.abstractmethod
|
||||
def output(self, filename):
|
||||
"""TODO Documentation"""
|
||||
return
|
||||
@@ -0,0 +1,120 @@
|
||||
"""
|
||||
Module printing the inheritance graph
|
||||
|
||||
The inheritance graph shows the relation between the contracts
|
||||
and their functions/modifiers/public variables.
|
||||
The output is a dot file named filename.dot
|
||||
"""
|
||||
|
||||
from slither.printers.abstractPrinter import AbstractPrinter
|
||||
from slither.detectors.shadowing.shadowingFunctionsDetection import ShadowingFunctionsDetection
|
||||
|
||||
from slither.core.declarations.contract import Contract
|
||||
|
||||
class PrinterInheritance(AbstractPrinter):
|
||||
|
||||
ARGUMENT = 'print-inheritance'
|
||||
HELP = 'Print the inheritance graph'
|
||||
|
||||
def __init__(self, slither, logger):
|
||||
super(PrinterInheritance, self).__init__(slither, logger)
|
||||
|
||||
inheritance = [x.inheritances for x in slither.contracts]
|
||||
self.inheritance = set([item for sublist in inheritance for item in sublist])
|
||||
|
||||
shadow = ShadowingFunctionsDetection(slither, None)
|
||||
ret = shadow.detect()
|
||||
functions_shadowed = {}
|
||||
for s in ret:
|
||||
if s['contractShadower'] not in functions_shadowed:
|
||||
functions_shadowed[s['contractShadower']] = []
|
||||
functions_shadowed[s['contractShadower']] += s['funcs']
|
||||
self.functions_shadowed = functions_shadowed
|
||||
|
||||
def _get_pattern_func(self, func, contract):
|
||||
# Html pattern, each line is a row in a table
|
||||
func_name = func.full_name
|
||||
pattern = '<TR><TD align="left"> %s</TD></TR>'
|
||||
pattern_shadow = '<TR><TD align="left"><font color="#FFA500"> %s</font></TD></TR>'
|
||||
if contract.name in self.functions_shadowed:
|
||||
if func_name in self.functions_shadowed[contract.name]:
|
||||
return pattern_shadow%func_name
|
||||
return pattern%func_name
|
||||
|
||||
def _get_pattern_var(self, var, contract):
|
||||
# Html pattern, each line is a row in a table
|
||||
var_name = var.name
|
||||
pattern = '<TR><TD align="left"> %s</TD></TR>'
|
||||
pattern_contract = '<TR><TD align="left"> %s<font color="blue" POINT-SIZE="10"> (%s)</font></TD></TR>'
|
||||
#pattern_arrow = '<TR><TD align="left" PORT="%s"><font color="blue"> %s</font></TD></TR>'
|
||||
if isinstance(var.type, Contract):
|
||||
return pattern_contract%(var_name, str(var.type))
|
||||
#return pattern_arrow%(self._get_port_id(var, contract), var_name)
|
||||
return pattern%var_name
|
||||
|
||||
def _get_port_id(self, var, contract):
|
||||
return "%s%s"%(var.name, contract.name)
|
||||
|
||||
def _summary(self, contract):
|
||||
"""
|
||||
Build summary using HTML
|
||||
"""
|
||||
ret = ''
|
||||
# Add arrows
|
||||
for i in contract.inheritances:
|
||||
ret += '%s -> %s;\n'%(contract.name, i)
|
||||
|
||||
# Functions
|
||||
visibilities = ['public', 'external']
|
||||
public_functions = [self._get_pattern_func(f, contract) for f in contract.functions if not f.is_constructor and f.contract == contract and f.visibility in visibilities]
|
||||
public_functions = ''.join(public_functions)
|
||||
private_functions = [self._get_pattern_func(f, contract) for f in contract.functions if not f.is_constructor and f.contract == contract and f.visibility not in visibilities]
|
||||
private_functions = ''.join(private_functions)
|
||||
# Modifiers
|
||||
modifiers = [self._get_pattern_func(m, contract) for m in contract.modifiers if m.contract == contract]
|
||||
modifiers = ''.join(modifiers)
|
||||
# Public variables
|
||||
public_variables = [self._get_pattern_var(v, contract) for v in contract.variables if v.visibility in visibilities]
|
||||
public_variables = ''.join(public_variables)
|
||||
|
||||
private_variables = [self._get_pattern_var(v, contract) for v in contract.variables if not v.visibility in visibilities]
|
||||
private_variables = ''.join(private_variables)
|
||||
|
||||
# Build the node label
|
||||
ret += '%s[shape="box"'%contract.name
|
||||
ret += 'label=< <TABLE border="0">'
|
||||
ret += '<TR><TD align="center"><B>%s</B></TD></TR>'%contract.name
|
||||
if public_functions:
|
||||
ret += '<TR><TD align="left"><I>Public Functions:</I></TD></TR>'
|
||||
ret += '%s'%public_functions
|
||||
if private_functions:
|
||||
ret += '<TR><TD align="left"><I>Private Functions:</I></TD></TR>'
|
||||
ret += '%s'%private_functions
|
||||
if modifiers:
|
||||
ret += '<TR><TD align="left"><I>Modifiers:</I></TD></TR>'
|
||||
ret += '%s'%modifiers
|
||||
if public_variables:
|
||||
ret += '<TR><TD align="left"><I>Public Variables:</I></TD></TR>'
|
||||
ret += '%s'%public_variables
|
||||
if private_variables:
|
||||
ret += '<TR><TD align="left"><I>Private Variables:</I></TD></TR>'
|
||||
ret += '%s'%private_variables
|
||||
ret += '</TABLE> >];\n'
|
||||
|
||||
return ret
|
||||
|
||||
def output(self, filename):
|
||||
"""
|
||||
Output the graph in filename
|
||||
Args:
|
||||
filename(string)
|
||||
"""
|
||||
if not filename.endswith('.dot'):
|
||||
filename += ".dot"
|
||||
info = 'Inheritance Graph: '+filename
|
||||
self.info(info)
|
||||
with open(filename, 'w') as f:
|
||||
f.write('digraph{\n')
|
||||
for c in self.contracts:
|
||||
f.write(self._summary(c))
|
||||
f.write('}')
|
||||
@@ -0,0 +1,30 @@
|
||||
import sys, inspect
|
||||
import logging
|
||||
|
||||
from slither.printers.abstractPrinter import AbstractPrinter
|
||||
|
||||
# Printer must be imported here
|
||||
from slither.printers.summary.printerSummary import PrinterSummary
|
||||
from slither.printers.summary.printerQuickSummary import PrinterQuickSummary
|
||||
from slither.printers.inheritance.printerInheritance import PrinterInheritance
|
||||
|
||||
logger_printer = logging.getLogger("Printers")
|
||||
|
||||
class Printers(object):
|
||||
|
||||
def __init__(self):
|
||||
self.printers = {}
|
||||
self._load_printers()
|
||||
|
||||
def _load_printers(self):
|
||||
for name, obj in inspect.getmembers(sys.modules[__name__]):
|
||||
if inspect.isclass(obj):
|
||||
if issubclass(obj, AbstractPrinter) and name != 'AbstractPrinter':
|
||||
if name in self.printers:
|
||||
raise Exception('Printer name collision: {}'.format(name))
|
||||
self.printers[name] = obj
|
||||
|
||||
def run_printer(self, slither, name):
|
||||
Printer = self.printers[name]
|
||||
instance = Printer(slither, logger_printer)
|
||||
return instance.output(slither.filename)
|
||||
@@ -0,0 +1,32 @@
|
||||
"""
|
||||
Module printing summary of the contract
|
||||
"""
|
||||
|
||||
from slither.printers.abstractPrinter import AbstractPrinter
|
||||
from slither.utils.colors import blue, green, magenta
|
||||
|
||||
class PrinterQuickSummary(AbstractPrinter):
|
||||
|
||||
ARGUMENT = 'print-quick-summary'
|
||||
HELP = 'Print a quick summary of the contract'
|
||||
|
||||
def output(self, _filename):
|
||||
"""
|
||||
_filename is not used
|
||||
Args:
|
||||
_filename(string)
|
||||
"""
|
||||
|
||||
txt = ""
|
||||
for c in self.contracts:
|
||||
(name, var, func_summaries, modif_summaries) = c.get_summary()
|
||||
txt += blue("\n+ Contract %s\n"%name)
|
||||
for (f_name, visi, modifiers, read, write, calls) in func_summaries:
|
||||
txt += " - "
|
||||
if visi in ['external', 'public']:
|
||||
txt += green("%s (%s)\n"%(f_name, visi))
|
||||
elif visi in ['internal','private']:
|
||||
txt += magenta("%s (%s)\n"%(f_name, visi))
|
||||
else:
|
||||
txt += "%s (%s)\n"%(f_name, visi)
|
||||
self.info(txt)
|
||||
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
Module printing summary of the contract
|
||||
"""
|
||||
|
||||
from prettytable import PrettyTable
|
||||
from slither.printers.abstractPrinter import AbstractPrinter
|
||||
|
||||
class PrinterSummary(AbstractPrinter):
|
||||
|
||||
ARGUMENT = 'print-summary'
|
||||
HELP = 'Print the summary of the contract'
|
||||
|
||||
@staticmethod
|
||||
def _convert(l):
|
||||
if l:
|
||||
n = 2
|
||||
l = [l[i:i + n] for i in xrange(0, len(l), n)]
|
||||
l = [str(x) for x in l]
|
||||
return "\n".join(l)
|
||||
return str(l)
|
||||
|
||||
def output(self, _filename):
|
||||
"""
|
||||
_filename is not used
|
||||
Args:
|
||||
_filename(string)
|
||||
"""
|
||||
|
||||
for c in self.contracts:
|
||||
(name, var, inheritances, func_summaries, modif_summaries) = c.get_summary()
|
||||
txt = "\nContract %s"%name
|
||||
txt += '\nContract vars: '+str(var)
|
||||
txt += '\nInheritances:: '+str(inheritances)
|
||||
table = PrettyTable(["Function", "Visibility", "Modifiers", "Read", "Write", "Calls"])
|
||||
for (f_name, visi, modifiers, read, write, calls) in func_summaries:
|
||||
read = self._convert(read)
|
||||
write = self._convert(write)
|
||||
calls = self._convert(calls)
|
||||
table.add_row([f_name, visi, modifiers, read, write, calls])
|
||||
txt += "\n \n"+str(table)
|
||||
table = PrettyTable(["Modifiers", "Visibility", "Read", "Write", "Calls"])
|
||||
for (f_name, visi, _, read, write, calls) in modif_summaries:
|
||||
read = self._convert(read)
|
||||
write = self._convert(write)
|
||||
calls = self._convert(calls)
|
||||
table.add_row([f_name, visi, read, write, calls])
|
||||
txt += "\n\n"+str(table)
|
||||
txt += "\n"
|
||||
self.info(txt)
|
||||
@@ -0,0 +1,61 @@
|
||||
import sys
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
from solcParsing.slitherSolc import SlitherSolc
|
||||
from utils.colors import red
|
||||
|
||||
logger = logging.getLogger("Slither")
|
||||
|
||||
class Slither(SlitherSolc):
|
||||
|
||||
def __init__(self, filename, solc='solc', disable_solc_warnings=False ,solc_arguments=''):
|
||||
|
||||
is_ast_file = False
|
||||
if filename.endswith('json'):
|
||||
is_ast_file = True
|
||||
elif not filename.endswith('.sol'):
|
||||
raise Exception('Incorrect file format')
|
||||
|
||||
if is_ast_file:
|
||||
with open(filename) as astFile:
|
||||
data = astFile.read()
|
||||
if not data:
|
||||
logger.info('Empty AST file: %s', filename)
|
||||
sys.exit(-1)
|
||||
else:
|
||||
cmd = [solc, filename, '--ast-json']
|
||||
if solc_arguments:
|
||||
# To parse, we first split the string on each '--'
|
||||
solc_args = solc_arguments.split('--')
|
||||
# Split each argument on the first space found
|
||||
# One solc option may have multiple argument sepparated with ' '
|
||||
# For example: --allow-paths /tmp .
|
||||
# split() removes the delimiter, so we add it again
|
||||
solc_args = [('--'+x).split(' ', 1) for x in solc_args if x]
|
||||
# Flat the list of list
|
||||
solc_args = [item for sublist in solc_args for item in sublist]
|
||||
cmd += solc_args
|
||||
# Add . as default allowed path
|
||||
if '--allow-paths' not in cmd:
|
||||
cmd += ['--allow-paths', '.']
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
data, err = process.communicate()
|
||||
|
||||
if err and (not disable_solc_warnings):
|
||||
err = err.split('\n')
|
||||
err = [x if 'Error' not in x else red(x) for x in err]
|
||||
err = '\n'.join(err)
|
||||
logger.info('Compilation warnings/errors on %s:\n%s', filename, err)
|
||||
|
||||
|
||||
data = data.split('\n=')
|
||||
|
||||
super(Slither, self).__init__(filename)
|
||||
for d in data:
|
||||
self.parse_contracts_from_json(d)
|
||||
|
||||
self.analyze_contracts()
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user