1455 Commits

Author SHA1 Message Date
Milos Gajdos
979a07472e fix(registry/handlers/app): redis CAs (#4668) 2025-09-03 07:06:09 -07:00
Wang Yan
8c60ad709b Fixes #4683 - uses X/Y instead of Gx/Gy for thumbprint of ecdsa keys (#4684) 2025-08-12 13:41:12 +08:00
João Pereira
7f2dad4420 Fixed data race in TestSchedule test (#4647) 2025-08-11 23:25:37 +01:00
Guillaume pelletier
6e59b82417 Fixes #4683 - uses X/Y instead of Gx/Gy for thumbprint of ecdsa keys
Signed-off-by: Guillaume Pelletier <guillaume.pelletier@genaiz.com>
2025-08-11 10:29:53 -04:00
Milos Gajdos
7d74ee7186 Fix S3 driver loglevel param (#4617) 2025-08-11 14:27:41 +01:00
Wang Yan
c54bcb3770 s3-aws: fix build for 386 (#4642) 2025-08-11 14:14:53 +08:00
Raj Siva-Rajah
b559f27a08 Switch to UUIDv7
Signed-off-by: Raj Siva-Rajah <raj@zapzap.cloud>
2025-07-31 06:54:27 +00:00
ChandonPierre
02b1f6e3af fix(registry/handlers/app): redis CAs
`configureRedis` currently sets `RequireAndVerifyClientCert` and `ClientCAs`, however these are server side mTLS configurations, and do not apply for the client initiating the handshake.

Since we never actually set client side `RootCAs`, connecting to Redis with a self-signed CA results in:

```
"error": "tls: failed to verify certificate: x509: certificate signed by unknown authority",
```
Fixed by switching Redis TLS config to use `RootCAs` instead, and updating configuration accordingly.

Signed-off-by: ChandonPierre <cpierre@coreweave.com>
2025-07-05 15:25:17 -04:00
Artem Khoroshev
bb278c2be6 fix: fixed data race in TestSchedule test
Signed-off-by: Artem Khoroshev <horoshev.artem@yandex.ru>
2025-06-06 20:12:59 +03:00
Chen Qi
6970080b10 s3-aws: fix build for 386
When building for 386, we got the following build error:

  registry/storage/driver/s3-aws/s3.go:312:99: cannot use
  maxChunkSize (untyped int constant 5368709120) as int value
  in argument to getParameterAsInteger (overflows)

This is because the s3_64bit.go is used. Adjust the build tag matching
in s3_32bit.go and s3_64bit.go to fix this issue.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
2025-05-29 11:35:59 +08:00
Milos Gajdos
97495e5397 Fix: resolve issue #4478 by using a temporary file for non-append writes (#4624) 2025-05-19 07:37:07 -07:00
Oded Porat
dde1e49f23 Changes:
Append a UUID to ensure uniqueness
Join delete error

Signed-off-by: Oded Porat <onporat@gmail.com>
2025-05-04 10:43:19 +03:00
Milos Gajdos
95647cba1d feat: extract redis config to separate struct (#4620) 2025-04-29 06:21:55 -07:00
Oded Porat
a5a6f1ba3d To address the issue where empty files are created when the write process is interrupted, the solution involves writing to a temporary file first and then atomically renaming it to the target file. This ensures that the target file is only updated if the write completes successfully, preventing empty or partially written files.
**Explanation:**

1. **Temporary File Creation:** The content is first written to a temporary file (appending `.tmp` to the original path). This ensures that the original file remains intact until the write is complete.

2. **Write to Temporary File:** Using the existing `Writer` with truncation (`false`), the content is written to the temporary file. If the write fails, the temporary file is closed and deleted.

3. **Commit and Rename:** After successfully writing to the temporary file, it is committed. Then, the temporary file is atomically renamed to the target path using `Move`, which is handled by the filesystem's rename operation (atomic on most systems).

4. **Cleanup on Failure:** If any step fails, the temporary file is cleaned up to avoid leaving orphaned files.

Signed-off-by: Oded Porat <onporat@gmail.com>
2025-04-23 11:37:55 +03:00
Youfu Zhang
4aab88fede fix: implement JWK thumbprint for Ed25519 public keys
Signed-off-by: Youfu Zhang <zhangyoufu@gmail.com>
2025-04-23 13:30:18 +08:00
Oded Porat
78456caf46 Fix: resolve issue #4478 by using a temporary file for non-append writes
To address the issue where a failed write operation results in an empty file, we can use a temporary file for non-append writes. This ensures that the original file is only replaced once the new content is fully written and committed.

**Key Changes:**

1. **Temporary File Handling:**
   - For non-append writes, a temporary file is created in the same directory as the target file.
   - All write operations are performed on the temporary file first.

2. **Atomic Commit:**
   - The temporary file is only renamed to the target path during `Commit()`, ensuring atomic replacement.
   - If `Commit()` fails, the temporary file is cleaned up.

3. **Error Handling:**
   - `Cancel()` properly removes temporary files if the operation is aborted.
   - `Close()` is made idempotent to handle multiple calls safely.

4. **Data Integrity:**
   - Directory sync after rename ensures metadata persistence.
   - Proper file flushing and syncing before rename operations.

Signed-off-by: Oded Porat <onporat@gmail.com>
2025-04-16 10:30:20 +03:00
closeobserve
a6ce1a7995 chore: make function comment match function name
Signed-off-by: closeobserve <pingcap@yahoo.com>
2025-04-13 17:40:27 +08:00
Mateusz Urbanek
fcb2deac0b feat: extract redis config to separate struct
Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
2025-04-10 16:53:45 +02:00
Lucas Melchior
ea6ab3652c fix newClient in azure storage provider
it can now return a client using default azure credentials
updated docs to include information on Azure Workload Identity

Signed-off-by: Lucas Melchior <lucasmelchior@flywheel.io>

fix anchor link in docs

Signed-off-by: Lucas Melchior <lucasmelchior@flywheel.io>
2025-04-08 10:22:34 -05:00
Milos Gajdos
369663e4be Fix S3 driver loglevel param
Unfortunately YAML struck us hard in this one.
It interprets "off" as a truthy value so setting loglevel to off sets it
to false.

This commit makes sure we set the loglevel to off if the param is
marshalled into false and if it's not a string.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-04-01 08:15:26 -07:00
Milos Gajdos
ebd20d3be7 Azure driver retry fix (#4576) 2025-03-14 10:20:25 -07:00
Milos Gajdos
2ffa1171c2 Azure driver fix
* Make copy poll max retry, a global driver max retry
* Get support for etags in Azure
* Fix storage driver tests
* Fix auth mess and update docs
* Refactor Azure client and enable Azure storage tests

We use Azurite for integration testing which requires TLS,
so we had to figure out how to skip TLS verification when running tests locally:
this required updating testsuites Driver and constructor due to TestRedirectURL
sending GET and HEAD requests to remote storage which in this case is Azurite.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-03-14 10:03:09 -07:00
Oleg Gnusarev
b30274f26c use cached blob statter in ManifestService if available
Signed-off-by: Oleg Gnusarev <ognusarev@mts.ru>
2025-03-11 19:41:25 +03:00
Milos Gajdos
7884c71297 Add code comment
Adding a code comment that explains setting MD5 Sum field.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-03-01 07:35:41 -08:00
Milos Gajdos
e20645c050 Enable MD5 check on GCS driver
Apparently you can upload 0-size content wihtout GCS reportin any errors
back to you.

This is something a lot of our users experienced and reported. See here
for at least one example:
github.com/distribution/distribution/issues/3018

This sets tbe MD5 sum on the uploaded content which should rectify
things according to the docs:
https://pkg.go.dev/cloud.google.com/go/storage#ObjectAttrs

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-02-28 07:20:48 -08:00
evanebb
64f780f6c5 Explicitly return zero value instead of partially filled struct
Signed-off-by: evanebb <git@evanus.nl>
2025-02-24 16:04:41 +01:00
evanebb
0762a1bb57 Fix error message for unsupported signing algorithm by not overriding var
Signed-off-by: evanebb <git@evanus.nl>
2025-02-23 22:17:17 +01:00
evanebb
70d99154ac Fix signing algorithm configuration for token authentication
Signed-off-by: evanebb <git@evanus.nl>
2025-02-23 22:16:11 +01:00
Milos Gajdos
63d3892315 registry/storage: add option to quiet GC output. (#4560) 2025-02-13 07:37:00 -08:00
Milos Gajdos
6ed60b0f48 Apply suggestions from code review
Co-authored-by: Sebastiaan van Stijn <thaJeztah@users.noreply.github.com>
Signed-off-by: Milos Gajdos <milosgajdos83@gmail.com>
2025-02-06 17:43:28 +00:00
Milos Gajdos
53c382641c Remove named returns and fix linting woes
Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-02-05 21:26:23 -08:00
Rafael Fonseca
a032989bf9 registry/storage: add option to quiet GC output.
Consumers might not want GC output to be displayed (e.g, if you have
your own logging system).

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
2025-02-02 10:18:45 +01:00
Milos Gajdos
f4a500caf6 Fix registry token authentication bug
When a JWT contains a JWK header without a certificate chain,
the original code only checked if the KeyID (kid) matches one of the trusted keys,
but doesn't verify that the actual key material matches.

As a result, if an attacker guesses the kid, they can inject an
untrusted key which would then be used to grant access to protected
data.

This fixes the issue such as only the trusted key is verified.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2025-02-01 15:30:18 -08:00
vitshev
328f802b8e fix(configuration): replace string literals with constants
Signed-off-by: vitshev <vitshev@tracto.ai>
2024-12-16 20:43:30 +01:00
vitshev
916bdeae94 feat(configuration): support mtls auth mod
Signed-off-by: vitshev <vitshev@tracto.ai>
2024-12-16 20:43:20 +01:00
Milos Gajdos
f7236ab041 feat: support custom exec-based credential helper in proxy mode (#4438) 2024-11-05 11:48:33 +00:00
Thomas Way
5ee5aaa058 fix(registry/storage/driver/s3-aws): use a consistent multipart chunk size
Some S3 compatible object storage systems like R2 require that all
multipart chunks are the same size. This was mostly true before, except
the final chunk was larger than the requested chunk size which causes
uploads to fail.

In addition, the two byte slices have been replaced with a single
*bytes.Buffer and the surrounding code simplified significantly.

Fixes: #3873

Signed-off-by: Thomas Way <thomas@6f.io>
2024-10-30 21:46:36 +00:00
Milos Gajdos
bce9fcd135 avoid appending directory as file path in s3 driver Walk (#4485) 2024-10-16 21:14:56 +01:00
Flavian Missi
2e7482cb89 avoid appending directory as file path in s3 driver Walk
when a directory is empty, the s3 api lists it with a trailing slash.
this causes the path to be appended twice to the walkInfo slice, causing
purge uploads path transformations to panic when the `_uploads` is
emtpy.

this adds a check for file paths ending on slash, and do not append
those as regular files to the walkInfo slice.

fixes #4358

Signed-off-by: Flavian Missi <fmissi@redhat.com>
2024-10-14 14:53:31 +02:00
Flavian Missi
e44d9317d0 test s3 driver walk of empty dir
Signed-off-by: Flavian Missi <fmissi@redhat.com>
2024-10-14 14:53:26 +02:00
Pratik
5e59a64896 fix existing doc first
Signed-off-by: Pratik <pratikgparikh@gmail.com>
2024-10-08 22:06:38 +05:30
Sebastiaan van Stijn
0ab7f326e6 replace uses of Descriptor alias
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-07 13:07:47 +02:00
Milos Gajdos
44be16a883 TestProxyManifestsMetrics: use actual size of manifest (#4467) 2024-10-03 10:02:30 +01:00
Jose D. Gomez R
b53946ded3 fix: Add the token's rootcert public key to the list of known keys
- Add Unit tests for `token.newAccessController`
  + Implemented swappable implementations for `token.getRootCerts` and
    `getJwks` to unit test their behavior over the accessController
    struct.

- Use RFC7638 [0] mechanics to compute the KeyID of the rootcertbundle
  provided in the token auth config.

- Extends token authentication docs:
  + Extend `jwt.md` write up on JWT headers & JWT Validation
  + Updated old reference to a draft that's now RFC7515.
  + Extended the JWT validation steps with the JWT Header validation.
  + Reference `jwt.md` in `token.md`

[0]: https://datatracker.ietf.org/doc/html/rfc7638#autoid-13

Signed-off-by: Jose D. Gomez R <jose.gomez@suse.com>
2024-10-02 11:58:41 +02:00
Sebastiaan van Stijn
4a0e027e4d TestProxyManifestsMetrics: use actual size of manifest
This test was using a hard-coded value for the size of the manifest,
which made it difficult to correlate the tested value with what it
was testing.

This patch updates populateRepo to return the actual size when
serialized, and updates manifestStoreTestEnv to include the
size to test for.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-18 22:10:15 +02:00
Milos Gajdos
a940e61623 Fix silly testing format mistakes
Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-08-30 11:18:18 +01:00
Milos Gajdos
170ac07a5e chore: bump golangci-lint and fix govert issues
The latest golangci-lint spits out some govet issues.
This commit fixes them. We are also bumping the linter version.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-08-30 10:28:24 +01:00
Chun-Hung Hsiao
eed9400d26 feat: support custom exec-based credential helper in proxy mode
This change allows users to run the registry as a pull-through cache
that can use a credential helper to authenticate against the upstream
registry.

Signed-off-by: Chun-Hung Hsiao <chhsiao@google.com>
2024-08-16 19:42:51 -07:00
Milos Gajdos
d8199f451b chore: fix typo in rewrite storage middleware init
https://github.com/distribution/distribution/pull/4146 introduced a new
rewrite storage middleware but somehow missed to update the init logging
message. This commit fixes that.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
2024-08-15 08:59:30 +01:00
Liang Zheng
db5c303e7e fix: skip removing layer's link file when '--dry-run' option spcified
Signed-off-by: Liang Zheng <zhengliang0901@gmail.com>
2024-07-31 23:21:45 +08:00