Skip to content
Open
Changes from 2 commits
Commits
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
5 changes: 5 additions & 0 deletions nxc/connection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
import os
import re
import random
import sys
import contextlib
Expand Down Expand Up @@ -245,6 +246,10 @@ def proto_flow(self):
else:
self.logger.debug("Created connection object")
self.enum_host_info()
sanitized = re.sub(r'[^\w\-.]', '_', self.hostname)
if sanitized != self.hostname:
self.logger.warning(f"Hostname contains invalid characters (received: {self.hostname!r}), sanitized to: {sanitized!r}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warnings are not displayed by default if not run at verbose or debug level. Please use .display()

self.hostname = sanitized

# Construct the output file template using os.path.join for OS compatibility
base_log_dir = os.path.join(NXC_PATH, "logs")
Expand Down