Skip to content

Commit

Permalink
Merge pull request #5 from quarkslab/refactor-logging
Browse files Browse the repository at this point in the history
update tritondse engine to comply with new logging mechanism
  • Loading branch information
cnheitman committed Jul 6, 2023
2 parents 21f5e0b + a74a14b commit 1fd69f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 3 additions & 5 deletions engines/pastis-triton/bin/pastis-triton
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ from libpastis.types import ExecMode, CoverageMode, SeedInjectLoc, CheckMode, Fu
from pastisdse import PastisDSE, __version__
from tritondse import CoverageStrategy, ProbeInterface, Config, SmtSolver
from tritondse.probes.basic_trace import BasicDebugTrace
import tritondse.logging

pastis = None


def configure_logs(level: int):
tritondse.logging.enable(level) # Enable tritondse to print logging information
coloredlogs.install(level=level,
fmt="%(asctime)s %(threadName)s [%(levelname)s] %(message)s",
level_styles={'debug': {'color': 'blue'}, 'info': {'color': 'white'}, 'warning': {'color': 'yellow'},
Expand Down Expand Up @@ -170,11 +172,7 @@ def offline(program: str,
else:
config = Config()

if debug:
configure_logs(logging.DEBUG)
config.debug = True
else:
configure_logs(logging.INFO)
configure_logs(logging.DEBUG if debug else logging.INFO)

if trace:
pastis.add_probe(BasicDebugTrace())
Expand Down
5 changes: 2 additions & 3 deletions engines/pastis-triton/pastisdse/pastisdse.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, agent: ClientAgent):
self.agent = agent
self._init_callbacks() # register callbacks on the given agent

self.config = Config(debug=False)
self.config = Config()
self.config.workspace = "" # Reset workspace so that it will computed in start_received
self.dse = None
self.program = None
Expand Down Expand Up @@ -100,7 +100,7 @@ def start(self):
def reset(self):
""" Reset the current DSE to be able to restart from fresh settings """
self.dse = None # remove DSE object
self.config = Config(debug=False)
self.config = Config()
self.config.workspace = "" # Reset workspace so that it will computed in start_received
self._last_id_pc = None
self._last_id = None
Expand Down Expand Up @@ -312,7 +312,6 @@ def start_received(self, fname: str, binary: bytes, engine: FuzzingEngineInfo, e
# ------- Create the TritonDSE configuration file ---------
if engine_args:
self.config = Config.from_json(engine_args)
logging.root.level = logging.DEBUG if self.config.debug else logging.INFO # dynamically change level
else:
self.config = Config() # Empty configuration

Expand Down

0 comments on commit 1fd69f2

Please sign in to comment.