From 6a37f937185677cb54c8ff5c534af97a510b6aa3 Mon Sep 17 00:00:00 2001 From: Quentin Machu Date: Wed, 17 Feb 2016 14:50:37 -0500 Subject: [PATCH] Make the Quay UI work for Clair 1.0 --- .../directives/repo-view/repo-panel-tags.js | 50 ++++++++------ static/js/pages/image-view.js | 66 +++++++++++------- static/partials/image-view.html | 67 +++++++++++-------- 3 files changed, 106 insertions(+), 77 deletions(-) diff --git a/static/js/directives/repo-view/repo-panel-tags.js b/static/js/directives/repo-view/repo-panel-tags.js index ddce687bf..21e061826 100644 --- a/static/js/directives/repo-view/repo-panel-tags.js +++ b/static/js/directives/repo-view/repo-panel-tags.js @@ -156,41 +156,48 @@ angular.module('quay').directive('repoPanelTags', function () { var params = { 'imageid': image_id, 'repository': $scope.repository.namespace + '/' + $scope.repository.name, + 'vulnerabilities': true, }; - ApiService.getRepoImageVulnerabilities(null, params).then(function(resp) { + ApiService.getRepoImageSecurity(null, params).then(function(resp) { imageData.loading = false; imageData.status = resp['status']; if (imageData.status == 'scanned') { - var vulnerabilities = resp.data.Vulnerabilities; - - imageData.hasVulnerabilities = !!vulnerabilities.length; - imageData.vulnerabilities = vulnerabilities; - + var vulnerabilities = []; var highest = { - 'Priority': 'Unknown', + 'Severity': 'Unknown', 'Count': 0, 'index': 100000 }; - resp.data.Vulnerabilities.forEach(function(v) { - if (VulnerabilityService.LEVELS[v.Priority].index == 0) { - $scope.defcon1[v.ID] = v; - $scope.hasDefcon1 = true; - } + if (resp.data && resp.data.Layer && resp.data.Layer.Features) { + resp.data.Layer.Features.forEach(function(feature) { + if (feature.Vulnerabilities) { + feature.Vulnerabilities.forEach(function(vuln) { + if (VulnerabilityService.LEVELS[vuln.Severity].index == 0) { + $scope.defcon1[vuln.ID] = v; + $scope.hasDefcon1 = true; + } - if (VulnerabilityService.LEVELS[v.Priority].index < highest.index) { - highest = { - 'Priority': v.Priority, - 'Count': 1, - 'index': VulnerabilityService.LEVELS[v.Priority].index + if (VulnerabilityService.LEVELS[vuln.Severity].index < highest.index) { + highest = { + 'Priority': vuln.Severity, + 'Count': 1, + 'index': VulnerabilityService.LEVELS[vuln.Severity].index + } + } else if (VulnerabilityService.LEVELS[vuln.Severity].index == highest.index) { + highest['Count']++; + } + + vulnerabilities.push(vuln); + }); } - } else if (VulnerabilityService.LEVELS[v.Priority].index == highest.index) { - highest['Count']++; - } - }); + }); + } + imageData.hasVulnerabilities = !!vulnerabilities.length; + imageData.vulnerabilities = vulnerabilities; imageData.highestVulnerability = highest; } }, function() { @@ -355,4 +362,3 @@ angular.module('quay').directive('repoPanelTags', function () { }; return directiveDefinitionObject; }); - diff --git a/static/js/pages/image-view.js b/static/js/pages/image-view.js index 253c389b2..5e377eac0 100644 --- a/static/js/pages/image-view.js +++ b/static/js/pages/image-view.js @@ -45,39 +45,53 @@ loadImage(); loadRepository(); - $scope.downloadPackages = function() { - if (!Features.SECURITY_SCANNER || $scope.packagesResource) { return; } - - var params = { - 'repository': namespace + '/' + name, - 'imageid': imageid - }; - - $scope.packagesResource = ApiService.getRepoImagePackagesAsResource(params).get(function(packages) { - $scope.packages = packages; - return packages; - }); - }; - - $scope.loadImageVulnerabilities = function() { - if (!Features.SECURITY_SCANNER || $scope.vulnerabilitiesResource) { return; } + $scope.loadImageSecurity = function() { + if (!Features.SECURITY_SCANNER || $scope.securityResource) { return; } $scope.VulnerabilityLevels = VulnerabilityService.getLevels(); var params = { 'repository': namespace + '/' + name, - 'imageid': imageid + 'imageid': imageid, + 'vulnerabilities': true, }; - $scope.vulnerabilitiesResource = ApiService.getRepoImageVulnerabilitiesAsResource(params).get(function(resp) { - $scope.vulnerabilityInfo = resp; - $scope.vulnerabilities = []; + $scope.securityResource = ApiService.getRepoImageSecurityAsResource(params).get(function(resp) { + $scope.securityStatus = resp.status; + $scope.securityFeatures = []; + $scope.securityVulnerabilities = []; - if (resp.data && resp.data.Vulnerabilities) { - resp.data.Vulnerabilities.forEach(function(vuln) { - vuln_copy = jQuery.extend({}, vuln); - vuln_copy['index'] = VulnerabilityService.LEVELS[vuln['Priority']]['index']; - $scope.vulnerabilities.push(vuln_copy); + if (resp.data && resp.data.Layer && resp.data.Layer.Features) { + resp.data.Layer.Features.forEach(function(feature) { + feature_obj = { + 'name': feature.Name, + 'namespace': feature.Namespace, + 'version': feature.Version, + 'addedBy': feature.AddedBy, + } + feature_vulnerabilities = [] + + if (feature.Vulnerabilities) { + feature.Vulnerabilities.forEach(function(vuln) { + vuln_obj = { + 'name': vuln.Name, + 'namespace': vuln.Namespace, + 'description': vuln.Description, + 'link': vuln.Link, + 'severity': vuln.Severity, + 'metadata': vuln.Metadata, + 'feature': jQuery.extend({}, feature_obj), + 'fixedBy': vuln.FixedBy, + 'index': VulnerabilityService.LEVELS[vuln['Severity']]['index'], + } + + feature_vulnerabilities.push(vuln_obj) + $scope.securityVulnerabilities.push(vuln_obj); + }); + } + + feature_obj['vulnerabilities'] = feature_vulnerabilities + $scope.securityFeatures.push(feature_obj); }); } @@ -94,4 +108,4 @@ }, 100); }; } -})(); \ No newline at end of file +})(); diff --git a/static/partials/image-view.html b/static/partials/image-view.html index 3cd8627a3..b3343802f 100644 --- a/static/partials/image-view.html +++ b/static/partials/image-view.html @@ -21,13 +21,13 @@ - @@ -42,51 +42,58 @@ ng-repeat="parent in reversedHistory"> - -
-
+ +
+
-
+

Image Security

-
+
This image has not been indexed yet
Please try again in a few minutes.
-
+
This image could not be indexed
Our security scanner was unable to index this image.
-
+
This image contains no recognized security vulnerabilities
- Quay currently indexes Debian, Red Hat and Ubuntu packages. + Quay currently indexes Debian, Red Hat and Ubuntu based images.
-
+
+ + - - + + + + + + +
Vulnerability PriorityIntroduced byFixed by Description
{{ vulnerability.ID }}
{{ vulnerability.name }} - - {{ vulnerability.Description }}{{ vulnerability.feature.name }} {{ vulnerability.feature.version }} + {{ vulnerability.feature.name }} {{ vulnerability.fixedBy }} + {{ vulnerability.description }}
-
No matching vulnerabilities found
@@ -110,41 +117,43 @@
- +
-
-
+
+

Image Packages

-
+
This image has not been indexed yet
Please try again in a few minutes.
-
+
This image could not be indexed
Our security scanner was unable to index this image.
- +
- + + - - - - + + + + +
Package Name Package VersionOSPackage OSNumber of vulnerabilities
{{ package.Name }}{{ package.Version }}{{ package.OS }}
{{ feature.name }}{{ feature.version }}{{ feature.namespace }}{{ feature.vulnerabilities.length }}
-
No matching packages found