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
1 change: 1 addition & 0 deletions .jules/janitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- 2026-01-20: Extract complex, self-contained logic blocks from main handlers into helper functions.
- 2026-01-26: Separate configuration data (like lists of magic strings) from business logic.
- 2025-02-18: Remove redundant tests that validate copy-pasted logic instead of the actual function.
- 2025-02-18: Always explicitly check errors in tests instead of ignoring them with blank identifier.
5 changes: 4 additions & 1 deletion api/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ func TestSSRFProtection(t *testing.T) {
// Test Unspecified IP (0.0.0.0) bypass attempt
// We manually construct a URL with 0.0.0.0 and a port (it doesn't need to be open for the check to fire)
unspecifiedURL := "http://0.0.0.0:8080"
reqUnspecified, _ := http.NewRequest("GET", unspecifiedURL, nil)
reqUnspecified, err := http.NewRequest("GET", unspecifiedURL, nil)
if err != nil {
t.Fatalf("failed to create request: %v", err)
}
_, err = httpClient.Do(reqUnspecified)
if err == nil {
t.Fatal("expected an error when dialing 0.0.0.0, but got none")
Expand Down
20 changes: 11 additions & 9 deletions api/reconstruct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,24 @@ func TestReconstructTargetURL(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u, _ := url.Parse("http://localhost/api" + tt.query)
u, err := url.Parse("http://localhost/api" + tt.query)
if err != nil {
t.Fatalf("failed to parse test URL: %v", err)
}
r := &http.Request{URL: u}
got := reconstructTargetURL(r)

if got == "" && tt.expected == "" {
return
}

gotU, _ := url.Parse(got)
expU, _ := url.Parse(tt.expected)

if gotU == nil || expU == nil {
if got != tt.expected {
t.Errorf("reconstructTargetURL() = %v, want %v", got, tt.expected)
}
return
gotU, err := url.Parse(got)
if err != nil {
t.Fatalf("failed to parse result URL %q: %v", got, err)
}
expU, err := url.Parse(tt.expected)
if err != nil {
t.Fatalf("failed to parse expected URL %q: %v", tt.expected, err)
}

if gotU.Scheme != expU.Scheme || gotU.Host != expU.Host || gotU.Path != expU.Path {
Expand Down