Skip to content

Commit

Permalink
secscan: handle remote layer url when sending request to Clair (PROJQ…
Browse files Browse the repository at this point in the history
…UAY-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.
  • Loading branch information
kleesc committed Jul 21, 2021
1 parent 6e80903 commit 65ec47a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def create_transaction(db):
FEATURE_SECURITY_NOTIFICATIONS = False

# The endpoint for the (deprecated) V2 security scanner.
SECURITY_SCANNER_ENDPOINT = "http://192.168.99.101:6060"
SECURITY_SCANNER_ENDPOINT = None

# The endpoint for the V4 security scanner.
SECURITY_SCANNER_V4_ENDPOINT = None
Expand Down
2 changes: 1 addition & 1 deletion data/secscan_model/secscan_v2_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, app, instance_keys, storage):

validator = V2SecurityConfigValidator(
app.config.get("FEATURE_SECURITY_SCANNER", False),
app.config.get("SECURITY_SCANNER_ENDPOINT"),
app.config.get("SECURITY_SCANNER_ENDPOINT", None),
)

if not validator.valid():
Expand Down
6 changes: 5 additions & 1 deletion util/secscan/v4/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ def _join(first, second):
"layers": [
{
"hash": str(l.layer_info.blob_digest),
"uri": self._blob_url_retriever.url_for_download(manifest.repository, l.blob),
"uri": self._blob_url_retriever.url_for_download(manifest.repository, l.blob)
if not l.layer_info.is_remote
else l.layer_info.urls[0],
"headers": _join(
{
"Accept": ["application/gzip"],
Expand All @@ -189,6 +191,8 @@ def _join(first, second):
self._blob_url_retriever.headers_for_download(
manifest.repository, l.blob, DOWNLOAD_VALIDITY_LIFETIME_S
)
if not l.layer_info.is_remote
else {}
),
),
}
Expand Down

0 comments on commit 65ec47a

Please sign in to comment.