Allow CLi config to be multiple formats (#1485)

(cherry picked from commit 7179942be3)
This commit is contained in:
Justin Ibarra
2021-09-15 20:12:39 -08:00
committed by github-actions[bot]
parent c864538606
commit 0a3bd9130d
2 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -107,7 +107,7 @@ ENV/
/_extras/
# detection rules
.detection-rules-cfg.json
.detection-rules-cfg.*
releases/
collections/
enriched-rule-indexes/
+7 -6
View File
@@ -4,11 +4,11 @@
# 2.0.
"""Misc support."""
import json
import os
import re
import time
import uuid
from pathlib import Path
from functools import wraps
from typing import NoReturn
@@ -252,14 +252,15 @@ def get_kibana_rules(*rule_paths, repo='elastic/kibana', branch='master', verbos
@cached
def parse_config():
"""Parse a default config file."""
config_file = get_path('.detection-rules-cfg.json')
import eql
config_file = next(Path(get_path()).glob('.detection-rules-cfg.*'), None)
config = {}
if os.path.exists(config_file):
with open(config_file) as f:
config = json.load(f)
if config_file and config_file.exists():
config = eql.utils.load_dump(str(config_file))
click.secho('Loaded config file: {}'.format(config_file), fg='yellow')
click.secho(f'Loaded config file: {config_file}', fg='yellow')
return config