serde-sarif-0.8.0/.cargo_vcs_info.json0000644000000001510000000000100132420ustar { "git": { "sha1": "c1a2c247095ed7277153e8e456064598dc885b39" }, "path_in_vcs": "serde-sarif" }serde-sarif-0.8.0/.gitignore000064400000000000000000000001261046102023000140240ustar 00000000000000# Added by cargo # # already existing elements were commented out /target Cargo.lock serde-sarif-0.8.0/Cargo.lock0000644000000323610000000000100112250ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "Inflector" version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" dependencies = [ "lazy_static", "regex", ] [[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "anyhow" version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "camino" version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" dependencies = [ "serde", ] [[package]] name = "cargo-platform" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" dependencies = [ "serde", ] [[package]] name = "cargo_metadata" version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" dependencies = [ "camino", "cargo-platform", "semver", "serde", "serde_json", "thiserror", ] [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "idna" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", ] [[package]] name = "indexmap" version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "itoa" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "prettyplease" version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" dependencies = [ "proc-macro2", "syn 2.0.101", ] [[package]] name = "proc-macro2" version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "pulldown-cmark" version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" dependencies = [ "bitflags", "memchr", "unicase", ] [[package]] name = "quote" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] name = "regex" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustversion" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schemafy_core" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bec29dddcfe60f92f3c0d422707b8b56473983ef0481df8d5236ed3ab8fdf24" dependencies = [ "serde", "serde_json", ] [[package]] name = "schemafy_lib" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af3d87f1df246a9b7e2bfd1f4ee5f88e48b11ef9cfc62e63f0dead255b1a6f5f" dependencies = [ "Inflector", "proc-macro2", "quote", "schemafy_core", "serde", "serde_derive", "serde_json", "syn 1.0.109", "uriparse", ] [[package]] name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] [[package]] name = "serde" version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde-sarif" version = "0.8.0" dependencies = [ "anyhow", "cargo_metadata", "once_cell", "prettyplease", "proc-macro2", "quote", "regex", "schemafy_lib", "serde", "serde_json", "strum", "strum_macros", "syn 2.0.101", "thiserror", "typed-builder", "version-sync", ] [[package]] name = "serde_derive" version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", "syn 2.0.101", ] [[package]] name = "serde_json" version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", "ryu", "serde", ] [[package]] name = "serde_spanned" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] [[package]] name = "strum" version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" [[package]] name = "strum_macros" version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", "syn 2.0.101", ] [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "syn" version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "thiserror" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", "syn 2.0.101", ] [[package]] name = "tinyvec" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", "toml_datetime", "toml_edit", ] [[package]] name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", "winnow", ] [[package]] name = "typed-builder" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce63bcaf7e9806c206f7d7b9c1f38e0dce8bb165a80af0898161058b19248534" dependencies = [ "typed-builder-macro", ] [[package]] name = "typed-builder-macro" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60d8d828da2a3d759d3519cdf29a5bac49c77d039ad36d0782edadbf9cd5415b" dependencies = [ "proc-macro2", "quote", "syn 2.0.101", ] [[package]] name = "unicase" version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" dependencies = [ "version_check", ] [[package]] name = "unicode-bidi" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "uriparse" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0200d0fc04d809396c2ad43f3c95da3582a2556eba8d453c1087f4120ee352ff" dependencies = [ "fnv", "lazy_static", ] [[package]] name = "url" version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] [[package]] name = "version-sync" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835169da0173ea373ddf5987632aac1f918967fbbe58195e304342282efa6089" dependencies = [ "proc-macro2", "pulldown-cmark", "regex", "semver", "syn 2.0.101", "toml", "url", ] [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "winnow" version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] serde-sarif-0.8.0/Cargo.toml0000644000000047210000000000100112470ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "serde-sarif" version = "0.8.0" authors = ["Paul Sastrasinh "] build = "build.rs" autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = "Serde serialization for SARIF files" homepage = "https://psastras.github.io/sarif-rs/" documentation = "https://docs.rs/serde_sarif" readme = "README.md" keywords = [ "sarif", "serde", "serialization", ] categories = ["encoding"] license = "MIT" repository = "https://github.com/psastras/sarif-rs" [badges.github] repository = "psastras/sarif-rs" [features] clang-tidy-converters = [ "regex", "anyhow", "once_cell", ] clippy-converters = [ "cargo_metadata", "regex", "anyhow", ] default = [] hadolint-converters = ["anyhow"] miri-converters = [ "cargo_metadata", "regex", "anyhow", ] opt-builder = [] shellcheck-converters = ["anyhow"] [lib] name = "serde_sarif" path = "src/lib.rs" [[test]] name = "version-numbers" path = "tests/version-numbers.rs" [dependencies.anyhow] version = "1.0.98" optional = true [dependencies.cargo_metadata] version = "0.19.2" optional = true [dependencies.once_cell] version = "1.21.3" optional = true [dependencies.regex] version = "1.11.1" optional = true [dependencies.serde] version = "1.0.219" [dependencies.serde_json] version = "1.0.140" [dependencies.strum] version = "0.27" [dependencies.strum_macros] version = "0.27" [dependencies.thiserror] version = "2.0.12" [dependencies.typed-builder] version = "0.21.0" [dev-dependencies.version-sync] version = "0.9" [build-dependencies.anyhow] version = "1.0.98" [build-dependencies.prettyplease] version = "0.2.32" [build-dependencies.proc-macro2] version = "1.0.95" [build-dependencies.quote] version = "1.0.40" [build-dependencies.schemafy_lib] version = "0.6.0" [build-dependencies.serde_json] version = "1.0.140" [build-dependencies.syn] version = "2.0.101" [lints.rust.unexpected_cfgs] level = "warn" priority = 0 check-cfg = ["cfg(doc_cfg)"] serde-sarif-0.8.0/Cargo.toml.orig000064400000000000000000000026111046102023000147240ustar 00000000000000[package] name = "serde-sarif" version = "0.8.0" authors = ["Paul Sastrasinh "] edition = "2018" description = "Serde serialization for SARIF files" license = "MIT" readme = "README.md" keywords = ["sarif", "serde", "serialization"] categories = ["encoding"] build = "build.rs" homepage = "https://psastras.github.io/sarif-rs/" documentation = "https://docs.rs/serde_sarif" repository = "https://github.com/psastras/sarif-rs" [badges] github = { repository = "psastras/sarif-rs" } [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] } [features] default = [] clippy-converters = ["cargo_metadata", "regex", "anyhow"] miri-converters = ["cargo_metadata", "regex", "anyhow"] hadolint-converters = ["anyhow"] shellcheck-converters = ["anyhow"] clang-tidy-converters = ["regex", "anyhow", "once_cell"] opt-builder = [] [dependencies] anyhow = { version = "1.0.98", optional = true } cargo_metadata = { version = "0.19.2", optional = true } regex = { version = "1.11.1", optional = true } serde = "1.0.219" serde_json = "1.0.140" strum = "0.27" strum_macros = "0.27" thiserror = "2.0.12" typed-builder = "0.21.0" once_cell = { version = "1.21.3", optional = true } [dev-dependencies] version-sync = "0.9" [build-dependencies] anyhow = "1.0.98" prettyplease = "0.2.32" proc-macro2 = "1.0.95" quote = "1.0.40" schemafy_lib = "0.6.0" serde_json = "1.0.140" syn = "2.0.101" serde-sarif-0.8.0/LICENSE000064400000000000000000000020431046102023000130410ustar 00000000000000Copyright (c) 2021 Paul Sastrasinh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. serde-sarif-0.8.0/README.md000064400000000000000000000053071046102023000133210ustar 00000000000000[![Workflow Status](https://github.com/psastras/sarif-rs/workflows/main/badge.svg)](https://github.com/psastras/sarif-rs/actions?query=workflow%3A%22main%22) # serde-sarif This crate provides a type safe [serde](https://serde.rs/) compatible [SARIF](https://sarifweb.azurewebsites.net/) 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](https://docs.rs/serde_sarif). serde is a popular serialization framework for Rust. More information can be found on the official repository: [https://github.com/serde-rs/serde](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/](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 ```rust 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. ## Example ```rust use serde_sarif::sarif::Message; let message = Message::builder() .id("id") .build(); ``` This uses [`TypedBuilder`](https://docs.rs/typed-builder/latest/typed_builder/derive.TypedBuilder.html) for compile time type checking. ## 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 depending on your use case. ### Example ```toml [dependencies] serde-sarif = { version = "*", features = ["clippy-converters"] } ``` ### Converters - **clang-tidy-converters** Provides conversions between clang tidy and SARIF types - **clippy-converters** Provides conversions between Clippy and SARIF types - **hadolint-converters** Provides conversions between hadolint and SARIF types - **miri-converters** Provides conversions between miri and SARIF types - **shellcheck-converters** Provides conversions between shellcheck and SARIF types ### Other - **opt-builder** Enables [`TypedBuilder`](https://docs.rs/typed-builder/latest/typed_builder/derive.TypedBuilder.html#customization-with-attributes)s fallback setters for easier conditional building License: MIT serde-sarif-0.8.0/build.rs000064400000000000000000000120401046102023000134770ustar 00000000000000use std::env; use std::fs::File; use std::io::Write; use std::path::Path; use std::path::PathBuf; use anyhow::Result; use schemafy_lib::Expander; use schemafy_lib::Schema; use syn::parse::Parser; // Add additional items to the generated sarif.rs file // Currently adds: derive(TypedBuilder) to each struct // and appropriate use statements at the top of the file // todo: this (and other parts) need a refactor and tests fn process_token_stream(input: proc_macro2::TokenStream) -> syn::File { let mut ast: syn::File = syn::parse2(input).unwrap(); // add use directives to top of the file ast.items.insert( 0, syn::parse_quote! { use serde::{Serialize, Deserialize}; }, ); ast.items.insert( 0, syn::parse_quote! { use typed_builder::TypedBuilder; }, ); ast.items.insert( 0, syn::parse_quote! { use std::collections::BTreeMap; }, ); // Checks if the type is an Option type (returns true if yes, false otherwise) fn path_is_option(path: &syn::Path) -> bool { let idents_of_path = path.segments.iter().fold(String::new(), |mut acc, v| { acc.push_str(&v.ident.to_string()); acc.push('|'); acc }); vec!["Option|", "std|option|Option|", "core|option|Option|"] .into_iter() .any(|s| idents_of_path == *s) } // Checks if the type is a collection type (returns true if yes, false otherwise) fn path_is_vec(path: &syn::Path) -> bool { let idents_of_path = path.segments.iter().fold(String::new(), |mut acc, v| { acc.push_str(&v.ident.to_string()); acc.push('|'); acc }); vec!["Vec|", "std|vec|Vec|"] .into_iter() .any(|s| idents_of_path.starts_with(s)) } ast.items.iter_mut().for_each(|ref mut item| { if let syn::Item::Struct(s) = item { // add builder attributes to each struct s.attrs.extend(vec![ syn::parse_quote! { #[derive(TypedBuilder)] }, syn::parse_quote! { #[builder(field_defaults(setter(into)))] }, ]); // Add a field to PropertyBag to allow arbitrary JSON data // The proper way to do this would be to modify the JSON schema parsing library to properly // output this. This is a workaround since there's only one struct in the SARIF schema that requires this. if s.ident == "PropertyBag" { if let syn::Fields::Named(fields) = &mut s.fields { fields.named.push( syn::Field::parse_named .parse2(syn::parse_quote! { #[doc = r"Arbitrary properties to include in the PropertyBag"] #[serde(flatten)] #[builder(default = ::std::collections::BTreeMap::new())] pub additional_properties: BTreeMap }) .unwrap(), ); } } // Rewrite Result::kind and Result::level to use ResultKind and // ResultLevel instead of serde_json::Value. // This is a workaround for schemafy's inability to produce appropriate // exhaustive enums here. if s.ident == "Result" { if let syn::Fields::Named(fields) = &mut s.fields { for field in fields.named.iter_mut() { if field.ident.as_ref().unwrap() == "kind" { field.ty = syn::parse_quote! { Option }; } else if field.ident.as_ref().unwrap() == "level" { field.ty = syn::parse_quote! { Option }; } } } } // for each struct field, if that field is Optional, set None // as the default value when using the builder (&mut s.fields).into_iter().for_each(|ref mut field| { if let syn::Type::Path(typepath) = &field.ty { if path_is_option(&typepath.path) { #[cfg(not(feature = "opt-builder"))] field.attrs.push(syn::parse_quote! { #[builder(setter(strip_option), default)] }); #[cfg(feature = "opt-builder")] field.attrs.push(syn::parse_quote! { #[builder(setter(strip_option(fallback_prefix = "opt_")), default)] }); } else if path_is_vec(&typepath.path) { field.attrs.push(syn::parse_quote! { #[builder(default)] }) } } }); } }); ast } fn main() -> Result<()> { // Rerun if the schema changes println!("cargo:rerun-if-changed=src/schema.json"); let path = Path::new("src/schema.json"); // Generate the Rust schema struct let json = std::fs::read_to_string(path).unwrap(); let schema: Schema = serde_json::from_str(&json)?; let path_str = path.to_str().unwrap(); let mut expander = Expander::new(Some("Sarif"), path_str, &schema); let generated = process_token_stream(expander.expand(&schema)); // Write the struct to the $OUT_DIR/sarif.rs file. let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let mut file = File::create(out_path.join("sarif.rs"))?; file.write_all(prettyplease::unparse(&generated).as_bytes())?; Ok(()) } serde-sarif-0.8.0/cliff.toml000064400000000000000000000063411046102023000140210ustar 00000000000000# git-cliff ~ default configuration file # https://git-cliff.org/docs/configuration # # Lines starting with "#" are comments. # Configuration options are organized into tables and keys. # See documentation for more information on available options. [changelog] # changelog header header = """ # Changelog\n """ # template for the changelog body # https://keats.github.io/tera/docs/#introduction body = """ {% if version %}\ ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} {% else %}\ ## [unreleased] {% endif %}\ {% for group, commits in commits | group_by(attribute="group") %} ### {{ group | striptags | trim | upper_first }} {% for commit in commits %} - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ {% if commit.breaking %}[**breaking**] {% endif %}\ {{ commit.message | upper_first }}\ {% endfor %} {% endfor %}\n """ # template for the changelog footer footer = """""" # remove the leading and trailing s trim = true # postprocessors postprocessors = [ # { pattern = '', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL ] [git] # parse the commits based on https://www.conventionalcommits.org conventional_commits = true # filter out the commits that are not conventional filter_unconventional = true # process each line of a commit as an individual commit split_commits = false # regex for preprocessing the commit messages commit_preprocessors = [ # Replace issue numbers #{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, # Check spelling of the commit with https://github.com/crate-ci/typos # If the spelling is incorrect, it will be automatically fixed. #{ pattern = '.*', replace_command = 'typos --write-changes -' }, ] # regex for parsing and grouping commits commit_parsers = [ { message = "^feat", group = "๐Ÿš€ Features" }, { message = "^fix", group = "๐Ÿ› Bug Fixes" }, { message = "^doc", group = "๐Ÿ“š Documentation" }, { message = "^perf", group = "โšก Performance" }, { message = "^refactor", group = "๐Ÿšœ Refactor" }, { message = "^style", group = "๐ŸŽจ Styling" }, { message = "^test", group = "๐Ÿงช Testing" }, { message = "^chore\\(release\\): prepare for", skip = true }, { message = "^chore\\(deps.*\\)", skip = true }, { message = "^chore\\(pr\\)", skip = true }, { message = "^chore\\(pull\\)", skip = true }, { message = "^chore|^ci", group = "โš™๏ธ Miscellaneous Tasks" }, { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, { message = "^revert", group = "โ—€๏ธ Revert" }, ] # protect breaking changes from being skipped due to matching a skipping commit_parser protect_breaking_commits = false # filter out the commits that are not matched by commit parsers filter_commits = true # regex for matching git tags tag_pattern = "serde-sarif-v[0-9].*" # regex for skipping tags # skip_tags = "" # regex for ignoring tags # ignore_tags = "" # sort the tags topologically topo_order = false # sort the commits inside sections by oldest/newest order sort_commits = "oldest" # limit the number of commits included in the changelog. # limit_commits = 42 serde-sarif-0.8.0/src/converters/cargo.rs000064400000000000000000000132571046102023000164670ustar 00000000000000use std::{ collections::HashMap, convert::From, io::{BufWriter, Write}, }; use crate::sarif::{self, Location}; use anyhow::Result; use cargo_metadata::{ self, diagnostic::{Diagnostic, DiagnosticLevel, DiagnosticSpan}, }; // TODO: refactor, add features, etc. impl From<&Diagnostic> for sarif::Message { fn from(diagnostic: &Diagnostic) -> Self { sarif::Message::builder().text(&diagnostic.message).build() } } impl From<&DiagnosticSpan> for sarif::ArtifactLocation { fn from(span: &DiagnosticSpan) -> Self { sarif::ArtifactLocation::builder() .uri(&span.file_name) .build() } } impl From<&DiagnosticSpan> for sarif::Region { fn from(span: &DiagnosticSpan) -> Self { sarif::Region::builder() .byte_offset(span.byte_start) .byte_length(span.byte_end - span.byte_start) .start_line(span.line_start as i64) .start_column(span.column_start as i64) .end_line(span.line_end as i64) .end_column(span.column_end as i64) .build() } } impl From<&DiagnosticLevel> for sarif::ResultLevel { fn from(level: &DiagnosticLevel) -> Self { match level { DiagnosticLevel::Help | DiagnosticLevel::Note => sarif::ResultLevel::Note, DiagnosticLevel::Warning => sarif::ResultLevel::Warning, DiagnosticLevel::Error => sarif::ResultLevel::Error, _ => sarif::ResultLevel::None, } } } impl From<&DiagnosticSpan> for sarif::Location { fn from(span: &DiagnosticSpan) -> Self { let artifact_location = sarif::ArtifactLocation::from(span); let region = sarif::Region::from(span); let location = sarif::Location::builder().physical_location( sarif::PhysicalLocation::builder() .artifact_location(artifact_location) .region(region) .build(), ); if let Some(label) = span.label.as_ref() { location .message(sarif::Message::builder().text(label).build()) .build() } else { location.build() } } } // recursively visits all diagnostic children which are non-local (have no span) // to build up diagnostic text. fn build_global_message( diagnostic: &Diagnostic, writer: &mut BufWriter, ) -> Result<()> { // if span exists, this message is local to a span, so skip it if diagnostic.spans.is_empty() { writeln!(writer, "{}", diagnostic.message)?; } diagnostic .children .iter() .try_for_each(|diagnostic| build_global_message(diagnostic, writer)) } /// Collects all the locations in the diagnostic's children spans fn get_related_locations( diagnostic: &Diagnostic, ) -> Result, anyhow::Error> { let mut related_locations = vec![]; for child in &diagnostic.children { let mut message = child.message.clone(); for child_span in &child.spans { let mut child_loc: Location = child_span.into(); if child_span.suggested_replacement.is_some() { let replacement = child_span.suggested_replacement.as_ref().unwrap(); message.push_str(&format!(" \"{replacement}\"")); } child_loc.message = Some(sarif::Message::from(&message)); related_locations.push(child_loc); } } Ok(related_locations) } pub(crate) fn process>( mut diagnostic_iter: I, tool_name: &str, tool_info_uri: &str, ) -> Result { let mut results = vec![]; let mut map = HashMap::new(); let mut rules = vec![]; let re = regex::Regex::new(r"^for further information visit (?P\S+)").unwrap(); diagnostic_iter.try_for_each(|diagnostic| -> Result<()> { diagnostic.spans.iter().try_for_each(|span| -> Result<()> { let diagnostic_code = match &diagnostic.code { Some(diagnostic_code) => diagnostic_code.code.clone(), _ => String::new(), }; if !map.contains_key(&diagnostic_code) { let mut writer = BufWriter::new(Vec::new()); build_global_message(&diagnostic, &mut writer)?; map.insert(diagnostic_code.clone(), map.len() as i64); let rule = sarif::ReportingDescriptor::builder() .id(&diagnostic_code) .full_description(&String::from_utf8(writer.into_inner()?)?); // help_uri is contained in a child diagnostic with a diagnostic level == help // search for the relevant child diagnostic, then extract the uri from the message let help_uri = diagnostic .children .iter() .find(|child| matches!(child.level, DiagnosticLevel::Help)) .and_then(|help| { re.captures(&help.message) .and_then(|captures| captures.name("url")) .map(|re_match| re_match.as_str()) }); let rule = if let Some(help_uri) = help_uri { rule.help_uri(help_uri).build() } else { rule.build() }; rules.push(rule); } if let Some(value) = map.get(&diagnostic_code) { let level: sarif::ResultLevel = (&diagnostic.level).into(); results.push( sarif::Result::builder() .rule_id(diagnostic_code) .rule_index(*value) .message(&diagnostic) .locations(vec![span.into()]) .level(level) .related_locations(get_related_locations(&diagnostic)?) .build(), ); } Ok(()) })?; Ok(()) })?; let tool_component: sarif::ToolComponent = sarif::ToolComponent::builder() .name(tool_name) .information_uri(tool_info_uri) .rules(rules) .build(); let run = sarif::Run::builder() .tool(tool_component) .results(results) .build(); let sarif = sarif::Sarif::builder() .version(sarif::Version::V2_1_0.to_string()) .schema(sarif::SCHEMA_URL) .runs(vec![run]) .build(); Ok(sarif) } serde-sarif-0.8.0/src/converters/clang_tidy.rs000064400000000000000000000136321046102023000175060ustar 00000000000000use crate::sarif::{self}; use anyhow::Result; use once_cell::sync::Lazy; use regex::Regex; use serde::{Deserialize, Serialize}; use std::convert::TryFrom; use std::convert::TryInto; use std::io::{BufRead, Write}; use std::str::FromStr; use typed_builder::TypedBuilder; #[derive(Clone, PartialEq, Debug, Deserialize, Serialize, TypedBuilder)] #[builder(field_defaults(setter(into)))] struct ClangTidyResult { #[builder(setter(strip_option), default)] pub file: Option, #[builder(setter(strip_option), default)] pub line: Option, #[builder(setter(strip_option), default)] pub column: Option, pub level: String, pub message: String, pub rules: String, } impl TryFrom<&ClangTidyResult> for sarif::ArtifactLocation { type Error = sarif::BuilderError; fn try_from(result: &ClangTidyResult) -> Result { result .file .as_ref() .ok_or(sarif::BuilderError::UninitializedField("file")) .map(|uri| sarif::ArtifactLocation::builder().uri(uri).build()) } } impl TryFrom<&ClangTidyResult> for sarif::Region { type Error = sarif::BuilderError; fn try_from(result: &ClangTidyResult) -> Result { let start_line = result .line .ok_or(sarif::BuilderError::UninitializedField("line"))?; let start_column = result .column .ok_or(sarif::BuilderError::UninitializedField("column"))?; Ok( sarif::Region::builder() .start_line(start_line) .start_column(start_column) .build(), ) } } impl TryFrom<&ClangTidyResult> for sarif::Location { type Error = sarif::BuilderError; fn try_from(result: &ClangTidyResult) -> Result { let artifact_location = sarif::ArtifactLocation::try_from(result)?; let region = sarif::Region::try_from(result)?; let location = sarif::Location::builder().physical_location( sarif::PhysicalLocation::builder() .artifact_location(artifact_location) .region(region) .build(), ); // Notes are converted to 'location' items with the message stored along with the location. // For other types of items (error, warning, info), the message will be stored inside the // 'result', so we skip it here. Ok(if result.level == "note" { location.message(&result.message).build() } else { location.build() }) } } fn parse_clang_tidy_line( line: Result, ) -> Option { static RE: Lazy = Lazy::new(|| { Regex::new( r"^(?P([a-zA-Z]:|)[\w/\.\- \\]+):(?P\d+):(?P\d+):\s+(?Perror|warning|info|note):\s+(?P.+?)(?:\s+\[(?P[^\]]+)\])?$" ).unwrap() }); let line = line.unwrap(); let caps = RE.captures(&line); if let Some(caps) = caps { if let Some(message) = caps.name("message") { return Some(ClangTidyResult { file: caps.name("file").map(|f| f.as_str().into()), line: caps .name("line") .and_then(|f| f.as_str().parse::().ok()), column: caps .name("column") .and_then(|f| f.as_str().parse::().ok()), level: caps .name("level") .map_or_else(|| "info".into(), |f| f.as_str().into()), message: message.as_str().into(), rules: caps .name("rules") .map_or_else(|| "".into(), |f| f.as_str().into()), }); } } None } fn process(reader: R) -> Result { let mut results = vec![]; // Create an iterator over all the ClangTidyResult items let mut clang_tidy_result_iter = reader.lines().filter_map(parse_clang_tidy_line).peekable(); while let Some(result) = clang_tidy_result_iter.next() { // The first check alias is used as the ruleId for the result let rule_id = result.rules.split(',').next().unwrap_or_default(); let location: sarif::Location = (&result).try_into()?; let mut related_locations = vec![]; // Since clang-tidy emits "note" items which have to be folded into // the previous error/warning/info items, look ahead at the next items // and collect all the "notes". while let Some(next_result) = clang_tidy_result_iter.peek() { match next_result.level.as_str() { "note" => { let note_location: sarif::Location = (next_result).try_into()?; related_locations.push(note_location); // Since we got the next result via .peek(), advance the iterator clang_tidy_result_iter.next(); } _ => { // Not a note, back to the outer loop break; } } } let builder = sarif::Result::builder() .rule_id(rule_id) .message(&result.message) .locations(vec![location]) .level(sarif::ResultLevel::from_str(&result.level)?); let result = if !related_locations.is_empty() { builder.related_locations(related_locations).build() } else { builder.build() }; results.push(result); } let tool_component: sarif::ToolComponent = sarif::ToolComponent::builder().name("clang-tidy").build(); let run = sarif::Run::builder() .tool(tool_component) .results(results) .build(); let sarif = sarif::Sarif::builder() .version(sarif::Version::V2_1_0.to_string()) .runs(vec![run]) .build(); Ok(sarif) } /// Returns [sarif::Sarif] serialized into a JSON stream /// /// # Arguments /// /// * `reader` - A `BufRead` of cargo output /// * `writer` - A `Writer` to write the results to pub fn parse_to_writer( reader: R, writer: W, ) -> Result<()> { let sarif = process(reader)?; serde_json::to_writer_pretty(writer, &sarif)?; Ok(()) } /// Returns [sarif::Sarif] serialized into a JSON string /// /// # Arguments /// /// * `reader` - A `BufRead` of clang-tidy output pub fn parse_to_string(reader: R) -> Result { let sarif = process(reader)?; let json = serde_json::to_string_pretty(&sarif)?; Ok(json) } serde-sarif-0.8.0/src/converters/clippy.rs000064400000000000000000000021321046102023000166620ustar 00000000000000use std::io::{BufRead, Write}; use crate::sarif; use anyhow::Result; use cargo_metadata::{self, Message}; fn process(reader: R) -> Result { let iter = Message::parse_stream(reader) .filter_map(|r| r.ok()) .filter_map(|m| match m { Message::CompilerMessage(msg) => Some(msg.message), _ => None, }); super::cargo::process( iter, "clippy", "https://rust-lang.github.io/rust-clippy/", ) } /// Returns [sarif::Sarif] serialized into a JSON stream /// /// # Arguments /// /// * `reader` - A `BufRead` of cargo output /// * `writer` - A `Writer` to write the results to pub fn parse_to_writer( reader: R, writer: W, ) -> Result<()> { let sarif = process(reader)?; serde_json::to_writer_pretty(writer, &sarif)?; Ok(()) } /// Returns [sarif::Sarif] serialized into a JSON string /// /// # Arguments /// /// * `reader` - A `BufRead` of cargo clippy output pub fn parse_to_string(reader: R) -> Result { let sarif = process(reader)?; let json = serde_json::to_string_pretty(&sarif)?; Ok(json) } serde-sarif-0.8.0/src/converters/hadolint.rs000064400000000000000000000102751046102023000171730ustar 00000000000000use std::{ collections::HashMap, io::{BufRead, Write}, str::FromStr, }; use strum_macros::Display; use strum_macros::EnumString; use typed_builder::TypedBuilder; use crate::sarif::{self, ResultLevel}; use anyhow::Result; use serde::{Deserialize, Serialize}; #[derive(Clone, PartialEq, Debug, Deserialize, Serialize, TypedBuilder)] #[builder(field_defaults(setter(into)))] struct HadolintResult { file: String, line: i64, column: i64, level: String, code: String, message: String, } #[doc = "A value specifying the severity level of the result."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(untagged)] enum HadolintLevel { #[strum(serialize = "info")] Info, #[strum(serialize = "warning")] Warning, #[strum(serialize = "error")] Error, #[strum(serialize = "style")] Style, } impl From for sarif::ResultLevel { fn from(level: HadolintLevel) -> Self { match level { HadolintLevel::Info => ResultLevel::Note, HadolintLevel::Warning => ResultLevel::Warning, HadolintLevel::Error => ResultLevel::Error, HadolintLevel::Style => ResultLevel::Note, } } } impl From<&HadolintResult> for sarif::ArtifactLocation { fn from(result: &HadolintResult) -> Self { sarif::ArtifactLocation::builder().uri(&result.file).build() } } impl From<&HadolintResult> for sarif::Location { fn from(result: &HadolintResult) -> Self { let artifact_location = sarif::ArtifactLocation::from(result); let region = sarif::Region::from(result); sarif::Location::builder() .physical_location( sarif::PhysicalLocation::builder() .artifact_location(artifact_location) .region(region) .build(), ) .build() } } impl From<&HadolintResult> for sarif::Region { fn from(result: &HadolintResult) -> Self { sarif::Region::builder() .start_line(result.line) .start_column(result.column) .build() } } fn process(mut reader: R) -> Result { let mut data = String::new(); reader.read_to_string(&mut data)?; let mut results = vec![]; let mut map = HashMap::new(); let mut rules = vec![]; let hadolint_results: Vec = serde_json::from_str(&data)?; hadolint_results .iter() .try_for_each(|result| -> Result<()> { if !map.contains_key(&result.code) { map.insert(result.code.clone(), map.len() as i64); rules.push( sarif::ReportingDescriptor::builder() .id(result.code.clone()) .name(result.code.clone()) .short_description(&result.code) .full_description(&format!( "For more information: https://github.com/hadolint/hadolint/wiki/{}", result.code )) .build(), ); } if let Some(value) = map.get(&result.code) { let level: sarif::ResultLevel = HadolintLevel::from_str(&result.level)?.into(); results.push( sarif::Result::builder() .rule_id(result.code.clone()) .rule_index(*value) .message(&result.message) .locations(vec![result.into()]) .level(level) .build(), ); } Ok(()) })?; let tool_component = sarif::ToolComponent::builder() .name("hadolint") .rules(rules) .build(); let run = sarif::Run::builder() .tool(tool_component) .results(results) .build(); Ok( sarif::Sarif::builder() .version(sarif::Version::V2_1_0.to_string()) .runs(vec![run]) .build(), ) } /// Returns [sarif::Sarif] serialized into a JSON stream /// /// # Arguments /// /// * `reader` - A `BufRead` of cargo output /// * `writer` - A `Writer` to write the results to pub fn parse_to_writer( reader: R, writer: W, ) -> Result<()> { let sarif = process(reader)?; serde_json::to_writer_pretty(writer, &sarif)?; Ok(()) } /// Returns [sarif::Sarif] serialized into a JSON string /// /// # Arguments /// /// * `reader` - A `BufRead` of hadolint output pub fn parse_to_string(reader: R) -> Result { let sarif = process(reader)?; let json = serde_json::to_string_pretty(&sarif)?; Ok(json) } serde-sarif-0.8.0/src/converters/miri.rs000064400000000000000000000032651046102023000163320ustar 00000000000000use std::io::{BufRead, Write}; use crate::sarif; use anyhow::Result; use cargo_metadata::{self, diagnostic::Diagnostic}; use serde::Deserialize; struct DiagnosticIter { input: R, } impl Iterator for DiagnosticIter { type Item = std::io::Result>; fn next(&mut self) -> Option { let mut line = String::new(); self .input .read_line(&mut line) .map(|n| { if n == 0 { None } else { if line.ends_with('\n') { line.truncate(line.len() - 1); } let mut deserializer = serde_json::Deserializer::from_str(&line); deserializer.disable_recursion_limit(); Some(Diagnostic::deserialize(&mut deserializer).ok()) } }) .transpose() } } fn process(reader: R) -> Result { let stream = DiagnosticIter { input: reader }; let iter = stream.filter_map(|r| r.ok()).flatten(); super::cargo::process(iter, "miri", "https://github.com/rust-lang/miri") } /// Returns [sarif::Sarif] serialized into a JSON stream /// /// # Arguments /// /// * `reader` - A `BufRead` of cargo miri output /// * `writer` - A `Writer` to write the results to pub fn parse_to_writer( reader: R, writer: W, ) -> Result<()> { let sarif = process(reader)?; serde_json::to_writer_pretty(writer, &sarif)?; Ok(()) } /// Returns [sarif::Sarif] serialized into a JSON string /// /// # Arguments /// /// * `reader` - A `BufRead` of cargo miri output pub fn parse_to_string(reader: R) -> Result { let sarif = process(reader)?; let json = serde_json::to_string_pretty(&sarif)?; Ok(json) } serde-sarif-0.8.0/src/converters/mod.rs000064400000000000000000000012401046102023000161400ustar 00000000000000#[cfg(any(feature = "clippy-converters", feature = "miri-converters"))] mod cargo; #[cfg(feature = "clippy-converters")] #[cfg_attr(doc, doc(cfg(feature = "clippy-converters")))] pub mod clippy; #[cfg(feature = "miri-converters")] #[cfg_attr(doc, doc(cfg(feature = "miri-converters")))] pub mod miri; #[cfg(feature = "hadolint-converters")] #[cfg_attr(doc, doc(cfg(feature = "hadolint-converters")))] pub mod hadolint; #[cfg(feature = "shellcheck-converters")] #[cfg_attr(doc, doc(cfg(feature = "shellcheck-converters")))] pub mod shellcheck; #[cfg(feature = "clang-tidy-converters")] #[cfg_attr(doc, doc(cfg(feature = "clang-tidy-converters")))] pub mod clang_tidy; serde-sarif-0.8.0/src/converters/shellcheck.rs000064400000000000000000000163531046102023000175010ustar 00000000000000use std::{ collections::HashMap, io::{BufRead, Write}, str::FromStr, }; use strum_macros::Display; use strum_macros::EnumString; use typed_builder::TypedBuilder; use crate::sarif::{self, ResultLevel}; use anyhow::Result; use serde::{Deserialize, Serialize}; #[derive(Clone, PartialEq, Debug, Deserialize, Serialize, TypedBuilder)] #[builder(field_defaults(setter(into)))] struct ShellcheckResult { file: String, line: i64, #[serde(rename = "endLine")] end_line: i64, column: i64, #[serde(rename = "endColumn")] end_column: i64, level: String, code: i64, message: String, #[builder(setter(strip_option), default)] fix: Option, } #[derive(Clone, PartialEq, Debug, Deserialize, Serialize, TypedBuilder)] #[builder(field_defaults(setter(into)))] struct JSON1Format { #[builder(setter(transform = |i: impl IntoIterator>| i.into_iter().map(Into::into).collect()))] comments: Vec, } #[derive(Clone, PartialEq, Debug, Deserialize, Serialize, TypedBuilder)] #[builder(field_defaults(setter(into)))] struct ShellcheckFix { #[builder(setter(transform = |i: impl IntoIterator>| i.into_iter().map(Into::into).collect()))] replacements: Vec, } #[derive(Clone, PartialEq, Debug, Deserialize, Serialize, TypedBuilder)] #[builder(field_defaults(setter(into)))] struct ShellcheckReplacement { line: i64, #[serde(rename = "endLine")] end_line: i64, precedence: i64, #[serde(rename = "insertionPoint")] insertion_point: String, column: i64, replacement: String, #[serde(rename = "endColumn")] end_column: i64, } #[doc = "A value specifying the severity level of the result."] #[derive( Display, Debug, Serialize, Deserialize, EnumString, Copy, Clone, PartialEq, )] #[serde(untagged)] enum ShellcheckLevel { #[strum(serialize = "info")] Info, #[strum(serialize = "warning")] Warning, #[strum(serialize = "error")] Error, #[strum(serialize = "style")] Style, } impl From for sarif::ResultLevel { fn from(level: ShellcheckLevel) -> Self { match level { ShellcheckLevel::Info => ResultLevel::Note, ShellcheckLevel::Warning => ResultLevel::Warning, ShellcheckLevel::Error => ResultLevel::Error, ShellcheckLevel::Style => ResultLevel::Note, } } } impl From<&ShellcheckResult> for sarif::ArtifactLocation { fn from(result: &ShellcheckResult) -> Self { sarif::ArtifactLocation::builder().uri(&result.file).build() } } impl From<&ShellcheckResult> for sarif::Location { fn from(result: &ShellcheckResult) -> Self { let artifact_location = sarif::ArtifactLocation::from(result); let region = sarif::Region::from(result); sarif::Location::builder() .physical_location( sarif::PhysicalLocation::builder() .artifact_location(artifact_location) .region(region) .build(), ) .build() } } impl From<&ShellcheckReplacement> for sarif::Region { fn from(replacement: &ShellcheckReplacement) -> Self { sarif::Region::builder() .start_line(replacement.line) .start_column(replacement.column) .end_line(replacement.end_line) .end_column(replacement.end_column) .build() } } impl From<&ShellcheckResult> for sarif::Region { fn from(result: &ShellcheckResult) -> Self { sarif::Region::builder() .start_line(result.line) .start_column(result.column) .end_line(result.end_line) .end_column(result.end_column) .build() } } fn process(mut reader: R, format: String) -> Result { let mut data = String::new(); reader.read_to_string(&mut data)?; let mut results = vec![]; let mut map = HashMap::new(); let mut rules = vec![]; let shellcheck_results: Vec = if format != "json1" { serde_json::from_str(&data)? } else { let json1_format: JSON1Format = serde_json::from_str(&data)?; json1_format.comments }; shellcheck_results .iter() .try_for_each(|result| -> Result<()> { #[allow(clippy::map_entry)] if !map.contains_key(&result.code.to_string()) { map.insert(result.code.to_string(), map.len() as i64); rules.push( sarif::ReportingDescriptor::builder() .id(result.code.to_string()) .name(result.code.to_string()) .short_description(&format!("SC{}", result.code)) .help_uri(format!( "https://www.shellcheck.net/wiki/SC{}", result.code )) .full_description(&format!( "For more information: https://www.shellcheck.net/wiki/SC{}", result.code )) .build(), ); } if let Some(value) = map.get(&result.code.to_string()) { let level: sarif::ResultLevel = ShellcheckLevel::from_str(&result.level)?.into(); let fixes = if let Some(fix) = result.fix.as_ref() { fix .replacements .iter() .map(|fix| { sarif::Fix::builder().description(&fix.replacement).build() }) // .filter_map(|v| v.ok()) .collect() } else { vec![] }; let related_locations = if let Some(fix) = result.fix.as_ref() { fix .replacements .iter() .map(|replacement| { sarif::Location::builder() .physical_location( sarif::PhysicalLocation::builder() .artifact_location(result) .region(replacement) .build(), ) .build() }) .collect() } else { vec![] }; results.push( sarif::Result::builder() .rule_id(result.code.to_string()) .rule_index(*value) .message(&result.message) .locations(vec![result.into()]) .related_locations(related_locations) .fixes(fixes) .level(level) .build(), ); } Ok(()) })?; let tool_component: sarif::ToolComponent = sarif::ToolComponent::builder() .name("shellcheck") .rules(rules) .build(); let run = sarif::Run::builder() .tool(tool_component) .results(results) .build(); Ok( sarif::Sarif::builder() .version(sarif::Version::V2_1_0.to_string()) .runs(vec![run]) .build(), ) } /// Returns [sarif::Sarif] serialized into a JSON stream /// /// # Arguments /// /// * `reader` - A `BufRead` of cargo output /// * `writer` - A `Writer` to write the results to /// * `format` - The format of the input pub fn parse_to_writer( reader: R, writer: W, format: String, ) -> Result<()> { let sarif = process(reader, format)?; serde_json::to_writer_pretty(writer, &sarif)?; Ok(()) } /// Returns [sarif::Sarif] serialized into a JSON string /// /// # Arguments /// /// * `reader` - A `BufRead` of shellcheck output /// * `format` - The format of the input pub fn parse_to_string( reader: R, format: String, ) -> Result { let sarif = process(reader, format)?; let json = serde_json::to_string_pretty(&sarif)?; Ok(json) } serde-sarif-0.8.0/src/lib.rs000064400000000000000000000052641046102023000137470ustar 00000000000000#![doc(html_root_url = "https://docs.rs/serde-sarif/0.8.0")] //! This crate provides a type safe [serde](https://serde.rs/) compatible //! [SARIF](https://sarifweb.azurewebsites.net/) 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](https://docs.rs/serde_sarif). //! //! serde is a popular serialization framework for Rust. More information can be //! found on the official repository: [https://github.com/serde-rs/serde](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/](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 //! //!```rust //! 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 construct these structs. Each //! structure has a builder with a default. //! //! ## Example //! //! ```rust //! use serde_sarif::sarif::Message; //! //! let message = Message::default() //! .id("id") //! .build(); //! ``` //! //! This uses [`TypedBuilder`](typed_builder::TypedBuilder) //! for compile time type checking. //! //! ## 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 depending on your //! use case. //! //! ### Example //! //! ```toml //! [dependencies] //! serde-sarif = { version = "*", features = ["clippy-converters"] } //! ``` //! //! ### Converters //! - **clang-tidy-converters** Provides conversions between clang tidy and SARIF types //! - **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 //! //! ### Other //! //! - **opt-builder** Enables //! [`TypedBuilder`](typed_builder::TypedBuilder) //! fallback setters for easier conditional building pub mod converters; pub mod sarif; serde-sarif-0.8.0/src/sarif.rs000064400000000000000000000155671046102023000143140ustar 00000000000000#![allow(clippy::derive_partial_eq_without_eq)] use strum_macros::Display; use strum_macros::EnumString; use thiserror::Error; include!(concat!(env!("OUT_DIR"), "/sarif.rs")); #[doc = "The SARIF format version of this log file."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] pub enum Version { #[strum(serialize = "2.1.0")] #[serde(rename = "2.1.0")] V2_1_0, } // todo: should be generated / synced with schema.json pub static SCHEMA_URL: &str = "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json"; #[doc = "The role or roles played by the artifact in the analysis."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum ArtifactRoles { AnalysisTarget, Attachment, ResponseFile, ResultFile, StandardStream, TracedFile, Unmodified, Modified, Added, Deleted, Renamed, Uncontrolled, Driver, Extension, Translation, Taxonomy, Policy, ReferencedOnCommandLine, MemoryContents, Directory, UserSpecifiedConfiguration, ToolSpecifiedConfiguration, DebugOutputFile, } #[doc = "The SARIF format version of this external properties object."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] pub enum ExternalPropertiesVersion { #[strum(serialize = "2.1.0")] #[serde(rename = "2.1.0")] V2_1_0, } #[doc = "A value specifying the severity level of the result."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum NotificationLevel { None, Note, Warning, Error, } #[doc = "Specifies the failure level for the report."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum ReportingConfigurationLevel { None, Note, Warning, Error, } #[doc = "A value that categorizes results by evaluation state."] #[derive( Clone, Display, Debug, Serialize, Deserialize, EnumString, PartialEq, )] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum ResultKind { NotApplicable, Pass, Fail, Review, Open, Informational, } #[doc = "A value specifying the severity level of the result."] #[derive( Clone, Copy, Display, Debug, Serialize, Deserialize, EnumString, PartialEq, )] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum ResultLevel { None, Note, Warning, Error, } #[doc = "The state of a result relative to a baseline of a previous run."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum ResultBaselineState { New, Unchanged, Updated, Absent, } #[doc = "Specifies the unit in which the tool measures columns."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum ResultColumnKind { Utf16CodeUnits, UnicodeCodePoints, } #[doc = "A string that indicates where the suppression is persisted."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum SupressionKind { InSource, External, } #[doc = "A string that indicates the review status of the suppression."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum SupressionStatus { Accepted, UnderReview, } #[doc = "Specifies the importance of this location in understanding the code flow in which it occurs. The order from most to least important is \"essential\", \"important\", \"unimportant\". Default: \"important\"."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum ThreadFlowLocationImportance { Important, Essential, } #[doc = "The kinds of data contained in this object."] #[derive(Display, Debug, Serialize, Deserialize, EnumString)] #[serde(rename_all = "camelCase")] #[strum(serialize_all = "camelCase")] pub enum ToolComponentContents { LocalizedData, NonLocalizedData, } #[derive(Error, Debug)] pub enum BuilderError { #[error("uninitialized field: {0}")] UninitializedField(&'static str), } // Note that due to the blanket implementation in core, TryFrom> // results in a compiler error. // https://github.com/rust-lang/rust/issues/50133 impl From<&String> for MultiformatMessageString { fn from(message: &String) -> Self { MultiformatMessageString::builder() .text(message.clone()) .build() } } impl From<&String> for Message { fn from(message: &String) -> Self { Message::builder().text(message.clone()).build() } } impl From<&str> for Message { fn from(message: &str) -> Self { Message::builder().text(message).build() } } impl From for Tool { fn from(tool_component: ToolComponent) -> Self { Tool::builder().driver(tool_component).build() } } #[cfg(test)] mod tests { use std::str::FromStr; use super::*; macro_rules! map { ($( $key: expr => $val: expr ),*) => {{ let mut map = ::std::collections::BTreeMap::new(); $( map.insert($key, serde_json::json!($val)); )* map }} } #[test] fn test_serialize_property_bag_empty() { let property_bag = PropertyBag::builder().build(); let json = serde_json::to_string_pretty(&property_bag).unwrap(); let json_expected = r#"{}"#; assert_eq!(json, json_expected); } #[test] fn test_serialize_property_bag_additional_properties() { let property_bag = PropertyBag::builder() .additional_properties(map!["key1".to_string() => "value1"]) .build(); let json = serde_json::to_string_pretty(&property_bag).unwrap(); let json_expected = r#"{ "key1": "value1" }"#; assert_eq!(json, json_expected); } #[test] fn test_deserialize_property_bag_empty() { let json = r#"{}"#; let property_bag: PropertyBag = serde_json::from_str(json).unwrap(); let property_bag_expected = PropertyBag::builder().build(); assert_eq!(property_bag, property_bag_expected); } #[test] fn test_deserialize_property_bag_additional_properties() { let json = r#"{ "key1": "value1" }"#; let property_bag: PropertyBag = serde_json::from_str(json).unwrap(); let property_bag_expected = PropertyBag::builder() .additional_properties(map!["key1".to_string() => "value1"]) .build(); assert_eq!(property_bag, property_bag_expected); } #[test] fn test_serialize_resultkind() { assert_eq!( serde_json::to_string(&ResultKind::Fail).unwrap(), "\"fail\"" ); } #[test] fn test_parse_utf16codeunits() { let v = ResultColumnKind::from_str("utf16CodeUnits").unwrap(); assert!(matches!(v, ResultColumnKind::Utf16CodeUnits)); } } serde-sarif-0.8.0/src/schema.json000064400000000000000000003325321046102023000147670ustar 00000000000000{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Static Analysis Results Format (SARIF) Version 2.1.0 JSON Schema", "$id": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", "description": "Static Analysis Results Format (SARIF) Version 2.1.0 JSON Schema: a standard format for the output of static analysis tools.", "additionalProperties": false, "type": "object", "properties": { "$schema": { "description": "The URI of the JSON schema corresponding to the version.", "type": "string", "format": "uri" }, "version": { "description": "The SARIF format version of this log file.", "enum": ["2.1.0"] }, "runs": { "description": "The set of runs contained in this log file.", "type": "array", "minItems": 0, "uniqueItems": false, "items": { "$ref": "#/definitions/run" } }, "inlineExternalProperties": { "description": "References to external property files that share data between runs.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/externalProperties" } }, "properties": { "description": "Key/value pairs that provide additional information about the log file.", "$ref": "#/definitions/propertyBag" } }, "required": ["version", "runs"], "definitions": { "address": { "description": "A physical or virtual address, or a range of addresses, in an 'addressable region' (memory or a binary file).", "additionalProperties": false, "type": "object", "properties": { "absoluteAddress": { "description": "The address expressed as a byte offset from the start of the addressable region.", "type": "integer", "minimum": -1, "default": -1 }, "relativeAddress": { "description": "The address expressed as a byte offset from the absolute address of the top-most parent object.", "type": "integer" }, "length": { "description": "The number of bytes in this range of addresses.", "type": "integer" }, "kind": { "description": "An open-ended string that identifies the address kind. 'data', 'function', 'header','instruction', 'module', 'page', 'section', 'segment', 'stack', 'stackFrame', 'table' are well-known values.", "type": "string" }, "name": { "description": "A name that is associated with the address, e.g., '.text'.", "type": "string" }, "fullyQualifiedName": { "description": "A human-readable fully qualified name that is associated with the address.", "type": "string" }, "offsetFromParent": { "description": "The byte offset of this address from the absolute or relative address of the parent object.", "type": "integer" }, "index": { "description": "The index within run.addresses of the cached object for this address.", "type": "integer", "default": -1, "minimum": -1 }, "parentIndex": { "description": "The index within run.addresses of the parent object.", "type": "integer", "default": -1, "minimum": -1 }, "properties": { "description": "Key/value pairs that provide additional information about the address.", "$ref": "#/definitions/propertyBag" } } }, "artifact": { "description": "A single artifact. In some cases, this artifact might be nested within another artifact.", "additionalProperties": false, "type": "object", "properties": { "description": { "description": "A short description of the artifact.", "$ref": "#/definitions/message" }, "location": { "description": "The location of the artifact.", "$ref": "#/definitions/artifactLocation" }, "parentIndex": { "description": "Identifies the index of the immediate parent of the artifact, if this artifact is nested.", "type": "integer", "default": -1, "minimum": -1 }, "offset": { "description": "The offset in bytes of the artifact within its containing artifact.", "type": "integer", "minimum": 0 }, "length": { "description": "The length of the artifact in bytes.", "type": "integer", "default": -1, "minimum": -1 }, "roles": { "description": "The role or roles played by the artifact in the analysis.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "enum": [ "analysisTarget", "attachment", "responseFile", "resultFile", "standardStream", "tracedFile", "unmodified", "modified", "added", "deleted", "renamed", "uncontrolled", "driver", "extension", "translation", "taxonomy", "policy", "referencedOnCommandLine", "memoryContents", "directory", "userSpecifiedConfiguration", "toolSpecifiedConfiguration", "debugOutputFile" ] } }, "mimeType": { "description": "The MIME type (RFC 2045) of the artifact.", "type": "string", "pattern": "[^/]+/.+" }, "contents": { "description": "The contents of the artifact.", "$ref": "#/definitions/artifactContent" }, "encoding": { "description": "Specifies the encoding for an artifact object that refers to a text file.", "type": "string" }, "sourceLanguage": { "description": "Specifies the source language for any artifact object that refers to a text file that contains source code.", "type": "string" }, "hashes": { "description": "A dictionary, each of whose keys is the name of a hash function and each of whose values is the hashed value of the artifact produced by the specified hash function.", "type": "object", "additionalProperties": { "type": "string" } }, "lastModifiedTimeUtc": { "description": "The Coordinated Universal Time (UTC) date and time at which the artifact was most recently modified. See \"Date/time properties\" in the SARIF spec for the required format.", "type": "string", "format": "date-time" }, "properties": { "description": "Key/value pairs that provide additional information about the artifact.", "$ref": "#/definitions/propertyBag" } } }, "artifactChange": { "description": "A change to a single artifact.", "additionalProperties": false, "type": "object", "properties": { "artifactLocation": { "description": "The location of the artifact to change.", "$ref": "#/definitions/artifactLocation" }, "replacements": { "description": "An array of replacement objects, each of which represents the replacement of a single region in a single artifact specified by 'artifactLocation'.", "type": "array", "minItems": 1, "uniqueItems": false, "items": { "$ref": "#/definitions/replacement" } }, "properties": { "description": "Key/value pairs that provide additional information about the change.", "$ref": "#/definitions/propertyBag" } }, "required": ["artifactLocation", "replacements"] }, "artifactContent": { "description": "Represents the contents of an artifact.", "type": "object", "additionalProperties": false, "properties": { "text": { "description": "UTF-8-encoded content from a text artifact.", "type": "string" }, "binary": { "description": "MIME Base64-encoded content from a binary artifact, or from a text artifact in its original encoding.", "type": "string" }, "rendered": { "description": "An alternate rendered representation of the artifact (e.g., a decompiled representation of a binary region).", "$ref": "#/definitions/multiformatMessageString" }, "properties": { "description": "Key/value pairs that provide additional information about the artifact content.", "$ref": "#/definitions/propertyBag" } } }, "artifactLocation": { "description": "Specifies the location of an artifact.", "additionalProperties": false, "type": "object", "properties": { "uri": { "description": "A string containing a valid relative or absolute URI.", "type": "string", "format": "uri-reference" }, "uriBaseId": { "description": "A string which indirectly specifies the absolute URI with respect to which a relative URI in the \"uri\" property is interpreted.", "type": "string" }, "index": { "description": "The index within the run artifacts array of the artifact object associated with the artifact location.", "type": "integer", "default": -1, "minimum": -1 }, "description": { "description": "A short description of the artifact location.", "$ref": "#/definitions/message" }, "properties": { "description": "Key/value pairs that provide additional information about the artifact location.", "$ref": "#/definitions/propertyBag" } } }, "attachment": { "description": "An artifact relevant to a result.", "type": "object", "additionalProperties": false, "properties": { "description": { "description": "A message describing the role played by the attachment.", "$ref": "#/definitions/message" }, "artifactLocation": { "description": "The location of the attachment.", "$ref": "#/definitions/artifactLocation" }, "regions": { "description": "An array of regions of interest within the attachment.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/region" } }, "rectangles": { "description": "An array of rectangles specifying areas of interest within the image.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/rectangle" } }, "properties": { "description": "Key/value pairs that provide additional information about the attachment.", "$ref": "#/definitions/propertyBag" } }, "required": ["artifactLocation"] }, "codeFlow": { "description": "A set of threadFlows which together describe a pattern of code execution relevant to detecting a result.", "additionalProperties": false, "type": "object", "properties": { "message": { "description": "A message relevant to the code flow.", "$ref": "#/definitions/message" }, "threadFlows": { "description": "An array of one or more unique threadFlow objects, each of which describes the progress of a program through a thread of execution.", "type": "array", "minItems": 1, "uniqueItems": false, "items": { "$ref": "#/definitions/threadFlow" } }, "properties": { "description": "Key/value pairs that provide additional information about the code flow.", "$ref": "#/definitions/propertyBag" } }, "required": ["threadFlows"] }, "configurationOverride": { "description": "Information about how a specific rule or notification was reconfigured at runtime.", "type": "object", "additionalProperties": false, "properties": { "configuration": { "description": "Specifies how the rule or notification was configured during the scan.", "$ref": "#/definitions/reportingConfiguration" }, "descriptor": { "description": "A reference used to locate the descriptor whose configuration was overridden.", "$ref": "#/definitions/reportingDescriptorReference" }, "properties": { "description": "Key/value pairs that provide additional information about the configuration override.", "$ref": "#/definitions/propertyBag" } }, "required": ["configuration", "descriptor"] }, "conversion": { "description": "Describes how a converter transformed the output of a static analysis tool from the analysis tool's native output format into the SARIF format.", "additionalProperties": false, "type": "object", "properties": { "tool": { "description": "A tool object that describes the converter.", "$ref": "#/definitions/tool" }, "invocation": { "description": "An invocation object that describes the invocation of the converter.", "$ref": "#/definitions/invocation" }, "analysisToolLogFiles": { "description": "The locations of the analysis tool's per-run log files.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/artifactLocation" } }, "properties": { "description": "Key/value pairs that provide additional information about the conversion.", "$ref": "#/definitions/propertyBag" } }, "required": ["tool"] }, "edge": { "description": "Represents a directed edge in a graph.", "type": "object", "additionalProperties": false, "properties": { "id": { "description": "A string that uniquely identifies the edge within its graph.", "type": "string" }, "label": { "description": "A short description of the edge.", "$ref": "#/definitions/message" }, "sourceNodeId": { "description": "Identifies the source node (the node at which the edge starts).", "type": "string" }, "targetNodeId": { "description": "Identifies the target node (the node at which the edge ends).", "type": "string" }, "properties": { "description": "Key/value pairs that provide additional information about the edge.", "$ref": "#/definitions/propertyBag" } }, "required": ["id", "sourceNodeId", "targetNodeId"] }, "edgeTraversal": { "description": "Represents the traversal of a single edge during a graph traversal.", "type": "object", "additionalProperties": false, "properties": { "edgeId": { "description": "Identifies the edge being traversed.", "type": "string" }, "message": { "description": "A message to display to the user as the edge is traversed.", "$ref": "#/definitions/message" }, "finalState": { "description": "The values of relevant expressions after the edge has been traversed.", "type": "object", "additionalProperties": { "$ref": "#/definitions/multiformatMessageString" } }, "stepOverEdgeCount": { "description": "The number of edge traversals necessary to return from a nested graph.", "type": "integer", "minimum": 0 }, "properties": { "description": "Key/value pairs that provide additional information about the edge traversal.", "$ref": "#/definitions/propertyBag" } }, "required": ["edgeId"] }, "exception": { "description": "Describes a runtime exception encountered during the execution of an analysis tool.", "type": "object", "additionalProperties": false, "properties": { "kind": { "type": "string", "description": "A string that identifies the kind of exception, for example, the fully qualified type name of an object that was thrown, or the symbolic name of a signal." }, "message": { "description": "A message that describes the exception.", "type": "string" }, "stack": { "description": "The sequence of function calls leading to the exception.", "$ref": "#/definitions/stack" }, "innerExceptions": { "description": "An array of exception objects each of which is considered a cause of this exception.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/exception" } }, "properties": { "description": "Key/value pairs that provide additional information about the exception.", "$ref": "#/definitions/propertyBag" } } }, "externalProperties": { "description": "The top-level element of an external property file.", "type": "object", "additionalProperties": false, "properties": { "schema": { "description": "The URI of the JSON schema corresponding to the version of the external property file format.", "type": "string", "format": "uri" }, "version": { "description": "The SARIF format version of this external properties object.", "enum": ["2.1.0"] }, "guid": { "description": "A stable, unique identifier for this external properties object, in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "runGuid": { "description": "A stable, unique identifier for the run associated with this external properties object, in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "conversion": { "description": "A conversion object that will be merged with a separate run.", "$ref": "#/definitions/conversion" }, "graphs": { "description": "An array of graph objects that will be merged with a separate run.", "type": "array", "minItems": 0, "default": [], "uniqueItems": true, "items": { "$ref": "#/definitions/graph" } }, "externalizedProperties": { "description": "Key/value pairs that provide additional information that will be merged with a separate run.", "$ref": "#/definitions/propertyBag" }, "artifacts": { "description": "An array of artifact objects that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/artifact" } }, "invocations": { "description": "Describes the invocation of the analysis tool that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/invocation" } }, "logicalLocations": { "description": "An array of logical locations such as namespaces, types or functions that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/logicalLocation" } }, "threadFlowLocations": { "description": "An array of threadFlowLocation objects that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/threadFlowLocation" } }, "results": { "description": "An array of result objects that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/result" } }, "taxonomies": { "description": "Tool taxonomies that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponent" } }, "driver": { "description": "The analysis tool object that will be merged with a separate run.", "$ref": "#/definitions/toolComponent" }, "extensions": { "description": "Tool extensions that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponent" } }, "policies": { "description": "Tool policies that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponent" } }, "translations": { "description": "Tool translations that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponent" } }, "addresses": { "description": "Addresses that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/address" } }, "webRequests": { "description": "Requests that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/webRequest" } }, "webResponses": { "description": "Responses that will be merged with a separate run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/webResponse" } }, "properties": { "description": "Key/value pairs that provide additional information about the external properties.", "$ref": "#/definitions/propertyBag" } } }, "externalPropertyFileReference": { "description": "Contains information that enables a SARIF consumer to locate the external property file that contains the value of an externalized property associated with the run.", "type": "object", "additionalProperties": false, "properties": { "location": { "description": "The location of the external property file.", "$ref": "#/definitions/artifactLocation" }, "guid": { "description": "A stable, unique identifier for the external property file in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "itemCount": { "description": "A non-negative integer specifying the number of items contained in the external property file.", "type": "integer", "default": -1, "minimum": -1 }, "properties": { "description": "Key/value pairs that provide additional information about the external property file.", "$ref": "#/definitions/propertyBag" } }, "anyOf": [{ "required": ["location"] }, { "required": ["guid"] }] }, "externalPropertyFileReferences": { "description": "References to external property files that should be inlined with the content of a root log file.", "additionalProperties": false, "type": "object", "properties": { "conversion": { "description": "An external property file containing a run.conversion object to be merged with the root log file.", "$ref": "#/definitions/externalPropertyFileReference" }, "graphs": { "description": "An array of external property files containing a run.graphs object to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "externalizedProperties": { "description": "An external property file containing a run.properties object to be merged with the root log file.", "$ref": "#/definitions/externalPropertyFileReference" }, "artifacts": { "description": "An array of external property files containing run.artifacts arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "invocations": { "description": "An array of external property files containing run.invocations arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "logicalLocations": { "description": "An array of external property files containing run.logicalLocations arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "threadFlowLocations": { "description": "An array of external property files containing run.threadFlowLocations arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "results": { "description": "An array of external property files containing run.results arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "taxonomies": { "description": "An array of external property files containing run.taxonomies arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "addresses": { "description": "An array of external property files containing run.addresses arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "driver": { "description": "An external property file containing a run.driver object to be merged with the root log file.", "$ref": "#/definitions/externalPropertyFileReference" }, "extensions": { "description": "An array of external property files containing run.extensions arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "policies": { "description": "An array of external property files containing run.policies arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "translations": { "description": "An array of external property files containing run.translations arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "webRequests": { "description": "An array of external property files containing run.requests arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "webResponses": { "description": "An array of external property files containing run.responses arrays to be merged with the root log file.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } }, "properties": { "description": "Key/value pairs that provide additional information about the external property files.", "$ref": "#/definitions/propertyBag" } } }, "fix": { "description": "A proposed fix for the problem represented by a result object. A fix specifies a set of artifacts to modify. For each artifact, it specifies a set of bytes to remove, and provides a set of new bytes to replace them.", "additionalProperties": false, "type": "object", "properties": { "description": { "description": "A message that describes the proposed fix, enabling viewers to present the proposed change to an end user.", "$ref": "#/definitions/message" }, "artifactChanges": { "description": "One or more artifact changes that comprise a fix for a result.", "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/definitions/artifactChange" } }, "properties": { "description": "Key/value pairs that provide additional information about the fix.", "$ref": "#/definitions/propertyBag" } }, "required": ["artifactChanges"] }, "graph": { "description": "A network of nodes and directed edges that describes some aspect of the structure of the code (for example, a call graph).", "type": "object", "additionalProperties": false, "properties": { "description": { "description": "A description of the graph.", "$ref": "#/definitions/message" }, "nodes": { "description": "An array of node objects representing the nodes of the graph.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/node" } }, "edges": { "description": "An array of edge objects representing the edges of the graph.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/edge" } }, "properties": { "description": "Key/value pairs that provide additional information about the graph.", "$ref": "#/definitions/propertyBag" } } }, "graphTraversal": { "description": "Represents a path through a graph.", "type": "object", "additionalProperties": false, "properties": { "runGraphIndex": { "description": "The index within the run.graphs to be associated with the result.", "type": "integer", "default": -1, "minimum": -1 }, "resultGraphIndex": { "description": "The index within the result.graphs to be associated with the result.", "type": "integer", "default": -1, "minimum": -1 }, "description": { "description": "A description of this graph traversal.", "$ref": "#/definitions/message" }, "initialState": { "description": "Values of relevant expressions at the start of the graph traversal that may change during graph traversal.", "type": "object", "additionalProperties": { "$ref": "#/definitions/multiformatMessageString" } }, "immutableState": { "description": "Values of relevant expressions at the start of the graph traversal that remain constant for the graph traversal.", "type": "object", "additionalProperties": { "$ref": "#/definitions/multiformatMessageString" } }, "edgeTraversals": { "description": "The sequences of edges traversed by this graph traversal.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/edgeTraversal" } }, "properties": { "description": "Key/value pairs that provide additional information about the graph traversal.", "$ref": "#/definitions/propertyBag" } }, "oneOf": [ { "required": ["runGraphIndex"] }, { "required": ["resultGraphIndex"] } ] }, "invocation": { "description": "The runtime environment of the analysis tool run.", "additionalProperties": false, "type": "object", "properties": { "commandLine": { "description": "The command line used to invoke the tool.", "type": "string" }, "arguments": { "description": "An array of strings, containing in order the command line arguments passed to the tool from the operating system.", "type": "array", "minItems": 0, "uniqueItems": false, "items": { "type": "string" } }, "responseFiles": { "description": "The locations of any response files specified on the tool's command line.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/artifactLocation" } }, "startTimeUtc": { "description": "The Coordinated Universal Time (UTC) date and time at which the invocation started. See \"Date/time properties\" in the SARIF spec for the required format.", "type": "string", "format": "date-time" }, "endTimeUtc": { "description": "The Coordinated Universal Time (UTC) date and time at which the invocation ended. See \"Date/time properties\" in the SARIF spec for the required format.", "type": "string", "format": "date-time" }, "exitCode": { "description": "The process exit code.", "type": "integer" }, "ruleConfigurationOverrides": { "description": "An array of configurationOverride objects that describe rules related runtime overrides.", "type": "array", "minItems": 0, "default": [], "uniqueItems": true, "items": { "$ref": "#/definitions/configurationOverride" } }, "notificationConfigurationOverrides": { "description": "An array of configurationOverride objects that describe notifications related runtime overrides.", "type": "array", "minItems": 0, "default": [], "uniqueItems": true, "items": { "$ref": "#/definitions/configurationOverride" } }, "toolExecutionNotifications": { "description": "A list of runtime conditions detected by the tool during the analysis.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/notification" } }, "toolConfigurationNotifications": { "description": "A list of conditions detected by the tool that are relevant to the tool's configuration.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/notification" } }, "exitCodeDescription": { "description": "The reason for the process exit.", "type": "string" }, "exitSignalName": { "description": "The name of the signal that caused the process to exit.", "type": "string" }, "exitSignalNumber": { "description": "The numeric value of the signal that caused the process to exit.", "type": "integer" }, "processStartFailureMessage": { "description": "The reason given by the operating system that the process failed to start.", "type": "string" }, "executionSuccessful": { "description": "Specifies whether the tool's execution completed successfully.", "type": "boolean" }, "machine": { "description": "The machine on which the invocation occurred.", "type": "string" }, "account": { "description": "The account under which the invocation occurred.", "type": "string" }, "processId": { "description": "The id of the process in which the invocation occurred.", "type": "integer" }, "executableLocation": { "description": "An absolute URI specifying the location of the executable that was invoked.", "$ref": "#/definitions/artifactLocation" }, "workingDirectory": { "description": "The working directory for the invocation.", "$ref": "#/definitions/artifactLocation" }, "environmentVariables": { "description": "The environment variables associated with the analysis tool process, expressed as key/value pairs.", "type": "object", "additionalProperties": { "type": "string" } }, "stdin": { "description": "A file containing the standard input stream to the process that was invoked.", "$ref": "#/definitions/artifactLocation" }, "stdout": { "description": "A file containing the standard output stream from the process that was invoked.", "$ref": "#/definitions/artifactLocation" }, "stderr": { "description": "A file containing the standard error stream from the process that was invoked.", "$ref": "#/definitions/artifactLocation" }, "stdoutStderr": { "description": "A file containing the interleaved standard output and standard error stream from the process that was invoked.", "$ref": "#/definitions/artifactLocation" }, "properties": { "description": "Key/value pairs that provide additional information about the invocation.", "$ref": "#/definitions/propertyBag" } }, "required": ["executionSuccessful"] }, "location": { "description": "A location within a programming artifact.", "additionalProperties": false, "type": "object", "properties": { "id": { "description": "Value that distinguishes this location from all other locations within a single result object.", "type": "integer", "minimum": -1, "default": -1 }, "physicalLocation": { "description": "Identifies the artifact and region.", "$ref": "#/definitions/physicalLocation" }, "logicalLocations": { "description": "The logical locations associated with the result.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/logicalLocation" } }, "message": { "description": "A message relevant to the location.", "$ref": "#/definitions/message" }, "annotations": { "description": "A set of regions relevant to the location.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/region" } }, "relationships": { "description": "An array of objects that describe relationships between this location and others.", "type": "array", "default": [], "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/locationRelationship" } }, "properties": { "description": "Key/value pairs that provide additional information about the location.", "$ref": "#/definitions/propertyBag" } } }, "locationRelationship": { "description": "Information about the relation of one location to another.", "type": "object", "additionalProperties": false, "properties": { "target": { "description": "A reference to the related location.", "type": "integer", "minimum": 0 }, "kinds": { "description": "A set of distinct strings that categorize the relationship. Well-known kinds include 'includes', 'isIncludedBy' and 'relevant'.", "type": "array", "default": ["relevant"], "uniqueItems": true, "items": { "type": "string" } }, "description": { "description": "A description of the location relationship.", "$ref": "#/definitions/message" }, "properties": { "description": "Key/value pairs that provide additional information about the location relationship.", "$ref": "#/definitions/propertyBag" } }, "required": ["target"] }, "logicalLocation": { "description": "A logical location of a construct that produced a result.", "additionalProperties": false, "type": "object", "properties": { "name": { "description": "Identifies the construct in which the result occurred. For example, this property might contain the name of a class or a method.", "type": "string" }, "index": { "description": "The index within the logical locations array.", "type": "integer", "default": -1, "minimum": -1 }, "fullyQualifiedName": { "description": "The human-readable fully qualified name of the logical location.", "type": "string" }, "decoratedName": { "description": "The machine-readable name for the logical location, such as a mangled function name provided by a C++ compiler that encodes calling convention, return type and other details along with the function name.", "type": "string" }, "parentIndex": { "description": "Identifies the index of the immediate parent of the construct in which the result was detected. For example, this property might point to a logical location that represents the namespace that holds a type.", "type": "integer", "default": -1, "minimum": -1 }, "kind": { "description": "The type of construct this logical location component refers to. Should be one of 'function', 'member', 'module', 'namespace', 'parameter', 'resource', 'returnType', 'type', 'variable', 'object', 'array', 'property', 'value', 'element', 'text', 'attribute', 'comment', 'declaration', 'dtd' or 'processingInstruction', if any of those accurately describe the construct.", "type": "string" }, "properties": { "description": "Key/value pairs that provide additional information about the logical location.", "$ref": "#/definitions/propertyBag" } } }, "message": { "description": "Encapsulates a message intended to be read by the end user.", "type": "object", "additionalProperties": false, "properties": { "text": { "description": "A plain text message string.", "type": "string" }, "markdown": { "description": "A Markdown message string.", "type": "string" }, "id": { "description": "The identifier for this message.", "type": "string" }, "arguments": { "description": "An array of strings to substitute into the message string.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "type": "string" } }, "properties": { "description": "Key/value pairs that provide additional information about the message.", "$ref": "#/definitions/propertyBag" } }, "anyOf": [{ "required": ["text"] }, { "required": ["id"] }] }, "multiformatMessageString": { "description": "A message string or message format string rendered in multiple formats.", "type": "object", "additionalProperties": false, "properties": { "text": { "description": "A plain text message string or format string.", "type": "string" }, "markdown": { "description": "A Markdown message string or format string.", "type": "string" }, "properties": { "description": "Key/value pairs that provide additional information about the message.", "$ref": "#/definitions/propertyBag" } }, "required": ["text"] }, "node": { "description": "Represents a node in a graph.", "type": "object", "additionalProperties": false, "properties": { "id": { "description": "A string that uniquely identifies the node within its graph.", "type": "string" }, "label": { "description": "A short description of the node.", "$ref": "#/definitions/message" }, "location": { "description": "A code location associated with the node.", "$ref": "#/definitions/location" }, "children": { "description": "Array of child nodes.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/node" } }, "properties": { "description": "Key/value pairs that provide additional information about the node.", "$ref": "#/definitions/propertyBag" } }, "required": ["id"] }, "notification": { "description": "Describes a condition relevant to the tool itself, as opposed to being relevant to a target being analyzed by the tool.", "type": "object", "additionalProperties": false, "properties": { "locations": { "description": "The locations relevant to this notification.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/location" } }, "message": { "description": "A message that describes the condition that was encountered.", "$ref": "#/definitions/message" }, "level": { "description": "A value specifying the severity level of the notification.", "default": "warning", "enum": ["none", "note", "warning", "error"] }, "threadId": { "description": "The thread identifier of the code that generated the notification.", "type": "integer" }, "timeUtc": { "description": "The Coordinated Universal Time (UTC) date and time at which the analysis tool generated the notification.", "type": "string", "format": "date-time" }, "exception": { "description": "The runtime exception, if any, relevant to this notification.", "$ref": "#/definitions/exception" }, "descriptor": { "description": "A reference used to locate the descriptor relevant to this notification.", "$ref": "#/definitions/reportingDescriptorReference" }, "associatedRule": { "description": "A reference used to locate the rule descriptor associated with this notification.", "$ref": "#/definitions/reportingDescriptorReference" }, "properties": { "description": "Key/value pairs that provide additional information about the notification.", "$ref": "#/definitions/propertyBag" } }, "required": ["message"] }, "physicalLocation": { "description": "A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of bytes or characters within that artifact.", "additionalProperties": false, "type": "object", "properties": { "address": { "description": "The address of the location.", "$ref": "#/definitions/address" }, "artifactLocation": { "description": "The location of the artifact.", "$ref": "#/definitions/artifactLocation" }, "region": { "description": "Specifies a portion of the artifact.", "$ref": "#/definitions/region" }, "contextRegion": { "description": "Specifies a portion of the artifact that encloses the region. Allows a viewer to display additional context around the region.", "$ref": "#/definitions/region" }, "properties": { "description": "Key/value pairs that provide additional information about the physical location.", "$ref": "#/definitions/propertyBag" } }, "anyOf": [ { "required": ["address"] }, { "required": ["artifactLocation"] } ] }, "propertyBag": { "description": "Key/value pairs that provide additional information about the object.", "type": "object", "additionalProperties": true, "properties": { "tags": { "description": "A set of distinct strings that provide additional information.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "type": "string" } } } }, "rectangle": { "description": "An area within an image.", "additionalProperties": false, "type": "object", "properties": { "top": { "description": "The Y coordinate of the top edge of the rectangle, measured in the image's natural units.", "type": "number" }, "left": { "description": "The X coordinate of the left edge of the rectangle, measured in the image's natural units.", "type": "number" }, "bottom": { "description": "The Y coordinate of the bottom edge of the rectangle, measured in the image's natural units.", "type": "number" }, "right": { "description": "The X coordinate of the right edge of the rectangle, measured in the image's natural units.", "type": "number" }, "message": { "description": "A message relevant to the rectangle.", "$ref": "#/definitions/message" }, "properties": { "description": "Key/value pairs that provide additional information about the rectangle.", "$ref": "#/definitions/propertyBag" } } }, "region": { "description": "A region within an artifact where a result was detected.", "additionalProperties": false, "type": "object", "properties": { "startLine": { "description": "The line number of the first character in the region.", "type": "integer", "minimum": 1 }, "startColumn": { "description": "The column number of the first character in the region.", "type": "integer", "minimum": 1 }, "endLine": { "description": "The line number of the last character in the region.", "type": "integer", "minimum": 1 }, "endColumn": { "description": "The column number of the character following the end of the region.", "type": "integer", "minimum": 1 }, "charOffset": { "description": "The zero-based offset from the beginning of the artifact of the first character in the region.", "type": "integer", "default": -1, "minimum": -1 }, "charLength": { "description": "The length of the region in characters.", "type": "integer", "minimum": 0 }, "byteOffset": { "description": "The zero-based offset from the beginning of the artifact of the first byte in the region.", "type": "integer", "default": -1, "minimum": -1 }, "byteLength": { "description": "The length of the region in bytes.", "type": "integer", "minimum": 0 }, "snippet": { "description": "The portion of the artifact contents within the specified region.", "$ref": "#/definitions/artifactContent" }, "message": { "description": "A message relevant to the region.", "$ref": "#/definitions/message" }, "sourceLanguage": { "description": "Specifies the source language, if any, of the portion of the artifact specified by the region object.", "type": "string" }, "properties": { "description": "Key/value pairs that provide additional information about the region.", "$ref": "#/definitions/propertyBag" } } }, "replacement": { "description": "The replacement of a single region of an artifact.", "additionalProperties": false, "type": "object", "properties": { "deletedRegion": { "description": "The region of the artifact to delete.", "$ref": "#/definitions/region" }, "insertedContent": { "description": "The content to insert at the location specified by the 'deletedRegion' property.", "$ref": "#/definitions/artifactContent" }, "properties": { "description": "Key/value pairs that provide additional information about the replacement.", "$ref": "#/definitions/propertyBag" } }, "required": ["deletedRegion"] }, "reportingDescriptor": { "description": "Metadata that describes a specific report produced by the tool, as part of the analysis it provides or its runtime reporting.", "additionalProperties": false, "type": "object", "properties": { "id": { "description": "A stable, opaque identifier for the report.", "type": "string" }, "deprecatedIds": { "description": "An array of stable, opaque identifiers by which this report was known in some previous version of the analysis tool.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "type": "string" } }, "guid": { "description": "A unique identifier for the reporting descriptor in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "deprecatedGuids": { "description": "An array of unique identifies in the form of a GUID by which this report was known in some previous version of the analysis tool.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" } }, "name": { "description": "A report identifier that is understandable to an end user.", "type": "string" }, "deprecatedNames": { "description": "An array of readable identifiers by which this report was known in some previous version of the analysis tool.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "type": "string" } }, "shortDescription": { "description": "A concise description of the report. Should be a single sentence that is understandable when visible space is limited to a single line of text.", "$ref": "#/definitions/multiformatMessageString" }, "fullDescription": { "description": "A description of the report. Should, as far as possible, provide details sufficient to enable resolution of any problem indicated by the result.", "$ref": "#/definitions/multiformatMessageString" }, "messageStrings": { "description": "A set of name/value pairs with arbitrary names. Each value is a multiformatMessageString object, which holds message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can be used to construct a message in combination with an arbitrary number of additional string arguments.", "type": "object", "additionalProperties": { "$ref": "#/definitions/multiformatMessageString" } }, "defaultConfiguration": { "description": "Default reporting configuration information.", "$ref": "#/definitions/reportingConfiguration" }, "helpUri": { "description": "A URI where the primary documentation for the report can be found.", "type": "string", "format": "uri" }, "help": { "description": "Provides the primary documentation for the report, useful when there is no online documentation.", "$ref": "#/definitions/multiformatMessageString" }, "relationships": { "description": "An array of objects that describe relationships between this reporting descriptor and others.", "type": "array", "default": [], "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/reportingDescriptorRelationship" } }, "properties": { "description": "Key/value pairs that provide additional information about the report.", "$ref": "#/definitions/propertyBag" } }, "required": ["id"] }, "reportingConfiguration": { "description": "Information about a rule or notification that can be configured at runtime.", "type": "object", "additionalProperties": false, "properties": { "enabled": { "description": "Specifies whether the report may be produced during the scan.", "type": "boolean", "default": true }, "level": { "description": "Specifies the failure level for the report.", "default": "warning", "enum": ["none", "note", "warning", "error"] }, "rank": { "description": "Specifies the relative priority of the report. Used for analysis output only.", "type": "number", "default": -1.0, "minimum": -1.0, "maximum": 100.0 }, "parameters": { "description": "Contains configuration information specific to a report.", "$ref": "#/definitions/propertyBag" }, "properties": { "description": "Key/value pairs that provide additional information about the reporting configuration.", "$ref": "#/definitions/propertyBag" } } }, "reportingDescriptorReference": { "description": "Information about how to locate a relevant reporting descriptor.", "type": "object", "additionalProperties": false, "properties": { "id": { "description": "The id of the descriptor.", "type": "string" }, "index": { "description": "The index into an array of descriptors in toolComponent.ruleDescriptors, toolComponent.notificationDescriptors, or toolComponent.taxonomyDescriptors, depending on context.", "type": "integer", "default": -1, "minimum": -1 }, "guid": { "description": "A guid that uniquely identifies the descriptor.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "toolComponent": { "description": "A reference used to locate the toolComponent associated with the descriptor.", "$ref": "#/definitions/toolComponentReference" }, "properties": { "description": "Key/value pairs that provide additional information about the reporting descriptor reference.", "$ref": "#/definitions/propertyBag" } }, "anyOf": [ { "required": ["index"] }, { "required": ["guid"] }, { "required": ["id"] } ] }, "reportingDescriptorRelationship": { "description": "Information about the relation of one reporting descriptor to another.", "type": "object", "additionalProperties": false, "properties": { "target": { "description": "A reference to the related reporting descriptor.", "$ref": "#/definitions/reportingDescriptorReference" }, "kinds": { "description": "A set of distinct strings that categorize the relationship. Well-known kinds include 'canPrecede', 'canFollow', 'willPrecede', 'willFollow', 'superset', 'subset', 'equal', 'disjoint', 'relevant', and 'incomparable'.", "type": "array", "default": ["relevant"], "uniqueItems": true, "items": { "type": "string" } }, "description": { "description": "A description of the reporting descriptor relationship.", "$ref": "#/definitions/message" }, "properties": { "description": "Key/value pairs that provide additional information about the reporting descriptor reference.", "$ref": "#/definitions/propertyBag" } }, "required": ["target"] }, "result": { "description": "A result produced by an analysis tool.", "additionalProperties": false, "type": "object", "properties": { "ruleId": { "description": "The stable, unique identifier of the rule, if any, to which this result is relevant.", "type": "string" }, "ruleIndex": { "description": "The index within the tool component rules array of the rule object associated with this result.", "type": "integer", "default": -1, "minimum": -1 }, "rule": { "description": "A reference used to locate the rule descriptor relevant to this result.", "$ref": "#/definitions/reportingDescriptorReference" }, "kind": { "description": "A value that categorizes results by evaluation state.", "default": "fail", "enum": [ "notApplicable", "pass", "fail", "review", "open", "informational" ] }, "level": { "description": "A value specifying the severity level of the result.", "default": "warning", "enum": ["none", "note", "warning", "error"] }, "message": { "description": "A message that describes the result. The first sentence of the message only will be displayed when visible space is limited.", "$ref": "#/definitions/message" }, "analysisTarget": { "description": "Identifies the artifact that the analysis tool was instructed to scan. This need not be the same as the artifact where the result actually occurred.", "$ref": "#/definitions/artifactLocation" }, "locations": { "description": "The set of locations where the result was detected. Specify only one location unless the problem indicated by the result can only be corrected by making a change at every specified location.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/location" } }, "guid": { "description": "A stable, unique identifier for the result in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "correlationGuid": { "description": "A stable, unique identifier for the equivalence class of logically identical results to which this result belongs, in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "occurrenceCount": { "description": "A positive integer specifying the number of times this logically unique result was observed in this run.", "type": "integer", "minimum": 1 }, "partialFingerprints": { "description": "A set of strings that contribute to the stable, unique identity of the result.", "type": "object", "additionalProperties": { "type": "string" } }, "fingerprints": { "description": "A set of strings each of which individually defines a stable, unique identity for the result.", "type": "object", "additionalProperties": { "type": "string" } }, "stacks": { "description": "An array of 'stack' objects relevant to the result.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/stack" } }, "codeFlows": { "description": "An array of 'codeFlow' objects relevant to the result.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/codeFlow" } }, "graphs": { "description": "An array of zero or more unique graph objects associated with the result.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/graph" } }, "graphTraversals": { "description": "An array of one or more unique 'graphTraversal' objects.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/graphTraversal" } }, "relatedLocations": { "description": "A set of locations relevant to this result.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/location" } }, "suppressions": { "description": "A set of suppressions relevant to this result.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/suppression" } }, "baselineState": { "description": "The state of a result relative to a baseline of a previous run.", "enum": ["new", "unchanged", "updated", "absent"] }, "rank": { "description": "A number representing the priority or importance of the result.", "type": "number", "default": -1.0, "minimum": -1.0, "maximum": 100.0 }, "attachments": { "description": "A set of artifacts relevant to the result.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/attachment" } }, "hostedViewerUri": { "description": "An absolute URI at which the result can be viewed.", "type": "string", "format": "uri" }, "workItemUris": { "description": "The URIs of the work items associated with this result.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "type": "string", "format": "uri" } }, "provenance": { "description": "Information about how and when the result was detected.", "$ref": "#/definitions/resultProvenance" }, "fixes": { "description": "An array of 'fix' objects, each of which represents a proposed fix to the problem indicated by the result.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/fix" } }, "taxa": { "description": "An array of references to taxonomy reporting descriptors that are applicable to the result.", "type": "array", "default": [], "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/reportingDescriptorReference" } }, "webRequest": { "description": "A web request associated with this result.", "$ref": "#/definitions/webRequest" }, "webResponse": { "description": "A web response associated with this result.", "$ref": "#/definitions/webResponse" }, "properties": { "description": "Key/value pairs that provide additional information about the result.", "$ref": "#/definitions/propertyBag" } }, "required": ["message"] }, "resultProvenance": { "description": "Contains information about how and when a result was detected.", "additionalProperties": false, "type": "object", "properties": { "firstDetectionTimeUtc": { "description": "The Coordinated Universal Time (UTC) date and time at which the result was first detected. See \"Date/time properties\" in the SARIF spec for the required format.", "type": "string", "format": "date-time" }, "lastDetectionTimeUtc": { "description": "The Coordinated Universal Time (UTC) date and time at which the result was most recently detected. See \"Date/time properties\" in the SARIF spec for the required format.", "type": "string", "format": "date-time" }, "firstDetectionRunGuid": { "description": "A GUID-valued string equal to the automationDetails.guid property of the run in which the result was first detected.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "lastDetectionRunGuid": { "description": "A GUID-valued string equal to the automationDetails.guid property of the run in which the result was most recently detected.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "invocationIndex": { "description": "The index within the run.invocations array of the invocation object which describes the tool invocation that detected the result.", "type": "integer", "default": -1, "minimum": -1 }, "conversionSources": { "description": "An array of physicalLocation objects which specify the portions of an analysis tool's output that a converter transformed into the result.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/physicalLocation" } }, "properties": { "description": "Key/value pairs that provide additional information about the result.", "$ref": "#/definitions/propertyBag" } } }, "run": { "description": "Describes a single run of an analysis tool, and contains the reported output of that run.", "additionalProperties": false, "type": "object", "properties": { "tool": { "description": "Information about the tool or tool pipeline that generated the results in this run. A run can only contain results produced by a single tool or tool pipeline. A run can aggregate results from multiple log files, as long as context around the tool run (tool command-line arguments and the like) is identical for all aggregated files.", "$ref": "#/definitions/tool" }, "invocations": { "description": "Describes the invocation of the analysis tool.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/invocation" } }, "conversion": { "description": "A conversion object that describes how a converter transformed an analysis tool's native reporting format into the SARIF format.", "$ref": "#/definitions/conversion" }, "language": { "description": "The language of the messages emitted into the log file during this run (expressed as an ISO 639-1 two-letter lowercase culture code) and an optional region (expressed as an ISO 3166-1 two-letter uppercase subculture code associated with a country or region). The casing is recommended but not required (in order for this data to conform to RFC5646).", "type": "string", "default": "en-US", "pattern": "^[a-zA-Z]{2}|^[a-zA-Z]{2}-[a-zA-Z]{2}]?$" }, "versionControlProvenance": { "description": "Specifies the revision in version control of the artifacts that were scanned.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/versionControlDetails" } }, "originalUriBaseIds": { "description": "The artifact location specified by each uriBaseId symbol on the machine where the tool originally ran.", "type": "object", "additionalProperties": { "$ref": "#/definitions/artifactLocation" } }, "artifacts": { "description": "An array of artifact objects relevant to the run.", "type": "array", "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/artifact" } }, "logicalLocations": { "description": "An array of logical locations such as namespaces, types or functions.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/logicalLocation" } }, "graphs": { "description": "An array of zero or more unique graph objects associated with the run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/graph" } }, "results": { "description": "The set of results contained in an SARIF log. The results array can be omitted when a run is solely exporting rules metadata. It must be present (but may be empty) if a log file represents an actual scan.", "type": "array", "minItems": 0, "uniqueItems": false, "items": { "$ref": "#/definitions/result" } }, "automationDetails": { "description": "Automation details that describe this run.", "$ref": "#/definitions/runAutomationDetails" }, "runAggregates": { "description": "Automation details that describe the aggregate of runs to which this run belongs.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/runAutomationDetails" } }, "baselineGuid": { "description": "The 'guid' property of a previous SARIF 'run' that comprises the baseline that was used to compute result 'baselineState' properties for the run.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "redactionTokens": { "description": "An array of strings used to replace sensitive information in a redaction-aware property.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "type": "string" } }, "defaultEncoding": { "description": "Specifies the default encoding for any artifact object that refers to a text file.", "type": "string" }, "defaultSourceLanguage": { "description": "Specifies the default source language for any artifact object that refers to a text file that contains source code.", "type": "string" }, "newlineSequences": { "description": "An ordered list of character sequences that were treated as line breaks when computing region information for the run.", "type": "array", "minItems": 1, "uniqueItems": true, "default": ["\r\n", "\n"], "items": { "type": "string" } }, "columnKind": { "description": "Specifies the unit in which the tool measures columns.", "enum": ["utf16CodeUnits", "unicodeCodePoints"] }, "externalPropertyFileReferences": { "description": "References to external property files that should be inlined with the content of a root log file.", "$ref": "#/definitions/externalPropertyFileReferences" }, "threadFlowLocations": { "description": "An array of threadFlowLocation objects cached at run level.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/threadFlowLocation" } }, "taxonomies": { "description": "An array of toolComponent objects relevant to a taxonomy in which results are categorized.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponent" } }, "addresses": { "description": "Addresses associated with this run instance, if any.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "$ref": "#/definitions/address" } }, "translations": { "description": "The set of available translations of the localized data provided by the tool.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponent" } }, "policies": { "description": "Contains configurations that may potentially override both reportingDescriptor.defaultConfiguration (the tool's default severities) and invocation.configurationOverrides (severities established at run-time from the command line).", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponent" } }, "webRequests": { "description": "An array of request objects cached at run level.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/webRequest" } }, "webResponses": { "description": "An array of response objects cached at run level.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/webResponse" } }, "specialLocations": { "description": "A specialLocations object that defines locations of special significance to SARIF consumers.", "$ref": "#/definitions/specialLocations" }, "properties": { "description": "Key/value pairs that provide additional information about the run.", "$ref": "#/definitions/propertyBag" } }, "required": ["tool"] }, "runAutomationDetails": { "description": "Information that describes a run's identity and role within an engineering system process.", "additionalProperties": false, "type": "object", "properties": { "description": { "description": "A description of the identity and role played within the engineering system by this object's containing run object.", "$ref": "#/definitions/message" }, "id": { "description": "A hierarchical string that uniquely identifies this object's containing run object.", "type": "string" }, "guid": { "description": "A stable, unique identifier for this object's containing run object in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "correlationGuid": { "description": "A stable, unique identifier for the equivalence class of runs to which this object's containing run object belongs in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "properties": { "description": "Key/value pairs that provide additional information about the run automation details.", "$ref": "#/definitions/propertyBag" } } }, "specialLocations": { "description": "Defines locations of special significance to SARIF consumers.", "type": "object", "additionalProperties": false, "properties": { "displayBase": { "description": "Provides a suggestion to SARIF consumers to display file paths relative to the specified location.", "$ref": "#/definitions/artifactLocation" }, "properties": { "description": "Key/value pairs that provide additional information about the special locations.", "$ref": "#/definitions/propertyBag" } } }, "stack": { "description": "A call stack that is relevant to a result.", "additionalProperties": false, "type": "object", "properties": { "message": { "description": "A message relevant to this call stack.", "$ref": "#/definitions/message" }, "frames": { "description": "An array of stack frames that represents a sequence of calls, rendered in reverse chronological order, that comprise the call stack.", "type": "array", "minItems": 0, "uniqueItems": false, "items": { "$ref": "#/definitions/stackFrame" } }, "properties": { "description": "Key/value pairs that provide additional information about the stack.", "$ref": "#/definitions/propertyBag" } }, "required": ["frames"] }, "stackFrame": { "description": "A function call within a stack trace.", "additionalProperties": false, "type": "object", "properties": { "location": { "description": "The location to which this stack frame refers.", "$ref": "#/definitions/location" }, "module": { "description": "The name of the module that contains the code of this stack frame.", "type": "string" }, "threadId": { "description": "The thread identifier of the stack frame.", "type": "integer" }, "parameters": { "description": "The parameters of the call that is executing.", "type": "array", "minItems": 0, "uniqueItems": false, "default": [], "items": { "type": "string", "default": [] } }, "properties": { "description": "Key/value pairs that provide additional information about the stack frame.", "$ref": "#/definitions/propertyBag" } } }, "suppression": { "description": "A suppression that is relevant to a result.", "additionalProperties": false, "type": "object", "properties": { "guid": { "description": "A stable, unique identifier for the suprression in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "kind": { "description": "A string that indicates where the suppression is persisted.", "enum": ["inSource", "external"] }, "status": { "description": "A string that indicates the review status of the suppression.", "enum": ["accepted", "underReview", "rejected"] }, "justification": { "description": "A string representing the justification for the suppression.", "type": "string" }, "location": { "description": "Identifies the location associated with the suppression.", "$ref": "#/definitions/location" }, "properties": { "description": "Key/value pairs that provide additional information about the suppression.", "$ref": "#/definitions/propertyBag" } }, "required": ["kind"] }, "threadFlow": { "description": "Describes a sequence of code locations that specify a path through a single thread of execution such as an operating system or fiber.", "type": "object", "additionalProperties": false, "properties": { "id": { "description": "An string that uniquely identifies the threadFlow within the codeFlow in which it occurs.", "type": "string" }, "message": { "description": "A message relevant to the thread flow.", "$ref": "#/definitions/message" }, "initialState": { "description": "Values of relevant expressions at the start of the thread flow that may change during thread flow execution.", "type": "object", "additionalProperties": { "$ref": "#/definitions/multiformatMessageString" } }, "immutableState": { "description": "Values of relevant expressions at the start of the thread flow that remain constant.", "type": "object", "additionalProperties": { "$ref": "#/definitions/multiformatMessageString" } }, "locations": { "description": "A temporally ordered array of 'threadFlowLocation' objects, each of which describes a location visited by the tool while producing the result.", "type": "array", "minItems": 1, "uniqueItems": false, "items": { "$ref": "#/definitions/threadFlowLocation" } }, "properties": { "description": "Key/value pairs that provide additional information about the thread flow.", "$ref": "#/definitions/propertyBag" } }, "required": ["locations"] }, "threadFlowLocation": { "description": "A location visited by an analysis tool while simulating or monitoring the execution of a program.", "additionalProperties": false, "type": "object", "properties": { "index": { "description": "The index within the run threadFlowLocations array.", "type": "integer", "default": -1, "minimum": -1 }, "location": { "description": "The code location.", "$ref": "#/definitions/location" }, "stack": { "description": "The call stack leading to this location.", "$ref": "#/definitions/stack" }, "kinds": { "description": "A set of distinct strings that categorize the thread flow location. Well-known kinds include 'acquire', 'release', 'enter', 'exit', 'call', 'return', 'branch', 'implicit', 'false', 'true', 'caution', 'danger', 'unknown', 'unreachable', 'taint', 'function', 'handler', 'lock', 'memory', 'resource', 'scope' and 'value'.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "type": "string" } }, "taxa": { "description": "An array of references to rule or taxonomy reporting descriptors that are applicable to the thread flow location.", "type": "array", "default": [], "minItems": 0, "uniqueItems": true, "items": { "$ref": "#/definitions/reportingDescriptorReference" } }, "module": { "description": "The name of the module that contains the code that is executing.", "type": "string" }, "state": { "description": "A dictionary, each of whose keys specifies a variable or expression, the associated value of which represents the variable or expression value. For an annotation of kind 'continuation', for example, this dictionary might hold the current assumed values of a set of global variables.", "type": "object", "additionalProperties": { "$ref": "#/definitions/multiformatMessageString" } }, "nestingLevel": { "description": "An integer representing a containment hierarchy within the thread flow.", "type": "integer", "minimum": 0 }, "executionOrder": { "description": "An integer representing the temporal order in which execution reached this location.", "type": "integer", "default": -1, "minimum": -1 }, "executionTimeUtc": { "description": "The Coordinated Universal Time (UTC) date and time at which this location was executed.", "type": "string", "format": "date-time" }, "importance": { "description": "Specifies the importance of this location in understanding the code flow in which it occurs. The order from most to least important is \"essential\", \"important\", \"unimportant\". Default: \"important\".", "enum": ["important", "essential", "unimportant"], "default": "important" }, "webRequest": { "description": "A web request associated with this thread flow location.", "$ref": "#/definitions/webRequest" }, "webResponse": { "description": "A web response associated with this thread flow location.", "$ref": "#/definitions/webResponse" }, "properties": { "description": "Key/value pairs that provide additional information about the threadflow location.", "$ref": "#/definitions/propertyBag" } } }, "tool": { "description": "The analysis tool that was run.", "additionalProperties": false, "type": "object", "properties": { "driver": { "description": "The analysis tool that was run.", "$ref": "#/definitions/toolComponent" }, "extensions": { "description": "Tool extensions that contributed to or reconfigured the analysis tool that was run.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponent" } }, "properties": { "description": "Key/value pairs that provide additional information about the tool.", "$ref": "#/definitions/propertyBag" } }, "required": ["driver"] }, "toolComponent": { "description": "A component, such as a plug-in or the driver, of the analysis tool that was run.", "additionalProperties": false, "type": "object", "properties": { "guid": { "description": "A unique identifier for the tool component in the form of a GUID.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "name": { "description": "The name of the tool component.", "type": "string" }, "organization": { "description": "The organization or company that produced the tool component.", "type": "string" }, "product": { "description": "A product suite to which the tool component belongs.", "type": "string" }, "productSuite": { "description": "A localizable string containing the name of the suite of products to which the tool component belongs.", "type": "string" }, "shortDescription": { "description": "A brief description of the tool component.", "$ref": "#/definitions/multiformatMessageString" }, "fullDescription": { "description": "A comprehensive description of the tool component.", "$ref": "#/definitions/multiformatMessageString" }, "fullName": { "description": "The name of the tool component along with its version and any other useful identifying information, such as its locale.", "type": "string" }, "version": { "description": "The tool component version, in whatever format the component natively provides.", "type": "string" }, "semanticVersion": { "description": "The tool component version in the format specified by Semantic Versioning 2.0.", "type": "string" }, "dottedQuadFileVersion": { "description": "The binary version of the tool component's primary executable file expressed as four non-negative integers separated by a period (for operating systems that express file versions in this way).", "type": "string", "pattern": "[0-9]+(\\.[0-9]+){3}" }, "releaseDateUtc": { "description": "A string specifying the UTC date (and optionally, the time) of the component's release.", "type": "string" }, "downloadUri": { "description": "The absolute URI from which the tool component can be downloaded.", "type": "string", "format": "uri" }, "informationUri": { "description": "The absolute URI at which information about this version of the tool component can be found.", "type": "string", "format": "uri" }, "globalMessageStrings": { "description": "A dictionary, each of whose keys is a resource identifier and each of whose values is a multiformatMessageString object, which holds message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can be used to construct a message in combination with an arbitrary number of additional string arguments.", "type": "object", "additionalProperties": { "$ref": "#/definitions/multiformatMessageString" } }, "notifications": { "description": "An array of reportingDescriptor objects relevant to the notifications related to the configuration and runtime execution of the tool component.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/reportingDescriptor" } }, "rules": { "description": "An array of reportingDescriptor objects relevant to the analysis performed by the tool component.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/reportingDescriptor" } }, "taxa": { "description": "An array of reportingDescriptor objects relevant to the definitions of both standalone and tool-defined taxonomies.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/reportingDescriptor" } }, "locations": { "description": "An array of the artifactLocation objects associated with the tool component.", "type": "array", "minItems": 0, "default": [], "items": { "$ref": "#/definitions/artifactLocation" } }, "language": { "description": "The language of the messages emitted into the log file during this run (expressed as an ISO 639-1 two-letter lowercase language code) and an optional region (expressed as an ISO 3166-1 two-letter uppercase subculture code associated with a country or region). The casing is recommended but not required (in order for this data to conform to RFC5646).", "type": "string", "default": "en-US", "pattern": "^[a-zA-Z]{2}|^[a-zA-Z]{2}-[a-zA-Z]{2}]?$" }, "contents": { "description": "The kinds of data contained in this object.", "type": "array", "uniqueItems": true, "default": ["localizedData", "nonLocalizedData"], "items": { "enum": ["localizedData", "nonLocalizedData"] } }, "isComprehensive": { "description": "Specifies whether this object contains a complete definition of the localizable and/or non-localizable data for this component, as opposed to including only data that is relevant to the results persisted to this log file.", "type": "boolean", "default": false }, "localizedDataSemanticVersion": { "description": "The semantic version of the localized strings defined in this component; maintained by components that provide translations.", "type": "string" }, "minimumRequiredLocalizedDataSemanticVersion": { "description": "The minimum value of localizedDataSemanticVersion required in translations consumed by this component; used by components that consume translations.", "type": "string" }, "associatedComponent": { "description": "The component which is strongly associated with this component. For a translation, this refers to the component which has been translated. For an extension, this is the driver that provides the extension's plugin model.", "$ref": "#/definitions/toolComponentReference" }, "translationMetadata": { "description": "Translation metadata, required for a translation, not populated by other component types.", "$ref": "#/definitions/translationMetadata" }, "supportedTaxonomies": { "description": "An array of toolComponentReference objects to declare the taxonomies supported by the tool component.", "type": "array", "minItems": 0, "uniqueItems": true, "default": [], "items": { "$ref": "#/definitions/toolComponentReference" } }, "properties": { "description": "Key/value pairs that provide additional information about the tool component.", "$ref": "#/definitions/propertyBag" } }, "required": ["name"] }, "toolComponentReference": { "description": "Identifies a particular toolComponent object, either the driver or an extension.", "type": "object", "additionalProperties": false, "properties": { "name": { "description": "The 'name' property of the referenced toolComponent.", "type": "string" }, "index": { "description": "An index into the referenced toolComponent in tool.extensions.", "type": "integer", "default": -1, "minimum": -1 }, "guid": { "description": "The 'guid' property of the referenced toolComponent.", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" }, "properties": { "description": "Key/value pairs that provide additional information about the toolComponentReference.", "$ref": "#/definitions/propertyBag" } } }, "translationMetadata": { "description": "Provides additional metadata related to translation.", "type": "object", "additionalProperties": false, "properties": { "name": { "description": "The name associated with the translation metadata.", "type": "string" }, "fullName": { "description": "The full name associated with the translation metadata.", "type": "string" }, "shortDescription": { "description": "A brief description of the translation metadata.", "$ref": "#/definitions/multiformatMessageString" }, "fullDescription": { "description": "A comprehensive description of the translation metadata.", "$ref": "#/definitions/multiformatMessageString" }, "downloadUri": { "description": "The absolute URI from which the translation metadata can be downloaded.", "type": "string", "format": "uri" }, "informationUri": { "description": "The absolute URI from which information related to the translation metadata can be downloaded.", "type": "string", "format": "uri" }, "properties": { "description": "Key/value pairs that provide additional information about the translation metadata.", "$ref": "#/definitions/propertyBag" } }, "required": ["name"] }, "versionControlDetails": { "description": "Specifies the information necessary to retrieve a desired revision from a version control system.", "type": "object", "additionalProperties": false, "properties": { "repositoryUri": { "description": "The absolute URI of the repository.", "type": "string", "format": "uri" }, "revisionId": { "description": "A string that uniquely and permanently identifies the revision within the repository.", "type": "string" }, "branch": { "description": "The name of a branch containing the revision.", "type": "string" }, "revisionTag": { "description": "A tag that has been applied to the revision.", "type": "string" }, "asOfTimeUtc": { "description": "A Coordinated Universal Time (UTC) date and time that can be used to synchronize an enlistment to the state of the repository at that time.", "type": "string", "format": "date-time" }, "mappedTo": { "description": "The location in the local file system to which the root of the repository was mapped at the time of the analysis.", "$ref": "#/definitions/artifactLocation" }, "properties": { "description": "Key/value pairs that provide additional information about the version control details.", "$ref": "#/definitions/propertyBag" } }, "required": ["repositoryUri"] }, "webRequest": { "description": "Describes an HTTP request.", "type": "object", "additionalProperties": false, "properties": { "index": { "description": "The index within the run.webRequests array of the request object associated with this result.", "type": "integer", "default": -1, "minimum": -1 }, "protocol": { "description": "The request protocol. Example: 'http'.", "type": "string" }, "version": { "description": "The request version. Example: '1.1'.", "type": "string" }, "target": { "description": "The target of the request.", "type": "string" }, "method": { "description": "The HTTP method. Well-known values are 'GET', 'PUT', 'POST', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT'.", "type": "string" }, "headers": { "description": "The request headers.", "type": "object", "additionalProperties": { "type": "string" } }, "parameters": { "description": "The request parameters.", "type": "object", "additionalProperties": { "type": "string" } }, "body": { "description": "The body of the request.", "$ref": "#/definitions/artifactContent" }, "properties": { "description": "Key/value pairs that provide additional information about the request.", "$ref": "#/definitions/propertyBag" } } }, "webResponse": { "description": "Describes the response to an HTTP request.", "type": "object", "additionalProperties": false, "properties": { "index": { "description": "The index within the run.webResponses array of the response object associated with this result.", "type": "integer", "default": -1, "minimum": -1 }, "protocol": { "description": "The response protocol. Example: 'http'.", "type": "string" }, "version": { "description": "The response version. Example: '1.1'.", "type": "string" }, "statusCode": { "description": "The response status code. Example: 451.", "type": "integer" }, "reasonPhrase": { "description": "The response reason. Example: 'Not found'.", "type": "string" }, "headers": { "description": "The response headers.", "type": "object", "additionalProperties": { "type": "string" } }, "body": { "description": "The body of the response.", "$ref": "#/definitions/artifactContent" }, "noResponseReceived": { "description": "Specifies whether a response was received from the server.", "type": "boolean", "default": false }, "properties": { "description": "Key/value pairs that provide additional information about the response.", "$ref": "#/definitions/propertyBag" } } } } } serde-sarif-0.8.0/tests/version-numbers.rs000064400000000000000000000003001046102023000166740ustar 00000000000000#[test] fn test_readme_deps() { version_sync::assert_markdown_deps_updated!("README.md"); } #[test] fn test_html_root_url() { version_sync::assert_html_root_url_updated!("src/lib.rs"); }