Commit Graph

478 Commits

Author SHA1 Message Date
Ramkumar Chinchani 0b2eaa0f9a feat(cosign): add support for cosign bundle (#4023)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-05-01 10:21:06 +03:00
Akash Kumar bb5b77aeaa fix(sync): apply tag filters before destination mapping (#4003)
* fix(sync): apply tag filters before destination mapping

Signed-off-by: Akash Kumar <meakash7902@gmail.com>

* fix(sync): return stable pointer from getContentByUpstreamRepo

Iterate by index and return &cm.contents[i] so callers get the slice
element rather than a copy of the loop variable, matching the existing
GetContentByLocalRepo helper.

Signed-off-by: Akash Kumar <meakash7902@gmail.com>

---------

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
2026-04-27 08:27:46 +03:00
Akash Kumar 8905b48bb7 fix(zli): Improve zli CVE diff output (#3994)
* fix(cli): improve zli CVE diff output

Signed-off-by: Akash Kumar <meakash7902@gmail.com>

* test(api): avoid TestRoutes port collision

Signed-off-by: Akash Kumar <meakash7902@gmail.com>

* test(cli): cover CVE diff formatting helpers

Signed-off-by: Akash Kumar <meakash7902@gmail.com>

* test(search): remove redundant test case copy

Signed-off-by: Akash Kumar <meakash7902@gmail.com>

---------

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
2026-04-26 22:25:10 +03:00
Ramkumar Chinchani 934b22d124 fix(security): enhance timeout configurations and body size limits fo… (#3984)
* fix(security): enhance timeout configurations and body size limits for HTTP requests

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

* fix(tests): refactor backend result handling in proxyHTTPRequest test

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

* fix(security): preserve ContentLength in proxied requests to prevent server hang

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

* fix(security): preserve explicit zero-length request bodies in proxyHTTPRequest
fix(tests): add test for normalizedTimeout function to ensure default fallback

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

* fix(security): prevent default HTTP timeout values from being set unless explicitly configured

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

* fix(security): refactor timeout handling to use explicit checks for nil and non-positive values

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

* fix(tests): add wait_for_event_count function to ensure expected event generation

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

* fix(security): improve timeout handling and update error responses for large requests

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

* fix(security): enhance HTTP timeout handling with explicit accessors and default values

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

* fix(security): increase default API key body size and timeout values for improved performance

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

* fix(security): unify timeout handling by replacing specific read/write timeouts with a single default timeout

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

* fix(security): consolidate HTTP timeout accessors and enhance timeout handling

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

* fix(security): simplify HTTP timeout accessors and set default values for read/write timeouts

Co-authored-by: Copilot <copilot@github.com>
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
Co-authored-by: Copilot <copilot@github.com>
2026-04-26 22:23:48 +03:00
Ramkumar Chinchani b47b643e05 fix(security): remove InsecureSkipVerify from metrics client (TLS-1) (#3982)
* fix(security): remove InsecureSkipVerify from metrics client (TLS-1)

Replace the unconditional InsecureSkipVerify: true TLS config in
newHTTPMetricsClient with the system cert pool (+ TLS 1.2 minimum).

Add an optional CACert field to MetricsConfig and to the exporter
ServerConfig so operators running zot with a self-signed or private
CA can point the exporter at the correct CA file instead of
disabling certificate verification entirely.

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

* feat(metrics): add HTTPS configuration for metrics exporter

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

* fix(security): enhance CA certificate handling in metrics client and add tests

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

* fix(security): improve CA certificate error handling in metrics client and update tests

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

* fix(tests): correct package name in minimal_client_test.go and simplify error declaration

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

* fix(tests): update package name in minimal_client_test.go for consistency

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

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-04-19 08:57:24 +03:00
Andrei Aaron 451e7b8e47 feat: Add TrivyConfig.VulnSeveritySources (Trivy's --vuln-severity-source) (#3943)
And default it to ["auto"] when unset, with an info log from applyDefaultValues.

Refactor CVE NewScanner to take *CVEConfig instead of separate DB repository
strings so the full Trivy block is available to the scanner.

Extend CLI and search tests for the new field and logged config; document
CVE/Trivy in examples/README and add examples/config-cve-trivy.json.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-04-08 09:39:26 +03:00
Ramkumar Chinchani 78c6e915dd chore: fix dependabot alerts (#3940)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-04-06 10:03:09 -07:00
Andrei Aaron a5cc8ab810 feat: support pushing multiple tags for a single manifest (#3885)
* feat: support pushing multiple tags for a single manifest

See https://github.com/opencontainers/distribution-spec/pull/600

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

* fix: constants not replaced in swagger output

Also godot mandates comments ending in dots,
which produces bad results in the swagger generated files, see the extra ". which is now fixed below:

```
diff --git a/swagger/docs.go b/swagger/docs.go
index 84b08277..fb2c45c3 100644
--- a/swagger/docs.go
+++ b/swagger/docs.go
@@ -114,7 +114,7 @@ const docTemplate = `{
                         }
                     },
                     "400": {
-                        "description": "bad request\".",
+                        "description": "bad request",
                         "schema": {
                             "type": "string"
                         }
@@ -200,7 +200,7 @@ const docTemplate = `{
                         }
                     },
                     "400": {
-                        "description": "bad request\".",
+                        "description": "bad request",
                         "schema": {
                             "type": "string"
                         }
diff --git a/swagger/swagger.json b/swagger/swagger.json
index cfeb3900..247f95fa 100644
--- a/swagger/swagger.json
+++ b/swagger/swagger.json
@@ -106,7 +106,7 @@
                         }
                     },
                     "400": {
-                        "description": "bad request\".",
+                        "description": "bad request",
                         "schema": {
                             "type": "string"
                         }
@@ -192,7 +192,7 @@
                         }
                     },
                     "400": {
-                        "description": "bad request\".",
+                        "description": "bad request",
                         "schema": {
                             "type": "string"
                         }
diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml
index 57641c2f..09b30dcc 100644
--- a/swagger/swagger.yaml
+++ b/swagger/swagger.yaml
@@ -310,7 +310,7 @@ paths:
           schema:
             type: string
         "400":
-          description: bad request".
+          description: bad request
           schema:
             type: string
         "500":
@@ -366,7 +366,7 @@ paths:
           schema:
             type: string
         "400":
-          description: bad request".
+          description: bad request
           schema:
             type: string
         "500":
```

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

---------

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-03-29 21:13:24 +03:00
John Wagner 8f0bf18d7e fix(search): expose LastPullTimestamp and PushedBy on index ImageSummary (#3865)
ImageIndex2ImageSummary was missing LastPullTimestamp assignment, causing
multi-arch image queries to always return null for this field. Also adds
the PushedBy field (already stored in MetaDB) to the GraphQL schema and
both conversion paths (manifest and index).

Signed-off-by: cainydev <wajo432@gmail.com>
2026-03-10 16:40:54 -07:00
Ramkumar Chinchani 2ba0525f01 chore: fix dependabot alerts (#3860)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-03-10 09:43:08 +02:00
Andrei Aaron 6f67fcdf8f feat(sync): add SyncLegacyCosignTags config to skip syncing legacy cosign/SBOM tags when disabled (#3842)
* feat(sync): add SyncLegacyCosignTags config to skip syncing legacy cosign/SBOM tags when disabled

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

* fix: sync on demand with referrers API should not use recursion to sync referrers of referrers

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

* fix: add tests SyncLegacyCosignTags and changes in /referrers on demand sync

Credit for the tests goes to @jzhn see:
https://github.com/project-zot/zot/pull/3840/changes

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

* fix: remove redundant syncRef logic which synced referrers both with the zot inner() implementation and with regctl native implementation

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

---------

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-03-06 19:12:31 +02:00
Uğur Tafralı 1ff6f609b7 fix: skip OCI conversion when image is already synced #3823
* Fix #3823: skip OCI conversion when image is already synced

When syncRef determines an image is already synced, it now returns a
bool to signal the skip. syncImage checks this and returns early before
attempting OCI conversion, preventing misleading 'failed to convert
docker image to oci' errors caused by a non-existent temp directory.

* Keep syncReferrers and CommitAll running for already-synced images

Address review feedback: new referrers can be added upstream after
initial sync, so we must not skip syncReferrers. Only the OCI
conversion is guarded by the skipped flag, since converting an
already-stored image is both unnecessary and incorrect.

Signed-off-by: Ugur Tafrali <ugur.tafrali@gmail.com>

---------

Signed-off-by: Ugur Tafrali <ugur.tafrali@gmail.com>
2026-02-28 19:37:01 +02:00
Ramkumar Chinchani 01bca48e33 chore: fix dependabot alerts (#3820)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-02-24 08:23:49 +02:00
Andrei Aaron 3454ad63dc chore: update github.com/sigstore/cosign/v3 from 3.0.2 to 3.0.4 (#3789)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-02-10 14:16:50 -08:00
Ramkumar Chinchani 67b8241a7b fix: correct typo var name mirroHostConfig (#3777)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
Co-authored-by: TeCHiScy <741195+TeCHiScy@users.noreply.github.com>
2026-02-05 11:25:09 +02:00
Andrei Aaron 3c8030b2c7 fix(meta): fixes for LastUpdated and TaggedTimestamp (#3754)
1. Parse repos without metadata in ParseStorage

The timestamp check in ParseStorage was skipping repos that exist in
storage but don't have metadata. When GetRepoLastUpdated returns zero
time (no metadata), we should always parse the repo to create its
metadata. Check if metaLastUpdated is zero before comparing timestamps.
If zero, always parse regardless of storageLastUpdated.

2. Change the logic of how LastUpdated is computed in RepoSummary

It is not the latest tagged timestamp from the available images or
the last updated image created timestamp, based on whichever is the
latest.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-02-03 21:10:35 +02:00
Andrei Aaron 3c7d5a5f1d feat: add TaggedTimestamp to ImageSummary returned by graphql API (#3731)
feat(meta): add TaggedTimestamp field and preserve during re-parsing

Add TaggedTimestamp field to track when image tags were created, exposed
through GraphQL API. Previously, when zot restarted and re-parsed storage,
ResetRepoReferences would clear all tags, causing timestamp information to
be lost and reset to the service restart time for existing images.

This change adds TaggedTimestamp support and modifies ResetRepoReferences to
selectively preserve tags that still exist in storage, maintaining their
TaggedTimestamp values. Tags that no longer exist in storage are removed as
before.

Changes:
- Add TaggedTimestamp field to GraphQL ImageSummary schema
- Update GraphQL conversion functions to populate TaggedTimestamp with
  fallback to PushTimestamp when unavailable
- Updated ResetRepoReferences interface to accept tagsToKeep parameter
- Modified ParseRepo to collect tags from storage before resetting
- Updated all backend implementations (Redis, DynamoDB, BoltDB) to preserve
  tags in tagsToKeep instead of clearing all tags
- Updated tests and mocks to match new signature

This ensures TaggedTimestamp accurately reflects when tags were originally
created, and exposes this information through the GraphQL API.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-30 23:05:14 +02:00
Andrei Aaron 14e537a5eb chore: remove direct usage of the github.com/aws/aws-sdk-go package (aws sdk v1) (#3701)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-15 21:43:34 +02:00
Ramkumar Chinchani 0cac8a7ee8 chore: fix dependabot alerts (#3707)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2026-01-15 20:42:39 +02:00
Andrei Aaron 7c9064574d fix: remove usage of deprecated function aws.EndpointResolverWithOptionsFunc (#3700)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-15 09:29:01 -08:00
Asgeir Storesund Nilsen 708adf63d4 fix: CVE-2025-30204 - golang-jwt DoS vulnerability via excessive memory allocation (#3687)
* fix: CVE-2025-30204 - golang-jwt DoS vulnerability via excessive memory
allocation

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

* fix: linting

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

* chore: update project-zot/mockoidc to remove golang-jwt v3

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

* test: Add more tests for bearer tokens

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

* fix: Rewrite tests to remove MakeAuthTestServerLegacy

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>

---------

Signed-off-by: Asgeir Nilsen <asgeir@twingine.no>
2026-01-14 11:34:58 +02:00
Ricardo Noriega ac5fbd9110 Fix typos in documentation (#3678)
docs: Fix typos in documentation

Signed-off-by: Ricardo Noriega De Soto <rnoriega@redhat.com>
2026-01-12 11:00:30 +02:00
Ramkumar Chinchani 800a545fbe chore: fix dependabot alerts (#3677)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-12-29 09:59:57 +02:00
Andrei Aaron 95b8d65c8a test: fix some coverage issues, refactored some of the pagination logic to accomplish this (#3674)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-23 19:06:13 +02:00
Andrei Aaron ed40bfd689 fix: more logging for sync extension (#3656)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-16 00:03:24 +02:00
Andrei Aaron cf8b0bdbf9 refactor: enhance TLS cert generation and refactor HTTP client architecture (#3638)
- Refactored HTTP client from global cache to struct-based approach (global state was shared between tests, including what certificates to use)
- Enhanced pkg/test/tls to support ECDSA and ED25519 key types
- Replaced static certificate files with dynamic generation in golang tests
- Fixed test cleanup issues and improved resource management

This eliminates dependency on external cert generation scripts and
improves test maintainability.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-13 09:47:32 +02:00
Ramkumar Chinchani e7b73b6c2d chore: fix dependabot alerts (#3636)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-12-09 10:49:45 +02:00
Andrei Aaron 4628080fa1 fix: remove misleading error messages on successful syncs (#3619)
See: https://github.com/project-zot/zot/issues/3560#issuecomment-3594856118
What happens is:
- syncRef skips the image ("skipping image because it's already synced")
- syncReferrers doesn't sync anything
- CommitAll is still called even though nothing was synced
- The temp directory exists but is empty (no index.json, no blobs)
- CommitAll fails because index.json is missing

Let's ensure we properly check for errors, and skip the log messages if some of the cases.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-09 08:11:28 +02:00
Andrei Aaron 9dfa7c3ae6 refactor(test): new apis for creating temporary files (#3605)
Replace MakeTempFile usage with MakeTempFilePath and MakeTempFileWithContent
helpers that automatically handle file lifecycle. This prevents resource
leaks by ensuring temporary files are properly closed.

Shoudld also make the tests easier to read.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-05 09:54:38 +02:00
Andrei Aaron edaef52d50 fix(trivy): cleanup Trivy temporary directory (#3618)
This Trivy commit changed the way the cleanup is done for Trivy operations:
https://github.com/aquasecurity/trivy/commit/8f5b56005a4e8752976524750089dc9ea2c91e40

We need to start calling the APIs to create and cleanup the temp dir to ensure we don't leave around content in the /tmp folder

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-03 10:11:32 +02:00
Andrei Aaron cc34a6f4ef fix(meta): handle cases when substores are nested (#3598)
fix(meta): handle cases where repositories when substores are nested

Note this is a case of bad configuration: having multiple stores
in the same tree structure. Guard against it in parse.go.

Fix getAllRepos to prevent duplicate repositories in metaDB when substore
directories are nested under the default store root directory.

The fix processes substores first, then the default store, using a
map-based deduplication approach to skip repositories that have already
been added. This ensures that when both the default store and substores
contain repositories with the same name (e.g., when a substore is nested
within the default store), only one instance is added to the repository
list.

Add test TestNoDuplicateReposWithSubstoresAndNestedRepoNames to verify
the deduplication logic works correctly with nested substores.

Also update the other tests to avoid these issues in the future
this is not a vali configuration.

This is not the intended use case for substores, and it may have caused:
https://github.com/project-zot/zot/actions/runs/19665302669/job/56320640980

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-27 20:11:52 +02:00
Andrei Aaron a296968c1a fix: multiple fixes based on recent test failures (#3582)
* fix(monitoring): fix race condition in TestPopulateStorageMetrics

Write images to filesystem before starting controller to prevent GC
from reading index.json while it's being written.

See failure:
https://github.com/project-zot/zot/actions/runs/19633819097/job/56219606041

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

* fix(sync): fix TestSignatures assertion on referrers order

Search through all referrers to find the expected OCI ref digest instead
of assuming it's at index.Manifests[1], as the order is not guaranteed.

See https://github.com/project-zot/zot/actions/runs/19630382617/job/56208492397?pr=3579

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

* fix(redis): fix error handling in GetMultipleRepoMeta

The function was returning err at the end, which could be nil even when
HGetAll should have failed, because err gets reassigned in the loop.
Changed to return nil on success path, ensuring HGetAll errors are
properly propagated. Fixes TestRedisUnreachable failure.

See https://github.com/project-zot/zot/actions/runs/19634990856/job/56223414955?pr=3582

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

* refactor(sync): simplify sync test structure and restore file permissions

Remove unnecessary nested Convey blocks and integrate error tests into
parent blocks. Add defer statements to restore file permissions after
chmod operations to prevent side effects on subsequent tests.

Fix potential root cause of https://github.com/project-zot/zot/actions/runs/19636284485/job/56227682319?pr=3579

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

---------

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-24 19:23:52 +02:00
mottetm 6f0e05e676 fix: sync should be disabled when enable is false (#3579)
Signed-off-by: Matthieu Mottet <m.mottet@outlook.com>
2025-11-24 16:51:56 +02:00
Andrei Aaron 3b931a3a7a fix: handle zero time values in LastUpdated sorting functions (#3580)
When GetRepoLastUpdated fails (e.g., redis: nil), it returns time.Time{}
which gets converted to &time.Time{} (not nil). The existing nil checks
in sorting functions didn't account for zero time values, which should
also be treated as "oldest" (sorted last in descending order).

This commit:
- Adds zero time checks in addition to existing nil checks
- Treats both nil and zero time values as "oldest"
- Adds comprehensive tests for zero time edge cases

Affects ImgSortByUpdateTime, RepoSortByUpdateTime, and GetExpandedRepoInfo
sort functions.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-24 11:02:33 +02:00
Andrei Aaron e072aa09e2 refactor: optimize code with modern Go patterns and pre-allocation (#3576)
This commit modernizes code across multiple packages by:
- Using Go 1.18+ features (slices.IndexFunc, strings.Cut)
- Pre-allocating slices and maps with known capacity
- Consolidating defensive checks and improving code clarity
- Fixing test data and build tag issues

CLI client improvements:
- Pre-allocate slices in search functions and service methods
- Replace strings.Split with strings.Cut for username:password parsing
- Use range-based iteration instead of manual index loops

Search extension optimizations:
- Cache sort functions in pagination modules
- Pre-allocate page buffers and maps
- Consolidate defensive checks in filterBaseImages/filterDerivedImages
- Fix image bas and derived logic allowing out of sequence layers for base images
- Fix image pagination reporting images groupped by repos when sorted by update time
- Remove duplicate resolver_test.go file

Monitoring extension:
- Replace manual loops with slices.IndexFunc
- Pre-allocate bucketsFloat2String map

Sync extension:
- Pre-allocate slice in parseRegistryURLs

Test utilities:
- Fix build tags in oci_layout.go

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-24 09:42:45 +02:00
Andrei Aaron da426850e7 chore: update golangci-lint and fix all issues (#3575)
* chore: Update golangci-lint

Signed-off-by: Lars Francke <git@lars-francke.de>

* chore: fix all golangci-lint issues

- Remove deprecated `// +build` tags
- Fix godoclint, modernize, wsl_v5, govet, lll, gci, noctx issues
- Update linter configuration
- Modernize code to use Go 1.22+ features (for range N, slices.Contains, etc.)
- Update make check lint the privileged tests

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

---------

Signed-off-by: Lars Francke <git@lars-francke.de>
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Co-authored-by: Lars Francke <git@lars-francke.de>
2025-11-22 23:36:48 +02:00
Andrei Aaron 566286ae42 fix: Add HTTP client timeouts to prevent indefinite hangs in sync operations (#3574) 2025-11-22 07:57:24 +02:00
Andrei Aaron 69dd648d20 fix(sync): properly handle CommitAll errors in syncImage and skip failed temp sync dirs (#3567)
- Return CommitAll errors instead of ignoring them
- Skip ErrRepoNotFound from temp sync dirs to allow other tags to sync
- Each tag uses separate temp directory, so failures are isolated

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-20 09:21:48 -08:00
Lars Francke 7fa53f5b0f Sync images with a background context (#3537)
feat: Sync images with a background context

This means syncs/pulls will not be cancelled anymore when the requesting client disconnects.

The timeout used can be configured per registry

Signed-off-by: Lars Francke <git@lars-francke.de>
2025-11-20 08:52:27 -08:00
Andrei Aaron 2b60e11ce4 chore: update cosign from v2 to v3 (#3561)
* chore: update cosign from v2 to v3

Also do not import cosing into zli, as it doubles the bianry size
See: https://github.com/project-zot/zot/actions/runs/19506399474/job/55833719683?pr=3561

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

* chore: privileged-test should not depend on downloaded images

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

---------

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-20 00:43:57 +02:00
Andrei Aaron b7ab9dab16 fix (metadb): make sure metadb statistics are initialized on image download, and minor metadb fixes for Docker v2 manifest compatibility (#3545)
fix: make sure metadb statistics are initialized on image download, and minor metadb fixes for Docker v2 manifest compatibility

Looking into potential causes of https://github.com/project-zot/zot/issues/3163

1. One possible reason is the statistics were not properly initialized in the first place because of (unknown and/or unavoidable) errors on image push.
To workaround this add logic to initialize the statistics on the call to download them.

2. Some images have the download statistics while others dont, one cause could be a bug in the logic handling manifest mediatypes in the search extension.
Add compatibility checks for Docker v2 manifest types in metadb convert functions, and more tests for covering the Docker mediatype use case.

Side fixes:
- Ensure PushedBy Statistics entries are properly initialized in SetRepoReference
- Fix and issue in the image upload test functions, they were uploading docker images with oci mediatypes in call headers

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-18 20:56:44 +02:00
Ramkumar Chinchani 49c15abf06 chore: fix dependabot alerts (#3555)
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-11-18 08:46:51 +02:00
Andrei Aaron c5f37546f5 fix: show relevant error messages in case of images which cannot be scanned by Trivy (#3554)
Old message example:
```
{"time":"2025-11-17T22:29:29.434073547Z","level":"debug","message":"image is not scannable","digest":"sha256:99155f2825186175c7f7e4df4f77d5d0ba68a018603afd9c014063d4ca11c0d6","mediaType":"application/vnd.oci.image.manifest.v1+json","error":"image 'nginx@sha256:99155f2825186175c7f7e4df4f77d5d0ba68a018603afd9c014063d4ca11c0d6' scanning is not supported for given image media type","caller":"zotregistry.dev/zot/v2/pkg/extensions/search/cve/cve.go:513","func":"zotregistry.dev/zot/v2/pkg/extensions/search/cve.BaseCveInfo.GetCVESummaryForImageMedia","goroutine":1246}
```

New message example:
```
{"time":"2025-11-17T22:25:10.33273421Z","level":"debug","message":"image is not scannable","digest":"sha256:99155f2825186175c7f7e4df4f77d5d0ba68a018603afd9c014063d4ca11c0d6","mediaType":"application/vnd.oci.image.manifest.v1+json","error":"image 'nginx@sha256:99155f2825186175c7f7e4df4f77d5d0ba68a018603afd9c014063d4ca11c0d6' scanning is not supported for given media type: layer media type 'application/octet-stream'","caller":"zotregistry.dev/zot/v2/pkg/extensions/search/cve/cve.go:513","func":"zotregistry.dev/zot/v2/pkg/extensions/search/cve.BaseCveInfo.GetCVESummaryForImageMedia","goroutine":1316}
```

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-17 20:35:57 -08:00
Ramkumar Chinchani 1d0eadc013 fix: img-src annotation changes with zui move to vite (#3539)
https://github.com/project-zot/zui/pull/484

zui is moving to vite framework but there are some changes in the
img-src annotations which must be allowed/accounted for in zot backend.

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-11-16 01:16:22 +02:00
Andrei Aaron 008527b7bb fix: gracefully handle manifests missing from storage (prepare for sparse indexes) (#3503)
GC and scrub should not stop if a manifest or index is missing from storage.
Other similar changes are also included.

WRT metadb, the missing manifests cannot be added, and the results returned from metadb
do not include the descriptors for these manifests.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-13 09:26:18 -08:00
Ramkumar Chinchani 04ae0a9409 fix: add support for sha256 and sha512 in htpasswd (#3497)
feat: add support for sha256 and sha512 htpasswd formats

Fixes issue #3495

We currently support only bcrypt htpasswd hashes, however bcrypt is not
FIPS-140 approved since it uses Blowfish.

This PR adds support for sha256 and sha512 formats and enforces that
bcrypt be disabled when fips140 mode is enabled.

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-11-09 15:28:29 +02:00
Lukasz Jakimczuk aaba362b4f fix: re-introduce pagination (#3521)
* fix: re-introduce pagination

Signed-off-by: Łukasz Jakimczuk <ljakimczuk@gmail.com>

* fix: use assignment

Signed-off-by: Łukasz Jakimczuk <ljakimczuk@gmail.com>

---------

Signed-off-by: Łukasz Jakimczuk <ljakimczuk@gmail.com>
2025-11-07 08:59:06 -08:00
Andrei Aaron 79ddc32b7c chore: fix monitoring goroutine leak in tests (#3500)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-10-31 13:55:43 +02: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
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