mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Merge pull request #3498 from Security-Onion-Solutions/fix/so-rule-apply
Fix so-rule apply - manually tested
This commit is contained in:
@@ -37,11 +37,9 @@ def print_err(string: str):
|
||||
|
||||
|
||||
def check_apply(args: dict, prompt: bool = True):
|
||||
cmd_arr = ['salt-call', 'state.apply', 'idstools', 'queue=True']
|
||||
|
||||
if args.apply:
|
||||
print('Configuration updated. Applying idstools state...')
|
||||
return subprocess.run(cmd_arr)
|
||||
print('Configuration updated. Applying changes:')
|
||||
return apply()
|
||||
else:
|
||||
if prompt:
|
||||
message = 'Configuration updated. Would you like to apply your changes now? (y/N) '
|
||||
@@ -51,12 +49,24 @@ def check_apply(args: dict, prompt: bool = True):
|
||||
if answer.lower() in [ 'n', '' ]:
|
||||
return 0
|
||||
else:
|
||||
print('Applying idstools state...')
|
||||
return subprocess.run(cmd_arr)
|
||||
print('Applying changes:')
|
||||
return apply()
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def apply():
|
||||
salt_cmd = ['salt-call', 'state.apply', '-l', 'quiet', 'idstools.sync_files', 'queue=True']
|
||||
update_cmd = ['so-rule-update']
|
||||
print('Syncing config files...')
|
||||
cmd = subprocess.run(salt_cmd, stdout=subprocess.DEVNULL)
|
||||
if cmd.returncode == 0:
|
||||
print('Updating rules...')
|
||||
return subprocess.run(update_cmd).returncode
|
||||
else:
|
||||
return cmd.returncode
|
||||
|
||||
|
||||
def find_minion_pillar() -> str:
|
||||
regex = '^.*_(manager|managersearch|standalone|import|eval)\.sls$'
|
||||
|
||||
@@ -442,9 +452,6 @@ def main():
|
||||
modify.print_help()
|
||||
sys.exit(0)
|
||||
|
||||
if isinstance(exit_code, subprocess.CompletedProcess):
|
||||
sys.exit(exit_code.returncode)
|
||||
else:
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
|
||||
@@ -19,13 +19,12 @@
|
||||
{% set IMAGEREPO = salt['pillar.get']('global:imagerepo') %}
|
||||
{% set MANAGER = salt['grains.get']('master') %}
|
||||
{% set ENGINE = salt['pillar.get']('global:mdengine', '') %}
|
||||
{% set proxy = salt['pillar.get']('manager:proxy') %}
|
||||
|
||||
include:
|
||||
- idstools.sync_files
|
||||
|
||||
# IDSTools Setup
|
||||
idstoolsdir:
|
||||
file.directory:
|
||||
- name: /opt/so/conf/idstools/etc
|
||||
- user: 939
|
||||
- group: 939
|
||||
- makedirs: True
|
||||
|
||||
idstoolslogdir:
|
||||
file.directory:
|
||||
@@ -34,14 +33,6 @@ idstoolslogdir:
|
||||
- group: 939
|
||||
- makedirs: True
|
||||
|
||||
idstoolsetcsync:
|
||||
file.recurse:
|
||||
- name: /opt/so/conf/idstools/etc
|
||||
- source: salt://idstools/etc
|
||||
- user: 939
|
||||
- group: 939
|
||||
- template: jinja
|
||||
|
||||
so-ruleupdatecron:
|
||||
cron.present:
|
||||
- name: /usr/sbin/so-rule-update > /opt/so/log/idstools/download.log 2>&1
|
||||
@@ -49,23 +40,6 @@ so-ruleupdatecron:
|
||||
- minute: '1'
|
||||
- hour: '7'
|
||||
|
||||
rulesdir:
|
||||
file.directory:
|
||||
- name: /opt/so/rules/nids
|
||||
- user: 939
|
||||
- group: 939
|
||||
- makedirs: True
|
||||
|
||||
# Don't show changes because all.rules can be large
|
||||
synclocalnidsrules:
|
||||
file.recurse:
|
||||
- name: /opt/so/rules/nids/
|
||||
- source: salt://idstools/
|
||||
- user: 939
|
||||
- group: 939
|
||||
- show_changes: False
|
||||
- include_pat: 'E@.rules'
|
||||
|
||||
so-idstools:
|
||||
docker_container.running:
|
||||
- image: {{ MANAGER }}:5000/{{ IMAGEREPO }}/so-idstools:{{ VERSION }}
|
||||
|
||||
46
salt/idstools/sync_files.sls
Normal file
46
salt/idstools/sync_files.sls
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright 2014,2015,2016,2017,2018 Security Onion Solutions, LLC
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
idstoolsdir:
|
||||
file.directory:
|
||||
- name: /opt/so/conf/idstools/etc
|
||||
- user: 939
|
||||
- group: 939
|
||||
- makedirs: True
|
||||
|
||||
idstoolsetcsync:
|
||||
file.recurse:
|
||||
- name: /opt/so/conf/idstools/etc
|
||||
- source: salt://idstools/etc
|
||||
- user: 939
|
||||
- group: 939
|
||||
- template: jinja
|
||||
|
||||
rulesdir:
|
||||
file.directory:
|
||||
- name: /opt/so/rules/nids
|
||||
- user: 939
|
||||
- group: 939
|
||||
- makedirs: True
|
||||
|
||||
# Don't show changes because all.rules can be large
|
||||
synclocalnidsrules:
|
||||
file.recurse:
|
||||
- name: /opt/so/rules/nids/
|
||||
- source: salt://idstools/
|
||||
- user: 939
|
||||
- group: 939
|
||||
- show_changes: False
|
||||
- include_pat: 'E@.rules'
|
||||
Reference in New Issue
Block a user