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

[WIP] Frontends synchronization, resuming and statistics #326

Merged
merged 47 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f45009e
uniform input seeds and output directory handling
GrosQuildu Feb 12, 2020
2f8822a
implement session resuming in afl/hfuzz/libfuzz and base for syncing
GrosQuildu Feb 12, 2020
dc1c8f1
fix angora compilation
GrosQuildu Feb 12, 2020
d6ba18a
fix eclipser compilator
GrosQuildu Feb 12, 2020
c056289
implement session resuming and base for syncing
GrosQuildu Feb 12, 2020
29bcbf2
rename compiler (like "dotnet") to runner
GrosQuildu Feb 12, 2020
e30bcf9
compile output extension from NAME
GrosQuildu Feb 12, 2020
bb5cb94
better statistic init
GrosQuildu Feb 12, 2020
824bdff
better run method
GrosQuildu Feb 13, 2020
20a06aa
better run method - working
GrosQuildu Feb 13, 2020
3b4941c
fix symex min_log_level
GrosQuildu Feb 14, 2020
fe299ae
fix symex output dir handling
GrosQuildu Feb 14, 2020
c851244
fix symex tests (logrun)
GrosQuildu Feb 14, 2020
263c8e7
symex testcases not save warning
GrosQuildu Feb 14, 2020
bd44ff6
add fuzzers tests
GrosQuildu Feb 14, 2020
afaa7d8
fuzzer test, fixes, stats
GrosQuildu Feb 14, 2020
fa5ac1e
fuzzer test CI
GrosQuildu Feb 14, 2020
0cc3d88
fuzzer test CI - fix1
GrosQuildu Feb 14, 2020
a87d9f7
pyflakes errors fix
GrosQuildu Feb 14, 2020
d1b70f9
fuzzer test CI - fix2
GrosQuildu Feb 14, 2020
a57b40f
fuzzer test CI - fix3
GrosQuildu Feb 14, 2020
2c1a268
fuzzer test CI - fix4
GrosQuildu Feb 14, 2020
2c52b9a
fuzzer test CI - fix5
GrosQuildu Feb 14, 2020
6000399
ensembling/syncing fuzzers init
GrosQuildu Feb 14, 2020
b16241d
pyflakes errors fix
GrosQuildu Feb 14, 2020
0d4ac4b
revert to old docker CI
GrosQuildu Feb 15, 2020
601fdb1
mv num_workers to symex only
GrosQuildu Feb 15, 2020
4bd377b
fix fuzzer syncing
GrosQuildu Feb 15, 2020
f7a4881
fix fuzzer syncing
GrosQuildu Feb 15, 2020
efb1298
update readme
GrosQuildu Feb 15, 2020
b6e1942
Merge branch 'frontend_sync_resume' of github.com:trailofbits/deepsta…
GrosQuildu Feb 15, 2020
5560155
rebuild w/o cache
GrosQuildu Feb 17, 2020
6661dc4
split documentation
GrosQuildu Feb 17, 2020
e8940a4
revert CI
GrosQuildu Feb 17, 2020
286e4da
fix for symex str formatting
GrosQuildu Feb 17, 2020
e8d271e
fix for CI fuzz test
GrosQuildu Feb 17, 2020
fab1757
fixes in docker build
GrosQuildu Feb 18, 2020
5d5f83a
fixes in docs
GrosQuildu Feb 18, 2020
b970059
fix afl on MacOS
GrosQuildu Feb 18, 2020
e3b7690
clear registry cache
GrosQuildu Feb 18, 2020
3bf101d
clear registry cache2
GrosQuildu Feb 18, 2020
0c14227
fix docker angora
GrosQuildu Feb 18, 2020
18a134c
fix CI fuzz tests
GrosQuildu Feb 18, 2020
40879e1
fix CI fuzz tests2
GrosQuildu Feb 18, 2020
7e193e9
fix CI fuzz tests3
GrosQuildu Feb 18, 2020
6e656ce
fix CI fuzz tests4
GrosQuildu Feb 19, 2020
eb7c9e6
fix CI fuzz tests5
GrosQuildu Feb 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,10 @@ jobs:
image_tag: latest
context: .
dockerfile: docker/Dockerfile
# pull_image_and_stages: false # if OOM error
push_image_and_stages: true # because we run workflow on PRs
build_extra_args: "--cache-from=deepstate-base"
build_extra_args: "--cache-from=deepstate-base --build-arg=make_j=2"
- name: Test fuzzers
run: |
echo core | sudo tee /proc/sys/kernel/core_pattern
docker run docker.pkg.github.com/trailofbits/deepstate/deepstate sh -c 'sudo pip3 install nose && nosetests tests/test_fuzzers.py'
511 changes: 24 additions & 487 deletions README.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion bin/deepstate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ def __init__(self, name: str) -> None:
logging.Logger.__init__(self, name=name)
self.trace = functools.partial(self.log, 15) # type: ignore
self.external = functools.partial(self.log, 45) # type: ignore
self.fuzz_stats = functools.partial(self.log, 46) # type: ignore


