From 4672b0c15c1d077c7cb85eef6b47db525489e03c Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Tue, 23 Nov 2021 10:06:14 -0500 Subject: [PATCH] Fix #6317 - Do not attempt to whitelist when wazuh isn't enabled --- salt/common/tools/sbin/so-allow | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/salt/common/tools/sbin/so-allow b/salt/common/tools/sbin/so-allow index 769dcc1e9..6a66876e7 100755 --- a/salt/common/tools/sbin/so-allow +++ b/salt/common/tools/sbin/so-allow @@ -79,10 +79,10 @@ def ip_prompt() -> str: def wazuh_enabled() -> bool: - for file in os.listdir(f'{LOCAL_SALT_DIR}/pillar'): - with open(file, 'r') as pillar: - if 'wazuh: 1' in pillar.read(): - return True + file = f'{LOCAL_SALT_DIR}/pillar/global.sls' + with open(file, 'r') as pillar: + if 'wazuh: 1' in pillar.read(): + return True return False @@ -124,7 +124,7 @@ def apply(role: str, ip: str) -> int: else: return cmd.returncode if cmd.returncode == 0: - if wazuh_enabled and role=='analyst': + if wazuh_enabled() and role=='analyst': try: add_wl(ip) print(f'Added whitelist entry for {ip} from {WAZUH_CONF}', file=sys.stderr)