yara download and update

This commit is contained in:
m0duspwnens
2023-07-10 09:42:37 -04:00
parent 6a5ff04804
commit f4dc73a206
5 changed files with 35 additions and 12 deletions

View File

@@ -93,25 +93,45 @@ strelkarepos:
- makedirs: True
{% endif %}
yara_update_script:
file.managed:
- name: /usr/sbin/so-yara-update
- source: salt://manager/tools/sbin_jinja/so-yara-update
- user: root
- group: root
yara_update_scripts:
file.recurse:
- name: /usr/sbin/
- source: salt://manager/tools/sbin_jinja/
- user: socore
- group: socore
- mode: 755
- template: jinja
- defaults:
ISAIRGAP: {{ GLOBALS.airgap }}
EXCLUDEDRULES: {{ STRELKAMERGED.rules.excluded }}
{% if GLOBALS.airgap %}
remove_strelka-yara-download:
cron.absent:
- user: socore
- identifier: strelka-yara-download
strelka-yara-update:
cron.present:
- user: root
- user: socore
- name: '/usr/sbin/so-yara-update >> /nsm/strelka/log/yara-update.log 2>&1'
- identifier: strelka-yara-update
- hour: '7'
- minute: '1'
{% else %}
remove_strelka-yara-update:
cron.absent:
- user: socore
- identifier: strelka-yara-update
strelka-yara-download:
cron.present:
- user: socore
- name: '/usr/sbin/so-yara-download >> /nsm/strelka/log/yara-download.log 2>&1'
- identifier: strelka-yara-download
- hour: '7'
- minute: '1'
{% endif %}
{% else %}

View File

@@ -39,7 +39,8 @@ if [ "$gh_status" == "200" ] || [ "$gh_status" == "301" ]; then
done < $repos
echo "Done!"
/usr/sbin/so-yara-update
else
echo "Server returned $gh_status status code."

View File

@@ -4,6 +4,8 @@
# https://securityonion.net/license; you may not use this file except in compliance with the
# Elastic License 2.0.
NOROOT=1
. /usr/sbin/so-common
echo "Starting to check for yara rule updates at $(date)..."
@@ -19,7 +21,7 @@ OUTPUTDIR=/opt/so/saltstack/local/salt/strelka/rules
mkdir -p $OUTPUTDIR
for i in $(find $SORUKLEDIR -name "*.yar*"); do
for i in $(find $SORULEDIR -name "*.yar*"); do
rule_name=$(echo $i | awk -F '/' '{print $NF}')
if [[ ! "${excluded_rules}" =~ ${rule_name} ]]; then
echo "Adding rule: $rule_name..."

View File

@@ -579,7 +579,7 @@ strelka:
helpLink: strelka.html
advanced: False
repos:
description: List of repos for so-yara-update to use to download rules.
description: List of repos for so-yara-download to use to download rules.
readonly: False
global: False
helpLink: strelka.html

View File

@@ -666,7 +666,7 @@ if ! [[ -f $install_opt_file ]]; then
title "Restarting Suricata to pick up the new rules"
logCmd "so-suricata-restart"
title "Downloading YARA rules"
logCmd "runuser -l socore 'so-yara-update'"
logCmd "runuser -l socore 'so-yara-download'"
title "Restarting Strelka to use new rules"
logCmd "so-strelka-restart"
fi