Allow CLi config to be multiple formats (#1485)
(cherry picked from commit 7179942be3)
This commit is contained in:
committed by
github-actions[bot]
parent
c864538606
commit
0a3bd9130d
+1
-1
@@ -107,7 +107,7 @@ ENV/
|
||||
/_extras/
|
||||
|
||||
# detection rules
|
||||
.detection-rules-cfg.json
|
||||
.detection-rules-cfg.*
|
||||
releases/
|
||||
collections/
|
||||
enriched-rule-indexes/
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user