mirror of
https://github.com/quay/quay.git
synced 2026-01-27 18:42:52 +03:00
This is in preparation for the beginning of support for the new API for ClairCore (V4) Fixes https://issues.redhat.com/browse/PROJQUAY-177
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import logging.config
|
|
import time
|
|
|
|
import features
|
|
|
|
from app import app
|
|
from data.secscan_model import secscan_model
|
|
from workers.worker import Worker
|
|
from util.log import logfile_path
|
|
from endpoints.v2 import v2_bp
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
DEFAULT_INDEXING_INTERVAL = 30
|
|
|
|
|
|
class SecurityWorker(Worker):
|
|
def __init__(self):
|
|
super(SecurityWorker, self).__init__()
|
|
self._next_token = None
|
|
|
|
interval = app.config.get("SECURITY_SCANNER_INDEXING_INTERVAL", DEFAULT_INDEXING_INTERVAL)
|
|
self.add_operation(self._index_in_scanner, interval)
|
|
|
|
def _index_in_scanner(self):
|
|
self._next_token = secscan_model.perform_indexing(self._next_token)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.register_blueprint(v2_bp, url_prefix="/v2")
|
|
|
|
if not features.SECURITY_SCANNER:
|
|
logger.debug("Security scanner disabled; skipping SecurityWorker")
|
|
while True:
|
|
time.sleep(100000)
|
|
|
|
logging.config.fileConfig(logfile_path(debug=False), disable_existing_loggers=False)
|
|
worker = SecurityWorker()
|
|
worker.start()
|