Commit Graph

1374 Commits

Author SHA1 Message Date
Ramkumar Chinchani a0943eccfe chore: fix dependabot alerts (#3496)
* chore: fix dependabot alerts

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: initialize logger in ut

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-30 14:21:53 -07:00
Andrei Aaron 41e10d4fe9 feat: add zot subcommand to enable testing retention policy settings (#3449)
feat: add verify-feature retention subcommand with comprehensive testing and validation

Add a `verify-feature retention` subcommand that allows users to preview and
validate retention policy changes without running the actual Zot server.
The command runs GC and retention tasks in dry-run mode for immediate feedback.

- Run verify-feature retention standalone without starting the server
- Preview retention policy decisions in dry-run mode
- Configurable GC interval override via command-line flag
- Optional timeout for task completion
- Configurable log output (stdout or file)

Basic usage:
```bash
zot verify-feature retention <config-file>
```

With log file output:
```bash
zot verify-feature retention -l /var/log/zot-retention-check.log <config-file>
```

With GC interval override (runs GC tasks every 30 seconds):
```bash
zot verify-feature retention -i 30s <config-file>
```

With timeout (wait up to 5 minutes for tasks to complete):
```bash
zot verify-feature retention -t 5m <config-file>
```

Combined flags:
```bash
zot verify-feature retention -l /var/log/zot-retention-check.log -i 1m -t 10m <config-file>
```

The command supports overriding GC settings from the config:
- `-i, --gc-interval`: Override the GC interval setting (applies to all storage paths including subpaths)

- Refactored `RunGCTasks` from `controller.go` to be reusable
- Added `checkServerRunning` validation to prevent conflicts
- Implemented signal handling for graceful shutdown
- Added configuration sanitization and logging
- Set GCMaxSchedulerDelay programmatically (not user-configurable)

Added tests for coverage on main function:
- Negative test cases (no args, bad config, GC disabled, server running)
- Both BoltDB and Redis
- Retention enabled scenarios with complex image setups
- Retention disabled scenarios
- Delete referrers functionality
- Subpaths configuration
- GC interval override validation

Run the verify-feature retention tests:
```bash
go test -v ./pkg/cli/server -run TestRetentionCheck
```

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-28 13:36:59 -07:00
Andrei Aaron 029f6f0a29 fix: configure cookie Secure flag based on TLS configuration (#3482)
Make the Secure flag for session cookies configurable based on Zot's
TLS settings. This allows cookies to work properly when Zot is
accessed over HTTP (without TLS).

Changes:
- Add SecureSession field to AuthConfig to allow explicit control
- Add UseSecureSession() method that returns true when TLS is
  configured, or uses SecureSession setting if provided
- Update saveUserLoggedSession() to accept and use secure parameter
- Add tests for UseSecureSession() in config_test.go
- Enhance authn tests to verify cookie Secure flag behavior
- Fix TestAuthnSessionErrors by creating new client without cookies

The logic is:
- If TLS is configured, cookies always have Secure=true
- If TLS is not configured but SecureSession is explicitly set,
  use that value
- Otherwise, default to Secure=false for HTTP-only deployments

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-27 17:21:21 +02:00
Andrei Aaron 22cfd9430b refactor: remove usage of goto in the image store (#2969)
Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
2025-10-25 17:14:38 +03:00
Andrei Aaron 66bb8341e3 fix: zot version broken after switching to /v2 (#3479)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-22 10:25:47 -07:00
Andrei Aaron a2c144693f chore: stabilize coverage in specific sync test (#3480)
Take care of https://app.codecov.io/gh/project-zot/zot/pull/3479/indirect-changes

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-22 12:21:29 +03:00
Ramkumar Chinchani 559d9cf2fc chore: fix dependabot alerts (#3477)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-22 09:46:03 +03:00
Andrei Aaron 1fb2b67419 fix: minor fixes based on intermittent test failures (#3465)
1. preload busybox image to fix: https://github.com/project-zot/zot/actions/runs/18614431126/job/53077015870?pr=3465
2. stabilize test coverage in by using different error type: https://app.codecov.io/gh/project-zot/zot/pull/3444/indirect-changes
3. attempt to fx an intermitent sync test failure:
Failures:

  * /home/andaaron/zot/pkg/extensions/sync/sync_test.go
  Line 4857:
  Expected: digest.Digest("sha256:dc1377539a9db8bf077100bfa3118052feb6b5c67509ca09bdd841e4ac14c4cc")
  Actual:   digest.Digest("sha256:3a3fb31a422846a680f0a07b8b666bdcb1122d912d1adca79523c7bf2715996e")
  (Should equal)!

4. fix a race condition in sync by, I don't have a link, but this is the failure:

  * zotregistry.dev/zot/pkg/extensions/sync/sync_test.go
  Line 5963:
  Expected: 1
  Actual:   2
  (Should equal)!

1426 total assertions

--- FAIL: TestOnDemandPullsOnce (0.42s)
    sync_test.go:5921: Goroutine 0: Sending request to http://127.0.0.1:36421/v2/zot-test/manifests/0.0.1
    sync_test.go:5921: Goroutine 1: Sending request to http://127.0.0.1:36421/v2/zot-test/manifests/0.0.1
    sync_test.go:5921: Goroutine 4: Sending request to http://127.0.0.1:36421/v2/zot-test/manifests/0.0.1
    sync_test.go:5921: Goroutine 3: Sending request to http://127.0.0.1:36421/v2/zot-test/manifests/0.0.1
    sync_test.go:5921: Goroutine 2: Sending request to http://127.0.0.1:36421/v2/zot-test/manifests/0.0.1
FAIL
coverage: 21.4% of statements in ./...
FAIL	zotregistry.dev/zot/pkg/extensions/sync	255.189s

5. Fix flaky coverage in https://app.codecov.io/gh/project-zot/zot/pull/3465/indirect-changes

6. Stability fix for https://github.com/project-zot/zot/actions/runs/18632536285/job/53119244557?pr=3465

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-19 17:59:32 -07:00
Andrei Aaron dfb5d1df54 fix: make config read/write thread safe (#3432)
* fix: make config read/write thread safe and fix some other similar issues

1. The config config has a lock, and safe methods to update and read the attributes
2. The config has methods to retrieve copies of specific attributes, such as the extyensions config, the auth config, and the authz config.
These are needed, as the config object may mutate in the middle of an auth/authz requests, and we avoid partial configuration being applied for that request.
3. Fix an issue with the monitoring server not stopping when the controller is shut down.
4. Fix an issue with the HTPasswdWatcher not stopping when the background tasks are supposed to finish.
5. Fix some tests using hardcoded ports.

Moved some of the methods which were on the main config to the auth, access control and extension configs

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
v2.1.10
2025-10-18 11:20:58 +03:00
Luca Muscariello 2402296e9a fix: migrate to Go module v2 for proper semantic versioning (#3462)
* fix: migrate to Go module v2 for proper semantic versioning

This change updates the module path from 'zotregistry.dev/zot' to
'zotregistry.dev/zot/v2' to comply with Go's semantic versioning rules.

According to Go's module versioning requirements, major version v2+
must include the major version in the module path. The current
module path 'zotregistry.dev/zot' only supports v0.x.x and v1.x.x
versions, making existing v2.x.x tags (like v2.1.8) unusable.

Changes:
- Updated go.mod module path to zotregistry.dev/zot/v2
- Updated all internal import paths across 280+ Go source files
- Updated configuration files (golangcilint.yaml, gqlgen.yml)
- Updated README.md Go reference badge

This fix enables proper use of existing v2.x.x Git tags and allows
external packages to import zot v2+ versions without compatibility
errors.

Resolves: Go module import compatibility for v2+ versions
Fixes: #3071
Signed-off-by: Luca Muscariello <muscariello@ieee.org>

* fix: regenerate GraphQL files with updated v2 import paths

The gqlgen tool needs to regenerate the GraphQL schema files after
the module path change to use the new v2 imports.

Signed-off-by: Luca Muscariello <muscariello@ieee.org>

---------

Signed-off-by: Luca Muscariello <muscariello@ieee.org>
2025-10-16 22:43:47 -07:00
Ramkumar Chinchani 73eef25681 ci: enable fips140 blackbox test (#3460)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
v2.1.9
2025-10-13 22:49:06 -07:00
Ramkumar Chinchani b2bbbb27f2 chore: fix dependabot alerts (#3461)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-14 08:07:24 +03:00
Andrei Aaron bd20426a1a ci: debugging blackbox failures (#3453)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-13 10:38:58 -07:00
Andrei Aaron b0f917a444 ci: pre download docker images used in bats tests (#3452)
Should help with issues such as https://github.com/project-zot/zot/actions/runs/18457240003/job/52580780359

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-13 10:41:30 +03:00
Ramkumar Chinchani 411a3d00b5 fix: update go-redsync for fips-140 compatibility (#3451)
* fix: update go-redsync for fips-140 compatibility

Fixes issue #3445

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: address comments and add a basic push-pull test

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: address comments

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-13 09:34:12 +03:00
Andrei Aaron f724107c8f ci: fix values in stale comment messages (#3448)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-11 10:57:07 +03:00
Andrei Aaron 0d42ba2744 feat: the default retention delay is not the GC delay (#3447)
Most users don't make the difference between retention deleting untagged manifests vs GC deleting other blobs.
This causes confusion since the GC delay and the retention delay (used for untagged manifests and orphan referrers) have different defaults, and are set separately in the zot configuration.
Most users don't configrue retention policies, and they still expect untagged manifests to be deleted at GC time.

With this change, if retention delay is not specified in the config file, the value used is the GC delay.
If GC delay is also unspecified in the config file, the default GC delay is used for both.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-10 14:30:29 -07:00
Andrei Aaron 466cbc36fd ci: update stale checks (#3446)
Since the job for triaging stale issues started running last week, it has been mainly running for recent issues.
Also 30 days of issue inactivity is too low at this moment.

Update to 90 days, and force it to start processing older issues/PRs first.
Increase the number of operations per execution, processing more issues/PRs per run.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-10 09:16:02 -07:00
Ramkumar Chinchani 1d9c9aeacf chore: fix dependabot alerts (#3444)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-07 14:14:34 +03:00
Andrei Aaron 3dcd7d1683 ci: fix nightly (#3431)
ci: fix nightly and show logs for nightly sync tests

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-05 12:58:04 -07:00
Vishwas Rajashekar 86af38abfc feat(sessions): add support for remote redis session store (#3345)
Description
====================
zot currently stores session cookies in memory or in a local directory.
For cases where the session cookies should be independent of the
instance where they were created such as multiple instances of zot, or a
fully stateless zot instance, there is a need to support a remote
session storage.
This change adds support for using Redis and Redis-compatible services as a
remote session driver as well as introduces a new configuration option
for it.

What has changed
=======================
- New config added under Auth config to specify configuration for
  the session driver.
- Examples README updated with details of the new Auth config.
- The config supports only 2 drivers in this change - local and redis
- Using the local driver is backwards compatible and behaves the same
  way that zot currently works for local session storage.
- Omitting this config does not result in an error. In this case, zot
  behaves as it normally does for local session storage.
- When configured, zot can use redis for persisting cookie
  information for zot UI.
- The cookie in the store is deleted on logout or after the max
  expiry time for the cookie.
- Configuration for the redis session driver accepts the same configuration
  values as that of the remote meta cache.
- A separate connection is established for the session driver. An
  existing connection for meta cache will not be re-used for the
  session driver.
- A key prefix is configurable for the redis session driver. The value will be
  converted into a string for use. If no value is provided, a default
  prefix of "zotsession" will be used.
- Redis sessions does not support hash key or encryption in this change.
- New BATS test added to verify zot behavior with Redis session store.
- Github workflow updated to install valkey-tools dependency for BATS.

Signed-off-by: Vishwas Rajashekar <dev@vrajashkr.com>
2025-10-05 10:13:38 +03:00
Andrei Aaron cbbd39745c chore: stabilize coverage for specific imagestore case (#3429)
https://app.codecov.io/gh/project-zot/zot/commit/636a6b1820088c4334b02ef5d2e61a3450c4b231/indirect-changes

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-04 23:40:25 -07:00
Lukasz Jakimczuk 50c7fa6dd8 feat(sync): enable regclient logs (#3363)
feat: enable regclient logs

Signed-off-by: Łukasz Jakimczuk <ljakimczuk@gmail.com>
2025-10-04 11:27:27 -07:00
Vishwas Rajashekar 636a6b1820 fix(ci): use fixed ranges for BATS server ports (#3428)
Changes in this PR
==================
- Replaces the get_free_port bash function in BATS tests
with get_free_port_for_service that returns a random free port
in a given range for a test file and service defined in a
ports.json file.
- Updates all get_free_port calls to use the new function.
- A new README file for details on the ports.json file.
- Updates some tests using fixed ports to use dynamic ports.
- Adds a ports.json file with all the allocations.
- Adds a new common helper for port fetching.

Signed-off-by: Vishwas Rajashekar <30438425+vrajashkr@users.noreply.github.com>
2025-10-04 19:16:03 +03:00
Ramkumar Chinchani b1842ab9e0 fix: migrate from github.com/rs/zerolog to golang-native log/slog (#3405)
* fix: migrate from github.com/rs/zerolog to golang-native log/slog

We have been using zerolog for a really long time.
golang now has structured logging using slog.
Best to move to this in interests of long-term support.

This is a tech debt item.

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: a few changes on top

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: address comments

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-03 12:34:03 -07:00
Ramkumar Chinchani d5779cfec8 ci: move workflow to oci runner (#3426)
* ci: move workflow to oci runner

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: some changes on top

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-03 11:51:12 -07:00
Ramkumar Chinchani 799496b7d3 ci: fix stale check (#3427)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-03 00:32:07 -07:00
Andrei Aaron 14736b8a53 ci: more sync/local driver tests to stabilize/increase coverage (#3425)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-02 09:19:43 -07:00
Ramkumar Chinchani 0aa0d6bb2d fix: broken CodeQL badge (#3424)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-10-02 12:46:32 +03:00
Andrei Aaron 5309e7f5cf chore: increase/stabilize go test coverage (#3411)
* chore: increase/stabilize coverage for the local storage driver

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

* chore: add/stabilize coverage for soring ImageSummary objects

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

* chore: stabilize coverage in sync tests

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>

---------

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-01 15:24:38 -07:00
Ramkumar Chinchani 5e5bd1e33c chore: fix dependabot alerts (#3422)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-09-30 09:56:53 +03:00
Andrei Aaron f49aaa0052 chore: update zui version (#3412)
- upgrade axios to v1.12.2 for cve fixes
- update mui libraries to 6.5.0 for cve fixes
- other updates for fixes
- react-scripts@5.0.1 is outdated and only supports TypeScript 4.9.5, so downgrade to 4.9.5
(note this was alreays done on npm install even in the previous commit)

Shoudl fix https://github.com/project-zot/zot/actions/runs/18036432234/job/51324327982

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-09-29 11:08:28 -07:00
Andrei Aaron e6dee9f1e6 chore: Update to graphql 5.2.0 (#3410)
chore: Update to graphql 5.2.0, previous version was not loading dependencies anymore

https://github.com/graphql/graphiql/tree/graphiql%405.2.0/examples/graphiql-cdn

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-09-29 19:59:05 +03:00
Andrei Aaron 1e9d9b8e60 feat: GC to cleanup untagged manifests by default (#3408)
Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
2025-09-26 22:09:54 -07:00
Ramkumar Chinchani 1fdf1aad9d chore: fix dependabot alerts (#3407)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-09-26 14:27:16 +03:00
Ramkumar Chinchani e49048958d chore: fix dependabot alerts (#3397)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-09-18 11:49:04 -07:00
Ramkumar Chinchani 97ab0e2568 chore: fix dependabot alerts (#3380)
* chore: fix dependabot alerts

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* ci: bump up golang version to 1.24.x

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-09-11 11:11:38 +03:00
Ramkumar Chinchani 9bb73d43b4 chore: fix dependabot alerts (#3365)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-09-07 00:04:16 -07:00
Lukasz Jakimczuk b740a6f037 fix: close the syncResult channel by any goroutine that receives the data (#3348)
fix: race condition in on-demand syncing

Signed-off-by: Łukasz Jakimczuk <ljakimczuk@gmail.com>
v2.1.8
2025-09-01 11:55:48 -07:00
Stephan Merker f0404e7e72 fix: gc for untagged docker manifests (#3349)
- fixes #3347: removeUntaggedManifests() did not consider compatible manifest types
- add AsDockerImage() to Image and MultiarchImage for testing
- extend TestGarbageCollectAndRetentionMetaDB to test docker image and multiarch image

Signed-off-by: Stephan Merker <stephan.merker@sap.com>
2025-09-01 09:20:35 -07:00
Ramkumar Chinchani cb520aa9e4 Fix deps (#3343)
* chore(ci): fix sync images workflow

golang image is sync'ed from dockerhub and it appears certs have expired
that is breaking 'docker trust inspect ...'

* chore: fix dependabot alerts

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-08-28 09:05:59 -07:00
Ramkumar Chinchani f689c13f2e chore: fix dependabot alerts (#3328)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-08-19 01:49:36 -07:00
Ramkumar Chinchani 59679865ff chore: update notation version (#3316)
to v1.3.2

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-08-17 10:25:18 -07:00
Ramkumar Chinchani 69e58b092d chore: fix dependabot alerts (#3312)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-08-16 00:23:35 -07:00
Ramkumar Chinchani e8b530ad9d ci: selectively revert this runner (#3297)
This workflow is failing. We will revisit once the default username
includes the docker group.

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-08-14 12:38:45 -07:00
Koray Oksay deb0e4a71b chore(ci): update github runners to oci gh arc runners (#3293)
ci: update github runners to oci gh arc runners

Signed-off-by: Koray Oksay <koray.oksay@gmail.com>
2025-08-06 21:01:12 -07:00
Ramkumar Chinchani a13c917b73 chore: fix dependabot alerts (#3292)
* chore: fix dependabot alerts

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: update trivy api call

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-08-06 10:09:53 -07:00
Ramkumar Chinchani 41183693b0 feat(freebsd): add support native freebsd container images (#3256)
* feat(freebsd): add support native freebsd container images

Fixes issue #1663

freebsd is now building and releasing official freebsd OCI container
images

https://hub.docker.com/r/freebsd/freebsd-runtime/tags
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: add freebsd support in publish workflow

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: bump stacker version

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: disable non-functional darwin OCI image builds

darwin OCI images are non-functional until we get a usable base image.
Remove them.

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

* fix: set freebsd-static as base image for FreeBSD images

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
v2.1.7
2025-08-03 08:58:30 -07:00
Ramkumar Chinchani 77abd8b101 chore: fix dependabot alerts (#3280)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-07-31 20:27:39 -07:00
Ramkumar Chinchani 642d9ba5cb fix: return the entire blob size in patch upload response (#3279)
https://github.com/regclient/regclient/issues/961
https://github.com/opencontainers/distribution-spec/pull/581

Previously, zot returned the size of the currently uploaded chunk.
Other registries the size of the entire blob.

Align with the latter behavior.

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-07-30 17:32:54 -07:00