Skip to content

Commit 2ce3f13

Browse files
Stacey Birleyonsi
authored andcommitted
reporters: add enhanced bounds checking in emitTimeline to prevent slice panic
- Add additional bounds validation (cursor <= len(gw) && end <= len(gw)) - Prevents slice bounds panic when timeline offsets are malformed - Fixes issue with specs skipped in ordered containers that have zero EndTime
1 parent acf208a commit 2ce3f13

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

reporters/default_reporter.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,6 @@ func (r *DefaultReporter) humanReadableState(state types.SpecState) string {
376376
}
377377

378378
func (r *DefaultReporter) emitTimeline(indent uint, report types.SpecReport, timeline types.Timeline) {
379-
// Skip timeline rendering for specs that never ran (e.g., skipped due to failed BeforeAll or in ordered containers)
380-
if report.EndTime.IsZero() && len(report.CapturedGinkgoWriterOutput) == 0 {
381-
return
382-
}
383-
384379
isVeryVerbose := r.conf.Verbosity().Is(types.VerbosityLevelVeryVerbose)
385380
gw := report.CapturedGinkgoWriterOutput
386381
cursor := 0
@@ -394,7 +389,7 @@ func (r *DefaultReporter) emitTimeline(indent uint, report types.SpecReport, tim
394389
if end < cursor {
395390
end = cursor
396391
}
397-
if cursor < end {
392+
if cursor < end && cursor <= len(gw) && end <= len(gw) {
398393
r.emit(r.fi(indent, "%s", gw[cursor:end]))
399394
cursor = end
400395
} else if cursor < len(gw) && end == len(gw) {

0 commit comments

Comments
 (0)