detached 1ec93bf

fix(audit): satisfy lint for downloader hardening

commit
1ec93bfbfa39f13e3e3704f813b110ab33a6edb3
author
brice · · 2026-06-11 04:10 UTC
parent
a19ed71
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +11 -5
M internal/infrastructure/filtering/downloader.go +3 -3
@@ -7,7 +7,7 @@ import (
77 "io"
88 "net/http"
99 "os"
10- "path"
10+ pathpkg "path"
1111 "path/filepath"
1212 "strings"
1313 "time"
@@ -312,8 +312,8 @@ func validateFilterFilename(filename string) (string, error) {
312312 }
313313 }
314314
315- clean := path.Clean(filename)
316- if path.Ext(clean) != ".json" {
315+ clean := pathpkg.Clean(filename)
316+ if pathpkg.Ext(clean) != ".json" {
317317 return "", fmt.Errorf("invalid filter filename %q: expected .json extension", filename)
318318 }
319319
@@ -7,7 +7,7 @@ import (
7 "io"7 "io"
8 "net/http"8 "net/http"
9 "os"9 "os"
10- "path"10+ pathpkg "path"
11 "path/filepath"11 "path/filepath"
12 "strings"12 "strings"
13 "time"13 "time"
@@ -312,8 +312,8 @@ func validateFilterFilename(filename string) (string, error) {
312 }312 }
313 }313 }
314 314
315- clean := path.Clean(filename)315+ clean := pathpkg.Clean(filename)
316- if path.Ext(clean) != ".json" {316+ if pathpkg.Ext(clean) != ".json" {
317 return "", fmt.Errorf("invalid filter filename %q: expected .json extension", filename)317 return "", fmt.Errorf("invalid filter filename %q: expected .json extension", filename)
318 }318 }
319 319
M internal/infrastructure/filtering/downloader_test.go +8 -2
@@ -122,7 +122,10 @@ func TestDownloader_DownloadFilters_AllowsSafeNestedManifestFilenames(t *testing
122122
123123 func TestDownloader_FetchManifest_RejectsOversizedManifest(t *testing.T) {
124124 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
125- require.Equal(t, "/"+FilterFiles.Manifest, r.URL.Path)
125+ if r.URL.Path != "/"+FilterFiles.Manifest {
126+ http.NotFound(w, r)
127+ return
128+ }
126129 _, _ = io.WriteString(w, strings.Repeat("x", 17))
127130 }))
128131 defer server.Close()
@@ -148,7 +151,10 @@ func TestDownloader_FetchManifest_RejectsTooManyFiles(t *testing.T) {
148151 require.NoError(t, err)
149152
150153 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
151- require.Equal(t, "/"+FilterFiles.Manifest, r.URL.Path)
154+ if r.URL.Path != "/"+FilterFiles.Manifest {
155+ http.NotFound(w, r)
156+ return
157+ }
152158 _, _ = w.Write(payload)
153159 }))
154160 defer server.Close()
@@ -122,7 +122,10 @@ func TestDownloader_DownloadFilters_AllowsSafeNestedManifestFilenames(t *testing
122 122
123 func TestDownloader_FetchManifest_RejectsOversizedManifest(t *testing.T) {123 func TestDownloader_FetchManifest_RejectsOversizedManifest(t *testing.T) {
124 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {124 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
125- require.Equal(t, "/"+FilterFiles.Manifest, r.URL.Path)125+ if r.URL.Path != "/"+FilterFiles.Manifest {
126+ http.NotFound(w, r)
127+ return
128+ }
126 _, _ = io.WriteString(w, strings.Repeat("x", 17))129 _, _ = io.WriteString(w, strings.Repeat("x", 17))
127 }))130 }))
128 defer server.Close()131 defer server.Close()
@@ -148,7 +151,10 @@ func TestDownloader_FetchManifest_RejectsTooManyFiles(t *testing.T) {
148 require.NoError(t, err)151 require.NoError(t, err)
149 152
150 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {153 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
151- require.Equal(t, "/"+FilterFiles.Manifest, r.URL.Path)154+ if r.URL.Path != "/"+FilterFiles.Manifest {
155+ http.NotFound(w, r)
156+ return
157+ }
152 _, _ = w.Write(payload)158 _, _ = w.Write(payload)
153 }))159 }))
154 defer server.Close()160 defer server.Close()

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 8

Tags 42

↑↓ moveenter openesc close