logging.basicConfig()
logging.addLevelName(15, "TRACE")
logging.addLevelName(45, "EXTERNAL")
logging.addLevelName(46, "FUZZ_STATS")
logging.setLoggerClass(DeepStateLogger)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -48,7 +50,9 @@ def __init__(self, name: str) -> None:

log_level_from_env: str = os.environ.get("DEEPSTATE_LOG", "2")
try:
logger.setLevel(LOG_LEVEL_INT_TO_STR[int(log_level_from_env)])
log_level_from_env_int: int = int(log_level_from_env)
logger.setLevel(LOG_LEVEL_INT_TO_STR[log_level_from_env_int])
logger.info("Setting log level from DEEPSTATE_LOG: %d", log_level_from_env_int)
except ValueError:
print("$DEEPSTATE_LOG contains invalid value `%s`, "
"should be int in 0-6 (debug, trace, info, warning, error, external, critical).",
Expand Down
22 changes: 10 additions & 12 deletions bin/deepstate/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ def __init__(self):
AnalysisBackend.compiler_exe = self.EXECUTABLES.pop("COMPILER", None)

# parsed argument attributes
self.binary: str = None
self.output_test_dir: str = f"{self}_out"
self.binary: Optional[str] = None
self.output_test_dir: str
self.timeout: int = 0
self.num_workers: int = 1
self.mem_limit: int = 50
self.min_log_level: int = 2

Expand Down Expand Up @@ -124,7 +123,8 @@ def parse_args(cls) -> Optional[argparse.Namespace]:
help="Linker flags (space seperated) to include for external libraries.")

compile_group.add_argument("--out_test_name", type=str,
help="Set name of generated instrumented binary.")
help=("Set name of generated instrumented binary. Default is `out`. "
"Automatically adds `.frontend_name_lowercase` suffix."))

compile_group.add_argument("--no_exit_compile", action="store_true",
help="Continue execution after compiling a harness (set as default if `--config` is set).")
Expand All @@ -135,8 +135,8 @@ def parse_args(cls) -> Optional[argparse.Namespace]:

# Analysis-related configurations
parser.add_argument(
"-o", "--output_test_dir", type=str, default="out",
help="Output directory where tests will be saved (default is `out`).")
"-o", "--output_test_dir", type=str,
help="Output directory where tests will be saved. Required. If not empty, will try to resume.")

parser.add_argument(
"-c", "--config", type=str,
Expand All @@ -146,10 +146,6 @@ def parse_args(cls) -> Optional[argparse.Namespace]:
"-t", "--timeout", default=0, type=int,
help="Time to kill analysis worker processes, in seconds (default is 0 for none).")

parser.add_argument(
"-w", "--num_workers", default=1, type=int,
help="Number of worker jobs to spawn for analysis (default is 1).")

parser.add_argument("--mem_limit", type=int, default=50,
help="Child process memory limit in MiB (default is 50). 0 for unlimited.")

Expand Down Expand Up @@ -183,6 +179,7 @@ def parse_args(cls) -> Optional[argparse.Namespace]:
target_args_parsed.append((key, val))
_args['target_args'] = target_args_parsed


# if configuration is specified, parse and replace argument instantiations
if args.config:
_args.update(cls.build_from_config(args.config)) # type: ignore
Expand All @@ -193,15 +190,16 @@ def parse_args(cls) -> Optional[argparse.Namespace]:
del _args["config"]

# log level fixing
if os.environ.get("DEEPSTATE_LOG", None) is None:
if not os.environ.get("DEEPSTATE_LOG"):
if _args["min_log_level"] < 0 or _args["min_log_level"] > 6:
raise AnalysisBackendError(f"`--min_log_level` is in invalid range, should be in 0-6 "
"(debug, trace, info, warning, error, external, critical).")

L.info("Setting log level from --min_log_level: %d", _args["min_log_level"])
logger = logging.getLogger("deepstate")
logger.setLevel(LOG_LEVEL_INT_TO_STR[_args["min_log_level"]])
else:
L.info("Using log level from $DEEPSTATE_LOG.")
L.debug("Using log level from $DEEPSTATE_LOG.")

cls._ARGS = args
return cls._ARGS
Expand Down
Loading