Crates.io | serde-sarif |
lib.rs | serde-sarif |
version | 0.6.6 |
source | src |
created_at | 2021-06-23 15:33:21.758647 |
updated_at | 2024-09-02 03:25:46.992984 |
description | Serde serialization for SARIF files |
homepage | https://psastras.github.io/sarif-rs/ |
repository | https://github.com/psastras/sarif-rs |
max_upload_size | |
id | 413993 |
size | 162,384 |
This crate provides a type safe serde compatible SARIF structure. It is intended for use in Rust code which may need to read or write SARIF files.
The latest documentation can be found here.
serde is a popular serialization framework for Rust. More information can be found on the official repository: https://github.com/serde-rs/serde
SARIF or the Static Analysis Results Interchange Format is an industry standard format for the output of static analysis tools. More information can be found on the official website: https://sarifweb.azurewebsites.net/.
For most cases, simply use the root [sarif::Sarif] struct with [serde] to read and write to and from the struct.
use serde_sarif::sarif::Sarif;
let sarif: Sarif = serde_json::from_str(
r#"{ "version": "2.1.0", "runs": [] }"#
).unwrap();
assert_eq!(
sarif.version.to_string(),
"\"2.1.0\"".to_string()
);
Because many of the [sarif::Sarif] structures contain a lot of optional fields, it is often convenient to use the builder pattern to contstruct these structs. Each structure has a builder method to accomplish this.
use serde_sarif::sarif::Message;
let message = Message::builder()
.id("id")
.build();
This uses TypedBuilder
for compile time type checking.
The root [sarif::Sarif] struct is automatically generated from the latest Sarif JSON schema, this is done at build time (via the buildscript).
This crate contains different features which may be enabled depending on your use case.
[dependencies]
serde-sarif = { version = "*", features = ["clippy-converters"] }
License: MIT