Skip to content

Defer MITRE ATT&CK data imports in analyze.py to avoid network fetch on CLI startup#89

Merged
thomaspatzke merged 1 commit intomainfrom
copilot/fix-cli-update-cache-error
Apr 18, 2026
Merged

Defer MITRE ATT&CK data imports in analyze.py to avoid network fetch on CLI startup#89
thomaspatzke merged 1 commit intomainfrom
copilot/fix-cli-update-cache-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

sigma/cli/analyze.py imports mitre_attack_techniques_tactics_mapping and mitre_attack_version at module level. Since main.py unconditionally imports analyze_group from this module, every CLI invocation triggers a MITRE ATT&CK data download — including sigma pysigma update-cache --url mitre_attack:"./enterprise-attack.json", which is specifically intended to load from a local file on offline systems.

  • Move the two sigma.data.mitre_attack imports from module scope into analyze_attack(), where they're actually used
# Before: module-level import triggers download on every CLI command
from sigma.data.mitre_attack import (
    mitre_attack_techniques_tactics_mapping,
    mitre_attack_version,
)

# After: deferred to function scope, only loads when `sigma analyze attack` runs
def analyze_attack(...):
    ...
    from sigma.data.mitre_attack import (
        mitre_attack_techniques_tactics_mapping,
        mitre_attack_version,
    )

This is consistent with how pysigma.py already handles the same imports via get_cache_datasets().

… requests on CLI startup

Agent-Logs-Url: https://github.com/SigmaHQ/sigma-cli/sessions/6807949e-b72e-452b-80df-8795263fd99a

Co-authored-by: thomaspatzke <1845601+thomaspatzke@users.noreply.github.com>
@thomaspatzke thomaspatzke marked this pull request as ready for review April 18, 2026 23:23
@thomaspatzke thomaspatzke merged commit 41c57a2 into main Apr 18, 2026
15 checks passed
@thomaspatzke thomaspatzke deleted the copilot/fix-cli-update-cache-error branch April 18, 2026 23:27
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