sarif-to-md-core
Core Rust library for parsing SARIF (Static Analysis Results Interchange Format) reports and converting them to Markdown.
Features
- SARIF Parsing - Robust parsing of SARIF v2.1.0 format
- Markdown Generation - Flexible template-based Markdown generation
- Multiple Formats - GitHub Flavored Markdown and CommonMark support
- Extensible - Builder pattern for easy customization
- Type-Safe - Strongly typed API with comprehensive error handling
- Zero-Copy - Efficient parsing with minimal allocations
Installation
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
use ;
use fs;
API Overview
Core Types
ReportProcessor<G>
Main processor for generating Markdown from SARIF reports.
ReportProcessorBuilder<G>
Builder for constructing ReportProcessor instances.
MarkdownGenerator Trait
Core trait for implementing custom Markdown generators.
Generators
SarifMarkdownGenerator
Built-in generator for SARIF reports.
Markdown Formats
Error Types
Advanced Usage
Custom Generator Implementation
Create your own Markdown generator by implementing the MarkdownGenerator trait:
use ;
use Deserialize;
;
// Use it
let processor = new
.generator
.content
.build?;
Customizing Output Format
use ;
// GitHub Flavored with collapsible sections
let gfm_generator = new;
// CommonMark for maximum compatibility
let cm_generator = new;
Error Handling
use ;
match processor.generate
Processing Multiple Files
use Path;
use ;
Template System
The library uses Askama for template rendering. Templates are located in templates/sarif/:
report.md- Main report templatemacros.md- Reusable template macros
Template Variables
Templates have access to:
Testing
# Run all tests
# Run with output
# Test specific module
Benchmarking
# Run benchmarks (requires nightly)
Documentation
Generate and open the full API documentation:
MSRV (Minimum Supported Rust Version)
This crate requires Rust 1.90 or later.
Dependencies
serde- Serialization frameworkserde_json- JSON parsingserde-sarif- SARIF format supportaskama- Template enginechrono- Date/time handlingthiserror- Error handling
Performance Considerations
- Parsing: O(n) complexity for SARIF parsing
- Template Rendering: O(m) where m is the number of findings
- Memory: Minimal allocations, most data is borrowed
- Throughput: Can process 1000+ findings per second on modern hardware
Architecture
sarif-to-md-core/
├── src/
│ ├── lib.rs # Public API
│ ├── error.rs # Error types
│ ├── generators.rs # Re-exports
│ └── markdown/
│ ├── mod.rs # Core traits
│ └── sarif/
│ ├── generator.rs # SARIF generator
│ └── types.rs # View models
└── templates/
└── sarif/
├── report.md # Main template
└── macros.md # Helper macros
Comparison with Alternatives
| Feature | sarif-to-md-core | Other Tools |
|---|---|---|
| Language | Rust | JavaScript/Python |
| Performance | High | Medium |
| Memory Usage | Low | Medium-High |
| Type Safety | Strong | Weak |
| Dependencies | Minimal | Many |
Contributing
See the parent repository's CONTRIBUTING.md for guidelines.
Changelog
See CHANGELOG.md for version history.
License
This project is dual-licensed under:
- MIT License (LICENSE-MIT)
- Apache License 2.0 (LICENSE-APACHE)
Choose the license that best suits your needs.