0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-01-06 22:40:28 -05:00
zot/pkg/extensions
Andreea Lupu 92e382ce39
refactor(scrub): replace umoci logic in scrub implementation (#1845)
- implement scrub also for S3 storage by replacing umoci
- change scrub implementation for ImageIndex
- take the `Subject` into consideration when running scrub
- remove test code relying on the umoci library. Since we started
relying on images in test/data, and we create our own images using
go code we can obtain digests by other means. (cherry picked from commit 489d4e2d23c1b4e48799283f8281024bbef6123f)

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
Signed-off-by: Andreea-Lupu <andreealupu1470@yahoo.com>
2023-09-26 11:02:11 -07:00
..
config refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
imagetrust refactor(test): move image utils for tests in a separate module (#1789) 2023-09-15 09:53:15 -07:00
lint fix(gc): sync repodb when gc'ing manifests (#1819) 2023-09-22 11:51:20 -07:00
monitoring refactor(test): move image utils for tests in a separate module (#1789) 2023-09-15 09:53:15 -07:00
scrub refactor(scrub): replace umoci logic in scrub implementation (#1845) 2023-09-26 11:02:11 -07:00
search refactor(scrub): replace umoci logic in scrub implementation (#1845) 2023-09-26 11:02:11 -07:00
sync fix(gc): sync repodb when gc'ing manifests (#1819) 2023-09-22 11:51:20 -07:00
_zot.md refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extension_image_trust.go feat: upload cosign public key and notation certificates to cloud (#1744) 2023-09-08 10:03:58 +03:00
extension_image_trust_disabled.go feat: upload cosign public key and notation certificates to cloud (#1744) 2023-09-08 10:03:58 +03:00
extension_image_trust_disabled_test.go refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extension_image_trust_test.go fix(gc): sync repodb when gc'ing manifests (#1819) 2023-09-22 11:51:20 -07:00
extension_metrics.go refactor: Review metrics endpoints (#1770) 2023-09-15 14:49:34 +03:00
extension_metrics_disabled.go refactor: Review metrics endpoints (#1770) 2023-09-15 14:49:34 +03:00
extension_mgmt.go feat(authn): add generic oidc and allow customizable name (#1691) 2023-08-24 12:33:35 +03:00
extension_mgmt_disabled.go refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extension_scrub.go refactor(scrub): replace umoci logic in scrub implementation (#1845) 2023-09-26 11:02:11 -07:00
extension_scrub_disabled.go initial design for task scheduler (#700) 2022-09-22 22:27:56 -07:00
extension_search.go feat(cve): implement CVE scanning as background tasks (#1833) 2023-09-22 11:49:17 -07:00
extension_search_disabled.go feat(cve): implement CVE scanning as background tasks (#1833) 2023-09-22 11:49:17 -07:00
extension_sync.go feat(refator): refactoring repodb into meta (#1626) 2023-07-18 10:27:26 -07:00
extension_sync_disabled.go feat(refator): refactoring repodb into meta (#1626) 2023-07-18 10:27:26 -07:00
extension_ui.go refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extension_ui_disabled.go refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extension_ui_test.go refactor(test): move image utils for tests in a separate module (#1789) 2023-09-15 09:53:15 -07:00
extension_userprefs.go refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extension_userprefs_disable.go refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extension_userprefs_test.go refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
extensions_lint.go image level lint: enforce manifest mandatory annotations 2022-07-27 11:48:04 +03:00
extensions_lint_disabled.go feat: propagate detailed error msgs to client (OCI dist-spec format) (#1681) 2023-08-23 20:59:52 +03:00
extensions_test.go feat(authn): add generic oidc and allow customizable name (#1691) 2023-08-24 12:33:35 +03:00
get_extensions.go feat: upload cosign public key and notation certificates to cloud (#1744) 2023-09-08 10:03:58 +03:00
get_extensions_disabled_test.go test(refactor): refactor tests that use zot-test to use smaller images (#1690) 2023-08-18 11:46:11 +03:00
README.md refactor: split AuthZ mdw in 2 different parts, each for a specific purpose (#1542) 2023-07-05 09:37:52 -07:00
README_imagetrust.md feat: upload cosign public key and notation certificates to cloud (#1744) 2023-09-08 10:03:58 +03:00
README_mgmt.md refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00
README_userprefs.md refactor(extensions)!: refactor the extensions URLs and errors (#1636) 2023-08-02 21:58:34 +03:00

Adding new extensions

As new requirements come and build time extensions need to be added, there are a few things that you have to make sure are present before commiting :

  • files that should be included in the binary only with a specific extension must contain the following syntax at the beginning of the file :

//go:build sync will be added automatically by the linter, so only the second line is mandatory .

NOTE: the third line in the example should be blank, otherwise the build tag would be just another comment.

//go:build sync
// +build sync

package extensions
...................
  • when adding a new tag, specify the new order in which multiple tags should be used (bottom of this page)

  • for each and every new file that contains functions (functionalities) specific to an extension, one should create a corresponding file that must contain the exact same functions, but no functionalities included. This file must begin with an "anti-tag" (e.g. // +build !sync) which will include this file in binaries that don't include this extension ( in this example, the file won't be used in binaries that include sync extension ). See extension-sync-disabled.go for an example.

  • each extension is responsible with implementing authorization for newly added HTTP endpoints. zot will provide the necessary data, including user permissions, to the extension, but actual enforcement of these permissions is the responsibility of each extension. Each extension http.Handler has access to a context previously populated by BaseAuthzHandler with relevant user info. That info has the following structure:

    type AccessControlContext struct {
      // read method action
      ReadGlobPatterns map[string]bool
      // detectManifestCollision behaviour action
      DmcGlobPatterns map[string]bool
      IsAdmin         bool
      Username        string
      Groups          []string
      } 
    

    This data can then be accessed from the request context so that every extension can apply its own authorization logic, if needed .

  • when a new extension comes out, the developer should also write some blackbox tests, where a binary that contains the new extension should be tested in a real usage scenario. See test/blackbox folder for multiple extensions examples.

  • newly added blackbox tests should have targets in Makefile. You should also add them as Github Workflows, in .github/workflows/ecosystem-tools.yaml

  • with every new extension, you should modify the EXTENSIONS variable in Makefile by adding the new extension. The EXTENSIONS variable represents all extensions and is used in Make targets that require them all (e.g make test).

  • the available extensions that can be used at the moment are: sync, scrub, metrics, search . NOTE: When multiple extensions are used, they should be listed in the above presented order.