Skip to content

fix: cache lookup fails after update-cache with custom URL in offline environments#467

Merged
thomaspatzke merged 1 commit intomainfrom
copilot/fix-redownload-cached-data
Apr 21, 2026
Merged

fix: cache lookup fails after update-cache with custom URL in offline environments#467
thomaspatzke merged 1 commit intomainfrom
copilot/fix-redownload-cached-data

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

After pre-populating the cache via sigma pysigma update-cache --url mitre_attack:"./file.json", subsequent sigma check runs in a fresh process fail with a network error instead of using the cached data.

Root cause: The diskcache key embedded the source URL — f"mitre_attack_data_{_custom_url or 'default'}". Data cached with a custom URL (key: "mitre_attack_data_./file.json") is invisible to a fresh process where _custom_url is None (key: "mitre_attack_data_default"), causing a miss and a download attempt.

Changes

  • sigma/data/mitre_attack.py — replace URL-dependent cache key with stable constant "mitre_attack_data"
  • sigma/data/mitre_d3fend.py — same fix, stable key "mitre_d3fend_data"
  • tests/test_validators_tags.py — add two tests that explicitly simulate the offline workflow: cache via custom URL → reset _custom_url to None → assert cached data is returned without a download

set_url() already calls clear_cache(), so cache invalidation when switching sources is unaffected.

…e_d3fend

Previously the cache key included the URL (e.g. "mitre_attack_data_./enterprise-attack.json"),
so data pre-populated via `update-cache --url mitre_attack:./file.json` was stored under a
URL-specific key. When `sigma check` ran in a fresh process with no custom URL set, it looked
for "mitre_attack_data_default" - a different key - got a cache miss, and attempted a network
download, breaking offline/restricted-network usage.

Fix: use a stable key ("mitre_attack_data" / "mitre_d3fend_data") so any pre-populated cache
entry is found regardless of the source URL. set_url() already calls clear_cache() to force
re-download when the source changes, so correctness is maintained.

Agent-Logs-Url: https://github.com/SigmaHQ/pySigma/sessions/55649932-4d52-4cc7-8e19-a843bfa99b0b

Co-authored-by: thomaspatzke <1845601+thomaspatzke@users.noreply.github.com>
@thomaspatzke thomaspatzke marked this pull request as ready for review April 21, 2026 14:22
@thomaspatzke thomaspatzke merged commit aca1185 into main Apr 21, 2026
20 checks passed
@thomaspatzke thomaspatzke deleted the copilot/fix-redownload-cached-data branch April 21, 2026 14:22
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