diff --git a/DataConnectors/Syslog/Sentinel_AMA_troubleshoot.py b/DataConnectors/Syslog/Sentinel_AMA_troubleshoot.py index 80e77ae25ce..122c8a33554 100644 --- a/DataConnectors/Syslog/Sentinel_AMA_troubleshoot.py +++ b/DataConnectors/Syslog/Sentinel_AMA_troubleshoot.py @@ -1,4 +1,4 @@ -#! /usr/local/bin/python3 +#!/usr/bin/env python3 # ---------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # ---------------------------------------------------------------------------- @@ -15,9 +15,13 @@ import re import argparse import sys -from distutils.version import StrictVersion -SCRIPT_VERSION = 2.51 + +def _parse_version(v): + parts = tuple(int(x) for x in v.split('.')) + return parts + (0,) * (3 - len(parts)) + +SCRIPT_VERSION = 2.52 PY3 = sys.version_info.major == 3 # GENERAL SCRIPT CONSTANTS @@ -298,7 +302,7 @@ def is_agent_version_updated(): This function tess whether the agent on the machine is running with this updated agent version. """ global IS_AGENT_VERSION_UPDATED - IS_AGENT_VERSION_UPDATED = StrictVersion(UPDATED_AGENT_VERSION) <= StrictVersion(AGENT_VERSION) + IS_AGENT_VERSION_UPDATED = _parse_version(UPDATED_AGENT_VERSION) <= _parse_version(AGENT_VERSION) @staticmethod def print_arc_version(): @@ -588,7 +592,7 @@ def verify_selinux_state(self): command_to_run = "sudo getenforce 2> /dev/null; if [ $? != 0 ]; then echo 'Disabled'; fi" result_keywords_array = ["Enforcing"] command_object = CommandVerification(command_name, command_to_run, result_keywords_array) - if StrictVersion(AGENT_VERSION) < StrictVersion(AGENT_MIN_HARDENING_VERSION): + if _parse_version(AGENT_VERSION) < _parse_version(AGENT_MIN_HARDENING_VERSION): command_object.run_full_test(True) if not command_object.is_successful: print_error(self.SELINUX_RUNNING_ERROR_MESSAGE) diff --git a/Solutions/ESET Inspect/Data Connectors/InspectGetDetections/__init__.py b/Solutions/ESET Inspect/Data Connectors/InspectGetDetections/__init__.py index ba3b8376575..03bc97595d4 100644 --- a/Solutions/ESET Inspect/Data Connectors/InspectGetDetections/__init__.py +++ b/Solutions/ESET Inspect/Data Connectors/InspectGetDetections/__init__.py @@ -19,12 +19,20 @@ import logging import os import re -from distutils.util import strtobool import azure.functions as func from datacollector import post_data from esetinspect import Inspect + +def _strtobool(val): + val = val.lower() + if val in ('y', 'yes', 't', 'true', 'on', '1'): + return True + if val in ('n', 'no', 'f', 'false', 'off', '0'): + return False + raise ValueError(f"invalid truth value {val!r}") + # Hack to keep the EI object cached (preventing multiple logins). # See: https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-functions/functions-reference-python.md#global-variables ei = None @@ -47,8 +55,8 @@ def main( base_url = os.environ["baseUrl"] username = os.environ["eiUsername"] password = os.environ["eiPassword"] - domain = bool(strtobool(os.environ["domainLogin"])) - verify = bool(strtobool(os.environ["verifySsl"])) + domain = bool(_strtobool(os.environ["domainLogin"])) + verify = bool(_strtobool(os.environ["verifySsl"])) start_from_id = int(os.environ["startFromID"]) workspace_id = os.environ["workspaceId"] workspace_key = os.environ["workspaceKey"]