mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-08 02:02:50 +01:00
[fix] Only prompt if entry doesn't exist, deep compare arrays
This commit is contained in:
@@ -36,19 +36,22 @@ def print_err(string: str):
|
|||||||
print(string, file=sys.stderr)
|
print(string, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def check_apply(args: dict):
|
def check_apply(args: dict, prompt: bool = True):
|
||||||
cmd_arr = ['salt-call', 'state.apply', 'idstools', 'queue=True']
|
cmd_arr = ['salt-call', 'state.apply', 'idstools', 'queue=True']
|
||||||
|
|
||||||
if args.apply:
|
if args.apply:
|
||||||
print('Applying idstools state...')
|
print('Applying idstools state...')
|
||||||
return subprocess.run(cmd_arr)
|
return subprocess.run(cmd_arr)
|
||||||
else:
|
else:
|
||||||
message = 'Would you like to apply your changes now? (y/N) '
|
if prompt:
|
||||||
answer = input(message)
|
message = 'Would you like to apply your changes now? (y/N) '
|
||||||
while answer.lower() not in [ 'y', 'n', '' ]:
|
|
||||||
answer = input(message)
|
answer = input(message)
|
||||||
if answer.lower() in [ 'n', '' ]:
|
while answer.lower() not in [ 'y', 'n', '' ]:
|
||||||
return subprocess.run(cmd_arr)
|
answer = input(message)
|
||||||
|
if answer.lower() in [ 'n', '' ]:
|
||||||
|
return subprocess.run(cmd_arr)
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@@ -181,7 +184,7 @@ def add_rem_disabled(args: dict):
|
|||||||
temp_pillar_dict = add_to_sids(pillar_dict, 'disabled', args.sid_pattern)
|
temp_pillar_dict = add_to_sids(pillar_dict, 'disabled', args.sid_pattern)
|
||||||
|
|
||||||
if temp_pillar_dict['idstools']['sids']['disabled'] == pillar_dict['idstools']['sids']['disabled']:
|
if temp_pillar_dict['idstools']['sids']['disabled'] == pillar_dict['idstools']['sids']['disabled']:
|
||||||
salt_proc = check_apply(args)
|
salt_proc = check_apply(args, prompt=False)
|
||||||
return salt_proc
|
return salt_proc
|
||||||
else:
|
else:
|
||||||
pillar_dict = temp_pillar_dict
|
pillar_dict = temp_pillar_dict
|
||||||
@@ -245,8 +248,8 @@ def add_rem_enabled(args: dict):
|
|||||||
else:
|
else:
|
||||||
temp_pillar_dict = add_to_sids(pillar_dict, 'enabled', args.sid_pattern)
|
temp_pillar_dict = add_to_sids(pillar_dict, 'enabled', args.sid_pattern)
|
||||||
|
|
||||||
if temp_pillar_dict == pillar_dict:
|
if temp_pillar_dict['idstools']['sids']['enabled'] == pillar_dict['idstools']['sids']['enabled']:
|
||||||
salt_proc = check_apply(args)
|
salt_proc = check_apply(args, prompt=False)
|
||||||
return salt_proc
|
return salt_proc
|
||||||
else:
|
else:
|
||||||
pillar_dict = temp_pillar_dict
|
pillar_dict = temp_pillar_dict
|
||||||
@@ -296,8 +299,8 @@ def add_rem_modify(args: dict):
|
|||||||
else:
|
else:
|
||||||
temp_pillar_dict = add_to_sids(pillar_dict, 'modify', string_val)
|
temp_pillar_dict = add_to_sids(pillar_dict, 'modify', string_val)
|
||||||
|
|
||||||
if temp_pillar_dict == pillar_dict:
|
if temp_pillar_dict['idstools']['sids']['modify'] == pillar_dict['idstools']['sids']['modify']:
|
||||||
salt_proc = check_apply(args)
|
salt_proc = check_apply(args, prompt=False)
|
||||||
return salt_proc
|
return salt_proc
|
||||||
else:
|
else:
|
||||||
pillar_dict = temp_pillar_dict
|
pillar_dict = temp_pillar_dict
|
||||||
|
|||||||
Reference in New Issue
Block a user