SARIF Rust Implementation
A comprehensive Rust library for parsing, generating, and manipulating SARIF (Static Analysis Results Interchange Format) v2.1.0 files.
Overview
This project implements a complete SARIF v2.1.0 library in Rust, providing:
- Type-safe parsing and generation of SARIF files
- Comprehensive validation against the SARIF specification
- Ergonomic builder patterns for creating SARIF documents
- High-performance streaming for large files
- Zero-copy parsing where possible
- Rich error handling with detailed diagnostics
Features
- ✅ Complete SARIF v2.1.0 Support: Full compatibility with the official specification
- ✅ Type Safety: Leverage Rust's type system to prevent invalid SARIF construction
- ✅ Performance: Optimized for handling large SARIF files efficiently
- ✅ Validation: Comprehensive validation with helpful error messages
- ✅ Builder API: Fluent interface for programmatic SARIF generation
- ✅ Streaming: Process large files without loading entirely into memory
- ✅ Extensibility: Support for custom properties and tool extensions
Quick Start
Parsing SARIF Files
use SarifLog;
// Parse from file
let sarif: SarifLog = from_file?;
// Parse from string
let json = read_to_string?;
let sarif: SarifLog = from_str?;
// Access results
for run in &sarif.runs
Creating SARIF Files
use ;
let sarif = new
.add_run
.build?;
// Serialize to JSON
let json = to_string_pretty?;
write?;
Streaming Large Files
use StreamingParser;
use File;
let file = open?;
let parser = new;
for run_result in parser.parse_runs
Project Structure
sarif_rust/
├── src/
│ ├── types/ # Core SARIF data structures
│ ├── builder/ # Builder pattern implementations
│ ├── parser/ # Parsing and validation
│ └── utils/ # Utility functions
├── tests/ # Integration tests
├── docs/ # Documentation
└── examples/ # Usage examples
Documentation
- Specification Analysis: Deep dive into SARIF v2.1.0 specification
- Implementation Plan: Detailed technical implementation roadmap
- API Documentation: Complete API reference (when published)
SARIF Specification Compliance
This library implements the complete SARIF v2.1.0 specification including:
Core Objects
- SarifLog: Root container with version and runs
- Run: Analysis tool execution with results and metadata
- Result: Individual findings with locations and metadata
- Location: Physical and logical location information
- Tool: Tool and component information
- Artifact: File and content references
Advanced Features
- External Property Files: Large-scale analysis support
- Taxonomies: Rule categorization and classification
- Code Flows: Multi-step analysis paths
- Threading Flows: Multi-threaded analysis support
- Web Requests/Responses: Web application analysis
- Fixes: Automated fix suggestions
Performance Characteristics
| Operation | File Size | Performance Target |
|---|---|---|
| Parse | 1-10 MB | < 100ms |
| Validate | 1-10 MB | < 50ms |
| Serialize | 1-10 MB | < 50ms |
| Stream Parse | 100+ MB | < 500MB RAM |
Development Roadmap
Phase 1: Core Types (Week 1)
- Define SARIF object model
- Implement core enums and types
- Basic JSON serialization support
Phase 2: Validation (Week 2)
- Custom validation traits
- URI and cross-reference validation
- Comprehensive error types
Phase 3: Builders (Week 3)
- Fluent builder interfaces
- Type-safe construction
- Ergonomic API design
Phase 4: Advanced Features (Week 4)
- Streaming parser implementation
- Cross-reference indexing
- Memory optimization
Phase 5: Polish (Week 5)
- Comprehensive testing
- Documentation and examples
- Performance benchmarking
Contributing
Contributions are welcome! Please see our contribution guidelines for details on:
- Code style and formatting
- Testing requirements
- Documentation standards
- Pull request process
License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Related Projects
- SARIF Standard: Official SARIF specification and tools
- Microsoft SARIF SDK: .NET implementation
- sarif-python: Python SARIF library
Status: 🚧 Under Development - See Implementation Plan for current progress