Commit Graph

815 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] a1d3dcf345 Improve pathRel to handle edge cases correctly
- Handle case where basepath equals targpath by returning "."
- Ensure basepath is treated as directory with trailing slash to avoid false prefix matches
- Fix linter issue by using += operator

Addresses code review feedback.

Co-authored-by: rchincha <45800463+rchincha@users.noreply.github.com>
2026-01-15 19:51:57 +00:00
copilot-swe-agent[bot] d464313d60 Fix Windows path handling for S3 storage driver
Add pathRel helper method to ImageStore that handles path operations correctly for both local and non-local storage drivers. For S3 and other non-local drivers, use forward slashes consistently to avoid Windows path separator issues where filepath.Rel fails when paths use forward slashes but Windows expects backslashes.

This fixes the memory exhaustion and high CPU usage issue on Windows when using S3 storage, which was caused by infinite loops in GetRepositories and related methods.

Co-authored-by: rchincha <45800463+rchincha@users.noreply.github.com>
2026-01-15 19:46:34 +00: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 d33c1e3b22 fix: now attempt to bind to the zot server socket to check if the server is running (#3703)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-15 20:02:15 +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
Andrei Aaron e2ba7c8e20 fix: pre-existing dynamodb versions table should be populated with version if it doesn't contain it already (#3699)
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2026-01-13 13:11:40 +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 4ad3fad3bc fix: do not reject requests having an Authorization header if basic auth is disabled (#3673)
See https://github.com/project-zot/zot/issues/3662

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-23 11:30:22 +02:00
Andrei Aaron f39c5e058e fix: make sure the function and caller information are added to log messages emitted by 3rd party libraries using slog directly. (#3659) 2025-12-19 07:32:13 +02:00
Andrei Aaron 79439bbf63 feat: add configurable mTLS identity extraction with fallback chain (#3640)
Add support for configurable identity attributes in mTLS authentication,
allowing identity extraction from CommonName, Subject DN, Email SAN,
URI SAN, or DNSName SAN with fallback chain support. Includes regex
pattern matching for URI SANs (e.g., SPIFFE workload IDs).

- Add MTLSConfig with identity attributes, URISANPattern, and index fields
- Implement extractMTLSIdentity with fallback chain logic
- Move the mtls tests in the api package to pkg/api/mtls_test.go

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-18 09:10:47 -08:00
Gianluca Boiano f2064c9af0 fix: prevent nil pointer dereference in RemoveImageFromRepoMeta (#3658)
* fix: prevent nil pointer dereference in RemoveImageFromRepoMeta

This commit fixes a critical bug where RemoveImageFromRepoMeta crashes with
a nil pointer dereference during retention policy execution and GC operations.

Root Cause:
The function was accessing blob metadata without checking if it exists first.
During GC/retention operations, the metadata database might have stale
references to blobs that no longer exist, causing runtime panics.

Changes:
- Added nil check for descriptorBlobInfo before accessing LastUpdated field
- Added nil check for blobInfo before dereferencing Size, Vendors, Platforms, and SubBlobs
- Made the function consistent with recalculateAggregateFields which already had these checks

Impact:
- Fixes crashes during retention policy execution
- Fixes crashes during GC manifest removal
- Fixes image deletion failures via API
- Eliminates need for dryRun: true workaround in retention config

The fix gracefully handles missing blob metadata by skipping those entries
instead of crashing.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* test: add comprehensive tests for RemoveImageFromRepoMeta nil checks

Add test coverage for the nil pointer dereference fixes in RemoveImageFromRepoMeta.
These tests ensure the function handles missing blob metadata gracefully during
GC and retention operations.

Test cases:
- Handle nil blob info for descriptor digest (line 280 check)
- Handle nil blob info in queue traversal (line 297 check)
- Verify correct behavior with valid blob info
- Handle empty tags edge case
- Skip tags with empty digest

Coverage: RemoveImageFromRepoMeta now has 100% test coverage

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* test: fix RemoveImageFromRepoMeta tests to match actual usage

Address review feedback:
- Delete tag from repoMeta.Tags before calling RemoveImageFromRepoMeta
- Fix blob count expectations after tag removal
- Add assertion to verify tag was removed from metadata
- Update comments to clarify expected behavior

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* test: add tag removal assertion to second test case

Add missing assertion to verify tag1 was removed from resultMeta.Tags
in the 'should handle nil blob info in queue traversal' test.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* refactor: improve nil blob handling documentation and test coverage

Address Copilot review feedback:
- Expand comment at line 278 to explain implications of skipping tags
  with missing blob info, clarifying that metadata inconsistency is
  acceptable in GC/cleanup scenarios
- Revise 'should handle nil blob info for descriptor digest' test to
  cover more realistic scenario: remove tag1 while tag2 has missing
  blob info, demonstrating graceful handling of data inconsistencies
  in remaining tags during removal operations

All tests pass with 49 total assertions.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* fix: prevent nil pointer in GetCandidates when statistics missing

Add defensive check in pkg/retention/candidate.go to handle cases where
a tag exists in repoMeta.Tags but has no corresponding entry in
repoMeta.Statistics. This prevents incorrect retention decisions based
on zero-value timestamps.

Changes:
- Check statistics existence before creating candidates
- Skip tags with missing statistics (retained by GetRetainedTagsFromMetaDB)
- Improve performance from O(n*m) to O(n) by using direct map lookup
- Add comprehensive test coverage for missing statistics scenarios

This addresses the concern raised in PR #3658 about metadata
inconsistencies due to non-transactional writes to blob store and metaDB.

Related: #3658
Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

* test: achieve 100% coverage for RemoveImageFromRepoMeta nil checks

Enhance test coverage for RemoveImageFromRepoMeta to address codecov failures
by adding comprehensive test cases that exercise all code paths including nil
pointer checks and continue statements.

Changes:
- Enhanced 'nil blob info for descriptor digest' test to verify processing
  continues with other valid tags after skipping nil entries
- Enhanced 'nil blob info in queue traversal' test to handle mixed valid/nil
  sub-blobs and verify correct processing continuation
- Added 'multiple nil blobs in deeply nested structure' test to cover complex
  scenarios with multiple missing blobs at various nesting levels
- Enhanced 'skip tags with empty digest' test to verify processing continues
  with valid tags after skipping empty digest entries
- Added 'combined edge cases' test to verify all edge cases work together:
  empty digest, nil descriptor blob, and nil queue blob

Coverage Results:
- RemoveImageFromRepoMeta: 100.0% line coverage (was 87.50%)
- All 7 test scenarios pass with 75 total assertions
- All nil check code paths fully exercised
- All continue statement behaviors validated

Fixes codecov/patch failure on PR #3658 where 2 lines were missing coverage.

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>

---------

Signed-off-by: Gianluca Boiano <morf3089@gmail.com>
2025-12-17 11:44:51 +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
Andrei Aaron 1447bb24b4 fix: accept log levels supported by older zot versions, validate configured log level (#3639)
In zot config accept the same log levels as in https://github.com/rs/zerolog/blob/5391dd7c34c86c2a3b731cd3c3f1b252706e7925/globals.go#L37
This is to maintain backward compatibility with other zot version configurations.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-12-13 00:33:54 +02:00
Andrei Aaron 08fae9104d feat: support mTLS-only authn/authz with AccessControl and allow combining mTLS with other auth mechanisms (#3624)
* feat: support mTLS-only authn/authz with AccessControl and allow combining mTLS with other auth mechanisms

Signed-off-by: Ivan Arkhipov <me@endevir.ru>

* refactor: improve authentication logic and TLS certificate generation

- Fix mTLS authentication to use only leaf certificate instead of iterating
  through all certificates in the chain
- Reject Authorization headers when corresponding auth method is disabled,
  regardless of mTLS status (security improvement)
- Simplify authentication switch statement ordering and logic
- Move ErrUserDataNotFound error handling into sessionAuthn method
- Refactor TLS certificate generation to use Options pattern with
  CertificateOptions struct for better extensibility
- Consolidate duplicate certificate generation code into helper functions
  (generateCertificate, parseCA, initializeTemplate, applyOptions)
- Rename certificate generation functions for clarity:
  - GenerateCertWithCN -> GenerateClientCert
  - GenerateSelfSignedCertWithCN -> GenerateClientSelfSignedCert
- Add support for SAN settings including email addresses in certificates
- Update tests to reflect new authentication behavior and certificate API

This commit improves both the security posture (rejecting disabled auth
methods) and code maintainability (consolidated certificate generation).

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

* fix: guard against multiple Authorization headers

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

---------

Signed-off-by: Ivan Arkhipov <me@endevir.ru>
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Co-authored-by: Ivan Arkhipov <me@endevir.ru>
2025-12-11 20:08: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 8226b25509 feat(config): validate storage root directories for path conflicts (#3602)
Add validation to reject configuration files where stores and substores
of the same storage type (local or S3) have root directories that are
nested within each other or identical. Stores of different types (local
vs S3) are allowed to share the same root directory since they use
different storage backends.

The validation:
- Checks all stores (default + substores) for path conflicts
- Only compares stores of the same storage type
- Reports clear error messages indicating which stores conflict and why

Add comprehensive tests covering:
- Same storage types with identical/nested paths (rejected)
- Different storage types with same/nested paths (allowed)
- Various combinations of default store and substores

Fixes issues where nested or identical root directories could cause
data corruption or routing conflicts.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-29 23:55:27 +02:00
Andrei Aaron e510ab6426 Fix error handling: return nil explicitly on successful completion (#3603)
fix: error handling: return nil explicitly on successful completion

Several functions in pkg/meta/redis/redis.go were returning 'err' at the
end of successful execution paths, which could lead to incorrect error
handling when 'err' was overwritten in loops or conditionals.

Changed the following functions to return nil explicitly when all
operations succeed:
- SearchRepos: return nil instead of err after successful loop
- SearchTags: return nil instead of err after successful loop
- GetRepoMeta: return nil instead of err after successful operations
- GetImageMeta: return nil instead of err after successful operations
- GetReferrersInfo: return nil instead of err after successful loop

This ensures that when functions complete successfully, they explicitly
return nil rather than relying on the last value of err, which may have
been overwritten during execution. This fixes TestRedisUnreachable which
was failing because SearchRepos was incorrectly returning nil error when
Redis was unreachable.

See failure in: https://github.com/project-zot/zot/actions/runs/19729927463/job/56528529923?pr=3599

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-28 11:49:17 +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 69c3a0b99b feat: explicitly log if each authentication method is enabled (#3599)
feat: explicitly log if each autentication methods is enabled

When the server starts or when the config is reloaded.
See the discussion in: https://github.com/project-zot/zot/pull/3577#issuecomment-3568505810

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-27 11:30:14 +02:00
Andrei Aaron e068b8dc9f chore: Enable Go jsonv2 experiment and update the trivy dependency (v0.67.2) (#3572)
It requires the encoding/json/jsontext
package which is only available when the goexperiment.jsonv2 build
tag is enabled. This was causing build constraint errors during
tests and builds.

Changes:
- Add GOEXPERIMENT=jsonv2 to Makefile export and all go build/test
  commands that use env (since env creates a fresh environment)
- Add GOEXPERIMENT=jsonv2 to GitHub workflows that use direct go
  commands (workflows using make inherit it from Makefile)

Fix other dependabot alerts.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-27 09:58:37 +02:00
Ramkumar Chinchani 6452bec403 chore: fix dependabot alerts (#3595)
* chore: fix dependabot alerts

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

* ci: bump up golang to 1.25.x

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

* fix: linter errors

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

* fix: stacker and docker build files to use golang 1.25

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

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
2025-11-26 11:21:36 +02:00
Andrei Aaron 09de471774 fix(storage): enforce standard OCI blob path structure in GetNextDigestWithBlobPaths (#3594)
Require blob files to follow standard OCI image layout:
rootDir/repo/blobs/algorithm/digest

- Validate grandparent directory is ImageBlobsDir
- Validate parent directory is valid digest algorithm
- Update tests to use standard OCI structure
- Add blobPath() helper to reduce duplication and fix linting

This should reduce the number of uneeded digest computations
if other non-oci specific files are present in the layout.

Fix also a race condition when picking ports in monitoring tests.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-25 11:50:48 +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
Ramkumar Chinchani 64829f9502 feat: allow claim mapping for user name with oidc (#3540)
* feat: allow claim mapping for user name with oidc

* feat: bats test for claim mapping

* test: fix dex config in openid mapping test

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

* test: add panva idp

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

* fix: address copilot comments

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

---------

Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
Co-authored-by: Sky Moore <i@msky.me>
2025-11-20 08:54:56 -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
Andrei Aaron a8a6d3be9e fix: separate cipher suites and curve preferences into FIPS and non FIPS, and use them accordingly (#3523)
See: https://github.com/project-zot/zot/actions/runs/19209741002/job/54910194536

`failed to ping registry localhost:11448: Get "https://localhost:11448/v2/": crypto/ecdh: use of X25519 is not allowed in FIPS 140-only mode`

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-10 23:24:59 +02:00
Andrei Aaron b64add7715 fix: deduplicate entries in referrers responses (#3524)
See: https://github.com/project-zot/zot/issues/2506

Note we are not loosing anything functionality-wise by making this change.
Initially we considered the tags are in the annotations present in the referrers
but the only annotations we set on referrers are the ones inside the manifests themselves,
not the ones in the manifest descriptors, so the tags were not presetn anyway.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
2025-11-10 21:08:47 +02: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
Mathias Bogaert 3fd69faf5d fix: support custom OAuth2 URLs for GitHub Enterprise and self-hosted providers (#3513)
- Use custom authURL/tokenURL from config instead of hardcoded github.com endpoints
- Properly configure GitHub Enterprise API base URL from auth endpoints

Fixes OAuth2 authentication with GitHub Enterprise Server and other
self-hosted OAuth2 providers.

Signed-off-by: Mathias Bogaert <mathias.bogaert@gmail.com>
2025-11-04 14:11:05 +02:00
Ravi Chamarthy fdba14b9a3 fix(log): ensure func record is correct (#3501)
The "func" field in log output is incorrect in some cases and
showing internal logging methods instead of the actual calling
function. This is happening because the caller information is
being captured statically (5 call frames) which can be different
for different call patterns.

Changes:

* Move the caller capture to the event creation
* Use deterministic skip (3 frames) for event creation
* Add test cases to verify that the caller is captured correctly

Note: tests needed to written outside convey to avoid call insertion

Signed-off-by: Ravi Chamarthy <ravi@chamarthy.dev>
2025-10-31 17:01:35 -07:00