Skip to content
Draft
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
20 changes: 18 additions & 2 deletions internal/scraper/modified.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"math"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -55,8 +56,23 @@ func buildModifiedEvents(path string, newData []byte, kind, scopeKind string, sc
}
oldMap := mapRawByID(oldPage.Results)

ids := make([]int64, 0, len(oldMap)+len(newMap))
seen := make(map[int64]struct{}, len(oldMap)+len(newMap))
const maxTrackedItems = 1_000_000

oldLen := len(oldMap)
newLen := len(newMap)
if oldLen > maxTrackedItems || newLen > maxTrackedItems {
return nil, fmt.Errorf("too many tracked items to build modified events")
}
if oldLen > math.MaxInt-newLen {
return nil, fmt.Errorf("too many tracked items to build modified events")
}
combinedLen := oldLen + newLen
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
if combinedLen > maxTrackedItems {
return nil, fmt.Errorf("too many tracked items to build modified events")
}

ids := make([]int64, 0, combinedLen)
seen := make(map[int64]struct{}, combinedLen)
for id := range oldMap {
seen[id] = struct{}{}
ids = append(ids, id)
Expand Down