Skip to content

Graceful degradation for MITRE data loaders on network failure#466

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-mitre-content-loading-issue
Draft

Graceful degradation for MITRE data loaders on network failure#466
Copilot wants to merge 2 commits intomainfrom
copilot/fix-mitre-content-loading-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

On offline systems, sigma pysigma update-cache --url mitre_attack:"./enterprise-attack.json" fails with urllib.error.URLError because the sigma-cli iterates all datasets and mitre_d3fend (without a URL override) still attempts to download from the default URL.

PR #465 deferred MITRE loading in tag validators, but the data loaders themselves still raise on any network failure, even when no custom URL was explicitly configured.

Changes

  • sigma/data/mitre_attack.py and sigma/data/mitre_d3fend.py: When loading from the default URL fails, return empty data with a warnings.warn() instead of raising RuntimeError. Custom URL failures still raise — the user explicitly configured a source and should know it's broken.
  • Added _empty_data() helpers returning the expected dict structure with empty collections.
  • 4 new tests covering both the graceful degradation path and the custom-URL-still-raises path for each module.
# Custom URL (explicit user config) — still raises on failure
mitre_attack.set_url("/bad/path.json")
mitre_attack.mitre_attack_tactics  # RuntimeError

# Default URL (no set_url called) — warns and returns empty
# Previously: RuntimeError / URLError
mitre_attack.mitre_attack_tactics  # {} + UserWarning

Copilot AI and others added 2 commits April 15, 2026 15:02
When loading MITRE ATT&CK or D3FEND data from the default URL fails (e.g.,
no internet connectivity), return empty data with a warning instead of
raising a RuntimeError. Custom URL failures still raise RuntimeError since
the user explicitly configured them.

This fixes the issue where sigma-cli update-cache --url mitre_attack:file
would fail with URLError on offline systems because mitre_d3fend (without
a URL override) would try to download from the internet.

Agent-Logs-Url: https://github.com/SigmaHQ/pySigma/sessions/23765f2f-b668-445b-84b7-980815228637

Co-authored-by: thomaspatzke <1845601+thomaspatzke@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants