Skip to content

Commit

Permalink
Windows compatibility for AppLogger & CWEDownloads (#301)
Browse files Browse the repository at this point in the history
* Conditionally import FullSysLogHandler

Import FullSysLogHandler
from CveXplore.core.logging.handlers.syslog_handler
only if configured (for Windows compatibility).

* CWEDownloads Windows compatibility fix
  • Loading branch information
oh2fih authored Aug 9, 2024
1 parent 30c8912 commit 4fc6920
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
28 changes: 13 additions & 15 deletions CveXplore/core/database_maintenance/sources_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,22 +997,20 @@ def __init__(self):
def file_to_queue(self, file_tuple: Tuple[str, str]):
working_dir, filename = file_tuple

for f in glob.glob(f"{working_dir}/*.xml"):
filename = f

self.parser.parse(f"file://{filename}")
x = 0
for cwe in self.ch.cwe:
try:
cwe["related_weaknesses"] = list(set(cwe["related_weaknesses"]))
cwe["description"] = cwe["Description"]
cwe.pop("Description")
except KeyError:
pass
self.process_item(cwe)
x += 1
for filename in glob.glob(f"{working_dir}/*.xml"):
self.parser.parse(filename)
x = 0
for cwe in self.ch.cwe:
try:
cwe["related_weaknesses"] = list(set(cwe["related_weaknesses"]))
cwe["description"] = cwe["Description"]
cwe.pop("Description")
except KeyError:
pass
self.process_item(cwe)
x += 1

self.logger.debug(f"Processed {x} entries from file: {filename}")
self.logger.debug(f"Processed {x} entries from file: {filename}")

try:
self.logger.debug(f"Removing working dir: {working_dir}")
Expand Down
6 changes: 5 additions & 1 deletion CveXplore/core/logging/logger_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from CveXplore.common.config import Configuration
from CveXplore.core.logging.formatters.task_formatter import TaskFormatter
from CveXplore.core.logging.handlers.gelf_handler import GelfUDPHandler
from CveXplore.core.logging.handlers.syslog_handler import FullSysLogHandler

CRITICAL = 50
FATAL = CRITICAL
Expand Down Expand Up @@ -77,6 +76,11 @@ def __init__(self, name, level=logging.NOTSET):
),
)
else:
# Import syslog_handler only if configured (for Windows compatibility)
from CveXplore.core.logging.handlers.syslog_handler import (
FullSysLogHandler,
)

syslog = FullSysLogHandler(
address=(syslog_server, syslog_port),
facility=FullSysLogHandler.LOG_LOCAL0,
Expand Down

0 comments on commit 4fc6920

Please sign in to comment.