cargo fmt

This commit is contained in:
DastInDark
2022-09-25 20:51:18 +09:00
parent 1abaf48d93
commit 703673c668
2 changed files with 14 additions and 14 deletions
+6 -6
View File
@@ -124,19 +124,19 @@ impl App {
} else {
None
};
let now_version = &format!("v{}",configs::CONFIG.read().unwrap().app.get_version().unwrap());
let now_version = &format!(
"v{}",
configs::CONFIG.read().unwrap().app.get_version().unwrap()
);
if latest_version_data.is_some()
&& now_version
!= latest_version_data
.as_ref()
.unwrap_or(now_version)
&& now_version != latest_version_data.as_ref().unwrap_or(now_version)
{
write_color_buffer(
&BufferWriter::stdout(ColorChoice::Always),
None,
&format!(
"There is a new version of Hayabusa: {}",
latest_version_data.unwrap().replace('\"',"")
latest_version_data.unwrap().replace('\"', "")
),
true,
)
+8 -8
View File
@@ -1,10 +1,10 @@
use serde_json::Value;
use crate::detections::message::AlertMessage;
use crate::detections::utils::write_color_buffer;
use crate::filter;
use crate::yaml::ParseYaml;
use chrono::{DateTime, Local, TimeZone};
use git2::Repository;
use serde_json::Value;
use std::fs::{self};
use std::path::Path;
@@ -22,19 +22,19 @@ pub struct Update {}
impl Update {
/// get latest hayabusa version number.
pub fn get_latest_hayabusa_version() -> Result<Option<String>, Box<dyn std::error::Error>> {
let res = reqwest::blocking::Client::new().get(
"https://api.github.com/repos/Yamato-Security/hayabusa/releases/latest",
).header("User-Agent", "HayabusaUpdateChecker")
.header("Accept", "application/vnd.github.v3+json").send()?;
let res = reqwest::blocking::Client::new()
.get("https://api.github.com/repos/Yamato-Security/hayabusa/releases/latest")
.header("User-Agent", "HayabusaUpdateChecker")
.header("Accept", "application/vnd.github.v3+json")
.send()?;
let text = res.text()?;
let json_res:Value = serde_json::from_str(&text)?;
let json_res: Value = serde_json::from_str(&text)?;
if json_res["tag_name"].is_null() {
Ok(None)
} else {
} else {
Ok(Some(json_res["tag_name"].to_string()))
}
}
/// update rules(hayabusa-rules subrepository)