Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/modules/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func runExtractors(extractors []Extractor, resp *http.Response, body string) map
continue
}
matches := re.FindStringSubmatch(part)
if len(matches) > e.Group {
if e.Group >= 0 && len(matches) > e.Group {
result[e.Name] = matches[e.Group]
break
}
Expand Down
8 changes: 8 additions & 0 deletions internal/modules/matchers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,14 @@ func TestRunExtractors(t *testing.T) {
},
wantNil: true,
},
{
// a negative group must be skipped, not panic on matches[-1].
name: "negative group is skipped",
extractors: []Extractor{
{Type: "regex", Name: "session", Part: "body", Regex: []string{`"session":"([^"]+)"`}, Group: -1},
},
wantNil: true,
},
{
name: "invalid pattern is skipped, no capture",
extractors: []Extractor{
Expand Down
Loading