Fix #6317 - Do not attempt to whitelist when wazuh isn't enabled

This commit is contained in:
Jason Ertel
2021-11-23 10:06:14 -05:00
parent 3bfc3b8943
commit 4672b0c15c

View File

@@ -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)