Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed new line characters in search output #1262

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG-Japanese.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

**バグ修正:**

- XXX
- `search`コマンドの出力に入っている不要な改行文字を削除した。 (#1253) (@hitenkoku)

**その他:**

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

**Bug Fixes:**

- XXX
- Removed newline characters in `search` command output. (#1253) (@hitenkoku)

**Other:**

Expand Down
4 changes: 4 additions & 0 deletions src/detections/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ lazy_static! {
Regex::new(r"^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$").unwrap();
pub static ref CONTROL_CHAT_REPLACE_MAP: HashMap<char, CompactString> =
create_control_chat_replace_map();
pub static ref ALLFIELDINFO_SPECIAL_CHARS: AhoCorasick = AhoCorasickBuilder::new()
.match_kind(MatchKind::LeftmostLongest)
.build(["🛂r", "🛂n", "🛂t"])
.unwrap();
}

pub struct ConfigReader {
Expand Down
17 changes: 13 additions & 4 deletions src/timeline/search.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::detections::configs::OutputOption;
use crate::detections::configs::{OutputOption, ALLFIELDINFO_SPECIAL_CHARS};
use crate::detections::field_data_map::FieldDataMapKey;
use crate::detections::message;
use crate::detections::utils::format_time;
Expand Down Expand Up @@ -180,14 +180,18 @@
if search_condition(keywords) {
let (timestamp, hostname, channel, eventid, recordid, allfieldinfo) =
extract_search_event_info(record, eventkey_alias, output_option);

let allfieldinfo_newline_splited = ALLFIELDINFO_SPECIAL_CHARS
.replace_all(&allfieldinfo, &["🦅", "🦅", "🦅"])
.split('🦅')
.filter(|x| !x.is_empty())
.join(" ");

Check warning on line 187 in src/timeline/search.rs

View check run for this annotation

Codecov / codecov/patch

src/timeline/search.rs#L183-L187

Added lines #L183 - L187 were not covered by tests
self.search_result.insert((
timestamp,
hostname,
channel,
eventid,
recordid,
allfieldinfo,
allfieldinfo_newline_splited.into(),

Check warning on line 194 in src/timeline/search.rs

View check run for this annotation

Codecov / codecov/patch

src/timeline/search.rs#L194

Added line #L194 was not covered by tests
self.filepath.clone(),
));
}
Expand Down Expand Up @@ -222,13 +226,18 @@
if re.is_match(&record.data_string) {
let (timestamp, hostname, channel, eventid, recordid, allfieldinfo) =
extract_search_event_info(record, eventkey_alias, output_option);
let allfieldinfo_newline_splited = ALLFIELDINFO_SPECIAL_CHARS
.replace_all(&allfieldinfo, &["🦅", "🦅", "🦅"])
.split('🦅')
.filter(|x| !x.is_empty())
.join(" ");

Check warning on line 233 in src/timeline/search.rs

View check run for this annotation

Codecov / codecov/patch

src/timeline/search.rs#L229-L233

Added lines #L229 - L233 were not covered by tests
self.search_result.insert((
timestamp,
hostname,
channel,
eventid,
recordid,
allfieldinfo,
allfieldinfo_newline_splited.into(),

Check warning on line 240 in src/timeline/search.rs

View check run for this annotation

Codecov / codecov/patch

src/timeline/search.rs#L240

Added line #L240 was not covered by tests
self.filepath.clone(),
));
}
Expand Down
Loading