diff options
author | Lukasz Woznicki <lukasz.woznicki@softwareag.com> | 2022-02-10 00:08:29 +0000 |
---|---|---|
committer | Lukasz Woznicki <lukasz.woznicki@softwareag.com> | 2022-02-11 14:43:33 +0000 |
commit | 0a4e9be259af0125c44394cb0e1463f85d1c7930 (patch) | |
tree | 8f73f7c4747bd2621ef5350b20b14867216d1a73 /crates/core/c8y_smartrest | |
parent | 195e81d86bceaa1c55cde0a5a91868bfe2326963 (diff) |
Use 'time' instead of 'chrono' due to CVE for c8y_smartrest and all dependent crates
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
Diffstat (limited to 'crates/core/c8y_smartrest')
-rw-r--r-- | crates/core/c8y_smartrest/Cargo.toml | 7 | ||||
-rw-r--r-- | crates/core/c8y_smartrest/src/smartrest_deserializer.rs | 12 |
2 files changed, 9 insertions, 10 deletions
diff --git a/crates/core/c8y_smartrest/Cargo.toml b/crates/core/c8y_smartrest/Cargo.toml index 2f613061..03f575bb 100644 --- a/crates/core/c8y_smartrest/Cargo.toml +++ b/crates/core/c8y_smartrest/Cargo.toml @@ -7,13 +7,12 @@ rust-version = "1.58.1" [dependencies] agent_interface = { path = "../agent_interface" } -download = { path = "../../common/download" } -thin_edge_json = { path = "../thin_edge_json" } -time = { version = "0.3", features = ["macros"] } -chrono = { version = "0.4", features = ["serde"] } csv = "1.1" +download = { path = "../../common/download" } serde = { version = "1.0", features = ["derive"] } +thin_edge_json = { path = "../thin_edge_json" } thiserror = "1.0" +time = { version = "0.3", features = ["formatting", "macros", "parsing", "serde"] } [dev-dependencies] anyhow = "1.0" diff --git a/crates/core/c8y_smartrest/src/smartrest_deserializer.rs b/crates/core/c8y_smartrest/src/smartrest_deserializer.rs index f6809569..a5265279 100644 --- a/crates/core/c8y_smartrest/src/smartrest_deserializer.rs +++ b/crates/core/c8y_smartrest/src/smartrest_deserializer.rs @@ -1,11 +1,11 @@ use crate::error::SmartRestDeserializerError; use agent_interface::{SoftwareModule, SoftwareModuleUpdate, SoftwareUpdateRequest}; -use chrono::{DateTime, FixedOffset}; use csv::ReaderBuilder; use download::DownloadInfo; use serde::de::Error; use serde::{Deserialize, Deserializer, Serialize}; use std::convert::{TryFrom, TryInto}; +use time::{format_description, OffsetDateTime}; #[derive(Debug)] enum CumulocitySoftwareUpdateActions { @@ -166,11 +166,11 @@ impl SmartRestUpdateSoftwareModule { } } -fn to_datetime<'de, D>(deserializer: D) -> Result<DateTime<FixedOffset>, D::Error> +fn to_datetime<'de, D>(deserializer: D) -> Result<OffsetDateTime, D::Error> where D: Deserializer<'de>, { - // NOTE `NaiveDateTime` is used here because c8y uses for log requests a date time string which + // NOTE `OffsetDateTime` is used here because c8y uses for log requests a date time string which // does not exactly equal `chrono::DateTime::parse_from_rfc3339` // c8y result: // 2021-10-23T19:03:26+0100 @@ -191,7 +191,7 @@ where _ => date_string, }; - match DateTime::parse_from_rfc3339(&date_string) { + match OffsetDateTime::parse(&date_string, &format_description::well_known::Rfc3339) { Ok(result) => Ok(result), Err(e) => Err(D::Error::custom(&format!("Error: {}", e))), } @@ -207,9 +207,9 @@ pub struct SmartRestLogRequest { pub device: String, pub log_type: String, #[serde(deserialize_with = "to_datetime")] - pub date_from: DateTime<FixedOffset>, + pub date_from: OffsetDateTime, #[serde(deserialize_with = "to_datetime")] - pub date_to: DateTime<FixedOffset>, + pub date_to: OffsetDateTime, pub needle: Option<String>, pub lines: usize, } |