diff --git a/modules/auxiliary/AzSniffer.py b/modules/auxiliary/AzSniffer.py index fc2e96b9e8a..9f14eafebd1 100644 --- a/modules/auxiliary/AzSniffer.py +++ b/modules/auxiliary/AzSniffer.py @@ -3,21 +3,26 @@ import subprocess from urllib.parse import urlparse -try: - from azure.core.exceptions import AzureError - from azure.identity import ClientSecretCredential - from azure.mgmt.network import NetworkManagementClient - from azure.mgmt.network.models import PacketCapture, PacketCaptureStorageLocation - from azure.mgmt.storage import StorageManagementClient - from azure.storage.blob import BlobServiceClient - - HAVE_AZURE = True -except ImportError: - HAVE_AZURE = False - print("Missing machinery-required libraries.") - print( - "poetry run python -m pip install azure-identity msrest msrestazure azure-mgmt-compute azure-mgmt-network azure-mgmt-storage azure-storage-blob" - ) +from lib.cuckoo.common.config import Config + +HAVE_AZURE = False +cfg = Config() +if cfg.cuckoo.machinery == "az": + try: + from azure.core.exceptions import AzureError + from azure.identity import ClientSecretCredential + from azure.mgmt.network import NetworkManagementClient + from azure.mgmt.network.models import PacketCapture, PacketCaptureStorageLocation + from azure.mgmt.storage import StorageManagementClient + from azure.storage.blob import BlobServiceClient + + HAVE_AZURE = True + except ImportError: + HAVE_AZURE = False + print("Missing machinery-required libraries.") + print( + "poetry run python -m pip install azure-identity msrest msrestazure azure-mgmt-compute azure-mgmt-network azure-mgmt-storage azure-storage-blob" + ) from lib.cuckoo.common.abstracts import Auxiliary from lib.cuckoo.common.config import Config diff --git a/modules/machinery/aws.py b/modules/machinery/aws.py index 27304d6fca9..2bb3fe12cfc 100644 --- a/modules/machinery/aws.py +++ b/modules/machinery/aws.py @@ -6,6 +6,7 @@ from lib.cuckoo.core.database import Machine cfg = Config() +HAVE_BOTO3 = False if cfg.cuckoo.machinery == "aws": try: import boto3 @@ -13,7 +14,7 @@ HAVE_BOTO3 = True except ImportError: sys.exit("Missed boto3 dependency: poetry run pip install boto3") - HAVE_BOTO3 = False + from lib.cuckoo.common.abstracts import Machinery from lib.cuckoo.common.config import Config diff --git a/modules/machinery/az.py b/modules/machinery/az.py index 1584746d3fa..fba0172b769 100644 --- a/modules/machinery/az.py +++ b/modules/machinery/az.py @@ -11,6 +11,7 @@ from lib.cuckoo.common.config import Config +HAVE_AZURE = False cfg = Config() if cfg.cuckoo.machinery == "az": try: @@ -23,7 +24,7 @@ HAVE_AZURE = True except ImportError: - HAVE_AZURE = False + print("Missing machinery-required libraries.") print("poetry run pip install azure-identity msrest msrestazure azure-mgmt-compute azure-mgmt-network")