[high] fix(chainsaw): pass the --mapping that hunt mode's --sigma requires - #113
Draft
elhoim wants to merge 1 commit into
Draft
[high] fix(chainsaw): pass the --mapping that hunt mode's --sigma requires#113elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
_run_chainsaw_hunt built `chainsaw hunt <evidence> -s <sigma> --json
--output <file>`. Chainsaw declares --mapping as a hard requirement of
--sigma, so clap rejects that command line before Chainsaw opens a single
log. Verified against the pinned release, chainsaw 2.16.0:
$ chainsaw hunt ./evidence -s ./sigma --json --output out.json
error: the following required arguments were not provided:
--mapping <MAPPING>
(exit 2)
The requirement is invisible in `chainsaw hunt --help`, which lists
--mapping as an ordinary option; it is enforced only at parse time. Hunt
mode is Chainsaw's Sigma engine, so it could never execute.
Resolve the mapping the chainsaw asset already ships
(mappings/sigma-event-logs-all.yml, present in the release tarball and in
the asset's supplement_paths) and pass it alongside --sigma. A missing
mapping is now reported as file_not_found with a 'mulder setup'
suggestion rather than left to surface as an opaque exit 2, and a new
mapping_path parameter mirrors sigma_rules_path so a PATH-installed
chainsaw can point at its own mappings.
Three tests in test_binary_resolution.py now provision the mapping as
incidental setup; they assert on binary resolution and are unchanged in
what they check.
Co-Authored-By: Claude Opus 5 (1M context) <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.
BLUF
main. It is Chainsaw's Sigma detection engine — the whole reason the tool is wrapped — and every invocation is rejected by argument parsing before a single log is opened._run_chainsaw_huntpasses-s <sigma rules>but never--mapping. Chainsaw declares--mappinga hard requirement of--sigma.chainsaw hunt --help, which lists--mappingas an ordinary option — it is enforced only at parse time. That is why the defect survived review.--sigma; report a missing mapping asfile_not_foundinstead of letting it surface as an opaque exit 2; add amapping_pathoverride mirroring the existingsigma_rules_path.src/mulder/server/tools/chainsaw.py, hunt mode only. No shared helper, no new abstraction, no change to search/srum/timeline.The bug
Verified empirically against the pinned release — I downloaded
chainsaw_x86_64-unknown-linux-gnu.tar.gzfor v2.16.0 (the version inmanifest.py) and ran mulder's exact argv:Adding the mapping is also sufficient — the same command line then runs, and Chainsaw resolves mulder's positional layout correctly:
(It then exits 1 only because my throwaway evidence directory was empty.)
The fix
plus a pre-flight so a missing asset is legible:
No new asset is required.
mappings/sigma-event-logs-all.ymlships inside the release tarball (strip_components=1lands it in the asset dir) and is also listed in the asset'ssupplement_paths=("mappings", "rules").The
mapping_pathparameter mirrors the existingsigma_rules_pathand exists for a concrete reason:_chainsaw_binary()deliberately lets a PATH install win ("so a SIFT/apt/cargo install keeps being used"), and such an install keeps its mappings elsewhere. Without an override, the pre-flight would hard-block exactly the users that docstring protects.Deliberately out of scope
sigma-event-logs-legacy.yml. Chainsaw ships two mappings;-allis the general one. Selecting per-log-format is a separate concern — the newmapping_pathparameter is the escape hatch in the meantime.fix/chainsaw-exit-code) makes a failed Chainsaw run report an error instead of a clean scan. The two are complementary and independent: [high] fix(chainsaw): report a failed Chainsaw run instead of a clean scan #95 makes this failure visible, this PR removes its cause. Neither depends on the other, and both branch offmain.chainsaw analyse srumexits 0 even when it fails to parse the database, so a returncode guard alone will not catch that case. Noting it; not addressed here.Verification
uvx pre-commit run --all-files(new test staged first) → ruff, ruff-format, mypy all pass.uv run --locked --extra dev pytest tests/ -q→ 862 passed, nothing deselected, nothing skipped.chainsaw.pyrestored toorigin/mainand the new tests kept, 5 of 6 fail:The tests assert on the parsed argv, not on a mock call count, and they deliberately avoid importing the new resolver at module scope so the failure is the missing flag rather than an
ImportError.test_timeline_mode_does_not_get_a_mappingpasses against both trees — it pins the fix's narrowness rather than the bug.tests/test_binary_resolution.pynow provision the mapping. They assert on binary resolution and none of them asserts anything about mappings; the mapping is incidental setup needed to reachsubprocess.runat all. Nothing they check was weakened.Context
Recovered from closed PR #69, which changed the CLI contract of every wrapped tool at once. This is one tool, one subcommand, one flag. The rejected outcome framework is not reintroduced and there is no
classify_tool_exitor second status taxonomy here, per the review on #32:Branched fresh from current
main(2e5432c); the closed branch was not revised in place.🤖 Generated with Claude Code