detached da431e6

fix(remote): cap error body reads to 1KB to prevent memory exhaustion

commit
da431e6b1624182ef6e0790cac59986a9278c9d0
author
bnema · · 2026-03-18 21:30 UTC
parent
98678d9
signature
unsigned
1 file · +2 -2
M internal/adapters/in/cli/remote/auth.go +2 -2
@@ -55,7 +55,7 @@ func (c *Client) Authenticate(ctx context.Context, username, password string) (*
5555 defer resp.Body.Close()
5656
5757 if resp.StatusCode >= 400 {
58- body, _ := io.ReadAll(resp.Body)
58+ body, _ := io.ReadAll(io.LimitReader(resp.Body, 1024))
5959 var errResp struct {
6060 Error string `json:"error"`
6161 }
@@ -95,7 +95,7 @@ func (c *Client) ExchangeRegistryToken(ctx context.Context, subject string) (str
9595 defer resp.Body.Close()
9696
9797 if resp.StatusCode >= 400 {
98- body, _ := io.ReadAll(resp.Body)
98+ body, _ := io.ReadAll(io.LimitReader(resp.Body, 1024))
9999 var errResp struct {
100100 Error string `json:"error"`
101101 }
@@ -55,7 +55,7 @@ func (c *Client) Authenticate(ctx context.Context, username, password string) (*
55 defer resp.Body.Close()55 defer resp.Body.Close()
56 56
57 if resp.StatusCode >= 400 {57 if resp.StatusCode >= 400 {
58- body, _ := io.ReadAll(resp.Body)58+ body, _ := io.ReadAll(io.LimitReader(resp.Body, 1024))
59 var errResp struct {59 var errResp struct {
60 Error string `json:"error"`60 Error string `json:"error"`
61 }61 }
@@ -95,7 +95,7 @@ func (c *Client) ExchangeRegistryToken(ctx context.Context, subject string) (str
95 defer resp.Body.Close()95 defer resp.Body.Close()
96 96
97 if resp.StatusCode >= 400 {97 if resp.StatusCode >= 400 {
98- body, _ := io.ReadAll(resp.Body)98+ body, _ := io.ReadAll(io.LimitReader(resp.Body, 1024))
99 var errResp struct {99 var errResp struct {
100 Error string `json:"error"`100 Error string `json:"error"`
101 }101 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close