Skip to content

Commit

Permalink
Add: check if notus via openvasd is enabled in the openvas config. Th…
Browse files Browse the repository at this point in the history
…en, do not initialize the mqtt client and daemon
  • Loading branch information
jjnicola committed Nov 16, 2023
1 parent fae8d23 commit 2a1a121
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,23 +495,6 @@ def __init__(
self._mqtt_broker_port = mqtt_broker_port

def init(self, server: BaseServer) -> None:
notus_handler = NotusResultHandler(self.report_results)

if self._mqtt_broker_address:
client = MQTTClient(
self._mqtt_broker_address, self._mqtt_broker_port, "ospd"
)
daemon = MQTTDaemon(client)
subscriber = MQTTSubscriber(client)

subscriber.subscribe(ResultMessage, notus_handler.result_handler)
daemon.run()
else:
logger.info(
"MQTT Broker Adress empty. MQTT disabled. Unable to get Notus"
" results."
)

self.scan_collection.init()

server.start(self.handle_client_stream)
Expand All @@ -520,6 +503,27 @@ def init(self, server: BaseServer) -> None:

self.set_params_from_openvas_settings()

# Do not init MQTT daemon if Notus runs via openvasd.
if not self.scan_only_params.get("openvasd_server"):
notus_handler = NotusResultHandler(self.report_results)

if self._mqtt_broker_address:
client = MQTTClient(
self._mqtt_broker_address, self._mqtt_broker_port, "ospd"
)
daemon = MQTTDaemon(client)
subscriber = MQTTSubscriber(client)

subscriber.subscribe(
ResultMessage, notus_handler.result_handler
)
daemon.run()
else:
logger.info(
"MQTT Broker Address empty. MQTT disabled. "
"Unable to get Notus results."
)

with self.feed_lock.wait_for_lock():
self.update_vts()
self.set_feed_info()
Expand Down

0 comments on commit 2a1a121

Please sign in to comment.