Skip to content

Commit 48a8b38

Browse files
Merge pull request #283 from Yamato-Security/281-fix-date
fix: correct date extraction in alert timeline query
2 parents e527a4f + 5b05116 commit 48a8b38

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

CHANGELOG-Japanese.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
- `automagic`コマンドのパースバグを修正した。 (#278) (@fukusuket)
1212
- HTMLレポートおよびサーバコマンドのJSON解析における`RecordID`の欠落を処理できるようにした。 (#279) (@fukusuket)
13+
- `html-server`の日付は、ローカル時間に変更されていた。 (#281) (@fukusuket)
1314

1415
## 2.14.0 [2025/11/15] - CODE BLUE Release
1516

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
- Fixed a parsing bug in the `automagic` command. (#278) (@fukusuket)
1212
- Handle missing `RecordID` in JSON parsing for HTML report and server commands. (#279) (@fukusuket)
13+
- Dates in the `html-server` was being converted to local time. (#281) (@fukusuket)
1314

1415
## 2.14.0 [2025/11/15] - CODE BLUE Release
1516

src/takajopkg/htmlReport.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ proc htmlReport*(output: string, quiet: bool = false, timeline: string, rulepath
203203

204204
# start analysis timeline
205205
# obtain datas from SQLite
206-
var query = sql"""select rule_title, rule_file, level, level_order, computer, min(datetime(timestamp, 'localtime')) as start_date, max(datetime(timestamp, 'localtime')) as end_date, count(*) as count
206+
var query = sql"""select rule_title, rule_file, level, level_order, computer, min(datetime(timestamp)) as start_date, max(datetime(timestamp)) as end_date, count(*) as count
207207
from timelines
208208
group by rule_title, level, computer
209209
order by level_order

src/takajopkg/web/controllers/computers.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ proc computer*(ctx: Context) {.async.} =
8282
let path = getDBPath(ctx)
8383
let db = open(path , "", "", "")
8484

85-
var query = """select rule_title, rule_file, level, level_order, computer, min(datetime(timestamp, 'localtime')) as start_date, max(datetime(timestamp, 'localtime')) as end_date, count(*) as count
85+
var query = """select rule_title, rule_file, level, level_order, computer, min(datetime(timestamp)) as start_date, max(datetime(timestamp)) as end_date, count(*) as count
8686
from timelines
8787
where """ & custom_query & """
8888
group by rule_title, level, computer
@@ -101,7 +101,7 @@ proc computer*(ctx: Context) {.async.} =
101101
"""
102102
let computer_counts = db.getRow(sql query, params)
103103

104-
query = """select level, level_order, date(datetime(timestamp, 'localtime')) AS date, count(*) as count
104+
query = """select level, level_order, date(datetime(timestamp)) AS date, count(*) as count
105105
from timelines
106106
where """ & custom_query & """
107107
group by date, level_order
@@ -136,8 +136,8 @@ proc sidemenu*(ctx: Context) {.async.} =
136136
rule_title,
137137
computer,
138138
COUNT(computer) AS computer_total,
139-
MIN(datetime(timestamp, 'localtime')) AS first_date,
140-
MAX(datetime(timestamp, 'localtime')) AS last_date
139+
MIN(datetime(timestamp)) AS first_date,
140+
MAX(datetime(timestamp)) AS last_date
141141
FROM timelines
142142
GROUP BY level_order, rule_title, computer
143143
ORDER BY level_order, rule_title, computer;

src/takajopkg/web/controllers/summary.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ proc list*(ctx: Context) {.async.} =
118118
var dates_with_most_total_detections = db.getAllRows(sql query, params)
119119

120120
query = """SELECT level, level_order, rule_title, computer, COUNT(*) AS alert_count,
121-
MIN(DATE(datetime(timestamp, 'localtime'))) AS first_seen, MAX(DATE(datetime(timestamp, 'localtime'))) AS last_seen
121+
MIN(DATE(timestamp)) AS first_seen, MAX(DATE(timestamp)) AS last_seen
122122
FROM timelines
123123
GROUP BY level, rule_title, computer
124124
ORDER BY level_order DESC

0 commit comments

Comments
 (0)