Expand description
String-level auto-fix applier shared by the CLI, LSP, and MCP server.
The linter attaches an optional Fix to each
LintWarning. This module turns those fixes into
concrete edits on a YAML source string using the yamlpath/yamlpatch
crates, preserving comments and formatting outside the edited spans.
Only FixDisposition::Safe fixes are applied; unsafe fixes are skipped so
a batch fixer never makes a change that needs human judgement.
§Usage
use rsigma_parser::lint::{lint_yaml_str, fix::apply_fixes_to_source};
let source = "title: Test\nStatus: test\nlogsource:\n category: test\ndetection:\n sel:\n field: value\n condition: sel\n";
let warnings = lint_yaml_str(source);
let fixable: Vec<_> = warnings.iter().filter(|w| w.fix.is_some()).collect();
let outcome = apply_fixes_to_source(source, &fixable);
assert!(outcome.fixed_source.contains("status: test"));Structs§
- Source
FixOutcome - Outcome of applying fixes to a single YAML source string.
Functions§
- apply_
fixes_ to_ source - Apply every safe fix from
warningstosource, returning the rewritten source plus applied/failed counts. - apply_
rename_ key - Rename a YAML key in-place using
query_key_onlyto get the exact byte span of the key, then replacing it in the document source. - apply_
single_ fix_ patch - Apply a single
FixPatchto ayamlpath::Document, returning a new Document. - json_
pointer_ to_ route - Convert an rsigma JSON-pointer path (e.g. “/tags/2”, “/detection/sel/CommandLine|contains”)
into a
yamlpath::Routewith owned components.