Replace static MITRE data with on-demand API loading #415
+393
−3,673
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.
Static MITRE ATT&CK and D3FEND data files (127KB) were shipped in the package and required manual updates. This replaces them with dynamic loaders that fetch latest data from official sources on first use, cached in memory for the process lifetime.
Changes
New modules:
sigma/data/mitre_attack_data.pyandsigma/data/mitre_d3fend_data.pygithub.com/mitre-attack/attack-stix-dataand D3FEND ontology__getattr__for backward-compatible module-level attribute access_cachevariableUpdated validators: Modified imports in
sigma/validators/core/tags.pyTest mocking: Added
tests/conftest.pywithautousefixture_get_cached_data()to return mock dataRemoved files:
sigma/data/mitre_attack.py(2471 lines)sigma/data/mitre_d3fend.py(882 lines)tools/update-*.pyscripts (298 lines)API Compatibility
Existing code continues to work unchanged. Validators initialize identically:
Data loading is transparent with 30s timeout and proper error handling via
RuntimeErroron network failures.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
d3fend.mitre.orgpython3 -c import requests try: # Check if the D3FEND JSON ontology is accessible response = requests.get('REDACTED', timeout=10) print(f'D3FEND JSON status: {response.status_code}') print(f'Content-Type: {response.headers.get("Content-Type")}') if response.status_code == 200: data = response.json() print(f'Keys in response: {list(data.keys())[:5]}') except Exception as e: print(f'Error: {e}')(dns block)/home/REDACTED/.cache/pypoetry/virtualenvs/pysigma-Tjs8INP8-py3.12/bin/python /home/REDACTED/.cache/pypoetry/virtualenvs/pysigma-Tjs8INP8-py3.12/bin/pytest tests/ -q(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.