mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
* 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
79 lines
2.7 KiB
Python
79 lines
2.7 KiB
Python
from abc import ABCMeta, abstractmethod, abstractproperty
|
|
from six import add_metaclass
|
|
|
|
from deprecated import deprecated
|
|
|
|
|
|
class InvalidConfigurationException(Exception):
|
|
"""
|
|
Exception raised when attempting to initialize a secscan model fails.
|
|
"""
|
|
|
|
|
|
@add_metaclass(ABCMeta)
|
|
class SecurityScannerInterface(object):
|
|
"""
|
|
Interface for code to work with the security scan data model.
|
|
|
|
This model encapsulates all access when speaking to an external security scanner, as well as any
|
|
data tracking in the database.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def load_security_information(self, manifest_or_legacy_image, include_vulnerabilities=False):
|
|
"""
|
|
Loads the security information for the given manifest or legacy image, returning a
|
|
SecurityInformationLookupResult structure.
|
|
|
|
The manifest_or_legacy_image must be a Manifest or LegacyImage datatype from the
|
|
registry_model.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def perform_indexing(self, start_token=None):
|
|
"""
|
|
Performs indexing of the next set of unindexed manifests/images.
|
|
|
|
If start_token is given, the indexing should resume from that point. Returns a new start
|
|
index for the next iteration of indexing. The tokens returned and given are assumed to be
|
|
opaque outside of this implementation and should not be relied upon by the caller to conform
|
|
to any particular format.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def register_model_cleanup_callbacks(self, data_model_config):
|
|
"""
|
|
Registers any cleanup callbacks with the data model.
|
|
|
|
Typically, a callback is registered to remove the manifest/image from the security indexer
|
|
if it has been GCed in the data model.
|
|
"""
|
|
|
|
@abstractproperty # type: ignore
|
|
@deprecated(reason="Only exposed for the legacy notification worker")
|
|
def legacy_api_handler(self):
|
|
"""
|
|
Exposes the legacy security scan API for legacy workers that need it or None if none.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def lookup_notification_page(self, notification_id, page_index=None):
|
|
"""
|
|
Performs the lookup of a page of results for an incoming notification from the security
|
|
scanner.
|
|
|
|
Returns a PaginatedNotificationResult or None if this engine doesn't support this method.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def process_notification_page(self, page_result):
|
|
"""
|
|
Processes the page of notification information given and yields UpdatedVulnerability's.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def mark_notification_handled(self, notification_id):
|
|
"""
|
|
Marks that a security notification from the scanner has been handled.
|
|
"""
|