Refresh ART/STIX at startup and degrade gracefully when offline#67
Merged
Conversation
clone_atomic_red_team_repo() now ensures the Atomic Red Team checkout is both present AND current on every startup: * missing/empty -> shallow clone * already present -> git fetch --depth 1 + fast-forward to latest HEAD This refreshes the atomic tests and the bundled ATT&CK STIX (enterprise-attack.json) together, so the 45MB STIX is pulled at startup rather than committed into the plugin, and stays current instead of being frozen at first-boot state. All network operations degrade gracefully: if the host is offline (or git is unavailable / the checkout is corrupt), a warning is logged and the existing on-disk copy is used; if nothing is on disk the import is skipped rather than crashing plugin enable. _populate_dict_techniques_tactics() likewise tolerates a missing enterprise-attack.json, falling back to the 'redcanary-unknown' tactic instead of raising FileNotFoundError. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
The plugin reads its ATT&CK technique→tactic mapping from
enterprise-attack.json, which is not committed here (it's 45 MB) — it arrives only as a side effect of the shallowgit cloneof Red Canary'satomic-red-teamon first boot. Two gaps followed from that:--depth 1clone is frozen at first-boot state; upstream ATT&CK / atomic-test updates never arrive.git cloneviacheck_callraised on any network failure, breaking plugin enable; and a missingenterprise-attack.jsoncrashed import withFileNotFoundError.Changes
clone_atomic_red_team_repo()now ensures the checkout is present and current on every startup:git fetch --depth 1 origin HEAD+ fast-forward (git reset --hard FETCH_HEAD) only when behindThis refreshes the atomic tests and the bundled STIX together, and a
reset --hardalso restoresenterprise-attack.jsonif it went missing.Everything degrades gracefully:
_populate_dict_techniques_tactics()tolerates a missingenterprise-attack.json, falling back to theredcanary-unknowntactic.Testing
python -m py_compileclean.git fetch --depth 1 origin HEAD+rev-parsecomparison verified against a live ART checkout (correctly reports up-to-date).CalledProcessError(clone/network failure) andOSError(git absent).🤖 Generated with Claude Code