Remove config.py in favor of diskcache-based JSON loading - #77
Merged
Conversation
…eption handling in data modules
thomaspatzke
self-requested a review
July 24, 2026 22:49
thomaspatzke
requested changes
Jul 24, 2026
Member
There was a problem hiding this comment.
Most of the code repeats in the other data modules. This redundancy can cause inconsistencies. Suggestion: transform into classes with a base class containing shared functions and implement only differences in specific classes.
Member
Author
There was a problem hiding this comment.
Thanks for the review. It's done .
…tion Addresses PR SigmaHQ#77 code review feedback: transform repeated cache/fetch logic in data_*.py modules into a base class with shared functions and subclass-specific _parse() implementations. - Add base.py with SigmahqDataLoader (ABC) for cache mgmt, JSON fetching, URL/config management, and module-level __getattr__ delegation - Convert data_filename.py, data_taxonomy.py, data_windows_eventid.py, data_windows_provider.py to thin subclasses - Add input validation for set_url() and set_cache_dir() - Fix AttributeError __name__ to reference the correct module - Add missing type annotations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces the monolithic
ConfigHQsingleton (which loaded all SigmaHQ data into memory at import time) with per-domain data modules backed bydiskcachefor lazy, cached loading. It also splits the overloadedfield.pyinto focused modules and refactors the status validator to properly handle regression-test rules.Closes #72.
Closes #74.
Motivation
The old
ConfigHQclass inconfig.py:sigmahq_data.pygenerated by a script (update_ref.py)The new architecture:
sigma/validators/sigmahq/data/, one per data domaindiskcacheto cache remote JSON locally (TTL-managed)__getattr__— data is fetched only when first accessedset_url()(for custom/local URLs) andset_cache_dir()Changes
Core refactoring
config.py,sigmahq_data.py,update_ref.pyConfigHQsingleton and its data generator script deleteddata_filename.py,data_taxonomy.py,data_windows_eventid.py,data_windows_provider.py— each lazy-loads from a JSON URL with local cachingSigmahqDataLoaderbase classbase.pywithSigmahqDataLoader(ABC)— shared cache management, JSON fetching, URL/config handling, and__getattr__delegation. Each data module becomes a thin subclass with only_parse()make_module_api()helperglobals().update(...)boilerplate into a single function inbase.py— each module calls it in one linefield.py→fieldname.py+modifier.pyfieldname.py: field name/presence validators.modifier.py: modifier-specific validators (duplicate value, invalid all-modifier)detection.py,filename.py,logsource.pynow import fromdata_*modules instead ofConfigHQtags.py,title.py: removed deadConfigHQimportsstatus.py:SigmahqStatusToHighValidatormin_dayswithmin_days_for_nolog_rule(60) +min_days_for_log_rule(0). Rules withregression_tests_pathnow use the lower log threshold. Early-return logic simplified. Fixes #72.JSON schema & tools
windows_validatorwindows_eventid(event ID categories) andwindows_provider(provider names)schema_sigmahq_windows_eventid.json,schema_sigmahq_windows_provider.jsonCI & docs
schema.ymlCHANGELOG.md,CONTRIBUTING.mdREADME.md0.21.0Bug fixes (from code review)
Dict[str, str]→Dict[str, Any]in eventid/provider modules; fixedDict[str, List[str]]→Dict[str, str]in filename modulejson_data["key"]with.get(key, default)to preventKeyErroron malformed JSONset_url()now resets_cache = Noneconsistently across all 4 moduleshttp.client.HTTPExceptionto except tuples to catchIncompleteReadand similar stream errorsdata_taxonomy.pyusesinfo.get("field", {}).get("native", [])instead of bare indexing_JSONDiskcustom serializer inbase.pyso non-root users can cache JSON (fixes pickling issues)AttributeErrormodule name__name__reference in base class to point to the correct subclass moduleTest infrastructure
conftest.pytools/*.jsonfiles during testing, avoiding 404 errors on CI (related to #74 — demonstrates offline/local usage)tests/sigmahq/field/totests/sigmahq/fieldname/andtests/sigmahq/modifier/; fixed imports; added parametrized tests for status validator