Skip to content

Commit

Permalink
Replace chrono dependency with humantime to avoid RUSTSEC-2020-0071 a…
Browse files Browse the repository at this point in the history
…nd RUSTSEC-2020-0159 (#171)
  • Loading branch information
juntyr authored Nov 15, 2021
1 parent 896b589 commit 8bb08be
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ thiserror = "1.0"
libc = "0.2.81"
streaming-iterator = "0.1.5"
bitflags = "1.2.1"
chrono = {version = "0.4.19", optional = true}
humantime = {version = "2.1.0", optional = true}
serde = {version = "1.0.118", features = ["derive"], optional = true}
serde_json = {version = "1.0.67", optional = true}
bincode = {version = "1.3.1", optional = true}
Expand All @@ -29,18 +29,19 @@ tskit-derive = {version = "0.1.0", path = "tskit-derive", optional = true}
[dev-dependencies]
clap = "~2.33.3"
serde = {version = "1.0.118", features = ["derive"]}
serde-pickle = "0.6"
serde-pickle = "1.1.0"
bincode = "1.3.1"
rand = "0.8.3"
rand_distr = "0.4.0"
chrono = "0.4.19"

[build-dependencies]
bindgen = "0.59.1"
cc = { version = "1.0", features = ["parallel"] }
pkg-config = "0.3"

[features]
provenance = ["chrono"]
provenance = ["humantime"]
derive = ["tskit-derive", "serde", "serde_json", "bincode"]

[package.metadata.docs.rs]
Expand Down
4 changes: 2 additions & 2 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@
//! // risk a `panic!`.
//! impl tskit::metadata::MetadataRoundtrip for Metadata {
//! fn encode(&self) -> Result<Vec<u8>, tskit::metadata::MetadataError> {
//! match serde_pickle::to_vec(self, true) {
//! match serde_pickle::to_vec(self, serde_pickle::SerOptions::default()) {
//! Ok(v) => Ok(v),
//! Err(e) => Err(tskit::metadata::MetadataError::RoundtripError{ value: Box::new(e) }),
//! }
//! }
//!
//! fn decode(md: &[u8]) -> Result<Self, tskit::metadata::MetadataError> {
//! match serde_pickle::from_slice(md) {
//! match serde_pickle::from_slice(md, serde_pickle::DeOptions::default()) {
//! Ok(x) => Ok(x),
//! Err(e) => Err(tskit::metadata::MetadataError::RoundtripError{ value: Box::new(e) }),
//! }
Expand Down
2 changes: 1 addition & 1 deletion src/table_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ impl crate::traits::NodeListGenerator for TableCollection {}
#[cfg(any(doc, feature = "provenance"))]
impl crate::provenance::Provenance for TableCollection {
fn add_provenance(&mut self, record: &str) -> Result<crate::ProvenanceId, TskitError> {
let timestamp = chrono::prelude::Local::now().to_rfc3339();
let timestamp = humantime::format_rfc3339(std::time::SystemTime::now()).to_string();
let rv = unsafe {
ll_bindings::tsk_provenance_table_add_row(
&mut (*self.as_mut_ptr()).provenances,
Expand Down
2 changes: 1 addition & 1 deletion src/trees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ impl crate::traits::NodeListGenerator for TreeSequence {}
#[cfg(any(doc, feature = "provenance"))]
impl crate::provenance::Provenance for TreeSequence {
fn add_provenance(&mut self, record: &str) -> Result<crate::ProvenanceId, TskitError> {
let timestamp = chrono::prelude::Local::now().to_rfc3339();
let timestamp = humantime::format_rfc3339(std::time::SystemTime::now()).to_string();
let rv = unsafe {
ll_bindings::tsk_provenance_table_add_row(
&mut (*self.inner.tables).provenances,
Expand Down

0 comments on commit 8bb08be

Please sign in to comment.