| 1 |
From: Reinhard Tartler <[email protected]> |
| 2 |
Date: Fri, 25 Sep 2026 06:28:39 -0400 |
| 3 |
Subject: Fix mockRemoteClient to return valid Location and Request matching |
| 4 |
registry host |
| 5 |
|
| 6 |
In oras-go >= 2.6.2 (GHSA-jxpm-75mh-9fp7), blob upload location validation |
| 7 |
requires the Location header to match the registry host. Because |
| 8 |
mockRemoteClient previously returned an http.Response with an empty |
| 9 |
Request and a relative Location ("test"), Location() could not resolve |
| 10 |
the host, leading to test failures in TestPushSignature and |
| 11 |
TestPushSignatureImageManifest. |
| 12 |
|
| 13 |
Passing the original req as Response.Request and providing a valid |
| 14 |
Location path under /v2/test/blobs/uploads/ allows Location() to resolve |
| 15 |
properly against the request URL and pass host validation in oras-go. |
| 16 |
|
| 17 |
Bug: https://github.com/notaryproject/notation-go/issues/587 |
| 18 |
Bug-Debian: https://bugs.debian.org/1148141 |
| 19 |
Forwarded: https://github.com/notaryproject/notation-go/issues/587 |
| 20 |
Last-Update: 2026-09-25 |
| 21 |
--- |
| 22 |
registry/repository_test.go | 8 +++----- |
| 23 |
1 file changed, 3 insertions(+), 5 deletions(-) |
| 24 |
|
| 25 |
diff --git a/registry/repository_test.go b/registry/repository_test.go |
| 26 |
index 708a974..4a7c09c 100644 |
| 27 |
--- a/registry/repository_test.go |
| 28 |
+++ b/registry/repository_test.go |
| 29 |
@@ -156,11 +156,9 @@ func (c mockRemoteClient) Do(req *http.Request) (*http.Response, error) { |
| 30 |
return &http.Response{ |
| 31 |
StatusCode: http.StatusAccepted, |
| 32 |
Body: io.NopCloser(bytes.NewReader([]byte(msg))), |
| 33 |
- Request: &http.Request{ |
| 34 |
- Header: map[string][]string{}, |
| 35 |
- }, |
| 36 |
+ Request: req, |
| 37 |
Header: map[string][]string{ |
| 38 |
- "Location": {"test"}, |
| 39 |
+ "Location": {"/v2/test/blobs/uploads/test"}, |
| 40 |
}, |
| 41 |
}, nil |
| 42 |
default: |
| 43 |
@@ -202,7 +200,7 @@ func (c mockRemoteClient) Do(req *http.Request) (*http.Response, error) { |
| 44 |
URL: &url.URL{Path: "/v2/test/referrers/" + zeroDigest}, |
| 45 |
}, |
| 46 |
}, nil |
| 47 |
- case validRepo: |
| 48 |
+ case "/v2/test/blobs/uploads/test", validRepo: |
| 49 |
return &http.Response{ |
| 50 |
StatusCode: http.StatusCreated, |
| 51 |
Body: io.NopCloser(bytes.NewReader([]byte(msg))), |