mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
fix parsing of noncompliant RFC3339 timestamps missing only a timezone (#3346)
This commit is contained in:
parent
172d6c6dc6
commit
5260cf16cc
2 changed files with 33 additions and 0 deletions
|
@ -44,6 +44,7 @@ func GenDateParse(date string) (string, time.Time) {
|
|||
"2006-01-02 15:04",
|
||||
"2006/01/02 15:04:05",
|
||||
"2006-01-02 15:04:05",
|
||||
"2006-01-02T15:04:05",
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -40,6 +40,38 @@ func TestDateParse(t *testing.T) {
|
|||
},
|
||||
expected: "2011-12-17T08:17:43Z",
|
||||
},
|
||||
{
|
||||
name: "ISO 8601, no timezone",
|
||||
evt: types.Event{
|
||||
StrTime: "2024-11-26T20:13:32",
|
||||
StrTimeFormat: "",
|
||||
},
|
||||
expected: "2024-11-26T20:13:32Z",
|
||||
},
|
||||
{
|
||||
name: "ISO 8601, no timezone, milliseconds",
|
||||
evt: types.Event{
|
||||
StrTime: "2024-11-26T20:13:32.123",
|
||||
StrTimeFormat: "",
|
||||
},
|
||||
expected: "2024-11-26T20:13:32.123Z",
|
||||
},
|
||||
{
|
||||
name: "ISO 8601, no timezone, microseconds",
|
||||
evt: types.Event{
|
||||
StrTime: "2024-11-26T20:13:32.123456",
|
||||
StrTimeFormat: "",
|
||||
},
|
||||
expected: "2024-11-26T20:13:32.123456Z",
|
||||
},
|
||||
{
|
||||
name: "ISO 8601, no timezone, nanoseconds",
|
||||
evt: types.Event{
|
||||
StrTime: "2024-11-26T20:13:32.123456789",
|
||||
StrTimeFormat: "",
|
||||
},
|
||||
expected: "2024-11-26T20:13:32.123456789Z",
|
||||
},
|
||||
}
|
||||
|
||||
logger := log.WithField("test", "test")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue