Skip to content

Commit

Permalink
fix: created_time doesnt get updated correctly (#43)
Browse files Browse the repository at this point in the history
* fix: created_time doesnt get updated correctly

* chore: bump version
  • Loading branch information
mmta authored Mar 17, 2024
1 parent 949d524 commit 3e72912
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ default-members = [
]

[workspace.package]
version = "1.2.4"
version = "1.2.5"
authors = ["Dsiem Authors"]
description = "OSSIM-style event correlation engine for ELK stack"
documentation = "https://github.com/defenxor/dsiem/blob/master/docs/README.md"
Expand Down
12 changes: 10 additions & 2 deletions server/src/backlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ impl Backlog {
fn set_created_time(&self) {
let created_time = self.created_time.load(Relaxed);
if created_time == 0 {
self.created_time.swap(created_time, Relaxed);
let updated_time = self.update_time.load(Relaxed);
self.created_time.swap(updated_time, Relaxed);
}
}

Expand Down Expand Up @@ -1223,8 +1224,11 @@ mod test {
assert!(backlog.title.contains(&src_host));
assert!(backlog.title.contains(&dst_host));

let arc_backlog = Arc::new(backlog);
let cloned = arc_backlog.clone();

let _detached = task::spawn(async move {
_ = backlog
_ = cloned
.start(event_rx, Some(evt_cloned), resptime_tx, 1)
.await;
});
Expand All @@ -1242,6 +1246,10 @@ mod test {
assert!(logs_contain("risk changed"));
assert!(logs_contain("stage increased to 4"));

// make sure created_time is set
let created_time = arc_backlog.created_time.load(Relaxed);
assert!(created_time != 0);

// event with out of order timestamp
sleep(Duration::from_millis(500)).await;
evt.timestamp = Utc::now().checked_sub_days(Days::new(1)).unwrap();
Expand Down

0 comments on commit 3e72912

Please sign in to comment.