1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Commit Graph

42 Commits

Author SHA1 Message Date
Brandon Caton
5c1c21bb1b ci: fixing app type import (PROJQUAY-8991) (#4021)
ci: fixing app type import
2025-06-10 09:14:57 -04:00
Ross Bryan
66fbe49ee2 secscan: implement basescore/cveid (PROJQUAY-6697) (#2684)
* secscan: implement basescore/cveid (PROJQUAY-6697)

Signed-off-by: Ross Bryan <robryan@redhat.com>

* docs: add docstrings to helper functions

Signed-off-by: Ross Bryan <robryan@redhat.com>

* secscan: refactor base_score builder loop

Signed-off-by: Ross Bryan <robryan@redhat.com>

* make cveIDs a unique, alpha sorted list

Signed-off-by: Ross Bryan <robryan@redhat.com>

---------

Signed-off-by: Ross Bryan <robryan@redhat.com>
2024-03-20 13:20:17 +01:00
Harish Govindarajulu
98811f5397 feat: Add auto-prune policy at repository level (PROJQUAY-6354) (#2691)
* feat: Add support for auto pruning at repository level (PROJQUAY-6354)

* Add repositoryautoprunepolicy table to alembic migration script

* Add repository auto-prune policy endpoints

* Add UI for repository auto-pruning policies

* case: apply repo auto-prune policy when no namespace policy given

* case: both namespace and repo pruning policy are given

* Add tests for repository autoprune endpoint

* Add cypress test for repository auto-prune

* Add repo auto-prune policy clean-up for repository deletion

* Add repository auto pruning tables to quay db snapshot for cypress tests

* Address review comments

* Add more tests + fix CI + reformat files

* Address review comments #2

---------

Signed-off-by: harishsurf <hgovinda@redhat.com>
2024-02-27 15:02:57 +05:30
Oleg Bulatov
84fa795ae7 chore: fix isort config and remove isort: skip_file (#2196)
* chore: pass config to isort as it doesn't always detect it

* chore: mark package "test" as local, not stdlib

* chore: remove "isort: skip_file"

* chore: fix app in test_load_security_information

* chore: fix app in test_notification

* chore: fix app in test_index_report
2023-09-21 11:46:03 -04:00
Syed Ahmed
54fcfd14f9 secscan: Cache clair vuln reports (PROJQUAY-6057) (#2245)
uses modelcache to for caching clair security report responses
2023-09-20 20:33:41 +00:00
Kenny Lee Sin Cheong
5f63b3a7bb chore: drop deprecated tables and remove unused code (PROJQUAY-522) (#2089)
* chore: drop deprecated tables and remove unused code

* isort imports

* migration: check for table existence before drop
2023-08-25 12:17:24 -04:00
Kenny Lee Sin Cheong
d47cea46fa database: remove foreign key constraints from deprecated tables (PROJQUAY-4879) (#1348)
* database: remove foreign key constraints from deprecated tables (PROJQUAY-4879)

* database: remove deprecated model tests (PROJQUAY-4879)
2023-06-28 09:37:07 -04:00
Marcus Kok
e622414280 config: Enable notifications for new indexes by default (PROJQUAY-5682) (#1993)
* config: Set feature flag default for new vulnerability notifications to True
(PROJQUAY-4659)

Change the default from `False` to `True` for
`FEATURE_SECURITY_SCANNING_NOTIFY_ON_NEW_INDEX`.

Since this flag addresses a bug, it should be enabled by default.

* add mock return values for unit tests
2023-06-27 16:01:43 +02:00
Kenny Lee Sin Cheong
d48df9b251 chore: deprecate image table support (PROJQUAY-522) (#1841)
Remove code related to deprecated image table
2023-06-14 10:54:54 -04:00
Kenny Lee Sin Cheong
80fdb92462 secscan: add config to limit manifests with layer size too large to index (PROJQUAY-4957) (#1733)
Also removes deprecated Clair v2 configs.
2023-01-31 15:50:16 -05:00
Joseph Crosland
98801bfd3e secscan: Generate key to reduce vulnerabilities (PROJQUAY-4562) (#1547)
Currently Quay is displaying the Clair response with no
interpretation meaning when Clair reports on vulns per repo
they appear to be duplicated (RHEL based images with multiple
repos and packages existing in more than one). The correct way
to fix this is via an interpretation layer in Quay, this change
is a stop-gap to improve readability for the user.

Signed-off-by: crozzy <joseph.crosland@gmail.com>

Signed-off-by: crozzy <joseph.crosland@gmail.com>
2022-10-18 09:54:38 -07:00
Joseph Crosland
5291daf8fe secscan: Don't delete manifest security status on error (PROJQUAY-4060) (#1434)
Currently if Clair returns errors Quay will delete the security
status for that manifest, meaning it will revert to a "Queued"
status and needs to be reindexed. This in-turn means that the
functionality is not immediately recovered when Clair becomes
healthy. It is also generally a bad idea (except in specific
use-cases to have a data modification in a read path).

Signed-off-by: crozzy <joseph.crosland@gmail.com>
2022-07-11 10:59:36 -04:00
Oleg Bulatov
5eaf0584db chore: Run mypy as CI job (#1363)
* Run mypy as CI job

* Fix peewee.pyi and configure pyright
2022-06-13 11:01:17 +02:00
Kenny Lee Sin Cheong
5471d3cbcb secscan: deprecate support for Clair V2 (PROJQUAY-2837) (#951)
Removes read support for Clair V2, along with the need to package
jwtproxy with Quay.

TODO: Drop deprecate image api + image table, remove image data model.
2022-05-31 10:15:54 -04:00
Kenny Lee Sin Cheong
d719dfadc5 secscan: optimize deduplicating manifests for indexing in securityworker (PROJQUAY-3501) (#1247)
Acquire lock on recent manifests batch to prevent multiple workers
from working on the same set.
2022-04-19 11:34:53 -04:00
Kenny Lee Sin Cheong
a52b00263a secscan: fix database manifest allocator for securityworker (PROJQUAY-3501) (#1235)
Have the securityworker send an abort signal in the case where the
conditions for indexing a manifest are not met after running the
candidate query. This could be when:
- a manifest has a reference to a manifestsecuritystatus instance
- the manifestsecuritystatus reindex threshold is no longer
valid (because it was recently updated)

This signals that another worker overlapped, and allows the current
worker to move on to the next set.
2022-04-11 13:06:46 -04:00
Kenny Lee Sin Cheong
dd1eab5238 Revert "secscan: add a global lock on security worker runs (PROJQUAY-3501) (#1226)" (#1232)
This reverts commit 9d89b6fa47.
2022-04-06 11:27:06 -04:00
Kenny Lee Sin Cheong
9d89b6fa47 secscan: add a global lock on security worker runs (PROJQUAY-3501) (#1226)
Add a global lock on security worker iterations, based on the value of
the current pagination token. This is to avoid multilple worker
processes possibly doing work on the same set of manifests.
2022-04-05 13:26:06 -04:00
Joseph Crosland
26eb7ff982 secscan: Don't save secscan result if returned state is unknown (PROJQUAY-2939) (#1047)
Currently it is possible that Clair returns a state that Quay doesn't
know about and the previous logic will save this as a completed
manifest.

Signed-off-by: crozzy <joseph.crosland@gmail.com>
2022-02-11 10:24:11 -06:00
Sunandadadi
162b79ec53 Quay: Fixing reclassified CVE ratings source (PROJQUAY-2691) (#937)
Fixed source of CVE ratings and fixed failing tests
2021-10-20 11:19:41 -04:00
Sunandadadi
20aef6a589 Quay.io UI: Fetching severity from cvss score and removing visibility… (#887)
* Quay.io UI: Fetching severity from cvss score and removing visibility of unknown metrics (PROJQUAY-2541)

If vulnerability's severity is missing mapping severity from cvss score if present. Removed visibility if severity or distribition is Unknow

* Quay.io UI: Fetching severity from cvss score and removing visibility of unknown metrics (PROJQUAY-2541)

Fixing Typo
2021-10-17 20:51:16 -04:00
Kenny Lee Sin Cheong
9f16b3247e secscan: fix secscan api ApiRequestFailure test (PROJQUAY-2563) (#896)
Follow-up to 694fa2ac. Correctly set the expected value for the
pagination token when not blocking on a failed API request.
2021-09-17 17:48:05 -04:00
Sunandadadi
fa0e861849 Secscan: clair v4 enrichment (PROJQUAY-2102) (#840)
Updated descriptions as per CVSS v3.1 vector strings
2021-07-22 16:15:21 -05:00
Arunprasad Rajkumar
d575f39136 PROJQUAY-963: Add package and vulnerability related metadata into secscan response (#515)
* clairv4: Add package and vulnerability metadata into secscan response

* Update field name

* Add missing mapping

* Fix code format

* Piggyback Metadata field to expose updater, repository and distro details

* Fix format

* Use distro and repo details from vulnerability

* Trigger PR check

* fix: Add missing model mapping

* Add response with Metadata field

* Modify response according to new Metadata format
2021-03-19 15:43:50 -04:00
Kurtis Mullins
bd7252c536 [PROJQUAY-1021] task: Update "Black" to version 20.8b1 2020-11-30 18:48:19 -05:00
thomasmckay
e1ecbbd467 PROJQUAY-1292 - do not scan manifest lists (#599) 2020-11-18 12:32:14 -05:00
thomasmckay
bde9d57bf4 PROJQUAY-1079 - do not rescan unsupported manifests (#561) 2020-10-08 14:00:21 -04:00
Alec Merdler
a4390c3785 implement notification system for security scanner v4 (#557) 2020-10-01 12:27:45 -07:00
Joseph Schorr
005b1e44f4 Mark invalid manifests in Secscan V4 (#512)
If we get an invalid manifest when indexing, we now mark the manifest
as invalid for security indexing

Fixes https://issues.redhat.com/browse/PROJQUAY-949
2020-08-10 13:17:44 -04:00
Joseph Schorr
0e628b1569 Deprecate Image rows and move to in-memory synthesized legacy images [Python 3] (#442)
* Change verbs to use a DerivedStorageForManifest table instead of DerivedStorageForImage

This allows us to deprecate the DerivedStorageForImage table.

Fixes https://issues.redhat.com/browse/PROJQUAY-519

* Change uploaded blob tracking to use its own table and deprecate
RepositoryTag

* Start recording the compressed layers size and config media type on the
manifest row in the database

NOTE: This change includes a database migration which will *lock* the
manifest table

* Change tag API to return the layers size from the manifest

* Remove unused code

* Add new config_media_type field to OCI types

* Fix secscan V2 test for us no longer writing temp images

* Remove unused uploading field

* Switch registry model to use synthetic legacy images

Legacy images are now (with exception of the V2 security model) read from the *manifest* and sythensized in memory. The legacy image IDs are generated realtime based on the hashids library. This change also further deprecates a bunch of our Image APIs, reducing them to only returning the image IDs, and emptying out the remaining metadata (to avoid the requirement of us loading the information for the manifest from storage).

This has been tested with our full clients test suite with success.

* Add a backfill worker for manifest layers compressed sizes

* Change image tracks into manifest tracks now that we no longer have
manifest-less tags

* Add back in the missing method

* Add missing joins to reduce extra queries

* Remove unnecessary join when looking up legacy images

* Remove extra hidden filter on tag queries

* Further DB improvements

* Delete all Verbs, as they were deprecated

* Add back missing parameter in manifest data type

* Fix join to return None for the robot if not defined on mirror config

* switch to using secscan_v4_model for all indexing and remove most of secscan_v2_model code

* Add a missing join

* Remove files accidentally re-added due to rebase

* Add back hashids lib

* Rebase fixes

* Fix broken test

* Remove unused GPG signer now that ACI conversion is removed

* Remove duplicated repomirrorworker

* Remove unused notification code for secscan. We'll re-add it once Clair
V4 security notifications are ready to go

* Fix formatting

* Stop writing Image rows when creating manifests

* Stop writing empty layer blobs for manifests

As these blobs are shared, we don't need to write ManifestBlob rows
for them

* Remove further unused code

* Add doc comment to _build_blob_map

* Add unit test for synthetic V1 IDs

* Remove unused import

* Add an invalid value test to synthetic ID decode tests

* Add manifest backfill worker back in

Seems to have been removed at some point

* Add a test for cached active tags

* Rename test_shared to not conflict with another same-named test file

Pytest doesn't like having two test modules with the same name

* Have manifestbackfillworker also copy over the config_media_type if present

Co-authored-by: alecmerdler <alecmerdler@gmail.com>
2020-07-28 13:03:10 -04:00
Kurtis Mullins
38be6d05d0 Python 3 (#153)
* Convert all Python2 to Python3 syntax.

* Removes oauth2lib dependency

* Replace mockredis with fakeredis

* byte/str conversions

* Removes nonexisting __nonzero__ in Python3

* Python3 Dockerfile and related

* [PROJQUAY-98] Replace resumablehashlib with rehash

* PROJQUAY-123 - replace gpgme with python3-gpg

* [PROJQUAY-135] Fix unhashable class error

* Update external dependencies for Python 3

- Move github.com/app-registry/appr to github.com/quay/appr
- github.com/coderanger/supervisor-stdout
- github.com/DevTable/container-cloud-config
- Update to latest mockldap with changes applied from coreos/mockldap
- Update dependencies in requirements.txt and requirements-dev.txt

* Default FLOAT_REPR function to str in json encoder and removes keyword assignment

True, False, and str were not keywords in Python2...

* [PROJQUAY-165] Replace package `bencode` with `bencode.py`

- Bencode is not compatible with Python 3.x and is no longer
  maintained. Bencode.py appears to be a drop-in replacement/fork
  that is compatible with Python 3.

* Make sure monkey.patch is called before anything else (

* Removes anunidecode dependency and replaces it with text_unidecode

* Base64 encode/decode pickle dumps/loads when storing value in DB

Base64 encodes/decodes the serialized values when storing them in the
DB. Also make sure to return a Python3 string instead of a Bytes when
coercing for db, otherwise, Postgres' TEXT field will convert it into
a hex representation when storing the value.

* Implement __hash__ on Digest class

In Python 3, if a class defines __eq__() but not __hash__(), its
instances will not be usable as items in hashable collections (e.g sets).

* Remove basestring check

* Fix expected message in credentials tests

* Fix usage of Cryptography.Fernet for Python3 (#219)

- Specifically, this addresses the issue where Byte<->String
  conversions weren't being applied correctly.

* Fix utils

- tar+stream layer format utils
- filelike util

* Fix storage tests

* Fix endpoint tests

* Fix workers tests

* Fix docker's empty layer bytes

* Fix registry tests

* Appr

* Enable CI for Python 3.6

* Skip buildman tests

Skip buildman tests while it's being rewritten to allow ci to pass.

* Install swig for CI

* Update expected exception type in redis validation test

* Fix gpg signing calls

Fix gpg calls for updated gpg wrapper, and add signing tests.

* Convert / to // for Python3 integer division

* WIP: Update buildman to use asyncio instead of trollius.

This dependency is considered deprecated/abandoned and was only
used as an implementation/backport of asyncio on Python 2.x
This is a work in progress, and is included in the PR just to get the
rest of the tests passing. The builder is actually being rewritten.

* Target Python 3.8

* Removes unused files

- Removes unused files that were added accidentally while rebasing
- Small fixes/cleanup
- TODO tasks comments

* Add TODO to verify rehash backward compat with resumablehashlib

* Revert "[PROJQUAY-135] Fix unhashable class error" and implements __hash__ instead.

This reverts commit 735e38e3c1d072bf50ea864bc7e119a55d3a8976.
Instead, defines __hash__ for encryped fields class, using the parent
field's implementation.

* Remove some unused files ad imports

Co-authored-by: Kenny Lee Sin Cheong <kenny.lee@redhat.com>
Co-authored-by: Tom McKay <thomasmckay@redhat.com>
2020-06-05 16:50:13 -04:00
Alec Merdler
f220bd1d9d create ManifestSecurityStatus with 'last_indexed' in the past to fix tests (#379) 2020-05-08 14:06:06 -07:00
Alec Merdler
6a68e399d7 fix re-indexing for Clair v4 security scanning (#373) 2020-05-08 09:11:27 -07:00
Alec Merdler
11eae32950 fix secscan model to work when only using Clair v2 (#362) 2020-04-30 14:24:08 -07:00
Jimmy Zelinskie
26dcf45802 data.secscan_model: canonicalize before comparing 2020-04-28 18:13:40 -04:00
Kenny Lee Sin Cheong
b703cb4524 Fix wrong reference name in ClairSecurityScannerAPI (#347)
* Fix wrong reference name in ClairSecurityScannerAPI

* Fix min_id referencing the value instead of the tuple reference
2020-04-22 15:27:05 -04:00
Alec Merdler
e003b8e8ed fix security scan column on tags view for Clair v2 (#324) 2020-04-07 14:40:58 -07:00
Alec Merdler
f39779db2c safe lookup of 'Features' property for Clair v2 (#320) 2020-04-06 15:30:05 -07:00
Alec Merdler
531b97c4f9 implement Clair v4 client and set up model splitting (#259) 2020-03-31 11:32:56 -07:00
Alec Merdler
7b827d953c add new 'ManifestSecurityStatus' database model for Clair v4 (#216) 2020-03-17 15:31:15 -07:00
Joseph Schorr
51e35e01cb Add additional tests for the new V2 secscan wrapper
Should help us catch typos in the future
2020-01-31 14:30:35 -05:00
Joseph Schorr
d9d6083ad6 Place all security scanner access behind a new data model interface
This is in preparation for the beginning of support for the new API for ClairCore (V4)

Fixes https://issues.redhat.com/browse/PROJQUAY-177
2020-01-29 13:02:14 -05:00