Skip to content
Merged
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
6 changes: 4 additions & 2 deletions pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ package registry
import (
"context"
"fmt"
"github.com/cheatmd-dev/cheatmd/internal/httputil"
"io"
"strings"
"time"

"github.com/cheatmd-dev/cheatmd/internal/httputil"

yaml "go.yaml.in/yaml/v3"
)

Expand Down Expand Up @@ -52,7 +53,8 @@ func Fetch(ctx context.Context, url string) (*Registry, error) {
}
defer respBody.Close()

data, err := io.ReadAll(respBody)
// Cap registry fetch to 5MB to prevent memory exhaustion
data, err := io.ReadAll(io.LimitReader(respBody, 5*1024*1024))
if err != nil {
return nil, fmt.Errorf("read registry body: %w", err)
}
Expand Down
Loading