Skip to content

Commit

Permalink
Merge pull request #1283 from guardicore/config-log-formatting
Browse files Browse the repository at this point in the history
Agent: Format config log messages so they are readable
  • Loading branch information
mssalvatore authored Jun 30, 2021
2 parents bfa6bca + f3e7976 commit 8735724
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 4 additions & 3 deletions monkey/infection_monkey/control.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import platform
from pprint import pformat
from socket import gethostname
from urllib.parse import urljoin

Expand Down Expand Up @@ -206,10 +207,10 @@ def load_control_config():

try:
unknown_variables = WormConfiguration.from_kv(reply.json().get("config"))
LOG.info(
"New configuration was loaded from server: %r"
% (WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict()),)
formatted_config = pformat(
WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict())
)
LOG.info(f"New configuration was loaded from server:\n{formatted_config}")
except Exception as exc:
# we don't continue with default conf here because it might be dangerous
LOG.error(
Expand Down
7 changes: 3 additions & 4 deletions monkey/infection_monkey/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import traceback
from multiprocessing import freeze_support
from pprint import pformat

# dummy import for pyinstaller
# noinspection PyUnresolvedReferences
Expand Down Expand Up @@ -76,10 +77,8 @@ def main():
"default" % (config_file,)
)

print(
"Loaded Configuration: %r"
% WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict())
)
formatted_config = pformat(WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict()))
print(f"Loaded Configuration:\n{formatted_config}")

# Make sure we're not in a machine that has the kill file
kill_path = (
Expand Down

0 comments on commit 8735724

Please sign in to comment.