aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock60
-rw-r--r--Cargo.toml8
-rw-r--r--Makefile7
-rw-r--r--src/command/status/configuration_status.rs74
4 files changed, 115 insertions, 34 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 279df6f..177c11b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -15,30 +15,30 @@ dependencies = [
[[package]]
name = "deranged"
-version = "0.3.11"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
+checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
dependencies = [
"powerfmt",
]
[[package]]
name = "gema_texto"
-version = "1.0.0"
+version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4056ce8c83e74c7f51c4676baea6ac2f2dc508b69d018260b56ed1d618de09e3"
+checksum = "ff101c368b563c1aace5a5f18255a52fcd150b6e97fadd5dd970b6f912f66571"
[[package]]
name = "itoa"
-version = "1.0.10"
+version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
+checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "memchr"
-version = "2.7.4"
+version = "2.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
+checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
[[package]]
name = "num-conv"
@@ -54,42 +54,42 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "proc-macro2"
-version = "1.0.92"
+version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
+checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.35"
+version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "ryu"
-version = "1.0.17"
+version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
+checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "serde"
-version = "1.0.217"
+version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
+checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.217"
+version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
+checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
@@ -98,9 +98,9 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.134"
+version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d"
+checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
dependencies = [
"itoa",
"memchr",
@@ -110,9 +110,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.94"
+version = "2.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3"
+checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
dependencies = [
"proc-macro2",
"quote",
@@ -125,9 +125,9 @@ version = "7.1.1"
[[package]]
name = "time"
-version = "0.3.37"
+version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21"
+checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
dependencies = [
"deranged",
"itoa",
@@ -140,15 +140,15 @@ dependencies = [
[[package]]
name = "time-core"
-version = "0.1.2"
+version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
+checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
[[package]]
name = "time-macros"
-version = "0.2.19"
+version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de"
+checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
dependencies = [
"num-conv",
"time-core",
@@ -156,6 +156,6 @@ dependencies = [
[[package]]
name = "unicode-ident"
-version = "1.0.12"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
diff --git a/Cargo.toml b/Cargo.toml
index fa81475..a8ec38a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,10 +8,10 @@ homepage = "https://r.bdr.sh/blog.html"
authors = ["Rubén Beltrán del Río <blog@r.bdr.sh>"]
[dependencies]
-gema_texto = "1.0.0"
-time = { version = "0.3.37", features = ["macros", "formatting"] }
-serde = { version = "1.0.217", features = ["derive"] }
-serde_json = "1.0.134"
+gema_texto = "1.0.3"
+time = { version = "0.3.41", features = ["macros", "formatting"] }
+serde = { version = "1.0.219", features = ["derive"] }
+serde_json = "1.0.140"
[dev-dependencies]
test_utilities = { path = "test_utilities" }
diff --git a/Makefile b/Makefile
index 01e240b..8ea69b4 100644
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,13 @@ format:
lint:
cargo fmt -- --check && cargo clippy
+audit:
+ cargo vet
+ # cargo crev verify --show-all
+
+supply-chain-report:
+ cargo supply-chain publishers
+
release: rpm tar deb
@$(eval filename := $(app_name)-$(target)-$(channel))
diff --git a/src/command/status/configuration_status.rs b/src/command/status/configuration_status.rs
index 7babff8..6f7db14 100644
--- a/src/command/status/configuration_status.rs
+++ b/src/command/status/configuration_status.rs
@@ -49,3 +49,77 @@ fn get_directory_stats(label: &str, directory: &PathBuf) -> Result<String> {
Ok(status_message)
}
+
+#[cfg(test)]
+mod tests {
+ use std::fs::{Permissions, create_dir_all, metadata, set_permissions};
+ use std::path::PathBuf;
+
+ #[cfg(unix)]
+ use std::os::unix::fs::PermissionsExt;
+
+ #[cfg(windows)]
+ use std::os::windows::fs::PermissionsExt;
+
+ use crate::configuration::Configuration;
+
+ use test_utilities::*;
+
+ use super::*;
+
+ #[test]
+ fn get_directory_stats_detects_nonexistent_directories() {
+ let test_dir = PathBuf::from("/krillinnoooootravez");
+
+ if let Ok(output) = get_directory_stats("krillin", &test_dir) {
+ assert!(output.contains("Does not exist."));
+ } else {
+ panic!("Could not get stats for directory that doesn't exist.");
+ }
+ }
+
+ #[test]
+ fn get_directory_detects_writability() {
+ let test_dir = setup_test_dir();
+
+ if let Ok(output) = get_directory_stats("yajirobe", &test_dir) {
+ assert!(output.contains("Exists"));
+ assert!(output.contains("is readable"));
+ } else {
+ panic!("Could not get stats for directory that doesn't exist.");
+ }
+
+ cleanup_test_dir(&test_dir);
+ }
+
+ #[test]
+ fn get_directory_detects_lack_of_writability() {
+ let test_dir = setup_test_dir();
+ let metadata = metadata(&test_dir).expect("Could not fetch metadata for test dir");
+ let mut permissions = metadata.permissions();
+
+ #[cfg(unix)]
+ {
+ permissions.set_mode(0o311);
+ }
+
+ set_permissions(&test_dir, permissions.clone())
+ .expect("Could not set read permissions on dir");
+
+ if let Ok(output) = get_directory_stats("roshi", &test_dir) {
+ assert!(output.contains("Exists"));
+ assert!(output.contains("is not readable"));
+ } else {
+ panic!("Could not get stats for directory that doesn't exist.");
+ }
+
+ #[cfg(unix)]
+ {
+ permissions.set_mode(0o755);
+ }
+
+ set_permissions(&test_dir, permissions).expect("Could not reset permissions on dir");
+
+ cleanup_test_dir(&test_dir);
+ }
+}