Rename secscan_endpoint where required, fix index and indentation
This commit is contained in:
parent
fa0897faae
commit
16c364a90c
2 changed files with 12 additions and 12 deletions
|
@ -5,7 +5,7 @@ import features
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from app import sec_endpoint
|
from app import secscan_endpoint
|
||||||
from data import model
|
from data import model
|
||||||
from endpoints.api import (require_repo_read, NotFound, DownstreamIssue, path_param,
|
from endpoints.api import (require_repo_read, NotFound, DownstreamIssue, path_param,
|
||||||
RepositoryParamResource, resource, nickname, show_if, parse_args,
|
RepositoryParamResource, resource, nickname, show_if, parse_args,
|
||||||
|
@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
|
||||||
def _call_security_api(relative_url, *args, **kwargs):
|
def _call_security_api(relative_url, *args, **kwargs):
|
||||||
""" Issues an HTTP call to the sec API at the given relative URL. """
|
""" Issues an HTTP call to the sec API at the given relative URL. """
|
||||||
try:
|
try:
|
||||||
response = sec_endpoint.call_api(relative_url, *args, **kwargs)
|
response = secscan_endpoint.call_api(relative_url, *args, **kwargs)
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
raise DownstreamIssue(payload=dict(message='API call timed out'))
|
raise DownstreamIssue(payload=dict(message='API call timed out'))
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
|
|
|
@ -12,7 +12,7 @@ from endpoints.notificationhelper import spawn_notification
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from sys import exc_info
|
from sys import exc_info
|
||||||
from peewee import JOIN_LEFT_OUTER
|
from peewee import JOIN_LEFT_OUTER
|
||||||
from app import app, storage, OVERRIDE_CONFIG_DIRECTORY, sec_endpoint
|
from app import app, storage, OVERRIDE_CONFIG_DIRECTORY, secscan_endpoint
|
||||||
from workers.worker import Worker
|
from workers.worker import Worker
|
||||||
from data.database import (Image, ImageStorage, ImageStorageLocation, ImageStoragePlacement,
|
from data.database import (Image, ImageStorage, ImageStorageLocation, ImageStoragePlacement,
|
||||||
db_random_func, UseThenDisconnect, RepositoryTag, Repository,
|
db_random_func, UseThenDisconnect, RepositoryTag, Repository,
|
||||||
|
@ -49,8 +49,8 @@ def _get_image_to_export(version):
|
||||||
|
|
||||||
for image in images:
|
for image in images:
|
||||||
rimages.append({'image_id': image[0],
|
rimages.append({'image_id': image[0],
|
||||||
'docker_image_id': image[0],
|
'docker_image_id': image[1],
|
||||||
'storage_uuid': image[1],
|
'storage_uuid': image[2],
|
||||||
'parent_docker_image_id': None,
|
'parent_docker_image_id': None,
|
||||||
'parent_storage_uuid': None})
|
'parent_storage_uuid': None})
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ def _get_storage_locations(uuid):
|
||||||
.switch(ImageStoragePlacement)
|
.switch(ImageStoragePlacement)
|
||||||
.join(ImageStorage, JOIN_LEFT_OUTER)
|
.join(ImageStorage, JOIN_LEFT_OUTER)
|
||||||
.where(ImageStorage.uuid == uuid))
|
.where(ImageStorage.uuid == uuid))
|
||||||
|
return query.get()
|
||||||
locations = list()
|
locations = list()
|
||||||
for location in query:
|
for location in query:
|
||||||
locations.append(location.location.name)
|
locations.append(location.location.name)
|
||||||
|
@ -189,11 +189,11 @@ class SecurityWorker(Worker):
|
||||||
if not storage.exists(locations, path):
|
if not storage.exists(locations, path):
|
||||||
locations = _get_storage_locations(img['storage_uuid'])
|
locations = _get_storage_locations(img['storage_uuid'])
|
||||||
|
|
||||||
if not storage.exists(locations, path):
|
if not storage.exists(locations, path):
|
||||||
logger.warning('Could not find a valid location to download layer %s',
|
logger.warning('Could not find a valid location to download layer %s',
|
||||||
img['docker_image_id']+'.'+img['storage_uuid'])
|
img['docker_image_id']+'.'+img['storage_uuid'])
|
||||||
_update_image(img, False, self._target_version)
|
_update_image(img, False, self._target_version)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
uri = storage.get_direct_download_url(locations, path)
|
uri = storage.get_direct_download_url(locations, path)
|
||||||
if uri == None:
|
if uri == None:
|
||||||
|
@ -256,7 +256,7 @@ class SecurityWorker(Worker):
|
||||||
# callback code, etc.
|
# callback code, etc.
|
||||||
try:
|
try:
|
||||||
logger.debug('Loading vulnerabilities for layer %s', img['image_id'])
|
logger.debug('Loading vulnerabilities for layer %s', img['image_id'])
|
||||||
response = sec_endpoint.call_api('layers/%s/vulnerabilities', request['ID'])
|
response = secscan_endpoint.call_api('layers/%s/vulnerabilities', request['ID'])
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
logger.debug('Timeout when calling Sec')
|
logger.debug('Timeout when calling Sec')
|
||||||
continue
|
continue
|
||||||
|
|
Reference in a new issue