Skip to content

Commit

Permalink
Merge branch 'master' into ek/fix-concretize-syscall-args
Browse files Browse the repository at this point in the history
* master:
  Remove Keystone from existing tests (#1684)
  Change URL for WASM spec (#1702)
  Overhaul Linux file emulation (#1673)
  • Loading branch information
ekilmer committed May 11, 2020
2 parents 6e3a7be + b1d93d2 commit ba684db
Show file tree
Hide file tree
Showing 19 changed files with 2,685 additions and 278 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ jobs:
# Install solc unconditionally because it only takes a second or two
sudo wget -O /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.4.24/solc-static-linux
sudo chmod +x /usr/bin/solc
EXTRAS="dev-noks"
if [[ "$TEST_TYPE" == "native" ]]; then
EXTRAS="dev"
fi
pip install -e .[$EXTRAS]
pip install -e ".[dev-noks]"
- name: Run Tests
env:
TEST_TYPE: ${{ matrix.type }}
Expand Down
30 changes: 16 additions & 14 deletions examples/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ CFLAGS=-O3 -static
NOSTDLIBFLAGS=-fno-builtin -static -nostdlib -fomit-frame-pointer -fno-stack-protector
PYTHON=python3

EXAMPLES= \
arguments \
basic \
crackme \
fclose \
fileio \
helloworld \
ibranch \
indexhell \
sendmail \
simpleassert \
simple_copy \
sindex \
strncmp \
EXAMPLES= \
arguments \
basic \
crackme \
fclose \
fileio \
helloworld \
ibranch \
indexhell \
ioctl_bogus \
ioctl_socket \
sendmail \
simpleassert \
simple_copy \
sindex \
strncmp \

OTHER_EXAMPLES=nostdlib

Expand Down
2 changes: 1 addition & 1 deletion examples/linux/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main(int argc, const char **argv) {
return 3;
}

if (strcmp("my voice is my passport verify me", line) == 0) {
if (strcmp("open sesame", line) == 0) {
fprintf(stdout, "Welcome!\n");
return 0;
} else {
Expand Down
20 changes: 20 additions & 0 deletions examples/linux/ioctl_bogus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This example demonstrates a particular syscall that fails at runtime.
// Used primarily as a test of Manticore's file-related syscall implementation.

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stropts.h>
#include <sys/socket.h>

int main() {
// try bogus ioctl on a non-open file descriptor
int rc = ioctl(42, I_FLUSH, FLUSHRW);
if (rc == -1) {
fprintf(stderr, "got expected error: %s\n", strerror(errno));
return 0;
} else {
fprintf(stdout, "unexpectedly succeeded!\n");
return 1;
}
}
26 changes: 26 additions & 0 deletions examples/linux/ioctl_socket.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// This example demonstrates a particular syscall that fails at runtime.
// Used primarily as a test of Manticore's file-related syscall implementation.

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stropts.h>
#include <sys/socket.h>

int main() {
// try bogus ioctl on a socket
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0) {
fprintf(stderr, "error opening socket: %s\n", strerror(errno));
return 1;
}

int rc = ioctl(sockfd, I_FLUSH, FLUSHRW);
if (rc == -1) {
fprintf(stderr, "got expected error calling ioctl: %s\n", strerror(errno));
return 0;
} else {
fprintf(stdout, "unexpectedly succeeded!\n");
return 2;
}
}
4 changes: 2 additions & 2 deletions manticore/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from manticore.native.cli import native_main


def main():
def main() -> None:
"""
Dispatches execution into one of Manticore's engines: evm or native.
"""
Expand All @@ -50,7 +50,7 @@ def main():
native_main(args, logger)


def parse_arguments():
def parse_arguments() -> argparse.Namespace:
def positive(value):
ivalue = int(value)
if ivalue <= 0:
Expand Down
3 changes: 2 additions & 1 deletion manticore/native/manticore.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ..core.manticore import ManticoreBase
from ..core.smtlib import ConstraintSet
from ..core.smtlib.solver import Z3Solver, issymbolic
from ..exceptions import ManticoreError
from ..utils import log, config

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -383,7 +384,7 @@ def _make_linux(
concrete_start="",
pure_symbolic=False,
stdin_size=None,
):
) -> State:
from ..platforms import linux

env = {} if env is None else env
Expand Down
Loading

0 comments on commit ba684db

Please sign in to comment.