Thx for getting back.
There's a caveat though, but not directly related to AR, and that is that if the file name has spaces the yara.sh script doesn't execute. The manager passes along the file name, that's not a problem, but the spaces in the file name are treated as if they were different params passed on to the script.
#!/bin/bash
# Wazuh - YARA active response
# Copyright (C) 2015-2020, Wazuh Inc.
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.
#------------------------- Gather parameters -------------------------#
# Static active response parameters
FILENAME=$8
LOCAL=`dirname $0`
# Extra arguments
# Move to the active response folder
cd $LOCAL
cd ../
# Set LOG_FILE path
PWD=`pwd`
#LOG_FILE="${PWD}/../logs/active-responses.log"
LOG_FILE="/var/ossec/logs/active-responses.log"
#----------------------- Analyze parameters -----------------------#
#if [[ ! $YARA_PATH ]] || [[ ! $YARA_RULES ]]
#then
# echo "wazuh-yara: error: Yara path and rules parameters are mandatory." >> ${LOG_FILE}
# exit
#fi
#------------------------- Main workflow --------------------------#
# Execute YARA scan on the specified filename
yara_output=$(/usr/bin/yara -C -w -r /usr/share/yara/valhalla-rules-compiled.yar $FILENAME)
#yara_output=$(${YARA_PATH}/yara -w -r $YARA_RULES $FILENAME)
if [[ $yara_output != "" ]]
then
# Iterate every detected rule and append it to the LOG_FILE
while read -r line; do
echo "wazuh-yara: info: $line" >> ${LOG_FILE}
done <<< "$yara_output"
fi
exit 1;
Juan.