-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathnode.py
executable file
·60 lines (43 loc) · 1.75 KB
/
node.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
import logging
import os
import subprocess
import sys
import config
logging.info('Starting logger for...')
l = logging.getLogger("mining.node")
l.setLevel("DEBUG")
def check_exec(d, p):
path = os.path.join(d, p)
return not os.path.isdir(path) and os.access(path, os.X_OK)
def binary_dir_sane():
if not os.path.isdir(config.BINARY_DIR):
l.error("the binary directory specified in the config is not a directory")
return False
if not any(filter(lambda x: check_exec(config.BINARY_DIR, x), os.listdir(config.BINARY_DIR))):
l.error("no binary files detected in binary directory specified")
return False
return True
def concolic_node(n, outfile, errfile):
if not binary_dir_sane():
return 1
l.info("spinning up a concolic node with %d workers", n)
args = ["celery", "-A", "tasks", "worker", "-c", str(n), "-Q", "concolic", "--loglevel=info", "-n", "concolic.%h"]
with open(outfile, "w") as o:
with open(errfile, "w") as e:
subprocess.Popen(args, stdout=o, stderr=e)
def fuzzer_node(n, outfile, errfile):
if not binary_dir_sane():
return 1
l.info("spinning up a fuzzer node with %d workers", n)
args = ["celery", "-A", "tasks", "worker", "-c", str(n), "-Q", "fuzzer", "--loglevel=info", "-Ofair", "-n", "fuzzer.%h"]
with open(outfile, "w") as o:
with open(errfile, "w") as e:
subprocess.Popen(args, stdout=o, stderr=e)
def main():
if config.concolic_WORKERS:
concolic_node(config.concolic_WORKERS, "log/concolic-out.log", "log/concolic-err.log")
if config.FUZZER_WORKERS:
fuzzer_node(config.FUZZER_WORKERS, "log/fuzzer-out.log", "log/fuzzer-err.log")
if __name__ == "__main__":
sys.exit(main())