#sarif #serde #serialization

serde-sarif

Serde serialization for SARIF files

19 releases

new 0.2.17 Sep 15, 2021
0.2.16 Jul 7, 2021
0.2.8 Jun 29, 2021
0.1.2 Jun 24, 2021

#160 in Encoding

Download history 108/week @ 2021-06-20 153/week @ 2021-06-27 86/week @ 2021-07-04 14/week @ 2021-07-11 32/week @ 2021-07-18 38/week @ 2021-07-25 48/week @ 2021-08-01 29/week @ 2021-08-08 42/week @ 2021-08-15 9/week @ 2021-08-22 5/week @ 2021-08-29 8/week @ 2021-09-05 28/week @ 2021-09-12

193 downloads per month
Used in 4 crates

MIT license

36KB
876 lines

Workflow Status

serde-sarif

WARNING: VERY UNSTABLE (EARLY IMPLEMENTATION)

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/.

Usage

For most cases, simply use the root [sarif::Sarif] struct with [serde] to read and write to and from the struct.

Example

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 with a default.

Example

use serde_sarif::sarif::MessageBuilder;

let message = MessageBuilder::default()
  .id("id")
  .build()
  .unwrap();

Internal Implementation Details

The root [sarif::Sarif] struct is automatically generated from the latest Sarif JSON schema, this is done at build time (via the buildscript).

Crate Features

This crate contains different features which may be enabled depndending on your use case.

Example

[dependencies]
serde-sarif = { version = "*", features = ["clippy-converters"] }

Converters

  • clippy-converters Provides conversions between Clippy and SARIF types
  • hadolint-converters Provides conversions between hadolint and SARIF types
  • shellcheck-converters Provides conversions between shellcheck and SARIF types

License: MIT

Dependencies

~2–2.8MB
~57K SLoC