Harden zip reader and syslog scan
This commit is contained in:
15
internal/parser/vendors/unraid/parser.go
vendored
15
internal/parser/vendors/unraid/parser.go
vendored
@@ -412,6 +412,9 @@ func parseSMARTFileToMap(content, filePath string, storageBySlot map[string]*mod
|
||||
if m := regexp.MustCompile(`(disk\d+|parity|cache\d*)`).FindStringSubmatch(filePath); len(m) > 0 {
|
||||
diskName = m[1]
|
||||
}
|
||||
if diskName == "" {
|
||||
return
|
||||
}
|
||||
|
||||
var disk models.Storage
|
||||
disk.Slot = diskName
|
||||
@@ -503,6 +506,7 @@ func parseSMARTFileToMap(content, filePath string, storageBySlot map[string]*mod
|
||||
|
||||
func parseSyslog(content string, result *models.AnalysisResult) {
|
||||
scanner := bufio.NewScanner(strings.NewReader(content))
|
||||
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)
|
||||
lineCount := 0
|
||||
maxLines := 100 // Limit parsing to avoid too many events
|
||||
|
||||
@@ -527,6 +531,17 @@ func parseSyslog(content string, result *models.AnalysisResult) {
|
||||
|
||||
lineCount++
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
result.Events = append(result.Events, models.Event{
|
||||
Timestamp: time.Now(),
|
||||
Source: "syslog",
|
||||
EventType: "System Log",
|
||||
Severity: models.SeverityWarning,
|
||||
Description: "syslog scan error",
|
||||
RawData: err.Error(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func parseSyslogLine(line string) (time.Time, string, models.Severity) {
|
||||
|
||||
Reference in New Issue
Block a user