Skip to content

Commit

Permalink
Merge pull request #1095 from spkenv/update-whoami
Browse files Browse the repository at this point in the history
Update whoami to address vulerability
  • Loading branch information
jrray authored Aug 7, 2024
2 parents f3c328f + 379af46 commit 1fc240c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
13 changes: 10 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ tracing = "0.1.35"
tracing-capture = "0.1"
tracing-subscriber = "0.3.14"
ulid = "1.0"
whoami = "1.2"
whoami = "1.5"
windows = "0.51"
winfsp = { version = "0.9.3", default-features = false }
winfsp-sys = "0.2"
Expand Down
13 changes: 11 additions & 2 deletions crates/spfs/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,23 @@ static CONFIG: OnceCell<RwLock<Arc<Config>>> = OnceCell::new();
#[serde(default)]
pub struct User {
pub name: String,
pub domain: String,
pub domain: Option<String>,
}

impl Default for User {
fn default() -> Self {
Self {
name: whoami::username(),
domain: whoami::hostname(),
domain: whoami::fallible::hostname().ok(),
}
}
}

impl std::fmt::Display for User {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self.domain {
Some(domain) => write!(f, "{}@{}", self.name, domain),
None => write!(f, "{}", self.name),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/spfs/src/runtime/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ impl Default for Author {
fn default() -> Self {
Self {
user_name: whoami::username(),
host_name: whoami::hostname(),
host_name: whoami::fallible::hostname()
.unwrap_or_else(|_| format!("unk-{}", ulid::Ulid::new())),
created: chrono::Local::now(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/spfs/src/tracking/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Tag {
name: spec.name(),
target,
parent: encoding::NULL_DIGEST.into(),
user: format!("{}@{}", config.user.name, config.user.domain),
user: format!("{}", config.user),
time: Utc::now().trunc_subsecs(6), // ignore microseconds
})
}
Expand Down

0 comments on commit 1fc240c

Please sign in to comment.