diff --git a/Cargo.lock b/Cargo.lock index 2f49a42..54d24c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4569,7 +4569,7 @@ dependencies = [ [[package]] name = "watchvuln-rs" -version = "0.1.1" +version = "0.1.4" dependencies = [ "async-trait", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index 21596c2..09fa7d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "watchvuln-rs" -version = "0.1.1" +version = "0.1.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/push/dingding.rs b/src/push/dingding.rs index 80472c0..4fa3fb5 100644 --- a/src/push/dingding.rs +++ b/src/push/dingding.rs @@ -1,3 +1,5 @@ +use std::time::SystemTime; + use crate::{ error::{Error, Result}, utils::{calc_hmac_sha256, http_client::Help}, @@ -72,8 +74,10 @@ impl DingDing { Help::new(headers) } pub fn generate_sign(&self) -> Result { - let now = chrono::Local::now().timestamp(); - let timestamp_and_secret = &format!("{}\n{}", now, self.secret_token); + let timestamp = SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH)? + .as_millis(); + let timestamp_and_secret = &format!("{}\n{}", timestamp, self.secret_token); let hmac_sha256 = calc_hmac_sha256( self.secret_token.as_bytes(), timestamp_and_secret.as_bytes(), @@ -81,7 +85,7 @@ impl DingDing { let sign = BASE64_STANDARD.encode(hmac_sha256); Ok(Sign { access_token: self.access_token.clone(), - timestamp: now, + timestamp, sign, }) } @@ -96,6 +100,6 @@ pub struct DingResponse { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Sign { pub access_token: String, - pub timestamp: i64, + pub timestamp: u128, pub sign: String, } diff --git a/src/push/msg_template.rs b/src/push/msg_template.rs index 54fdf06..161ae9e 100644 --- a/src/push/msg_template.rs +++ b/src/push/msg_template.rs @@ -28,9 +28,10 @@ const INIT_MSG_TEMPLATE: &str = r#" 当前版本: {{ version }} 本地漏洞数量: {{ vuln_count }} 检查周期配置: {{ cron_config }} - -目前爬取的数据源:{% for v in grabs %} -{{ loop.index }}.{{ v }}{% endfor %}"#; +目前爬取的数据源: +{% for v in grabs %} +{{ loop.index }}.{{ v }} +{% endfor %}"#; const MAX_REFERENCE_LENGTH: usize = 8;