Skip to content

Commit bd70983

Browse files
authored
Remove Local Dep for Taxonomy (#66)
* Update config.py * Update sigma/validators/sigmahq/config.py
1 parent b6d38c6 commit bd70983

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

sigma/validators/sigmahq/config.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ def key_logsource(source: dict) -> str:
3030

3131

3232
class ConfigHQ:
33-
"""Loads SigmaHQ configuration from local JSON files if available, otherwise uses reference data.
34-
35-
Supports both local and remote configuration sources with caching and fallback mechanisms.
36-
"""
33+
"""Loads SigmaHQ configuration with support for remote URLs or local files"""
3734

3835
JSON_FOLDER: str = "validator_json"
3936
JSON_NAME_TAXONOMY: str = "sigmahq_taxonomy.json"
4037
JSON_NAME_FILENAME: str = "sigmahq_filename.json"
4138
JSON_NAME_WINDOWS_PROVIDER: str = "sigmahq_windows_validator.json"
39+
DEFAULT_REMOTE_URL: str = (
40+
"https://raw.githubusercontent.com/SigmaHQ/pySigma-validators-sigmaHQ/main/tools"
41+
)
4242

4343
def __init__(self, data_place: Optional[str] = None):
4444
# Initialize with internal reference data
@@ -57,19 +57,22 @@ def __init__(self, data_place: Optional[str] = None):
5757
self.config_url: Optional[str] = None
5858

5959
if data_place is None:
60-
# Check default local folder
60+
# Prioritize the remote URL by default, with local folder as fallback
61+
self.config_url = self.DEFAULT_REMOTE_URL
6162
default_path = Path.cwd() / self.JSON_FOLDER
6263
if default_path.exists():
64+
# Prioritize local if it exists (for offline work)
6365
self.config_dir = default_path
66+
self.config_url = None
6467
elif data_place.startswith("http://") or data_place.startswith("https://"):
6568
self.config_url = data_place.rstrip("/")
6669
else:
6770
self.config_dir = Path(data_place)
6871

69-
# Load configuration if path exists
70-
if (
72+
# Try to load configuration from source
73+
if self.config_url is not None or (
7174
self.config_dir is not None and self.config_dir.exists()
72-
) or self.config_url is not None:
75+
):
7376
self._load_sigma_json()
7477
self._load_filename_json()
7578
self._load_windows_provider_json()

0 commit comments

Comments
 (0)