From c1884b6dcebc214f3e733d64bd2a379e29289910 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 21 Sep 2023 21:39:36 +0900 Subject: [PATCH 1/5] config(Cargo/utils): removed hhmmss crate #1181 implemented the necessary processing to exclude the hhmmss crate to reduce dependencies of the time crate --- Cargo.lock | 270 +++++--------------------- Cargo.toml | 1 - rules | 2 +- src/debug/checkpoint_process_timer.rs | 4 +- src/detections/utils.rs | 17 +- src/main.rs | 6 +- 6 files changed, 66 insertions(+), 234 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a1e5cac3..6a7d87e9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] @@ -150,12 +150,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base-x" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" - [[package]] name = "base64" version = "0.21.4" @@ -230,7 +224,7 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", - "semver 1.0.18", + "semver", "serde", "serde_json", ] @@ -305,9 +299,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.3" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" +checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" dependencies = [ "clap_builder", "clap_derive", @@ -315,9 +309,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" dependencies = [ "anstream", "anstyle", @@ -334,7 +328,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.35", + "syn 2.0.37", ] [[package]] @@ -396,12 +390,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "const_fn" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" - [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -417,16 +405,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -555,12 +533,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "downcast" version = "0.11.0" @@ -798,9 +770,9 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "git2" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ef350ba88a33b4d524b1d1c79096c9ade5ef8c59395df0e60d1e1889414c0e" +checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ "bitflags 2.4.0", "libc", @@ -842,7 +814,7 @@ dependencies = [ "bytesize", "chrono", "cidr-utils", - "clap 4.4.3", + "clap 4.4.4", "comfy-table", "compact_str", "crossbeam-utils", @@ -854,7 +826,6 @@ dependencies = [ "git2", "hashbrown 0.14.0", "hex", - "hhmmss", "horrorshow", "indexmap 2.0.0", "indicatif", @@ -904,9 +875,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -914,16 +885,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hhmmss" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a3a7d0916cb01ef108a66108640419767991ea31d11a1c851bed37686a6062" -dependencies = [ - "chrono", - "time 0.2.27", -] - [[package]] name = "horrorshow" version = "0.8.4" @@ -998,9 +959,9 @@ dependencies = [ [[package]] name = "indoc" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" [[package]] name = "instant" @@ -1017,7 +978,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", "windows-sys 0.48.0", ] @@ -1110,7 +1071,7 @@ checksum = "8244e0ff6c548152c07559ee9779dec5a5411eeee5bfd6146b38bd414a6841c6" dependencies = [ "anyhow", "chrono", - "clap 4.4.3", + "clap 4.4.4", "file-chunker", "memmap2 0.7.1", "num_cpus", @@ -1434,7 +1395,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", ] @@ -1491,7 +1452,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.35", + "syn 2.0.37", ] [[package]] @@ -1502,9 +1463,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.1.3+3.1.2" +version = "300.1.5+3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd2c101a165fff9935e34def4669595ab1c7847943c42be86e21503e482be107" +checksum = "559068e4c12950d7dcaa1857a61725c0d38d4fc03ff8e070ab31a75d6e316491" dependencies = [ "cc", ] @@ -1611,12 +1572,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro2" version = "1.0.67" @@ -1688,9 +1643,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -1698,14 +1653,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -1787,15 +1740,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustix" version = "0.37.23" @@ -1812,9 +1756,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.13" +version = "0.38.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" dependencies = [ "bitflags 2.4.0", "errno", @@ -1892,15 +1836,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.18" @@ -1910,12 +1845,6 @@ dependencies = [ "serde", ] -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.188" @@ -1933,7 +1862,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.35", + "syn 2.0.37", ] [[package]] @@ -1947,21 +1876,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - [[package]] name = "shell-words" version = "1.1.0" @@ -2006,7 +1920,7 @@ checksum = "acee08041c5de3d5048c8b3f6f13fafb3026b24ba43c6a695a0c76179b844369" dependencies = [ "log", "termcolor", - "time 0.3.28", + "time", ] [[package]] @@ -2026,9 +1940,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "socket2" @@ -2046,70 +1960,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "standback" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" -dependencies = [ - "version_check", -] - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn 1.0.109", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn 1.0.109", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - [[package]] name = "strsim" version = "0.10.0" @@ -2148,9 +2004,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.35" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59bf04c28bee9043ed9ea1e41afc0552288d3aba9c6efdd78903b802926f4879" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -2166,7 +2022,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall", - "rustix 0.38.13", + "rustix 0.38.14", "windows-sys 0.48.0", ] @@ -2195,7 +2051,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.38.13", + "rustix 0.38.14", "windows-sys 0.48.0", ] @@ -2228,22 +2084,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.35", -] - -[[package]] -name = "time" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" -dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", - "time-macros 0.1.1", - "version_check", - "winapi", + "syn 2.0.37", ] [[package]] @@ -2258,7 +2099,7 @@ dependencies = [ "num_threads", "serde", "time-core", - "time-macros 0.2.14", + "time-macros", ] [[package]] @@ -2267,16 +2108,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" -[[package]] -name = "time-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - [[package]] name = "time-macros" version = "0.2.14" @@ -2286,19 +2117,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "time-macros-impl" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn 1.0.109", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -2341,7 +2159,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.35", + "syn 2.0.37", ] [[package]] @@ -2376,9 +2194,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "untrusted" @@ -2468,7 +2286,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.35", + "syn 2.0.37", "wasm-bindgen-shared", ] @@ -2490,7 +2308,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.35", + "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2538,9 +2356,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index c1ca840e2..6bc46ffe8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ yaml-rust = "0.4.*" tokio = { version = "1", features = ["full"] } num_cpus = "1.*" downcast-rs = "1.*" -hhmmss = "*" indicatif = "*" hashbrown = "0.14.*" hex = "0.4.*" diff --git a/rules b/rules index a2dc8dad8..3118742b7 160000 --- a/rules +++ b/rules @@ -1 +1 @@ -Subproject commit a2dc8dad83ee487f7459414d4e67eff54ac2d6e8 +Subproject commit 3118742b76c18a79066f3676ea7b97e78550250a diff --git a/src/debug/checkpoint_process_timer.rs b/src/debug/checkpoint_process_timer.rs index 6125f671d..c9b94548d 100644 --- a/src/debug/checkpoint_process_timer.rs +++ b/src/debug/checkpoint_process_timer.rs @@ -1,7 +1,7 @@ use std::sync::Mutex; +use crate::detections::utils::output_duration; use chrono::{DateTime, Local}; -use hhmmss::Hhmmss; use lazy_static::lazy_static; use nested::Nested; @@ -38,7 +38,7 @@ impl CheckPointProcessTimer { self.stocked_results.push(format!( "{}: {} ", output_str, - (new_checkpoint - self.prev_checkpoint.unwrap()).hhmmssxxx() + output_duration(new_checkpoint - self.prev_checkpoint.unwrap()) )); self.prev_checkpoint = Some(new_checkpoint); } diff --git a/src/detections/utils.rs b/src/detections/utils.rs index 45ea19cb3..d404f7206 100644 --- a/src/detections/utils.rs +++ b/src/detections/utils.rs @@ -11,7 +11,7 @@ use itertools::Itertools; use nested::Nested; use std::path::{Path, PathBuf}; -use chrono::Local; +use chrono::{Duration, Local}; use termcolor::{Color, ColorChoice}; use tokio::runtime::{Builder, Runtime}; @@ -676,6 +676,21 @@ pub fn is_filtered_by_computer_name( false } +///Durationから出力文字列を作成する関数。絶対値での秒数から算出してhh:mm:ss.fffの形式で出力する。 +pub fn output_duration(d: Duration) -> String { + let mut s = d.num_seconds(); + let mut ms = d.num_milliseconds() - 1000 * s; + if s < 0 { + s = -s; + ms = -ms; + } + let h = s / 3600; + s %= 3600; + let m = s / 60; + s %= 60; + format!("{h:02}:{m:02}:{s:02}.{ms:03}") +} + #[cfg(test)] mod tests { use std::path::Path; diff --git a/src/main.rs b/src/main.rs index 03606facd..4c4e4dc99 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,8 @@ use hayabusa::detections::detection::{self, EvtxRecordInfo}; use hayabusa::detections::message::{AlertMessage, ERROR_LOG_STACK}; use hayabusa::detections::rule::{get_detection_keys, RuleNode}; use hayabusa::detections::utils::{ - check_setting_path, get_writable_color, output_and_data_stack_for_html, output_profile_name, + check_setting_path, get_writable_color, output_and_data_stack_for_html, output_duration, + output_profile_name, }; use hayabusa::options; use hayabusa::options::htmlreport::{self, HTML_REPORTER}; @@ -31,7 +32,6 @@ use hayabusa::timeline::computer_metrics::countup_event_by_computer; use hayabusa::{afterfact::after_fact, detections::utils}; use hayabusa::{detections::configs, timeline::timelines::Timeline}; use hayabusa::{detections::utils::write_color_buffer, filter}; -use hhmmss::Hhmmss; use indicatif::ProgressBar; use indicatif::{ProgressDrawTarget, ProgressStyle}; use itertools::Itertools; @@ -700,7 +700,7 @@ impl App { // 処理時間の出力 let analysis_end_time: DateTime = Local::now(); let analysis_duration = analysis_end_time.signed_duration_since(analysis_start_time); - let elapsed_output_str = format!("Elapsed time: {}", &analysis_duration.hhmmssxxx()); + let elapsed_output_str = format!("Elapsed time: {}", output_duration(analysis_duration)); output_and_data_stack_for_html( &elapsed_output_str, "General Overview {#general_overview}", From 8a5ef4a28cd2ca10639dcc9b070571b4164a500c Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 21 Sep 2023 21:57:30 +0900 Subject: [PATCH 2/5] docs(CHANGELOG): added next version format --- CHANGELOG-Japanese.md | 18 ++++++++++++++++++ CHANGELOG.md | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/CHANGELOG-Japanese.md b/CHANGELOG-Japanese.md index 53bf82b43..02fe90fb1 100644 --- a/CHANGELOG-Japanese.md +++ b/CHANGELOG-Japanese.md @@ -1,5 +1,23 @@ # 変更点 +## 2.10.0 [2023/XX/XX] "xxx Release" + +**新機能:** + +- XXX + +**改善:** + +- XXX + +**バグ修正:** + +- XXX + +**その他:** + +- XXX + ## 2.9.0 [2023/XX/XX] "xxx Release" **新機能:** diff --git a/CHANGELOG.md b/CHANGELOG.md index 55886e735..1d4465425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changes +## 2.10.0 [2023/XX/XX] "xxx Release" + +**New Features:** + +- XXX + +**New Features:** + +- XXX + +**Enhancements:** + +- XXX + +**Bug Fixes:** + +- XXX + +**Other:** + +- XXX + ## 2.9.0 [2023/XX/XX] "xxx Release" **New Features:** From df1c4f0de3e670ec945b3b6025983a7ffc1a2b0f Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 21 Sep 2023 22:00:14 +0900 Subject: [PATCH 3/5] docs(CHANGELOG): added #1181 --- CHANGELOG-Japanese.md | 2 +- CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-Japanese.md b/CHANGELOG-Japanese.md index 02fe90fb1..5093c5e11 100644 --- a/CHANGELOG-Japanese.md +++ b/CHANGELOG-Japanese.md @@ -16,7 +16,7 @@ **その他:** -- XXX +- CIを通すためにtimeクレートを利用している更新されていないhhmmssクレートを除外した。 (#1181) (@hitenkoku) ## 2.9.0 [2023/XX/XX] "xxx Release" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d4465425..e7a96e8f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ **Other:** -- XXX +- Excluded unupdated hhmmss crates that use time crates to pass CI. (#1181) (@hitenkoku) ## 2.9.0 [2023/XX/XX] "xxx Release" From a870a546d0767b4e2375ddf858122a9c69b7788f Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 21 Sep 2023 22:00:44 +0900 Subject: [PATCH 4/5] test(utils): added output_duration test #1181 --- src/detections/utils.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/detections/utils.rs b/src/detections/utils.rs index d404f7206..94d89bcfb 100644 --- a/src/detections/utils.rs +++ b/src/detections/utils.rs @@ -706,13 +706,14 @@ mod tests { }, options::htmlreport::HTML_REPORTER, }; + use chrono::NaiveDate; use compact_str::CompactString; use hashbrown::{HashMap, HashSet}; use nested::Nested; use regex::Regex; use serde_json::Value; - use super::output_profile_name; + use super::{output_profile_name, output_duration}; #[test] fn test_create_recordinfos() { @@ -1113,4 +1114,14 @@ mod tests { ), )); } + + #[test] + /// Durationから出力文字列を作成する関数のテスト + fn test_output_duration() { + let time1 = NaiveDate::from_ymd_opt(2021, 12, 26).unwrap().and_hms_milli_opt(2,34, 49, 0).unwrap(); + let time2 = NaiveDate::from_ymd_opt(2021, 12, 25).unwrap().and_hms_milli_opt(1,23, 45, 678).unwrap(); + assert_eq!(output_duration(time1 - time2), "25:11:03.322".to_string()); + assert_eq!(output_duration(time2 - time1), "25:11:03.322".to_string()); + } + } From 7aa1794ff65dc43f1324536a80c020be68055a3a Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Thu, 21 Sep 2023 22:01:05 +0900 Subject: [PATCH 5/5] style(utils): cargo fmt --- src/detections/utils.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/detections/utils.rs b/src/detections/utils.rs index 94d89bcfb..7c62b9ab2 100644 --- a/src/detections/utils.rs +++ b/src/detections/utils.rs @@ -713,7 +713,7 @@ mod tests { use regex::Regex; use serde_json::Value; - use super::{output_profile_name, output_duration}; + use super::{output_duration, output_profile_name}; #[test] fn test_create_recordinfos() { @@ -1118,10 +1118,15 @@ mod tests { #[test] /// Durationから出力文字列を作成する関数のテスト fn test_output_duration() { - let time1 = NaiveDate::from_ymd_opt(2021, 12, 26).unwrap().and_hms_milli_opt(2,34, 49, 0).unwrap(); - let time2 = NaiveDate::from_ymd_opt(2021, 12, 25).unwrap().and_hms_milli_opt(1,23, 45, 678).unwrap(); + let time1 = NaiveDate::from_ymd_opt(2021, 12, 26) + .unwrap() + .and_hms_milli_opt(2, 34, 49, 0) + .unwrap(); + let time2 = NaiveDate::from_ymd_opt(2021, 12, 25) + .unwrap() + .and_hms_milli_opt(1, 23, 45, 678) + .unwrap(); assert_eq!(output_duration(time1 - time2), "25:11:03.322".to_string()); assert_eq!(output_duration(time2 - time1), "25:11:03.322".to_string()); } - }