Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacken Manticore #1438

Merged
merged 20 commits into from
May 23, 2019
Merged
4 changes: 4 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ plugins:
enabled: false
E701:
enabled: false
E203:
enabled: false
W503:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loud thinking: afaik we can comment in yaml using # as in Python, so it might be good to add a readable text what we disable.

Let's do it in another PR.

enabled: false
sonar-python:
enabled: false
config:
Expand Down
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python:
- 3.6.6

stages:
- format
- prepare
- test
- submit
Expand Down Expand Up @@ -36,6 +37,10 @@ cache:

jobs:
include:
- stage: format
env: TEST_TYPE=format
script:
- git diff --name-only $TRAVIS_COMMIT_RANGE | python3 scripts/pyfile_exists.py | xargs black -t py36 -l 100 --check
- stage: prepare
env: TEST_TYPE=env
script:
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ more documentation, look [here](https://guides.github.com/activities/forking/).

Some pull request guidelines:

- We use the [`black`](https://black.readthedocs.io/en/stable/index.html) auto-formatter
to enforce style conventions in Manticore. To ensure your code is properly
formatted, run `black -t py36 -l 100 .` in the manticore directory before
ekilmer marked this conversation as resolved.
Show resolved Hide resolved
committing.
- Minimize irrelevant changes (formatting, whitespace, etc) to code that would
otherwise not be touched by this patch. Save formatting or style corrections
for a separate pull request that does not make any semantic changes.
Expand Down
51 changes: 25 additions & 26 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc']
extensions = ["sphinx.ext.autodoc"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'Manticore'
copyright = u'2017, Trail of Bits'
author = u'Trail of Bits'
project = "Manticore"
copyright = "2019, Trail of Bits"
author = "Trail of Bits"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0.1.0'
version = "0.2.5"
# The full version, including alpha/beta/rc tags.
release = u'0.1.0'
release = "0.2.5"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -68,10 +68,10 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -82,7 +82,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -93,13 +93,13 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Manticoredoc'
htmlhelp_basename = "Manticoredoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -108,15 +108,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -126,19 +123,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Manticore.tex', u'Manticore Documentation',
u'Trail of Bits', 'manual'),
(master_doc, "Manticore.tex", "Manticore Documentation", "Trail of Bits", "manual")
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'manticore', u'Manticore Documentation',
[author], 1)
]
man_pages = [(master_doc, "manticore", "Manticore Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -147,9 +140,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Manticore', u'Manticore Documentation',
author, 'Manticore', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"Manticore",
"Manticore Documentation",
author,
"Manticore",
"One line description of project.",
"Miscellaneous",
)
]


Expand Down
66 changes: 33 additions & 33 deletions examples/evm/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,53 @@
import pyevmasm as ea
from binascii import hexlify


def printi(instruction):
print(f'Instruction: {instruction}')
print('\tdescription:', instruction.description)
print('\tgroup:', instruction.group)
print('\taddress:', instruction.pc)
print('\tsize:', instruction.size)
print('\thas_operand:', instruction.has_operand)
print('\toperand_size:', instruction.operand_size)
print('\toperand:', instruction.operand)
print('\tsemantics:', instruction.semantics)
print('\tpops:', instruction.pops)
print('\tpushes:', instruction.pushes)
print(f'\tbytes: 0x'+hexlify(instruction.bytes).decode())
print('\twrites to stack:', instruction.writes_to_stack)
print('\treads from stack:', instruction.reads_from_stack)
print('\twrites to memory:', instruction.writes_to_memory)
print('\treads from memory:', instruction.reads_from_memory)
print('\twrites to storage:', instruction.writes_to_storage)
print('\treads from storage:', instruction.reads_from_storage)
print('\tis terminator', instruction.is_terminator)


instruction = ea.disassemble_one('\x60\x10')
print(f"Instruction: {instruction}")
print("\tdescription:", instruction.description)
print("\tgroup:", instruction.group)
print("\taddress:", instruction.pc)
print("\tsize:", instruction.size)
print("\thas_operand:", instruction.has_operand)
print("\toperand_size:", instruction.operand_size)
print("\toperand:", instruction.operand)
print("\tsemantics:", instruction.semantics)
print("\tpops:", instruction.pops)
print("\tpushes:", instruction.pushes)
print(f"\tbytes: 0x" + hexlify(instruction.bytes).decode())
print("\twrites to stack:", instruction.writes_to_stack)
print("\treads from stack:", instruction.reads_from_stack)
print("\twrites to memory:", instruction.writes_to_memory)
print("\treads from memory:", instruction.reads_from_memory)
print("\twrites to storage:", instruction.writes_to_storage)
print("\treads from storage:", instruction.reads_from_storage)
print("\tis terminator", instruction.is_terminator)


instruction = ea.disassemble_one("\x60\x10")
printi(instruction)

instruction = ea.assemble_one('PUSH1 0x10')
instruction = ea.assemble_one("PUSH1 0x10")
printi(instruction)

for instruction in ea.disassemble_all('\x30\x31'):
for instruction in ea.disassemble_all("\x30\x31"):
printi(instruction)

for instruction in ea.assemble_all('ADDRESS\nBALANCE'):
for instruction in ea.assemble_all("ADDRESS\nBALANCE"):
printi(instruction)


#High level simple assembler/disassembler
print(ea.assemble_hex(
"""PUSH1 0x60
# High level simple assembler/disassembler
print(
ea.assemble_hex(
"""PUSH1 0x60
BLOCKHASH
MSTORE
PUSH1 0x2
PUSH2 0x100
"""
))


print(ea.disassemble_hex('0x606040526002610100'))

)
)


print(ea.disassemble_hex("0x606040526002610100"))
Loading