From 44b1c627a8762a6a48fb1a9be4455e66314a35f6 Mon Sep 17 00:00:00 2001 From: joshmc Date: Sat, 19 Dec 2020 08:16:11 +0000 Subject: [PATCH] ISSUE-151 - Add new GitHubMarkdown output type: * Update README integration test snapshots * Adding report for `cargo-geiger` to README Signed-off-by: joshmc --- Cargo.lock | 8 +- README.md | 304 ++++++++++++++++++ cargo-geiger/Cargo.toml | 4 +- cargo-geiger/src/args.rs | 65 ++-- cargo-geiger/src/format.rs | 24 +- cargo-geiger/src/format/emoji_symbols.rs | 36 ++- cargo-geiger/src/format/print_config.rs | 87 ++++- cargo-geiger/src/format/table.rs | 43 ++- .../src/format/table/handle_text_tree_line.rs | 20 +- cargo-geiger/src/mapping.rs | 5 + cargo-geiger/src/mapping/metadata.rs | 13 +- cargo-geiger/src/readme.rs | 33 +- cargo-geiger/src/scan/default.rs | 11 +- cargo-geiger/src/scan/default/table.rs | 50 +-- cargo-geiger/src/scan/forbid.rs | 11 +- cargo-geiger/src/scan/forbid/table.rs | 6 +- cargo-geiger/src/tree.rs | 32 +- .../src/tree/traversal/dependency_kind.rs | 10 +- .../src/tree/traversal/dependency_node.rs | 6 +- cargo-geiger/tests/integration_test/mod.rs | 4 +- cargo-geiger/tests/run/mod.rs | 2 +- ...ts__test1_package_with_no_deps.readme.snap | 10 +- ...est2_package_with_shallow_deps.readme.snap | 14 +- ...test3_package_with_nested_deps.readme.snap | 22 +- ...rkspace_with_top_level_package.readme.snap | 12 +- ...__test6_cargo_lock_out_of_date.readme.snap | 26 +- ...test7_package_with_patched_dep.readme.snap | 14 +- 27 files changed, 678 insertions(+), 194 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0147b9cc..200525f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1368,15 +1368,15 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "strum" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89a286a7e3b5720b9a477b23253bc50debac207c8d21505f8e70b36792f11b5" +checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c" [[package]] name = "strum_macros" -version = "0.19.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e61bb0be289045cb80bfce000512e32d09f8337e54c186725da381377ad1f8d5" +checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149" dependencies = [ "heck", "proc-macro2", diff --git a/README.md b/README.md index efce1b9e..8c61c7d6 100644 --- a/README.md +++ b/README.md @@ -98,3 +98,307 @@ The changelog can be found [here](https://github.com/rust-secure-code/cargo-geig [cargo]: https://crates.io/crates/cargo [cargo-geiger]: https://crates.io/crates/cargo-geiger [changelog]: https://github.com/rust-secure-code/cargo-geiger/blob/master/CHANGELOG.md + +## Cargo Geiger Safety Report +``` + +Metric output format: x/y + x = unsafe code used by the build + y = total unsafe code found in the crate + +Symbols: + 🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)] + ❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)] + ☢️ = `unsafe` usage found + +Functions Expressions Impls Traits Methods Dependency + +0/0 0/0 0/0 0/0 0/0 🔒 cargo-geiger 0.10.2 +10/10 210/210 0/0 0/0 1/1 ☢️ ├── anyhow 1.0.33 +4/4 341/347 0/0 0/0 3/3 ☢️ ├── cargo 0.47.0 +10/10 210/210 0/0 0/0 1/1 ☢️ │ ├── anyhow 1.0.33 +2/2 45/45 0/0 0/0 0/0 ☢️ │ ├── atty 0.2.14 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ └── libc 0.2.79 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── bytesize 1.0.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde_derive 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── proc-macro2 1.0.24 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ │ └── unicode-xid 0.2.1 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ ├── quote 1.0.7 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── proc-macro2 1.0.24 +0/0 45/45 3/3 0/0 2/2 ☢️ │ │ └── syn 1.0.53 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── proc-macro2 1.0.24 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ ├── quote 1.0.7 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ └── unicode-xid 0.2.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── cargo-platform 0.1.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/0 1/1 0/0 0/0 0/0 ☢️ │ ├── clap 2.33.3 +0/0 23/23 0/0 0/0 0/0 ☢️ │ │ ├── ansi_term 0.11.0 +2/2 45/45 0/0 0/0 0/0 ☢️ │ │ ├── atty 0.2.14 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── bitflags 1.2.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── strsim 0.8.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── textwrap 0.11.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── unicode-width 0.1.8 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── unicode-width 0.1.8 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── vec_map 0.8.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── crates-io 0.31.1 +10/10 210/210 0/0 0/0 1/1 ☢️ │ │ ├── anyhow 1.0.33 +4/4 854/855 5/5 0/0 2/2 ☢️ │ │ ├── curl 0.4.34 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── curl-sys 0.4.38+curl-7.73.0 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ │ ├── libc 0.2.79 +0/0 0/1 0/0 0/0 0/0 ❓ │ │ │ │ ├── libnghttp2-sys 0.1.4+1.41.0 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ │ │ └── libc 0.2.79 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ │ ├── libz-sys 1.1.2 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ │ │ └── libc 0.2.79 +39/39 142/142 0/0 0/0 0/0 ☢️ │ │ │ │ └── openssl-sys 0.9.58 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ │ └── libc 0.2.79 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ ├── libc 0.2.79 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── openssl-probe 0.1.2 +39/39 142/142 0/0 0/0 0/0 ☢️ │ │ │ ├── openssl-sys 0.9.58 +0/0 585/1063 0/0 0/0 6/10 ☢️ │ │ │ └── socket2 0.3.15 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── cfg-if 0.1.10 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ └── libc 0.2.79 +0/0 3/3 0/0 0/0 0/0 ☢️ │ │ ├── percent-encoding 2.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── serde_derive 1.0.117 +0/0 5/5 0/0 0/0 0/0 ☢️ │ │ ├── serde_json 1.0.59 +0/0 103/108 1/1 0/0 2/2 ☢️ │ │ │ ├── indexmap 1.6.0 +2/2 1006/1098 16/19 0/0 35/39 ☢️ │ │ │ │ ├── hashbrown 0.9.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ │ └── serde 1.0.117 +0/0 1/1 0/0 0/0 0/0 ☢️ │ │ │ ├── itoa 0.4.6 +8/12 674/921 0/0 0/0 2/2 ☢️ │ │ │ ├── ryu 1.0.5 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── serde 1.0.117 +0/0 2/2 0/0 0/0 0/0 ☢️ │ │ └── url 2.1.1 +0/0 1/1 0/0 0/0 0/0 ☢️ │ │ ├── idna 0.2.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── matches 0.1.8 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ │ ├── unicode-bidi 0.3.4 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ │ ├── matches 0.1.8 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ │ └── serde 1.0.117 +0/0 20/20 0/0 0/0 0/0 ☢️ │ │ │ └── unicode-normalization 0.1.13 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ │ └── tinyvec 0.3.4 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── matches 0.1.8 +0/0 3/3 0/0 0/0 0/0 ☢️ │ │ ├── percent-encoding 2.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +4/4 78/78 14/14 0/0 0/0 ☢️ │ ├── crossbeam-utils 0.7.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── cfg-if 0.1.10 +0/0 7/7 1/1 0/0 0/0 ☢️ │ │ └── lazy_static 1.4.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── crypto-hash 0.3.4 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── hex 0.3.2 +30/30 5375/5375 29/29 3/3 16/16 ☢️ │ │ └── openssl 0.10.30 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── bitflags 1.2.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── cfg-if 0.1.10 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── foreign-types 0.3.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── foreign-types-shared 0.1.1 +0/0 7/7 1/1 0/0 0/0 ☢️ │ │ ├── lazy_static 1.4.0 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ ├── libc 0.2.79 +39/39 142/142 0/0 0/0 0/0 ☢️ │ │ └── openssl-sys 0.9.58 +4/4 854/855 5/5 0/0 2/2 ☢️ │ ├── curl 0.4.34 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── curl-sys 0.4.38+curl-7.73.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── env_logger 0.7.1 +2/2 45/45 0/0 0/0 0/0 ☢️ │ │ ├── atty 0.2.14 +0/0 5/5 0/0 0/0 0/0 ☢️ │ │ ├── humantime 1.3.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── quick-error 1.2.3 +1/1 16/28 0/0 0/0 0/2 ☢️ │ │ ├── log 0.4.11 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── cfg-if 0.1.10 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── serde 1.0.117 +0/0 34/34 0/1 0/0 2/2 ☢️ │ │ ├── regex 1.4.2 +19/19 678/678 0/0 0/0 22/22 ☢️ │ │ │ ├── aho-corasick 0.7.14 +26/27 1823/1896 0/0 0/0 0/0 ☢️ │ │ │ │ └── memchr 2.3.3 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ │ └── libc 0.2.79 +26/27 1823/1896 0/0 0/0 0/0 ☢️ │ │ │ ├── memchr 2.3.3 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ │ ├── regex-syntax 0.6.21 +1/1 146/146 2/2 0/0 4/4 ☢️ │ │ │ └── thread_local 1.0.1 +0/0 7/7 1/1 0/0 0/0 ☢️ │ │ │ └── lazy_static 1.4.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── termcolor 1.1.0 +0/0 21/78 0/0 0/0 0/0 ☢️ │ ├── filetime 0.2.12 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── cfg-if 0.1.10 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ └── libc 0.2.79 +4/4 129/129 2/2 0/0 2/2 ☢️ │ ├── flate2 1.0.18 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── cfg-if 0.1.10 +5/6 108/156 0/0 0/0 0/0 ☢️ │ │ ├── crc32fast 1.2.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── cfg-if 0.1.10 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ ├── libc 0.2.79 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── libz-sys 1.1.2 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ └── miniz_oxide 0.4.3 +0/0 0/0 0/0 0/0 0/0 🔒 │ │ └── adler 0.2.3 +6/6 3635/3655 3/3 0/0 80/80 ☢️ │ ├── git2 0.13.12 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── bitflags 1.2.1 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ ├── libc 0.2.79 +0/0 18/18 0/0 0/0 0/0 ☢️ │ │ ├── libgit2-sys 0.12.14+1.1.0 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ ├── libc 0.2.79 +2/2 6/6 0/0 0/0 0/0 ☢️ │ │ │ ├── libssh2-sys 0.2.19 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ │ ├── libc 0.2.79 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ │ ├── libz-sys 1.1.2 +39/39 142/142 0/0 0/0 0/0 ☢️ │ │ │ │ └── openssl-sys 0.9.58 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── libz-sys 1.1.2 +39/39 142/142 0/0 0/0 0/0 ☢️ │ │ │ └── openssl-sys 0.9.58 +1/1 16/28 0/0 0/0 0/2 ☢️ │ │ ├── log 0.4.11 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── openssl-probe 0.1.2 +39/39 142/142 0/0 0/0 0/0 ☢️ │ │ ├── openssl-sys 0.9.58 +0/0 2/2 0/0 0/0 0/0 ☢️ │ │ └── url 2.1.1 +1/1 17/19 0/0 0/0 0/0 ☢️ │ ├── git2-curl 0.14.1 +4/4 854/855 5/5 0/0 2/2 ☢️ │ │ ├── curl 0.4.34 +6/6 3635/3655 3/3 0/0 80/80 ☢️ │ │ ├── git2 0.13.12 +1/1 16/28 0/0 0/0 0/2 ☢️ │ │ ├── log 0.4.11 +0/0 2/2 0/0 0/0 0/0 ☢️ │ │ └── url 2.1.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── glob 0.3.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── hex 0.4.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/0 0/14 0/0 0/0 0/0 ❓ │ ├── home 0.5.3 +0/0 0/0 0/0 0/0 0/0 🔒 │ ├── humantime 2.0.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── ignore 0.4.16 +4/4 78/78 14/14 0/0 0/0 ☢️ │ │ ├── crossbeam-utils 0.7.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── globset 0.4.5 +19/19 678/678 0/0 0/0 22/22 ☢️ │ │ │ ├── aho-corasick 0.7.14 +8/8 365/377 0/0 0/0 0/0 ☢️ │ │ │ ├── bstr 0.2.14 +0/0 7/7 1/1 0/0 0/0 ☢️ │ │ │ │ ├── lazy_static 1.4.0 +26/27 1823/1896 0/0 0/0 0/0 ☢️ │ │ │ │ ├── memchr 2.3.3 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── fnv 1.0.7 +1/1 16/28 0/0 0/0 0/2 ☢️ │ │ │ ├── log 0.4.11 +0/0 34/34 0/1 0/0 2/2 ☢️ │ │ │ ├── regex 1.4.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── serde 1.0.117 +0/0 7/7 1/1 0/0 0/0 ☢️ │ │ ├── lazy_static 1.4.0 +1/1 16/28 0/0 0/0 0/2 ☢️ │ │ ├── log 0.4.11 +26/27 1823/1896 0/0 0/0 0/0 ☢️ │ │ ├── memchr 2.3.3 +0/0 34/34 0/1 0/0 2/2 ☢️ │ │ ├── regex 1.4.2 +0/0 3/3 0/0 0/0 0/0 ☢️ │ │ ├── same-file 1.0.6 +1/1 146/146 2/2 0/0 4/4 ☢️ │ │ ├── thread_local 1.0.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── walkdir 2.3.1 +0/0 3/3 0/0 0/0 0/0 ☢️ │ │ └── same-file 1.0.6 +1/1 122/122 2/2 0/0 4/4 ☢️ │ ├── im-rc 15.0.0 +0/0 100/100 0/0 0/0 9/9 ☢️ │ │ ├── bitmaps 2.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── typenum 1.12.0 +0/0 22/22 0/0 0/0 0/0 ☢️ │ │ ├── rand_core 0.5.1 +2/4 50/150 1/1 0/0 3/3 ☢️ │ │ │ ├── getrandom 0.1.15 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ │ ├── cfg-if 0.1.10 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ │ ├── libc 0.2.79 +1/1 16/28 0/0 0/0 0/2 ☢️ │ │ │ │ └── log 0.4.11 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── rand_xoshiro 0.4.0 +0/0 22/22 0/0 0/0 0/0 ☢️ │ │ │ ├── rand_core 0.5.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── serde 1.0.117 +0/1 295/615 0/0 0/0 19/38 ☢️ │ │ ├── sized-chunks 0.6.2 +0/0 100/100 0/0 0/0 9/9 ☢️ │ │ │ ├── bitmaps 2.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── typenum 1.12.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── typenum 1.12.0 +0/0 188/282 0/2 0/0 4/6 ☢️ │ ├── jobserver 0.1.21 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ └── libc 0.2.79 +0/0 7/7 1/1 0/0 0/0 ☢️ │ ├── lazy_static 1.4.0 +0/0 43/43 2/2 0/0 0/0 ☢️ │ ├── lazycell 1.3.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/5 12/259 0/0 0/0 2/22 ☢️ │ ├── libc 0.2.79 +0/0 18/18 0/0 0/0 0/0 ☢️ │ ├── libgit2-sys 0.12.14+1.1.0 +1/1 16/28 0/0 0/0 0/2 ☢️ │ ├── log 0.4.11 +26/27 1823/1896 0/0 0/0 0/0 ☢️ │ ├── memchr 2.3.3 +0/0 72/72 0/0 0/0 0/0 ☢️ │ ├── num_cpus 1.13.0 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ └── libc 0.2.79 +0/0 6/6 0/0 0/0 0/0 ☢️ │ ├── opener 0.4.1 +30/30 5375/5375 29/29 3/3 16/16 ☢️ │ ├── openssl 0.10.30 +0/0 3/3 0/0 0/0 0/0 ☢️ │ ├── percent-encoding 2.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── rustc-workspace-hack 1.0.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── rustfix 0.5.1 +10/10 210/210 0/0 0/0 1/1 ☢️ │ │ ├── anyhow 1.0.33 +1/1 16/28 0/0 0/0 0/2 ☢️ │ │ ├── log 0.4.11 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── serde 1.0.117 +0/0 5/5 0/0 0/0 0/0 ☢️ │ │ └── serde_json 1.0.59 +0/0 3/3 0/0 0/0 0/0 ☢️ │ ├── same-file 1.0.6 +0/0 0/4 0/0 0/0 0/0 ❓ │ ├── semver 0.10.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── semver-parser 0.7.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── serde_ignored 0.1.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/0 5/5 0/0 0/0 0/0 ☢️ │ ├── serde_json 1.0.59 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── shell-escape 0.1.5 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── strip-ansi-escapes 0.1.0 +0/0 4/5 0/0 0/0 0/0 ☢️ │ │ └── vte 0.3.3 +1/1 5/5 0/0 0/0 0/0 ☢️ │ │ └── utf8parse 0.1.1 +2/2 52/52 0/0 0/0 0/0 ☢️ │ ├── tar 0.4.30 +0/0 21/78 0/0 0/0 0/0 ☢️ │ │ ├── filetime 0.2.12 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ └── libc 0.2.79 +0/0 36/82 0/0 0/0 0/0 ☢️ │ ├── tempfile 3.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── cfg-if 0.1.10 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ ├── libc 0.2.79 +0/0 15/15 0/0 0/0 0/0 ☢️ │ │ ├── rand 0.7.3 +2/4 50/150 1/1 0/0 3/3 ☢️ │ │ │ ├── getrandom 0.1.15 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ │ ├── libc 0.2.79 +1/1 16/28 0/0 0/0 0/2 ☢️ │ │ │ ├── log 0.4.11 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── rand_chacha 0.2.2 +2/2 566/642 0/0 0/0 14/22 ☢️ │ │ │ │ ├── ppv-lite86 0.2.9 +0/0 22/22 0/0 0/0 0/0 ☢️ │ │ │ │ └── rand_core 0.5.1 +0/0 22/22 0/0 0/0 0/0 ☢️ │ │ │ └── rand_core 0.5.1 +0/0 0/79 0/0 0/0 0/0 ❓ │ │ └── remove_dir_all 0.5.3 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── termcolor 1.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── toml 0.5.7 +0/0 103/108 1/1 0/0 2/2 ☢️ │ │ ├── indexmap 1.6.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── unicode-width 0.1.8 +0/0 0/0 0/0 0/0 0/0 🔒 │ ├── unicode-xid 0.2.1 +0/0 2/2 0/0 0/0 0/0 ☢️ │ ├── url 2.1.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ └── walkdir 2.3.1 +0/0 0/0 0/0 0/0 0/0 🔒 ├── cargo-geiger-serde 0.1.0 +0/0 0/4 0/0 0/0 0/0 ❓ │ ├── semver 0.11.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── semver-parser 0.10.1 +2/2 57/57 0/0 0/0 2/2 ☢️ │ │ │ └── pest 2.1.3 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ ├── serde 1.0.117 +0/0 5/5 0/0 0/0 0/0 ☢️ │ │ │ ├── serde_json 1.0.59 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ │ └── ucd-trie 0.1.3 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── serde 1.0.117 +0/0 2/2 0/0 0/0 0/0 ☢️ │ └── url 2.1.1 +0/0 0/0 0/0 0/0 0/0 ❓ ├── cargo-platform 0.1.1 +0/0 0/0 0/0 0/0 0/0 ❓ ├── cargo_metadata 0.12.0 +0/0 0/4 0/0 0/0 0/0 ❓ │ ├── semver 0.11.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── serde 1.0.117 +0/0 5/5 0/0 0/0 0/0 ☢️ │ └── serde_json 1.0.59 +0/0 13/13 0/0 0/0 0/0 ☢️ ├── colored 2.0.0 +2/2 45/45 0/0 0/0 0/0 ☢️ │ ├── atty 0.2.14 +0/0 7/7 1/1 0/0 0/0 ☢️ │ └── lazy_static 1.4.0 +0/1 148/317 0/0 0/0 0/0 ☢️ ├── console 0.11.3 +0/0 7/7 1/1 0/0 0/0 ☢️ │ ├── lazy_static 1.4.0 +0/5 12/259 0/0 0/0 2/22 ☢️ │ ├── libc 0.2.79 +0/0 34/34 0/1 0/0 2/2 ☢️ │ ├── regex 1.4.2 +0/0 5/8 0/0 0/0 0/0 ☢️ │ ├── terminal_size 0.1.13 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ └── libc 0.2.79 +2/2 75/75 0/0 0/0 0/0 ☢️ │ ├── termios 0.3.3 +0/5 12/259 0/0 0/0 2/22 ☢️ │ │ └── libc 0.2.79 +0/0 0/0 0/0 0/0 0/0 ❓ │ └── unicode-width 0.1.8 +0/0 0/0 0/0 0/0 0/0 ❓ ├── env_logger 0.7.1 +0/0 0/0 0/0 0/0 0/0 🔒 ├── geiger 0.4.6 +0/0 0/0 0/0 0/0 0/0 🔒 │ ├── cargo-geiger-serde 0.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── proc-macro2 1.0.24 +0/0 45/45 3/3 0/0 2/2 ☢️ │ └── syn 1.0.53 +0/0 0/0 0/0 0/0 0/0 ❓ ├── krates 0.5.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── cargo_metadata 0.12.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── cfg-expr 0.5.0 +1/1 402/402 7/7 1/1 13/13 ☢️ │ │ └── smallvec 1.4.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde 1.0.117 +2/2 75/75 4/4 1/1 1/1 ☢️ │ ├── petgraph 0.5.1 +0/0 62/62 0/0 0/0 0/0 ☢️ │ │ ├── fixedbitset 0.2.0 +0/0 103/108 1/1 0/0 2/2 ☢️ │ │ ├── indexmap 1.6.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ ├── serde 1.0.117 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── serde_derive 1.0.117 +0/0 0/4 0/0 0/0 0/0 ❓ │ └── semver 0.11.0 +2/2 75/75 4/4 1/1 1/1 ☢️ ├── petgraph 0.5.1 +0/0 0/0 0/0 0/0 0/0 ❓ ├── pico-args 0.3.4 +0/0 34/34 0/1 0/0 2/2 ☢️ ├── regex 1.4.2 +0/0 0/0 0/0 0/0 0/0 ❓ ├── serde 1.0.117 +0/0 5/5 0/0 0/0 0/0 ☢️ ├── serde_json 1.0.59 +0/0 0/0 0/0 0/0 0/0 ❓ ├── strum 0.19.5 +0/0 0/0 0/0 0/0 0/0 ❓ │ └── strum_macros 0.19.4 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── heck 0.3.1 +0/0 0/0 0/0 0/0 0/0 ❓ │ │ └── unicode-segmentation 1.6.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ ├── proc-macro2 1.0.24 +0/0 0/0 0/0 0/0 0/0 🔒 │ ├── quote 1.0.7 +0/0 45/45 3/3 0/0 2/2 ☢️ │ └── syn 1.0.53 +0/0 0/0 0/0 0/0 0/0 ❓ ├── strum_macros 0.19.4 +0/0 2/2 0/0 0/0 0/0 ☢️ ├── url 2.1.1 +0/0 0/0 0/0 0/0 0/0 ❓ └── walkdir 2.3.1 + +191/206 18950/21161 92/98 5/5 250/309 + +``` diff --git a/cargo-geiger/Cargo.toml b/cargo-geiger/Cargo.toml index 5dc61ec5..ab7e7bd4 100644 --- a/cargo-geiger/Cargo.toml +++ b/cargo-geiger/Cargo.toml @@ -28,8 +28,8 @@ pico-args = "0.3.3" regex = "1.4.2" serde = { version = "1.0.116", features = ["derive"] } serde_json = "1.0.57" -strum = "0.19.2" -strum_macros = "0.19.2" +strum = "0.20.0" +strum_macros = "0.20.1" walkdir = "2.3.1" anyhow = "1.0.31" url = "2.1.1" diff --git a/cargo-geiger/src/args.rs b/cargo-geiger/src/args.rs index 33d017b9..00b31eaf 100644 --- a/cargo-geiger/src/args.rs +++ b/cargo-geiger/src/args.rs @@ -1,5 +1,4 @@ use crate::format::print_config::OutputFormat; -use crate::format::Charset; use cargo::core::shell::ColorChoice; use cargo::{CliResult, Config}; @@ -29,11 +28,10 @@ OPTIONS: than a tree), but prefixed with the depth. -a, --all Don't truncate dependencies that have already been displayed. - --charset Character set to use in output: utf8, ascii - [default: utf8]. --format Format string used for printing dependencies [default: {p}]. - --json Output in JSON format. + --output-format Output format for the report: Ascii, GitHubMarkdown, + Json, Utf8 [default: Utf8] --update-readme Writes output to ./README.md. Looks for a Safety Report section, replaces if found, adds if not. Throws an error if no README.md exists. @@ -67,7 +65,6 @@ OPTIONS: #[derive(Default)] pub struct Args { pub all: bool, - pub charset: Charset, pub color: Option, pub deps_args: DepsArgs, pub features_args: FeaturesArgs, @@ -81,6 +78,7 @@ pub struct Args { pub manifest_path: Option, pub no_indent: bool, pub offline: bool, + pub output_format: OutputFormat, pub package: Option, pub prefix_depth: bool, pub quiet: bool, @@ -89,7 +87,6 @@ pub struct Args { pub unstable_flags: Vec, pub verbose: u32, pub version: bool, - pub output_format: Option, } impl Args { @@ -103,11 +100,8 @@ impl Args { pub fn parse_args( mut raw_args: Arguments, ) -> Result> { - let args = Args { + let mut args = Args { all: raw_args.contains(["-a", "--all"]), - charset: raw_args - .opt_value_from_str("--charset")? - .unwrap_or(Charset::Utf8), color: raw_args.opt_value_from_str("--color")?, deps_args: DepsArgs { all_deps: raw_args.contains("--all-dependencies"), @@ -158,12 +152,22 @@ impl Args { (true, _) => 2, }, version: raw_args.contains(["-V", "--version"]), - output_format: if raw_args.contains("--json") { - Some(OutputFormat::Json) - } else { - None - }, + output_format: raw_args + .opt_value_from_str("--output-format")? + .unwrap_or(OutputFormat::Utf8), }; + + if args.readme_args.update_readme + && args.output_format != OutputFormat::GitHubMarkdown + { + eprintln!( + "OutputFormat has been specified as {:?}, but the `--update-readme` flag has also been provided. \ + To ensure the report written to the README.md is correct, a reduced charset will be used.", + args.output_format + ); + args.output_format = OutputFormat::GitHubMarkdown + } + Ok(args) } @@ -244,6 +248,7 @@ fn parse_features(raw_features: Option) -> Vec { pub mod args_tests { use super::*; + use cargo::core::shell::ColorChoice; use cargo::core::Verbosity; use rstest::*; use std::ffi::OsString; @@ -251,43 +256,55 @@ pub mod args_tests { #[rstest( input_argument_vector, expected_all, - expected_charset, + expected_output_format, expected_verbose, case( vec![], false, - Charset::Utf8, + OutputFormat::Utf8, 0 ), case( vec![OsString::from("--all")], true, - Charset::Utf8, + OutputFormat::Utf8, 0, ), case( - vec![OsString::from("--charset"), OsString::from("ascii")], + vec![OsString::from("--output-format"), OsString::from("Ascii")], false, - Charset::Ascii, + OutputFormat::Ascii, 0 ), case( vec![OsString::from("-v")], false, - Charset::Utf8, + OutputFormat::Utf8, 1 ), case( vec![OsString::from("-vv")], false, - Charset::Utf8, + OutputFormat::Utf8, 2 + ), + case( + vec![OsString::from("--update-readme")], + false, + OutputFormat::GitHubMarkdown, + 0 + ), + case( + vec![OsString::from("--update-readme"), OsString::from("--output-format"), OsString::from("Ascii")], + false, + OutputFormat::GitHubMarkdown, + 0 ) )] fn parse_args_test( input_argument_vector: Vec, expected_all: bool, - expected_charset: Charset, + expected_output_format: OutputFormat, expected_verbose: u32, ) { let args_result = @@ -298,7 +315,7 @@ pub mod args_tests { let args = args_result.unwrap(); assert_eq!(args.all, expected_all); - assert_eq!(args.charset, expected_charset); + assert_eq!(args.output_format, expected_output_format); assert_eq!(args.verbose, expected_verbose) } diff --git a/cargo-geiger/src/format.rs b/cargo-geiger/src/format.rs index fd38ed42..9355f267 100644 --- a/cargo-geiger/src/format.rs +++ b/cargo-geiger/src/format.rs @@ -14,6 +14,7 @@ use strum_macros::EnumIter; #[derive(Clone, Copy, Debug, PartialEq)] pub enum Charset { Ascii, + GitHubMarkdown, Utf8, } @@ -35,8 +36,10 @@ impl FromStr for Charset { type Err = &'static str; fn from_str(s: &str) -> Result { - match s { + let comparison_string = String::from(s).to_lowercase(); + match comparison_string.as_str() { "ascii" => Ok(Charset::Ascii), + "githubmarkdown" => Ok(Charset::GitHubMarkdown), "utf8" => Ok(Charset::Utf8), _ => Err("invalid charset"), } @@ -94,11 +97,20 @@ mod format_tests { use rstest::*; - #[rstest] - fn charset_from_str_test() { - assert_eq!(Charset::from_str("ascii"), Ok(Charset::Ascii)); - assert_eq!(Charset::from_str("utf8"), Ok(Charset::Utf8)); - assert_eq!(Charset::from_str("invalid_str"), Err("invalid charset")); + #[rstest( + input_string, + expected_enum_result, + case("ascii", Ok(Charset::Ascii)), + case("githubmarkdown", Ok(Charset::GitHubMarkdown)), + case("utf8", Ok(Charset::Utf8)), + case("UTF8", Ok(Charset::Utf8)), + case("invalid_str", Err("invalid charset")) + )] + fn charset_from_str_test( + input_string: &str, + expected_enum_result: Result, + ) { + assert_eq!(Charset::from_str(input_string), expected_enum_result); } #[rstest] diff --git a/cargo-geiger/src/format/emoji_symbols.rs b/cargo-geiger/src/format/emoji_symbols.rs index f5d2f8c7..53773cf0 100644 --- a/cargo-geiger/src/format/emoji_symbols.rs +++ b/cargo-geiger/src/format/emoji_symbols.rs @@ -1,11 +1,12 @@ -use crate::format::{Charset, SymbolKind}; +use crate::format::print_config::{colorize, OutputFormat}; +use crate::format::{CrateDetectionStatus, SymbolKind}; -use colored::Colorize; +use colored::ColoredString; pub struct EmojiSymbols { - charset: Charset, emojis: [&'static str; 3], - fallbacks: [colored::ColoredString; 3], + fallbacks: [ColoredString; 3], + output_format: OutputFormat, } impl EmojiSymbols { @@ -18,16 +19,33 @@ impl EmojiSymbols { } } - pub fn new(charset: Charset) -> EmojiSymbols { + pub fn new(output_format: OutputFormat) -> EmojiSymbols { Self { - charset, emojis: ["🔒", "❓", "☢️"], - fallbacks: [":)".green(), "?".normal(), "!".red().bold()], + fallbacks: [ + colorize( + &CrateDetectionStatus::NoneDetectedForbidsUnsafe, + output_format, + String::from(":)"), + ), + colorize( + &CrateDetectionStatus::NoneDetectedAllowsUnsafe, + output_format, + String::from("?"), + ), + colorize( + &CrateDetectionStatus::UnsafeDetected, + output_format, + String::from("!"), + ), + ], + output_format, } } pub fn will_output_emoji(&self) -> bool { - self.charset == Charset::Utf8 - && console::Term::stdout().features().wants_emoji() + (self.output_format == OutputFormat::Utf8 + && console::Term::stdout().features().wants_emoji()) + || self.output_format == OutputFormat::GitHubMarkdown } } diff --git a/cargo-geiger/src/format/print_config.rs b/cargo-geiger/src/format/print_config.rs index 5606f3c7..aa56637e 100644 --- a/cargo-geiger/src/format/print_config.rs +++ b/cargo-geiger/src/format/print_config.rs @@ -1,12 +1,13 @@ use crate::args::Args; use crate::format::pattern::Pattern; -use crate::format::{Charset, CrateDetectionStatus, FormatError}; +use crate::format::{CrateDetectionStatus, FormatError}; use cargo::core::shell::Verbosity; use cargo::util::errors::CliError; -use colored::Colorize; +use colored::{ColoredString, Colorize}; use geiger::IncludeTests; use petgraph::EdgeDirection; +use strum_macros::EnumString; #[derive(Clone, Copy, Debug, PartialEq)] pub enum Prefix { @@ -15,9 +16,18 @@ pub enum Prefix { None, } -#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, EnumString, Eq, PartialEq)] pub enum OutputFormat { + Ascii, Json, + GitHubMarkdown, + Utf8, +} + +impl Default for OutputFormat { + fn default() -> Self { + OutputFormat::Utf8 + } } #[derive(Debug, PartialEq)] @@ -26,7 +36,6 @@ pub struct PrintConfig { pub all: bool, pub allow_partial_results: bool, - pub charset: Charset, pub direction: EdgeDirection, // Is anyone using this? This is a carry-over from cargo-tree. @@ -35,7 +44,7 @@ pub struct PrintConfig { pub include_tests: IncludeTests, pub prefix: Prefix, - pub output_format: Option, + pub output_format: OutputFormat, pub verbosity: Verbosity, } @@ -83,7 +92,6 @@ impl PrintConfig { Ok(PrintConfig { all: args.all, allow_partial_results, - charset: args.charset, direction, format, include_tests, @@ -95,13 +103,17 @@ impl PrintConfig { } pub fn colorize( - string: String, crate_detection_status: &CrateDetectionStatus, -) -> colored::ColoredString { - match crate_detection_status { - CrateDetectionStatus::NoneDetectedForbidsUnsafe => string.green(), - CrateDetectionStatus::NoneDetectedAllowsUnsafe => string.normal(), - CrateDetectionStatus::UnsafeDetected => string.red().bold(), + output_format: OutputFormat, + string: String, +) -> ColoredString { + match output_format { + OutputFormat::GitHubMarkdown => ColoredString::from(string.as_str()), + _ => match crate_detection_status { + CrateDetectionStatus::NoneDetectedForbidsUnsafe => string.green(), + CrateDetectionStatus::NoneDetectedAllowsUnsafe => string.normal(), + CrateDetectionStatus::UnsafeDetected => string.red().bold(), + }, } } @@ -109,8 +121,8 @@ pub fn colorize( mod print_config_tests { use super::*; - use colored::ColoredString; use rstest::*; + use std::str::FromStr; #[rstest( input_invert_bool, @@ -208,31 +220,72 @@ mod print_config_tests { assert_eq!(print_config_result.unwrap().verbosity, expected_verbosity); } + #[rstest( + input_raw_str, + expected_output_format_result, + case("Ascii", Ok(OutputFormat::Ascii)), + case("Json", Ok(OutputFormat::Json)), + case("GitHubMarkdown", Ok(OutputFormat::GitHubMarkdown)), + case("Utf8", Ok(OutputFormat::Utf8)), + case("unknown_variant", Err(strum::ParseError::VariantNotFound)) + )] + fn output_format_from_str_test( + input_raw_str: &str, + expected_output_format_result: Result, + ) { + let output_format = OutputFormat::from_str(input_raw_str); + assert_eq!(output_format, expected_output_format_result); + } + #[rstest( input_crate_detection_status, - expected_colorized_string, + input_output_format, + expected_colored_string, case( CrateDetectionStatus::NoneDetectedForbidsUnsafe, + OutputFormat::Ascii, String::from("string_value").green() ), case( CrateDetectionStatus::NoneDetectedAllowsUnsafe, + OutputFormat::Utf8, String::from("string_value").normal() ), case( CrateDetectionStatus::UnsafeDetected, + OutputFormat::Ascii, String::from("string_value").red().bold() + ), + case( + CrateDetectionStatus::NoneDetectedForbidsUnsafe, + OutputFormat::GitHubMarkdown, + ColoredString::from("string_value") + ), + case( + CrateDetectionStatus::NoneDetectedAllowsUnsafe, + OutputFormat::GitHubMarkdown, + ColoredString::from("string_value") + ), + case( + CrateDetectionStatus::UnsafeDetected, + OutputFormat::GitHubMarkdown, + ColoredString::from("string_value") ) )] fn colorize_test( input_crate_detection_status: CrateDetectionStatus, - expected_colorized_string: ColoredString, + input_output_format: OutputFormat, + expected_colored_string: ColoredString, ) { let string_value = String::from("string_value"); assert_eq!( - colorize(string_value, &input_crate_detection_status), - expected_colorized_string + colorize( + &input_crate_detection_status, + input_output_format, + string_value + ), + expected_colored_string ); } } diff --git a/cargo-geiger/src/format/table.rs b/cargo-geiger/src/format/table.rs index 043f5015..330d0967 100644 --- a/cargo-geiger/src/format/table.rs +++ b/cargo-geiger/src/format/table.rs @@ -2,7 +2,7 @@ mod handle_text_tree_line; mod total_package_counts; use crate::format::emoji_symbols::EmojiSymbols; -use crate::format::print_config::{colorize, PrintConfig}; +use crate::format::print_config::{colorize, OutputFormat, PrintConfig}; use crate::format::CrateDetectionStatus; use crate::mapping::CargoMetadataParameters; use crate::scan::{GeigerContext, ScanResult}; @@ -15,6 +15,7 @@ use handle_text_tree_line::{ use total_package_counts::TotalPackageCounts; use cargo_geiger_serde::{Count, CounterBlock}; +use colored::ColoredString; use std::collections::HashSet; use std::path::PathBuf; @@ -40,7 +41,7 @@ pub fn create_table_from_text_tree_lines( let mut warning_count = 0; let mut visited_package_ids = HashSet::new(); let emoji_symbols = - EmojiSymbols::new(table_parameters.print_config.charset); + EmojiSymbols::new(table_parameters.print_config.output_format); let mut handle_package_parameters = HandlePackageParameters { total_package_counts: &mut total_package_counts, visited_package_ids: &mut visited_package_ids, @@ -81,6 +82,7 @@ pub fn create_table_from_text_tree_lines( table_footer( total_package_counts.total_counter_block, total_package_counts.total_unused_counter_block, + table_parameters.print_config.output_format, total_detection_status ) )); @@ -102,8 +104,9 @@ pub struct TableParameters<'a> { fn table_footer( used: CounterBlock, not_used: CounterBlock, + output_format: OutputFormat, status: CrateDetectionStatus, -) -> colored::ColoredString { +) -> ColoredString { let fmt = |used: &Count, not_used: &Count| { format!("{}/{}", used.unsafe_, used.unsafe_ + not_used.unsafe_) }; @@ -115,7 +118,7 @@ fn table_footer( fmt(&used.item_traits, ¬_used.item_traits), fmt(&used.methods, ¬_used.methods), ); - colorize(output, &status) + colorize(&status, output_format, output) } fn table_row(used: &CounterBlock, not_used: &CounterBlock) -> String { @@ -157,24 +160,44 @@ mod table_tests { use std::path::Path; use strum::IntoEnumIterator; - #[rstest] - fn table_footer_test() { + #[rstest( + input_output_format, + expected_line, + case( + OutputFormat::Ascii, + String::from("2/4 4/8 6/12 8/16 10/20 ") + ), + case( + OutputFormat::GitHubMarkdown, + String::from("2/4 4/8 6/12 8/16 10/20 ") + ), + case( + OutputFormat::Utf8, + String::from("2/4 4/8 6/12 8/16 10/20 ") + ) + )] + fn table_footer_test( + input_output_format: OutputFormat, + expected_line: String, + ) { let used_counter_block = create_counter_block(); let not_used_counter_block = create_counter_block(); - let expected_line = - String::from("2/4 4/8 6/12 8/16 10/20 "); - for crate_detection_status in CrateDetectionStatus::iter() { let table_footer = table_footer( used_counter_block.clone(), not_used_counter_block.clone(), + input_output_format, crate_detection_status.clone(), ); assert_eq!( table_footer, - colorize(expected_line.clone(), &crate_detection_status) + colorize( + &crate_detection_status, + input_output_format, + expected_line.clone() + ) ); } } diff --git a/cargo-geiger/src/format/table/handle_text_tree_line.rs b/cargo-geiger/src/format/table/handle_text_tree_line.rs index 232256dc..6ea665d3 100644 --- a/cargo-geiger/src/format/table/handle_text_tree_line.rs +++ b/cargo-geiger/src/format/table/handle_text_tree_line.rs @@ -1,5 +1,5 @@ use crate::format::emoji_symbols::EmojiSymbols; -use crate::format::print_config::colorize; +use crate::format::print_config::{colorize, OutputFormat}; use crate::format::{get_kind_group_name, CrateDetectionStatus, SymbolKind}; use crate::mapping::CargoMetadataParameters; use crate::scan::unsafe_stats; @@ -91,6 +91,8 @@ pub fn handle_text_tree_line_package( }; let package_name = colorize( + &crate_detection_status, + table_parameters.print_config.output_format, format!( "{}", table_parameters @@ -98,11 +100,11 @@ pub fn handle_text_tree_line_package( .format .display(cargo_metadata_parameters, &package_id) ), - &crate_detection_status, ); let unsafe_info = colorize( - table_row(&unsafe_info.used, &unsafe_info.unused), &crate_detection_status, + table_parameters.print_config.output_format, + table_row(&unsafe_info.used, &unsafe_info.unused), ); let shift_chars = unsafe_info.chars().count() + 4; @@ -117,9 +119,19 @@ pub fn handle_text_tree_line_package( // count as a single character if using the column formatting provided by // Rust. This could be unrelated to Rust and a quirk of this particular // symbol or something in the Terminal app on macOS. - if emoji_symbols.will_output_emoji() { + if emoji_symbols.will_output_emoji() + && table_parameters.print_config.output_format + != OutputFormat::GitHubMarkdown + { line.push('\r'); // Return the cursor to the start of the line. line.push_str(format!("\x1B[{}C", shift_chars).as_str()); // Move the cursor to the right so that it points to the icon character. + } else if table_parameters.print_config.output_format + == OutputFormat::GitHubMarkdown + && crate_detection_status == CrateDetectionStatus::UnsafeDetected + { + // When rendering output in the GitHubMarkdown format, the Rads symbol + // is only rendered as a single char, needing an extra space + line.push_str(" "); } table_lines.push(format!("{} {}{}", line, tree_vines, package_name)); diff --git a/cargo-geiger/src/mapping.rs b/cargo-geiger/src/mapping.rs index 52eb35b1..da183cb6 100644 --- a/cargo-geiger/src/mapping.rs +++ b/cargo-geiger/src/mapping.rs @@ -3,6 +3,7 @@ mod krates; mod metadata; use ::krates::Krates; +use cargo::core::dependency::DepKind; use cargo_metadata::Metadata; use std::collections::HashSet; use std::path::PathBuf; @@ -68,6 +69,10 @@ pub trait QueryResolve { fn query_resolve(&self, query: &str) -> Option; } +pub trait ToCargoCoreDepKind { + fn to_cargo_core_dep_kind(&self) -> DepKind; +} + pub trait ToCargoGeigerDependencyKind { fn to_cargo_geiger_dependency_kind( &self, diff --git a/cargo-geiger/src/mapping/metadata.rs b/cargo-geiger/src/mapping/metadata.rs index 3a5b55fe..6ef242de 100644 --- a/cargo-geiger/src/mapping/metadata.rs +++ b/cargo-geiger/src/mapping/metadata.rs @@ -137,15 +137,13 @@ impl ToCargoMetadataPackage for cargo_metadata::PackageId { mod metadata_tests { use super::*; - use super::super::GetPackageNameFromCargoMetadataPackageId; + use super::super::{ + GetPackageNameFromCargoMetadataPackageId, ToCargoCoreDepKind, + }; use crate::args::FeaturesArgs; use crate::cli::get_workspace; - // ISSUE-69 - These dependencies are used for testing only, to confirm - // that the changes made for ISSUE-16 retain feature parity. A discussion can - // be had about if it is worth keeping these in and paying the corresponding - // cost in compile time when building tests use cargo::core::dependency::DepKind; use cargo::core::registry::PackageRegistry; use cargo::core::resolver::ResolveOpts; @@ -153,7 +151,6 @@ mod metadata_tests { Package, PackageId, PackageIdSpec, PackageSet, Resolve, Workspace, }; use cargo::{ops, CargoResult, Config}; - use cargo_metadata::{CargoOpt, Metadata, MetadataCommand}; use krates::Builder as KratesBuilder; use rstest::*; @@ -346,10 +343,6 @@ mod metadata_tests { Ok((packages, resolve)) } - trait ToCargoCoreDepKind { - fn to_cargo_core_dep_kind(&self) -> DepKind; - } - impl ToCargoCoreDepKind for DependencyKind { fn to_cargo_core_dep_kind(&self) -> DepKind { match self { diff --git a/cargo-geiger/src/readme.rs b/cargo-geiger/src/readme.rs index e533253f..b38ad6ce 100644 --- a/cargo-geiger/src/readme.rs +++ b/cargo-geiger/src/readme.rs @@ -60,7 +60,7 @@ fn find_start_and_end_lines_of_safety_report_section( let start_line_pattern = construct_regex_expression_for_section_header(readme_args); - let end_line_pattern = Regex::new("#+.*").unwrap(); + let end_line_pattern = Regex::new("^#+.*").unwrap(); for (line_number, line) in readme_content.iter().enumerate() { if start_line_pattern.is_match(line) { @@ -84,14 +84,14 @@ fn construct_regex_expression_for_section_header( ) -> Regex { match &readme_args.section_name { Some(section_name) => { - let mut regex_string = String::from("#+\\s"); + let mut regex_string = String::from("^#+\\s"); regex_string.push_str(§ion_name.replace(' ', "\\s")); regex_string.push_str("\\s*"); Regex::new(®ex_string).unwrap() } None => { - Regex::new("#+\\sCargo\\sGeiger\\sSafety\\sReport\\s*").unwrap() + Regex::new("^#+\\sCargo\\sGeiger\\sSafety\\sReport\\s*").unwrap() } } } @@ -119,7 +119,7 @@ fn update_readme_content( readme_content: &mut Vec, scan_result: &[String], ) { - let (start_line_number, end_line_number) = + let (start_line_number, mut end_line_number) = find_start_and_end_lines_of_safety_report_section( readme_args, &readme_content, @@ -141,10 +141,16 @@ fn update_readme_content( ); } } + readme_content.push(String::from("```")); for scan_result_line in scan_result { readme_content.push(scan_result_line.to_string()) } + readme_content.push(String::from("```")); } else { + if end_line_number == -1 { + end_line_number = readme_content.len() as i32; + } + // When Cargo Geiger Safety Report is present in README, remove the // section and and replace, preserving header level (h1/h2/h3) for _ in start_line_number + 1..end_line_number { @@ -153,6 +159,10 @@ fn update_readme_content( let mut running_scan_line_index = start_line_number + 1; + readme_content + .insert(running_scan_line_index as usize, String::from("```")); + running_scan_line_index += 1; + for scan_result_line in scan_result { readme_content.insert( running_scan_line_index as usize, @@ -160,6 +170,9 @@ fn update_readme_content( ); running_scan_line_index += 1; } + + readme_content + .insert(running_scan_line_index as usize, String::from("```")); } } @@ -190,7 +203,7 @@ mod readme_tests { } #[rstest] - fn create_or_replace_section_test_reademe_doesnt_contain_section() { + fn create_or_replace_section_test_readme_doesnt_contain_section() { let temp_dir = tempdir().unwrap(); let readme_path = temp_dir.path().join("README.md"); @@ -229,9 +242,11 @@ mod readme_tests { String::from("## Another header"), String::from("More text"), CARGO_GEIGER_SAFETY_REPORT_SECTION_HEADER.to_string(), + String::from("```"), String::from("First safety report line"), String::from("Second safety report line"), String::from("Third safety report line"), + String::from("```"), ]; assert_eq!(updated_file_content, expected_readme_content) @@ -245,14 +260,14 @@ mod readme_tests { section_name: None, ..Default::default() }, - Regex::new("#+\\sCargo\\sGeiger\\sSafety\\sReport\\s*").unwrap() + Regex::new("^#+\\sCargo\\sGeiger\\sSafety\\sReport\\s*").unwrap() ), case( ReadmeArgs{ section_name: Some(String::from("Test Section Name")), ..Default::default() }, - Regex::new("#+\\sTest\\sSection\\sName\\s*").unwrap() + Regex::new("^#+\\sTest\\sSection\\sName\\s*").unwrap() ) )] fn construct_regex_expression_for_section_header_test( @@ -420,9 +435,11 @@ mod readme_tests { String::from("another line of text"), String::from("## another header"), expected_section_header, + String::from("```"), String::from("first line of scan result"), String::from("second line of scan result"), String::from("third line of scan result"), + String::from("```"), ]; assert_eq!(readme_content, expected_readme_content); @@ -456,9 +473,11 @@ mod readme_tests { String::from("line of text"), String::from("another line of text"), CARGO_GEIGER_SAFETY_REPORT_SECTION_HEADER.to_string(), + String::from("```"), String::from("first line of scan result"), String::from("second line of scan result"), String::from("third line of scan result"), + String::from("```"), String::from("# another header"), String::from("line of text"), ]; diff --git a/cargo-geiger/src/scan/default.rs b/cargo-geiger/src/scan/default.rs index 9a99855d..4ae6ef71 100644 --- a/cargo-geiger/src/scan/default.rs +++ b/cargo-geiger/src/scan/default.rs @@ -29,15 +29,15 @@ pub fn scan_unsafe( workspace: &Workspace, ) -> Result { match scan_parameters.args.output_format { - Some(output_format) => scan_to_report( + OutputFormat::Json => scan_to_report( cargo_metadata_parameters, graph, - output_format, + scan_parameters.args.output_format, root_package_id, scan_parameters, workspace, ), - None => scan_to_table( + _ => scan_to_table( cargo_metadata_parameters, graph, root_package_id, @@ -145,12 +145,13 @@ fn scan_to_report( list_files_used_but_not_scanned(&geiger_context, &rs_files_used) .into_iter() .collect(); - let s = match output_format { + let json_string = match output_format { OutputFormat::Json => serde_json::to_string(&report).unwrap(), + _ => panic!("Only implemented for OutputFormat::Json"), }; Ok(ScanResult { - scan_output_lines: vec![s], + scan_output_lines: vec![json_string], warning_count: 0, }) } diff --git a/cargo-geiger/src/scan/default/table.rs b/cargo-geiger/src/scan/default/table.rs index faa0af86..301e3c76 100644 --- a/cargo-geiger/src/scan/default/table.rs +++ b/cargo-geiger/src/scan/default/table.rs @@ -1,4 +1,5 @@ use crate::format::emoji_symbols::EmojiSymbols; +use crate::format::print_config::OutputFormat; use crate::format::table::{ create_table_from_text_tree_lines, TableParameters, UNSAFE_COUNTERS_HEADER, }; @@ -39,8 +40,12 @@ pub fn scan_to_table( combined_scan_output_lines.append(&mut rs_files_used_lines); } - let emoji_symbols = EmojiSymbols::new(scan_parameters.print_config.charset); - let mut output_key_lines = construct_key_lines(&emoji_symbols); + let emoji_symbols = + EmojiSymbols::new(scan_parameters.print_config.output_format); + let mut output_key_lines = construct_key_lines( + &emoji_symbols, + scan_parameters.print_config.output_format, + ); combined_scan_output_lines.append(&mut output_key_lines); let text_tree_lines = walk_dependency_tree( @@ -81,7 +86,10 @@ pub fn scan_to_table( }) } -fn construct_key_lines(emoji_symbols: &EmojiSymbols) -> Vec { +fn construct_key_lines( + emoji_symbols: &EmojiSymbols, + output_format: OutputFormat, +) -> Vec { let mut output_key_lines = Vec::::new(); output_key_lines.push(String::new()); @@ -97,12 +105,15 @@ fn construct_key_lines(emoji_symbols: &EmojiSymbols) -> Vec { let unknown = "No `unsafe` usage found, missing #![forbid(unsafe_code)]"; let guilty = "`unsafe` usage found"; - let shift_sequence = if emoji_symbols.will_output_emoji() { - "\r\x1B[7C" // The radiation icon's Unicode width is 2, - // but by most terminals it seems to be rendered at width 1. - } else { - "" - }; + let shift_sequence = + match (output_format, emoji_symbols.will_output_emoji()) { + (OutputFormat::GitHubMarkdown, true) => " ", + (_, true) => { + "\r\x1B[7C" // The radiation icon's Unicode width is 2, + // but by most terminals it seems to be rendered at width 1. + } + _ => "", + }; let symbol_kinds_to_string_values = vec![ (SymbolKind::Lock, "", forbids), @@ -122,15 +133,18 @@ fn construct_key_lines(emoji_symbols: &EmojiSymbols) -> Vec { } output_key_lines.push(String::new()); - output_key_lines.push(format!( - "{}", - UNSAFE_COUNTERS_HEADER - .iter() - .map(|s| s.to_owned()) - .collect::>() - .join(" ") - .bold() - )); + + let key = UNSAFE_COUNTERS_HEADER + .iter() + .map(|s| s.to_owned()) + .collect::>() + .join(" "); + + match output_format { + OutputFormat::GitHubMarkdown => output_key_lines.push(key), + _ => output_key_lines.push(key.bold().to_string()), + } + output_key_lines.push(String::new()); output_key_lines diff --git a/cargo-geiger/src/scan/forbid.rs b/cargo-geiger/src/scan/forbid.rs index 7e5e3cdb..a1aaede3 100644 --- a/cargo-geiger/src/scan/forbid.rs +++ b/cargo-geiger/src/scan/forbid.rs @@ -20,15 +20,15 @@ pub fn scan_forbid_unsafe( scan_parameters: &ScanParameters, ) -> Result { match scan_parameters.args.output_format { - Some(output_format) => scan_forbid_to_report( + OutputFormat::Json => scan_forbid_to_report( cargo_metadata_parameters, scan_parameters.config, graph, - output_format, + scan_parameters.args.output_format, scan_parameters.print_config, root_package_id, ), - None => scan_forbid_to_table( + _ => scan_forbid_to_table( cargo_metadata_parameters, scan_parameters.config, graph, @@ -77,12 +77,13 @@ fn scan_forbid_to_report( }; report.packages.insert(entry.package.id.clone(), entry); } - let s = match output_format { + let json_string = match output_format { OutputFormat::Json => serde_json::to_string(&report).unwrap(), + _ => panic!("Only implemented for OutputFormat::Json"), }; Ok(ScanResult { - scan_output_lines: vec![s], + scan_output_lines: vec![json_string], warning_count: 0, }) } diff --git a/cargo-geiger/src/scan/forbid/table.rs b/cargo-geiger/src/scan/forbid/table.rs index a1ea427b..3578fdce 100644 --- a/cargo-geiger/src/scan/forbid/table.rs +++ b/cargo-geiger/src/scan/forbid/table.rs @@ -23,7 +23,7 @@ pub fn scan_forbid_to_table( root_package_id: PackageId, ) -> Result { let mut scan_output_lines = Vec::::new(); - let emoji_symbols = EmojiSymbols::new(print_config.charset); + let emoji_symbols = EmojiSymbols::new(print_config.output_format); let mut output_key_lines = construct_key_lines(&emoji_symbols); scan_output_lines.append(&mut output_key_lines); @@ -150,12 +150,12 @@ fn handle_package_text_tree_line( #[cfg(test)] mod forbid_tests { use super::*; - use crate::format::Charset; + use crate::format::print_config::OutputFormat; use rstest::*; #[rstest] fn construct_scan_mode_forbid_only_output_key_lines_test() { - let emoji_symbols = EmojiSymbols::new(Charset::Utf8); + let emoji_symbols = EmojiSymbols::new(OutputFormat::Utf8); let output_key_lines = construct_key_lines(&emoji_symbols); assert_eq!(output_key_lines.len(), 5); diff --git a/cargo-geiger/src/tree.rs b/cargo-geiger/src/tree.rs index 2dae271f..37a8b559 100644 --- a/cargo-geiger/src/tree.rs +++ b/cargo-geiger/src/tree.rs @@ -1,7 +1,6 @@ pub mod traversal; -use crate::format::print_config::{Prefix, PrintConfig}; -use crate::format::Charset; +use crate::format::print_config::{OutputFormat, Prefix, PrintConfig}; use cargo_metadata::{DependencyKind, PackageId}; @@ -31,7 +30,7 @@ fn construct_tree_vines_string( levels_continue: &mut Vec, print_config: &PrintConfig, ) -> String { - let tree_symbols = get_tree_symbols(print_config.charset); + let tree_symbols = get_tree_symbols(print_config.output_format); match print_config.prefix { Prefix::Depth => format!("{} ", levels_continue.len()), @@ -56,10 +55,10 @@ fn construct_tree_vines_string( } } -pub fn get_tree_symbols(charset: Charset) -> TreeSymbols { - match charset { - Charset::Utf8 => UTF8_TREE_SYMBOLS, - Charset::Ascii => ASCII_TREE_SYMBOLS, +pub fn get_tree_symbols(output_format: OutputFormat) -> TreeSymbols { + match output_format { + OutputFormat::Ascii => ASCII_TREE_SYMBOLS, + _ => UTF8_TREE_SYMBOLS, } } @@ -82,7 +81,7 @@ mod tree_tests { use super::*; use crate::format::pattern::Pattern; - use crate::format::Charset; + use crate::format::print_config::OutputFormat; use cargo::core::shell::Verbosity; use geiger::IncludeTests; @@ -110,16 +109,20 @@ mod tree_tests { } #[rstest( - input_charset, + input_output_format, expected_tree_symbols, - case(Charset::Utf8, UTF8_TREE_SYMBOLS), - case(Charset::Ascii, ASCII_TREE_SYMBOLS) + case(OutputFormat::Ascii, ASCII_TREE_SYMBOLS), + case(OutputFormat::GitHubMarkdown, UTF8_TREE_SYMBOLS), + case(OutputFormat::Utf8, UTF8_TREE_SYMBOLS) )] fn get_tree_symbols_test( - input_charset: Charset, + input_output_format: OutputFormat, expected_tree_symbols: TreeSymbols, ) { - assert_eq!(get_tree_symbols(input_charset), expected_tree_symbols); + assert_eq!( + get_tree_symbols(input_output_format), + expected_tree_symbols + ); } fn construct_print_config(prefix: Prefix) -> PrintConfig { @@ -130,10 +133,9 @@ mod tree_tests { direction: EdgeDirection::Outgoing, prefix, format: pattern, - charset: Charset::Ascii, allow_partial_results: false, include_tests: IncludeTests::Yes, - output_format: None, + output_format: OutputFormat::Ascii, } } } diff --git a/cargo-geiger/src/tree/traversal/dependency_kind.rs b/cargo-geiger/src/tree/traversal/dependency_kind.rs index ee1a2b18..7dd225d0 100644 --- a/cargo-geiger/src/tree/traversal/dependency_kind.rs +++ b/cargo-geiger/src/tree/traversal/dependency_kind.rs @@ -23,7 +23,7 @@ pub fn walk_dependency_kind( deps.sort_by_key(|n| n.clone()); let tree_symbols = - get_tree_symbols(walk_dependency_parameters.print_config.charset); + get_tree_symbols(walk_dependency_parameters.print_config.output_format); let mut text_tree_lines = Vec::new(); if let Prefix::Indent = walk_dependency_parameters.print_config.prefix { push_extra_deps_group_text_tree_line_for_non_normal_dependencies( @@ -91,7 +91,7 @@ fn push_extra_deps_group_text_tree_line_for_non_normal_dependencies( mod traversal_tests { use super::*; - use crate::format::Charset; + use crate::format::print_config::OutputFormat; use crate::tree::TextTreeLine::ExtraDepsGroup; use rstest::*; @@ -118,7 +118,7 @@ mod traversal_tests { kind: DependencyKind::Build, tree_vines: format!( " {} ", - get_tree_symbols(Charset::Utf8).down + get_tree_symbols(OutputFormat::Utf8).down ) } ] @@ -131,7 +131,7 @@ mod traversal_tests { kind: DependencyKind::Development, tree_vines: format!( "{} ", - get_tree_symbols(Charset::Utf8).down + get_tree_symbols(OutputFormat::Utf8).down ) } ] @@ -158,7 +158,7 @@ mod traversal_tests { expected_text_tree_lines: Vec, ) { let mut text_tree_lines: Vec = vec![]; - let tree_symbols = get_tree_symbols(Charset::Utf8); + let tree_symbols = get_tree_symbols(OutputFormat::Utf8); push_extra_deps_group_text_tree_line_for_non_normal_dependencies( input_dep_kind, diff --git a/cargo-geiger/src/tree/traversal/dependency_node.rs b/cargo-geiger/src/tree/traversal/dependency_node.rs index 67fb9f01..1e795f46 100644 --- a/cargo-geiger/src/tree/traversal/dependency_node.rs +++ b/cargo-geiger/src/tree/traversal/dependency_node.rs @@ -122,8 +122,7 @@ mod dependency_node_tests { use super::*; use crate::format::pattern::Pattern; - use crate::format::print_config::{Prefix, PrintConfig}; - use crate::format::Charset; + use crate::format::print_config::{OutputFormat, Prefix, PrintConfig}; use cargo::core::Verbosity; use cargo_metadata::DependencyKind; @@ -251,12 +250,11 @@ mod dependency_node_tests { PrintConfig { all: false, allow_partial_results: false, - charset: Charset::Ascii, direction: edge_direction, format: Pattern(vec![]), include_tests: IncludeTests::Yes, prefix: Prefix::Depth, - output_format: None, + output_format: OutputFormat::Ascii, verbosity: Verbosity::Verbose, } } diff --git a/cargo-geiger/tests/integration_test/mod.rs b/cargo-geiger/tests/integration_test/mod.rs index af8da9bc..46aa725f 100644 --- a/cargo-geiger/tests/integration_test/mod.rs +++ b/cargo-geiger/tests/integration_test/mod.rs @@ -34,9 +34,9 @@ pub trait IntegrationTest { } fn run_geiger_json(test_name: &str) -> (Output, Context) { - run_geiger_with(test_name, &["--json"]) + run_geiger_with(test_name, &["--output-format", "Json"]) } fn run_geiger_json_quick(test_name: &str) -> (Output, Context) { - run_geiger_with(test_name, &["--forbid-only", "--json"]) + run_geiger_with(test_name, &["--forbid-only", "--output-format", "Json"]) } diff --git a/cargo-geiger/tests/run/mod.rs b/cargo-geiger/tests/run/mod.rs index 8fa4e1c9..aea46edc 100644 --- a/cargo-geiger/tests/run/mod.rs +++ b/cargo-geiger/tests/run/mod.rs @@ -14,7 +14,7 @@ where .arg("geiger") .arg("--color=never") .arg("--quiet") - .arg("--charset=ascii") + .arg("--output-format=Ascii") .arg("--all-targets") .arg("--all-features") .args(extra_args) diff --git a/cargo-geiger/tests/snapshots/readme_integration_tests__test1_package_with_no_deps.readme.snap b/cargo-geiger/tests/snapshots/readme_integration_tests__test1_package_with_no_deps.readme.snap index 4102bfde..fac54af6 100644 --- a/cargo-geiger/tests/snapshots/readme_integration_tests__test1_package_with_no_deps.readme.snap +++ b/cargo-geiger/tests/snapshots/readme_integration_tests__test1_package_with_no_deps.readme.snap @@ -3,20 +3,22 @@ source: cargo-geiger/tests/readme_integration_tests.rs expression: readme_content --- ## Cargo Geiger Safety Report +``` Metric output format: x/y x = unsafe code used by the build y = total unsafe code found in the crate Symbols: - :) = No `unsafe` usage found, declares #![forbid(unsafe_code)] - ? = No `unsafe` usage found, missing #![forbid(unsafe_code)] - ! = `unsafe` usage found + 🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)] + ❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)] + ☢️ = `unsafe` usage found Functions Expressions Impls Traits Methods Dependency -1/1 2/2 0/0 0/0 0/0 ! test1_package_with_no_deps 0.1.0 +1/1 2/2 0/0 0/0 0/0 ☢️ test1_package_with_no_deps 0.1.0 1/1 2/2 0/0 0/0 0/0 +``` diff --git a/cargo-geiger/tests/snapshots/readme_integration_tests__test2_package_with_shallow_deps.readme.snap b/cargo-geiger/tests/snapshots/readme_integration_tests__test2_package_with_shallow_deps.readme.snap index 8b6e4437..a5d3437f 100644 --- a/cargo-geiger/tests/snapshots/readme_integration_tests__test2_package_with_shallow_deps.readme.snap +++ b/cargo-geiger/tests/snapshots/readme_integration_tests__test2_package_with_shallow_deps.readme.snap @@ -3,22 +3,24 @@ source: cargo-geiger/tests/readme_integration_tests.rs expression: readme_content --- ## Cargo Geiger Safety Report +``` Metric output format: x/y x = unsafe code used by the build y = total unsafe code found in the crate Symbols: - :) = No `unsafe` usage found, declares #![forbid(unsafe_code)] - ? = No `unsafe` usage found, missing #![forbid(unsafe_code)] - ! = `unsafe` usage found + 🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)] + ❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)] + ☢️ = `unsafe` usage found Functions Expressions Impls Traits Methods Dependency -1/1 4/4 0/0 0/0 0/0 ! test2_package_with_shallow_deps 0.1.0 -0/0 2/2 0/0 0/0 0/0 ! |-- ref_slice 1.1.1 -1/1 2/2 0/0 0/0 0/0 ! `-- test1_package_with_no_deps 0.1.0 +1/1 4/4 0/0 0/0 0/0 ☢️ test2_package_with_shallow_deps 0.1.0 +0/0 2/2 0/0 0/0 0/0 ☢️ ├── ref_slice 1.1.1 +1/1 2/2 0/0 0/0 0/0 ☢️ └── test1_package_with_no_deps 0.1.0 2/2 8/8 0/0 0/0 0/0 +``` diff --git a/cargo-geiger/tests/snapshots/readme_integration_tests__test3_package_with_nested_deps.readme.snap b/cargo-geiger/tests/snapshots/readme_integration_tests__test3_package_with_nested_deps.readme.snap index 36c4eafc..0b319960 100644 --- a/cargo-geiger/tests/snapshots/readme_integration_tests__test3_package_with_nested_deps.readme.snap +++ b/cargo-geiger/tests/snapshots/readme_integration_tests__test3_package_with_nested_deps.readme.snap @@ -9,28 +9,30 @@ Some text Some more text ## Cargo Geiger Safety Report +``` Metric output format: x/y x = unsafe code used by the build y = total unsafe code found in the crate Symbols: - :) = No `unsafe` usage found, declares #![forbid(unsafe_code)] - ? = No `unsafe` usage found, missing #![forbid(unsafe_code)] - ! = `unsafe` usage found + 🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)] + ❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)] + ☢️ = `unsafe` usage found Functions Expressions Impls Traits Methods Dependency -0/0 1/1 0/0 0/0 0/0 ! test3_package_with_nested_deps 0.1.0 -0/0 0/0 0/0 0/0 0/0 ? |-- doc-comment 0.3.1 -0/0 0/72 0/3 0/1 0/3 ? |-- itertools 0.8.0 -0/0 0/0 0/0 0/0 0/0 ? | `-- either 1.5.2 -1/1 4/4 0/0 0/0 0/0 ! `-- test2_package_with_shallow_deps 0.1.0 -0/0 2/2 0/0 0/0 0/0 ! |-- ref_slice 1.1.1 -1/1 2/2 0/0 0/0 0/0 ! `-- test1_package_with_no_deps 0.1.0 +0/0 1/1 0/0 0/0 0/0 ☢️ test3_package_with_nested_deps 0.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ ├── doc-comment 0.3.1 +0/0 0/72 0/3 0/1 0/3 ❓ ├── itertools 0.8.0 +0/0 0/0 0/0 0/0 0/0 ❓ │ └── either 1.5.2 +1/1 4/4 0/0 0/0 0/0 ☢️ └── test2_package_with_shallow_deps 0.1.0 +0/0 2/2 0/0 0/0 0/0 ☢️ ├── ref_slice 1.1.1 +1/1 2/2 0/0 0/0 0/0 ☢️ └── test1_package_with_no_deps 0.1.0 2/2 9/81 0/3 0/1 0/3 +``` ## Second Section Header Some more text diff --git a/cargo-geiger/tests/snapshots/readme_integration_tests__test4_workspace_with_top_level_package.readme.snap b/cargo-geiger/tests/snapshots/readme_integration_tests__test4_workspace_with_top_level_package.readme.snap index e4ea9096..daef5b4d 100644 --- a/cargo-geiger/tests/snapshots/readme_integration_tests__test4_workspace_with_top_level_package.readme.snap +++ b/cargo-geiger/tests/snapshots/readme_integration_tests__test4_workspace_with_top_level_package.readme.snap @@ -9,21 +9,23 @@ Some text Some more text ## Test Section Name +``` Metric output format: x/y x = unsafe code used by the build y = total unsafe code found in the crate Symbols: - :) = No `unsafe` usage found, declares #![forbid(unsafe_code)] - ? = No `unsafe` usage found, missing #![forbid(unsafe_code)] - ! = `unsafe` usage found + 🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)] + ❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)] + ☢️ = `unsafe` usage found Functions Expressions Impls Traits Methods Dependency -0/0 0/1 0/0 0/0 0/0 ? test4_workspace_with_top_level_package 0.1.0 -1/1 2/2 0/0 0/0 0/0 ! `-- test1_package_with_no_deps 0.1.0 +0/0 0/1 0/0 0/0 0/0 ❓ test4_workspace_with_top_level_package 0.1.0 +1/1 2/2 0/0 0/0 0/0 ☢️ └── test1_package_with_no_deps 0.1.0 1/1 2/3 0/0 0/0 0/0 +``` diff --git a/cargo-geiger/tests/snapshots/readme_integration_tests__test6_cargo_lock_out_of_date.readme.snap b/cargo-geiger/tests/snapshots/readme_integration_tests__test6_cargo_lock_out_of_date.readme.snap index 41a14f17..2d249579 100644 --- a/cargo-geiger/tests/snapshots/readme_integration_tests__test6_cargo_lock_out_of_date.readme.snap +++ b/cargo-geiger/tests/snapshots/readme_integration_tests__test6_cargo_lock_out_of_date.readme.snap @@ -3,28 +3,30 @@ source: cargo-geiger/tests/readme_integration_tests.rs expression: readme_content --- ## Cargo Geiger Safety Report +``` Metric output format: x/y x = unsafe code used by the build y = total unsafe code found in the crate Symbols: - :) = No `unsafe` usage found, declares #![forbid(unsafe_code)] - ? = No `unsafe` usage found, missing #![forbid(unsafe_code)] - ! = `unsafe` usage found + 🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)] + ❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)] + ☢️ = `unsafe` usage found Functions Expressions Impls Traits Methods Dependency -0/0 0/0 0/0 0/0 0/0 :) test6_cargo_lock_out_of_date 0.1.0 -0/0 0/0 0/0 0/0 0/0 :) |-- generational-arena 0.2.2 -0/0 0/0 0/0 0/0 0/0 ? | `-- cfg-if 0.1.9 -0/0 1/1 0/0 0/0 0/0 ! `-- idna 0.1.5 -0/0 0/0 0/0 0/0 0/0 ? |-- matches 0.1.8 -0/0 0/0 0/0 0/0 0/0 :) |-- unicode-bidi 0.3.4 -0/0 0/0 0/0 0/0 0/0 ? | `-- matches 0.1.8 -0/0 20/20 0/0 0/0 0/0 ! `-- unicode-normalization 0.1.8 -2/2 354/354 4/4 1/1 13/13 ! `-- smallvec 0.6.9 +0/0 0/0 0/0 0/0 0/0 🔒 test6_cargo_lock_out_of_date 0.1.0 +0/0 0/0 0/0 0/0 0/0 🔒 ├── generational-arena 0.2.2 +0/0 0/0 0/0 0/0 0/0 ❓ │ └── cfg-if 0.1.9 +0/0 1/1 0/0 0/0 0/0 ☢️ └── idna 0.1.5 +0/0 0/0 0/0 0/0 0/0 ❓ ├── matches 0.1.8 +0/0 0/0 0/0 0/0 0/0 🔒 ├── unicode-bidi 0.3.4 +0/0 0/0 0/0 0/0 0/0 ❓ │ └── matches 0.1.8 +0/0 20/20 0/0 0/0 0/0 ☢️ └── unicode-normalization 0.1.8 +2/2 354/354 4/4 1/1 13/13 ☢️ └── smallvec 0.6.9 2/2 375/375 4/4 1/1 13/13 +``` diff --git a/cargo-geiger/tests/snapshots/readme_integration_tests__test7_package_with_patched_dep.readme.snap b/cargo-geiger/tests/snapshots/readme_integration_tests__test7_package_with_patched_dep.readme.snap index 0755e4d8..a51485b1 100644 --- a/cargo-geiger/tests/snapshots/readme_integration_tests__test7_package_with_patched_dep.readme.snap +++ b/cargo-geiger/tests/snapshots/readme_integration_tests__test7_package_with_patched_dep.readme.snap @@ -3,22 +3,24 @@ source: cargo-geiger/tests/readme_integration_tests.rs expression: readme_content --- ## Test Section Name +``` Metric output format: x/y x = unsafe code used by the build y = total unsafe code found in the crate Symbols: - :) = No `unsafe` usage found, declares #![forbid(unsafe_code)] - ? = No `unsafe` usage found, missing #![forbid(unsafe_code)] - ! = `unsafe` usage found + 🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)] + ❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)] + ☢️ = `unsafe` usage found Functions Expressions Impls Traits Methods Dependency -0/0 0/0 0/0 0/0 0/0 :) test7_package_with_patched_dep 0.1.0 -0/0 0/0 0/0 0/0 0/0 ? `-- num_cpus 1.10.1 -1/1 2/2 0/0 0/0 0/0 ! `-- test1_package_with_no_deps 0.1.0 +0/0 0/0 0/0 0/0 0/0 🔒 test7_package_with_patched_dep 0.1.0 +0/0 0/0 0/0 0/0 0/0 ❓ └── num_cpus 1.10.1 +1/1 2/2 0/0 0/0 0/0 ☢️ └── test1_package_with_no_deps 0.1.0 1/1 2/2 0/0 0/0 0/0 +```