feat(trivy): Return Trivy DB update timestamp in /api/v1/metadata response (#11285)

Resolves: #11284

Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
This commit is contained in:
Daniel Pacak 2020-03-26 12:22:28 +01:00 committed by GitHub
parent 73f3a305ce
commit 48df949c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 5 deletions

View File

@ -103,8 +103,8 @@ NOTARYVERSION=v0.6.1
CLAIRVERSION=v2.1.1
NOTARYMIGRATEVERSION=v3.5.4
CLAIRADAPTERVERSION=v1.0.1
TRIVYVERSION=v0.5.2
TRIVYADAPTERVERSION=v0.5.0
TRIVYVERSION=v0.5.3
TRIVYADAPTERVERSION=v0.7.0
# version of chartmuseum
CHARTMUSEUMVERSION=v0.9.0

View File

@ -114,6 +114,7 @@ The `Makefile` contains these configurable parameters:
| COMPILETAG | Compile model flag, default: compile_normal (local golang build) |
| NOTARYFLAG | Notary mode flag, default: false |
| CLAIRFLAG | Clair mode flag, default: false |
| TRIVYFLAG | Trivy mode flag, default: false |
| HTTPPROXY | NPM http proxy for Clarity UI builder |
| REGISTRYSERVER | Remote registry server IP address |
| REGISTRYUSER | Remote registry server user name |

View File

@ -8,7 +8,7 @@ import { ScannerMetadata } from "../scanner-metadata";
import { DatePipe } from "@angular/common";
import { TranslateService } from "@ngx-translate/core";
import { ErrorHandler } from "../../../../lib/utils/error-handler";
import { DATABASE_UPDATED_PROPERTY } from "../../../../lib/utils/utils";
import {DATABASE_NEXT_UPDATE_PROPERTY, DATABASE_UPDATED_PROPERTY} from "../../../../lib/utils/utils";
@Component({
selector: 'scanner-metadata',
@ -34,14 +34,26 @@ export class ScannerMetadataComponent implements OnInit {
});
}
parseDate(item: any): string {
if (item && item.value && item.key === DATABASE_UPDATED_PROPERTY) {
if (this.hasValue(item) && this.hasDateValue(item)) {
return new DatePipe(this.translate.currentLang).transform(item.value, 'short');
}
if (item && item.value) {
if (this.hasValue(item)) {
return item.value;
}
return '';
}
hasValue(item: any): boolean {
return item && item.value;
}
hasDateValue(item: any): boolean {
switch (item.key) {
case DATABASE_UPDATED_PROPERTY:
case DATABASE_NEXT_UPDATE_PROPERTY:
return true;
default:
return false;
}
}
toString(arr: string[]) {
if (arr && arr.length > 0) {
return "[" + arr.join(" , ") + "]";

View File

@ -245,6 +245,7 @@ export const DEFAULT_SUPPORTED_MIME_TYPE = "application/vnd.scanner.adapter.vuln
* the property name of vulnerability database updated time
*/
export const DATABASE_UPDATED_PROPERTY = "harbor.scanner-adapter/vulnerability-database-updated-at";
export const DATABASE_NEXT_UPDATE_PROPERTY = "harbor.scanner-adapter/vulnerability-database-next-update-at";
/**
* The state of vulnerability scanning