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

78 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
Syed Ahmed
723102e641 build: move quay to python 3.12 (PROJQUAY-8800) (#3780)
Move Quay to python version 3.12 and switch out rehash with the resumable hash library.
2025-05-29 09:35:48 -04:00
Sunandadadi
0ad0da6f04 secscan: Move secscan worker queries to read-only replica (PROJQUAY-7682) (#3151)
* secscan: Move secscan worker queries to read-only replica (PROJQUAY-7682)

* fix formatting
2024-08-20 12:10:37 -04:00
Ivan Bazulic
6392ca972a secscan: Fix Slack notification creation on initial index (PROJQUAY-7037) (#2923)
* secscan: Fix Slack notification creation on initial index (PROJQUAY-7037)
This fixes the Slack and e-mail notifications when images are indexed on initial push, where `tags` information was missing. If an image is a manifest child, instead of the tag, we provide a full SHA digest to the client.
Also adds the ability to filter security vulnerabilites depending on their severity. If the `NOTIFICATION_MIN_SEVERITY_ON_NEW_INDEX` is not set in the `config.yaml` file, we will automatically create notifications only for vulnerabilities marked "high" or "critical". This variable can take values defined here:

3248a72da6/util/secscan/__init__.py (L1)

Example:

```
NOTIFICATION_MIN_SEVERITY_ON_NEW_INDEX: Medium
```

* Removed superfulous debug statements

* Add default to config.yaml, remove extra comment

* Fix isort sorting

* Update vulnerability_found.html

* Update vulnerability_found.html

* Isort formatting fix

* Update vulnerability_found.html
2024-06-12 09:51:11 -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
Joseph Crosland
93086fa588 secscan: update error from secscan delete (PROJQUAY-0000) (#2077)
Currently the error message doesn't align with the operation.

Signed-off-by: crozzy <joseph.crosland@gmail.com>
2023-08-09 13:18:58 +02:00
Hank Donnay
50224e2dd1 secscan_model: attempt urldecoding fixed_in_version (PROJQUAY-5886) (#2060)
In Clair 4.7, an API field documented to have version information in no
particular format may URL encode it. This change attempts to decode and
read a known field that contains the "fixed" version. If that fails, the
value will be passed through, as it is now.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
2023-07-26 10:03:35 -05:00
Kenny Lee Sin Cheong
0ea4826956 secscan: garbage collect manifests (#1663)
Garbage collect manifests no longer referenced in Quay from the
security scanner service.

Also moved quota related code from data/registry_model/ to data/model/
to avoid circular dependencies.
2023-07-06 11:59:47 -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
Oleg Bulatov
ea49bb53a3 chore: Bump mypy (#1962) 2023-06-28 13:47:32 +02: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
Marcus Kok
ff68f86c90 data: Fix error getting tag while calculating scan results SLO (#1952)
(PROJQUAY-5600)

Catch exception thrown when looking up tag `lifetime_start_ms` and set
`created_at` property for a manifest to None.

If `created_at` is None, don't calculate indexing SLI for manifest.
2023-06-07 16:24:22 -04:00
Marcus Kok
c3fc3a82ab secscan: send notifications for new indexes (PROJQUAY-4659) (#1813)
On new pushes, allow notifications being sent to user if vulnerabilities are found.
2023-03-29 13:17:52 -04:00
Marcus Kok
d84b67c73c secscan: add scan metric (PROJQUAY-4488) (#1719)
re-adding metric for initial scan results duration, update bucket range
2023-02-01 11:56:53 -05: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
Marcus Kok
5e4ae6495a Revert "secscan: add metric for scan results (PROJQUAY-4488) (#1674)" (#1714)
This reverts commit 8f9d6c9447.
2023-01-19 15:53:44 -05:00
Marcus Kok
8f9d6c9447 secscan: add metric for scan results (PROJQUAY-4488) (#1674)
Add histogram metric that calculates time taken to get security scan results after pushing image to quay.
2023-01-16 10:44:49 -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
Brandon Caton
9eb4fb6aa4 Revert workqueue refactor (#1456)
Currently the prometheus and GC workers are not running correctly.
Reverting the following commits:
- 4e1a985e70
- dac183a1ef
- 68a0d9eaf0
- af1aacea08
- f334b80098
2022-07-22 13:11:39 -04:00
Oleg Bulatov
4e1a985e70 Initialize model.config on its import (PROJQUAY-4006) (#1412)
* Initialize model.config on its import

* Initialze registry_model and secscan_model on import

Co-authored-by: Dave O'Connor <1656866+HammerMeetNail@users.noreply.github.com>
2022-07-12 01:15:30 +02: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
3acc55b96c secscan: split the recent manifest chunk of work into multiple batch (PROJQUAY-3501) (#1300)
Split the work of indexing the recent manifests iterator into multiple
batches. This can reduce how often duplicate work happens when
allowing multiple workers to work on the same chunk of the table.
2022-05-04 11:02:56 -04:00
Kenny Lee Sin Cheong
9ac30007f9 secscan: cleanup secscan interface (PROJQUAY-3501) (#1284) 2022-04-25 14:24:08 -04:00
Kenny Lee Sin Cheong
ed77147b21 secscan: split indexing of recent manifest into separate background operation (PROJQUAY-3501) (#1281)
Index recent manifests in a separate background process, allowing the
main process to correctly select random slabs from the entire table
set and marking them completed in the allocator (rbtree). This avoids
the worker having to start iterating from the beginning of the table
whenever it is restarted.
2022-04-25 11:21:45 -04:00
Kenny Lee Sin Cheong
035f582075 secscan: fix check for end of table (PROJQUAY-3501) (#1270)
Correctly check for the end of the manifest table, for when the worker
needs to start over. Also add missing token to lock key.
2022-04-20 13:15:21 -04:00
Kenny Lee Sin Cheong
7d0f318baa secscan: update the secscan model interface (PROJQUAY-3501) (#1254)
Add index_manifests as part of secscan interface. index_manifests is
a superset of perform_indexing, but also indexes a batch of recent manifests.
2022-04-19 13:39:51 -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
53aaa5493b secscan: add indexer service request duration metric (PROJQUAY-3501) (#1243)
Add histogram for request duration on indexer service. Add random
batch to manifest iterator to reduce duplicate work while manifests
are being backfilled.
2022-04-13 10:04:43 -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
Syed Mushtaq Ahmed
4295a8f660 secscan: scan recent manifests in addition to regular backfill (PROJQUAY-3287) (#1169)
Adds a new iterator for exclusively scanning
recent manifests
2022-03-04 12:23:42 -05:00
Syed Mushtaq Ahmed
6a8567f830 secscan: log manifest ID when indexing (PROJQUAY-3287) (#1166)
for debugging quay.io clair issues
2022-03-03 15:47:58 -05:00
Syed Mushtaq Ahmed
7162be3791 secscan: make batch_size configurable (PROJQUAY-3287) (#1156)
For larger databases like quay.io the default batch
size is too high to complete the job in a resonable
time. Make the batch_size configurable so we can
adjust how many scans can be in-flight for a worker
2022-02-28 14:51:28 -05:00
Syed Mushtaq Ahmed
4db5999037 sescan: prioritize scanning new pushes (PROJQUAY-3287) (#1147)
Currently we randomly scan for entries to be indexed. This could take a
long time if we have a lot of unindexed images. Ideally, we want to
priortize scanning of newer images before we go to the old ones.

This PR creates a smaller batch of size `batch_size` from
`max_id - batch_size` to `max_id` to priortize scanning
those
2022-02-25 13:09:38 -05:00
Kenny Lee Sin Cheong
369ee78a2c secscan: clairv2 - fix datatype bug (PROJQUAY-3279) (#1138) 2022-02-22 12:08:13 -05:00
Kenny Lee Sin Cheong
b32ca3142a secscan: ClairV2 datatype compatibility (PROJQUAY-3279) (#1133)
Mormalize metadata fields when serializing from dict, if not defined.
2022-02-22 09:20:04 -05: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
mosen
fca67e7729 feat: mypy type annotations (PROJQUAY-740) (#455)
* Add dev dependencies mypy and typing

* Add makefile target `types-test`, not yet included in `test` target.

* Generate stubs for imported modules to avoid mypy complaining about missing types.

* Remove generated stubs as there are way too many and they cause tons of mess in the repo. Switched to ignoring untyped modules for now, to concentrate on Quay-only type checking.

* mypy config changed to ignore missing imports

* ignore property decorator as it is not supported by mypy

* mypy annotations for many configuration variables

* re-generate mypy_stubs directory as its necessary in some classes for base classes to prevent mypy errors

* util/registry/queuefile referred to non existent definition of Empty class in multiprocessing.queues

* ignore type checking for things like monkey patching and exported/re-imported objects that 
mypy does not allow.

* Adjust mypy config to warn us about unreachable return paths and useless expressions.

* Add the __annotations__ property to INTERNAL_ONLY_PROPERTIES so that it is not part of the config schema testing

* Remove redundant dependencies `typing` and `typing-extensions` which are NOOP after Python 3.5

* Remove mypy-extensions which only provides a TypedDict implementation but has not been updated since 2019.

* updated mypy to 0.910 which requires all types packages to be installed manually.

* exclude local-dev from type checking until core team can suggest an outcome for __init__.py duplicate packages

* re-add typing dependency which will be needed until Python 3.9

* ignore .mypy_cache

* add mypy stub for features module to replace inline definitions

* import annotations eager evaluation in billing.py as it was required to reference a class declared later in the module.

* remove the type definition of V1ProtocolSteps/V2ProtocolSteps to make tox happy
2021-10-25 09:56:26 +02: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
Joseph Crosland
694fa2acaf secscan: continue iterating after failure (PROJQUAY-2563) (#892)
If Clair returns an error the current behaviour is to
error out, thus not indexing any subsequent manifests.
This change allows the worker to continue indexing
subsequent manifests after one failure.

Signed-off-by: crozzy <joseph.crosland@gmail.com>
2021-09-17 16:29:07 -04:00