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

64 Commits

Author SHA1 Message Date
Sunandadadi
db48948865 [redhat-3.9] chore: update werkzeug and related package versions (PROJQUAY-5098) (#3570)
* chore: update werkzeug and related package versions (PROJQUAY-5098)

* update authlib to 1.2.1

* upgrade cryptography

* upgrade grpc

* remove uninitialised import

* update botocore

* revert mypy changes

* fixing types test

* fixing cloud storage tests
2025-01-17 10:18:23 -05:00
OpenShift Cherrypick Robot
3757824708 secscan_model: attempt urldecoding fixed_in_version (PROJQUAY-5886) (#2063)
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>
Co-authored-by: Hank Donnay <hdonnay@redhat.com>
2023-07-27 17:44:07 +02:00
Marcus Kok
6eeb45b7c0 config: Set feature flag default for new vulnerability notifications to True (#1995)
(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.
2023-06-27 17:56:42 +02: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
Kenny Lee Sin Cheong
79e9778576 secscan: handle proxy model fallback to noop v2 (PROJQUAY-2289) (#847)
Handles the case where a V2 scanner is not configured (noop
implementation) and the proxy model tries to load security information
that has not been indexed in V4 yet. In such case, the noop
implementation of the V2 scanner should return a COULD_NOT_LOAD
status (instead of None, to comply to the secscan model interface),
and ignore the fallback to V2, and finally just return the V4
status (NOT_YET_INDEXED)
2021-07-23 12:09:00 -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
Kenny Lee Sin Cheong
65ec47ab4b secscan: handle remote layer url when sending request to Clair (PROJQUAY-2269) (#841)
Handle the case where a layer might be remote (not hosted in Quay's
storage) and add the remote blob url instead of the storage's download
url.
2021-07-21 13:14:31 -04: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
Louis DeLosSantos
b389f885cf sec: implement jwt signing to ClairV4 (#554)
this commit adds jwt signing directly in Quay when contacting
ClairV4

Signed-off-by: ldelossa <louis@localhost.localdomain>

Co-authored-by: ldelossa <louis@localhost.localdomain>
2020-10-02 11:00:56 -07: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
f1237bdb29 [PROJQUAY-753] Reduce logging noise (#445) 2020-06-18 13:54:20 -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
Joseph Schorr
556c46311d Enable Clair V4 to work with local storage (for POC only) (#380)
* Enable Clair V4 to work with local storage (for POC only)

* `.update` does not return the dictionary, so this call was returning `None` for headers
2020-05-18 11:06:56 -04:00