-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/portal/lib/src/project-policy-config/project-policy-config.component.scss b/src/portal/lib/src/project-policy-config/project-policy-config.component.scss
index af7084564..474a7fbad 100644
--- a/src/portal/lib/src/project-policy-config/project-policy-config.component.scss
+++ b/src/portal/lib/src/project-policy-config/project-policy-config.component.scss
@@ -1,8 +1,63 @@
-#severity-blk div
-{
- display: inline-block;
+#severity-blk div {
+ display: inline-block;
}
.select {
- width: 120px;
-}
\ No newline at end of file
+ width: 120px;
+}
+
+.whitelist-window {
+ border: 1px solid #ccc;
+ border-radius: 3px;
+ padding: 12px;
+ height: 224px;
+ width: 222px;
+ color: #0079bb;
+ overflow-y: auto;
+ white-space: nowrap;
+
+ li {
+ height: 24px;
+ list-style-type: none;
+ }
+}
+
+.width-70per {
+ width: 70%;
+}
+
+.none {
+ color: #ccc;
+}
+
+.underline {
+ border-bottom: 1px solid;
+}
+
+.color-0079bb {
+ color: #0079bb;
+}
+
+.padding-top-8 {
+ padding-top: 8px;
+}
+
+.padding-left-80 {
+ padding-left: 80px;
+}
+
+.add-modal {
+ position: absolute;
+ padding: 0 8px;
+ background-color: rgb(238, 238, 238);
+
+ input {
+ width: 100%;
+ border: 1px solid;
+ }
+
+ button {
+ float: right;
+ }
+}
+
diff --git a/src/portal/lib/src/project-policy-config/project-policy-config.component.ts b/src/portal/lib/src/project-policy-config/project-policy-config.component.ts
index 1aff2d114..8af7184d0 100644
--- a/src/portal/lib/src/project-policy-config/project-policy-config.component.ts
+++ b/src/portal/lib/src/project-policy-config/project-policy-config.component.ts
@@ -1,176 +1,370 @@
-import { Component, Input, OnInit, ViewChild } from '@angular/core';
+import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
-import { compareValue, clone } from '../utils';
-import { ProjectService } from '../service/project.service';
-import { ErrorHandler } from '../error-handler/error-handler';
-import { State } from '../service/interface';
+import {compareValue, clone} from '../utils';
+import {ProjectService} from '../service/project.service';
+import {ErrorHandler} from '../error-handler/error-handler';
+import {State, SystemCVEWhitelist} from '../service/interface';
-import { ConfirmationState, ConfirmationTargets } from '../shared/shared.const';
-import { ConfirmationMessage } from '../confirmation-dialog/confirmation-message';
-import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation-dialog.component';
-import { ConfirmationAcknowledgement } from '../confirmation-dialog/confirmation-state-message';
-import { TranslateService } from '@ngx-translate/core';
+import {ConfirmationState, ConfirmationTargets} from '../shared/shared.const';
+import {ConfirmationMessage} from '../confirmation-dialog/confirmation-message';
+import {ConfirmationDialogComponent} from '../confirmation-dialog/confirmation-dialog.component';
+import {ConfirmationAcknowledgement} from '../confirmation-dialog/confirmation-state-message';
+import {TranslateService} from '@ngx-translate/core';
-import { Project } from './project';
+import {Project} from './project';
import {SystemInfo, SystemInfoService} from '../service/index';
-import { UserPermissionService } from '../service/permission.service';
-import { USERSTATICPERMISSION } from '../service/permission-static';
+import {UserPermissionService} from '../service/permission.service';
+import {USERSTATICPERMISSION} from '../service/permission-static';
+
+
+const ONE_THOUSAND: number = 1000;
+const LOW: string = 'low';
export class ProjectPolicy {
- Public: boolean;
- ContentTrust: boolean;
- PreventVulImg: boolean;
- PreventVulImgSeverity: string;
- ScanImgOnPush: boolean;
+ Public: boolean;
+ ContentTrust: boolean;
+ PreventVulImg: boolean;
+ PreventVulImgSeverity: string;
+ ScanImgOnPush: boolean;
- constructor() {
- this.Public = false;
- this.ContentTrust = false;
- this.PreventVulImg = false;
- this.PreventVulImgSeverity = 'low';
- this.ScanImgOnPush = false;
- }
+ constructor() {
+ this.Public = false;
+ this.ContentTrust = false;
+ this.PreventVulImg = false;
+ this.PreventVulImgSeverity = LOW;
+ this.ScanImgOnPush = false;
+ }
- initByProject(pro: Project) {
- this.Public = pro.metadata.public === 'true' ? true : false;
- this.ContentTrust = pro.metadata.enable_content_trust === 'true' ? true : false;
- this.PreventVulImg = pro.metadata.prevent_vul === 'true' ? true : false;
- if (pro.metadata.severity) { this.PreventVulImgSeverity = pro.metadata.severity; }
- this.ScanImgOnPush = pro.metadata.auto_scan === 'true' ? true : false;
- }
+ initByProject(pro: Project) {
+ this.Public = pro.metadata.public === 'true' ? true : false;
+ this.ContentTrust = pro.metadata.enable_content_trust === 'true' ? true : false;
+ this.PreventVulImg = pro.metadata.prevent_vul === 'true' ? true : false;
+ if (pro.metadata.severity) {
+ this.PreventVulImgSeverity = pro.metadata.severity;
+ }
+ this.ScanImgOnPush = pro.metadata.auto_scan === 'true' ? true : false;
+ }
}
@Component({
- selector: 'hbr-project-policy-config',
- templateUrl: './project-policy-config.component.html',
- styleUrls: ['./project-policy-config.component.scss']
+ selector: 'hbr-project-policy-config',
+ templateUrl: './project-policy-config.component.html',
+ styleUrls: ['./project-policy-config.component.scss']
})
export class ProjectPolicyConfigComponent implements OnInit {
- onGoing = false;
- @Input() projectId: number;
- @Input() projectName = 'unknown';
+ onGoing = false;
+ @Input() projectId: number;
+ @Input() projectName = 'unknown';
- @Input() hasSignedIn: boolean;
- @Input() hasProjectAdminRole: boolean;
+ @Input() hasSignedIn: boolean;
+ @Input() hasProjectAdminRole: boolean;
- @ViewChild('cfgConfirmationDialog') confirmationDlg: ConfirmationDialogComponent;
+ @ViewChild('cfgConfirmationDialog') confirmationDlg: ConfirmationDialogComponent;
+ @ViewChild('dateInput') dateInput: ElementRef;
+ @ViewChild('dateSystemInput') dateSystemInput: ElementRef;
- systemInfo: SystemInfo;
- orgProjectPolicy = new ProjectPolicy();
- projectPolicy = new ProjectPolicy();
- hasChangeConfigRole: boolean;
- severityOptions = [
- {severity: 'high', severityLevel: 'VULNERABILITY.SEVERITY.HIGH'},
- {severity: 'medium', severityLevel: 'VULNERABILITY.SEVERITY.MEDIUM'},
- {severity: 'low', severityLevel: 'VULNERABILITY.SEVERITY.LOW'},
- {severity: 'negligible', severityLevel: 'VULNERABILITY.SEVERITY.NEGLIGIBLE'},
- ];
+ systemInfo: SystemInfo;
+ orgProjectPolicy = new ProjectPolicy();
+ projectPolicy = new ProjectPolicy();
+ hasChangeConfigRole: boolean;
+ severityOptions = [
+ {severity: 'high', severityLevel: 'VULNERABILITY.SEVERITY.HIGH'},
+ {severity: 'medium', severityLevel: 'VULNERABILITY.SEVERITY.MEDIUM'},
+ {severity: 'low', severityLevel: 'VULNERABILITY.SEVERITY.LOW'},
+ {severity: 'negligible', severityLevel: 'VULNERABILITY.SEVERITY.NEGLIGIBLE'},
+ ];
+ userSystemWhitelist: boolean = true;
+ showAddModal: boolean = false;
+ systemWhitelist: SystemCVEWhitelist;
+ cveIds: string;
+ systemExpiresDate: Date;
+ systemExpiresDateString: string;
+ userProjectWhitelist = false;
+ systemWhitelistOrProjectWhitelist: string;
+ systemWhitelistOrProjectWhitelistOrigin: string;
+ projectWhitelist;
+ projectWhitelistOrigin;
- constructor(
- private errorHandler: ErrorHandler,
- private translate: TranslateService,
- private projectService: ProjectService,
- private systemInfoService: SystemInfoService,
- private userPermission: UserPermissionService
- ) {}
-
- ngOnInit(): void {
- // assert if project id exist
- if (!this.projectId) {
- this.errorHandler.error('Project ID cannot be unset.');
- return;
+ constructor(
+ private errorHandler: ErrorHandler,
+ private translate: TranslateService,
+ private projectService: ProjectService,
+ private systemInfoService: SystemInfoService,
+ private userPermission: UserPermissionService,
+ ) {
}
- // get system info
- this.systemInfoService.getSystemInfo()
- .subscribe(systemInfo => this.systemInfo = systemInfo
- , error => this.errorHandler.error(error));
+ ngOnInit(): void {
+ // assert if project id exist
+ if (!this.projectId) {
+ this.errorHandler.error('Project ID cannot be unset.');
+ return;
+ }
+ // get system info
+ this.systemInfoService.getSystemInfo()
+ .subscribe(systemInfo => {
+ this.systemInfo = systemInfo;
+ setTimeout(() => {
+ this.dateSystemInput.nativeElement.parentNode.setAttribute("hidden", "hidden");
+ }, 100);
+ } , error => this.errorHandler.error(error));
- // retrive project level policy data
- this.retrieve();
- this.getPermission();
- }
- private getPermission(): void {
- this.userPermission.getPermission(this.projectId,
- USERSTATICPERMISSION.CONFIGURATION.KEY, USERSTATICPERMISSION.CONFIGURATION.VALUE.UPDATE).subscribe(permissins => {
- this.hasChangeConfigRole = permissins as boolean;
- });
- }
- public get withNotary(): boolean {
- return this.systemInfo ? this.systemInfo.with_notary : false;
- }
-
- public get withClair(): boolean {
- return this.systemInfo ? this.systemInfo.with_clair : false;
- }
-
- retrieve(state?: State): any {
- this.projectService.getProject(this.projectId)
- .subscribe(
- response => {
- this.orgProjectPolicy.initByProject(response);
- this.projectPolicy.initByProject(response);
- }, error => this.errorHandler.error(error));
- }
-
- updateProjectPolicy(projectId: string|number, pp: ProjectPolicy) {
- this.projectService.updateProjectPolicy(projectId, pp);
- }
-
- refresh() {
- this.retrieve();
- }
-
- isValid() {
- let flag = false;
- if (!this.projectPolicy.PreventVulImg || this.severityOptions.some(x => x.severity === this.projectPolicy.PreventVulImgSeverity)) {
- flag = true;
+ // retrive project level policy data
+ this.retrieve();
+ this.getPermission();
+ this.getSystemWhitelist();
}
- return flag;
- }
- hasChanges() {
- return !compareValue(this.orgProjectPolicy, this.projectPolicy);
- }
-
- save() {
- if (!this.hasChanges()) {
- return;
+ getSystemWhitelist() {
+ this.systemInfoService.getSystemWhitelist()
+ .subscribe((systemWhitelist) => {
+ if (systemWhitelist) {
+ this.systemWhitelist = systemWhitelist;
+ if (this.systemWhitelist.expires_at) {
+ this.systemExpiresDate = new Date(this.systemWhitelist.expires_at * ONE_THOUSAND);
+ setTimeout( () => {
+ this.systemExpiresDateString = this.dateSystemInput.nativeElement.value;
+ }, 100);
+ }
+ }
+ }, error => {
+ this.errorHandler.error(error);
+ }
+ );
}
- this.onGoing = true;
- this.projectService.updateProjectPolicy(this.projectId, this.projectPolicy)
- .subscribe(() => {
- this.onGoing = false;
- this.translate.get('CONFIG.SAVE_SUCCESS').subscribe((res: string) => {
- this.errorHandler.info(res);
- });
- this.refresh();
- }, error => {
- this.onGoing = false;
- this.errorHandler.error(error);
- });
- }
-
- cancel(): void {
- let msg = new ConfirmationMessage(
- 'CONFIG.CONFIRM_TITLE',
- 'CONFIG.CONFIRM_SUMMARY',
- '',
- {},
- ConfirmationTargets.CONFIG
- );
- this.confirmationDlg.open(msg);
- }
-
- reset(): void {
- this.projectPolicy = clone(this.orgProjectPolicy);
- }
-
- confirmCancel(ack: ConfirmationAcknowledgement): void {
- if (ack && ack.source === ConfirmationTargets.CONFIG &&
- ack.state === ConfirmationState.CONFIRMED) {
- this.reset();
+ private getPermission(): void {
+ this.userPermission.getPermission(this.projectId,
+ USERSTATICPERMISSION.CONFIGURATION.KEY, USERSTATICPERMISSION.CONFIGURATION.VALUE.UPDATE).subscribe(permissins => {
+ this.hasChangeConfigRole = permissins as boolean;
+ });
+ }
+
+ public get withNotary(): boolean {
+ return this.systemInfo ? this.systemInfo.with_notary : false;
+ }
+
+ public get withClair(): boolean {
+ return this.systemInfo ? this.systemInfo.with_clair : false;
+ }
+
+ retrieve(state?: State): any {
+ this.projectService.getProject(this.projectId)
+ .subscribe(
+ response => {
+ this.orgProjectPolicy.initByProject(response);
+ this.projectPolicy.initByProject(response);
+ // get projectWhitelist
+ if (!response.cve_whitelist) {
+ response.cve_whitelist = {
+ items: [],
+ expires_at: null
+ };
+ }
+ if (!response.cve_whitelist['items']) {
+ response.cve_whitelist['items'] = [];
+ }
+ if (!response.cve_whitelist['expires_at']) {
+ response.cve_whitelist['expires_at'] = null;
+ }
+ if (response && response.cve_whitelist) {
+ this.projectWhitelist = clone(response.cve_whitelist);
+ this.projectWhitelistOrigin = clone(response.cve_whitelist);
+ this.systemWhitelistOrProjectWhitelist = response.metadata.reuse_sys_cve_whitelist;
+ this.systemWhitelistOrProjectWhitelistOrigin = response.metadata.reuse_sys_cve_whitelist;
+ }
+ }, error => this.errorHandler.error(error));
+ }
+
+ refresh() {
+ this.retrieve();
+ }
+
+ isValid() {
+ let flag = false;
+ if (!this.projectPolicy.PreventVulImg || this.severityOptions.some(x => x.severity === this.projectPolicy.PreventVulImgSeverity)) {
+ flag = true;
+ }
+ return flag;
+ }
+
+ hasChanges() {
+ return !compareValue(this.orgProjectPolicy, this.projectPolicy);
+ }
+
+ save() {
+ if (!this.hasChanges() && !this.hasWhitelistChanged) {
+ return;
+ }
+ this.onGoing = true;
+ this.projectService.updateProjectPolicy(
+ this.projectId,
+ this.projectPolicy,
+ this.systemWhitelistOrProjectWhitelist,
+ this.projectWhitelist)
+ .subscribe(() => {
+ this.onGoing = false;
+ this.translate.get('CONFIG.SAVE_SUCCESS').subscribe((res: string) => {
+ this.errorHandler.info(res);
+ });
+ this.refresh();
+ }, error => {
+ this.onGoing = false;
+ this.errorHandler.error(error);
+ });
+ }
+
+ cancel(): void {
+ let msg = new ConfirmationMessage(
+ 'CONFIG.CONFIRM_TITLE',
+ 'CONFIG.CONFIRM_SUMMARY',
+ '',
+ {},
+ ConfirmationTargets.CONFIG
+ );
+ this.confirmationDlg.open(msg);
+ }
+
+ reset(): void {
+ this.projectPolicy = clone(this.orgProjectPolicy);
+ }
+
+ confirmCancel(ack: ConfirmationAcknowledgement): void {
+ if (ack && ack.source === ConfirmationTargets.CONFIG &&
+ ack.state === ConfirmationState.CONFIRMED) {
+ this.reset();
+ if (this.hasWhitelistChanged) {
+ this.projectWhitelist = clone(this.projectWhitelistOrigin);
+ this.systemWhitelistOrProjectWhitelist = this.systemWhitelistOrProjectWhitelistOrigin;
+ }
+ }
+ }
+
+ isUseSystemWhitelist(): boolean {
+ return this.systemWhitelistOrProjectWhitelist === 'true';
+ }
+
+ deleteItem(index: number) {
+ this.projectWhitelist.items.splice(index, 1);
+ }
+
+ addSystem() {
+ this.showAddModal = false;
+ if (!(this.systemWhitelist && this.systemWhitelist.items && this.systemWhitelist.items.length > 0)) {
+ return;
+ }
+ if (this.projectWhitelist && !this.projectWhitelist.items) {
+ this.projectWhitelist.items = [];
+ }
+ // remove duplication and add to projectWhitelist
+ let map = {};
+ this.projectWhitelist.items.forEach(item => {
+ map[item.cve_id] = true;
+ });
+ this.systemWhitelist.items.forEach(item => {
+ if (!map[item.cve_id]) {
+ map[item.cve_id] = true;
+ this.projectWhitelist.items.push(item);
+ }
+ });
+ }
+
+ addToProjectWhitelist() {
+ if (this.projectWhitelist && !this.projectWhitelist.items) {
+ this.projectWhitelist.items = [];
+ }
+ // remove duplication and add to projectWhitelist
+ let map = {};
+ this.projectWhitelist.items.forEach(item => {
+ map[item.cve_id] = true;
+ });
+ this.cveIds.split(/[\n,]+/).forEach(id => {
+ let cveObj: any = {};
+ cveObj.cve_id = id.trim();
+ if (!map[cveObj.cve_id]) {
+ map[cveObj.cve_id] = true;
+ this.projectWhitelist.items.push(cveObj);
+ }
+ });
+ // clear modal and close modal
+ this.cveIds = null;
+ this.showAddModal = false;
+ }
+
+ get hasWhitelistChanged(): boolean {
+ return !(compareValue(this.projectWhitelist, this.projectWhitelistOrigin)
+ && this.systemWhitelistOrProjectWhitelistOrigin === this.systemWhitelistOrProjectWhitelist);
+ }
+
+ isDisabled(): boolean {
+ if (this.cveIds) {
+ let arr = this.cveIds.split(/[\n,]+/);
+ let flag = false;
+ for (let i = 0; i < arr.length; i++) {
+ let id = arr[i].trim();
+ if (!/^CVE-[\d]+-[\d]+$/.test(id)) {
+ flag = true;
+ break;
+ }
+ }
+ return flag;
+ }
+ return true;
+ }
+
+ get expiresDate() {
+ if (this.systemWhitelistOrProjectWhitelist === 'true') {
+ if (this.systemWhitelist && this.systemWhitelist.expires_at) {
+ return new Date(this.systemWhitelist.expires_at * ONE_THOUSAND);
+ }
+ } else {
+ if (this.projectWhitelist && this.projectWhitelist.expires_at) {
+ return new Date(this.projectWhitelist.expires_at * ONE_THOUSAND);
+ }
+ }
+ return null;
+ }
+
+ set expiresDate(date) {
+ if (this.systemWhitelistOrProjectWhitelist === 'false') {
+ if (this.projectWhitelist && date) {
+ this.projectWhitelist.expires_at = Math.floor(date.getTime() / ONE_THOUSAND);
+ }
+ }
+ }
+
+ get neverExpires(): boolean {
+ if (this.systemWhitelistOrProjectWhitelist === 'true') {
+ if (this.systemWhitelist && this.systemWhitelist.expires_at) {
+ return !(this.systemWhitelist && this.systemWhitelist.expires_at);
+ }
+ } else {
+ if (this.projectWhitelist && this.projectWhitelist.expires_at) {
+ return !(this.projectWhitelist && this.projectWhitelist.expires_at);
+ }
+ }
+ return true;
+ }
+
+ set neverExpires(flag) {
+ if (flag) {
+ this.projectWhitelist.expires_at = null;
+ this.systemInfoService.resetDateInput(this.dateInput);
+ } else {
+ this.projectWhitelist.expires_at = Math.floor(new Date().getTime() / ONE_THOUSAND);
+ }
+ }
+
+ get hasExpired(): boolean {
+ if (this.systemWhitelistOrProjectWhitelist === 'true') {
+ if (this.systemWhitelist && this.systemWhitelist.expires_at) {
+ return new Date().getTime() > this.systemWhitelist.expires_at * ONE_THOUSAND;
+ }
+ } else {
+ if (this.projectWhitelistOrigin && this.projectWhitelistOrigin.expires_at) {
+ return new Date().getTime() > this.projectWhitelistOrigin.expires_at * ONE_THOUSAND;
+ }
+ }
+ return false;
}
- }
}
diff --git a/src/portal/lib/src/project-policy-config/project.ts b/src/portal/lib/src/project-policy-config/project.ts
index ed1d26e01..c38b88b60 100644
--- a/src/portal/lib/src/project-policy-config/project.ts
+++ b/src/portal/lib/src/project-policy-config/project.ts
@@ -18,7 +18,9 @@ export class Project {
prevent_vul: string | boolean;
severity: string;
auto_scan: string | boolean;
+ reuse_sys_cve_whitelist?: string;
};
+ cve_whitelist?: object;
constructor () {
this.metadata.public = false;
this.metadata.enable_content_trust = false;
diff --git a/src/portal/lib/src/service/interface.ts b/src/portal/lib/src/service/interface.ts
index 448e8e0e5..f1410c056 100644
--- a/src/portal/lib/src/service/interface.ts
+++ b/src/portal/lib/src/service/interface.ts
@@ -434,8 +434,15 @@ export interface HttpOptionTextInterface {
withCredentials?: boolean;
}
+
export interface ProjectRootInterface {
NAME: string;
VALUE: number;
LABEL: string;
}
+export interface SystemCVEWhitelist {
+ id: number;
+ project_id: number;
+ expires_at: number;
+ items: Array<{ "cve_id": string; }>;
+}
diff --git a/src/portal/lib/src/service/project.service.ts b/src/portal/lib/src/service/project.service.ts
index 1a4062f61..e6f6ef0a8 100644
--- a/src/portal/lib/src/service/project.service.ts
+++ b/src/portal/lib/src/service/project.service.ts
@@ -1,8 +1,8 @@
import {throwError as observableThrowError, Observable } from "rxjs";
-import { Injectable, Inject } from "@angular/core";
+import {Injectable, Inject} from "@angular/core";
import { HttpClient, HttpParams, HttpResponse } from "@angular/common/http";
-import { map , catchError } from "rxjs/operators";
+import { catchError } from "rxjs/operators";
import { SERVICE_CONFIG, IServiceConfig } from "../service.config";
import { Project } from "../project-policy-config/project";
@@ -12,7 +12,6 @@ import {
HTTP_GET_OPTIONS,
buildHttpRequestOptionsWithObserveResponse
} from "../utils";
-import { RequestQueryParams } from "./RequestQueryParams";
/**
* Define the service methods to handle the Project related things.
@@ -47,7 +46,9 @@ export abstract class ProjectService {
*/
abstract updateProjectPolicy(
projectId: number | string,
- projectPolicy: ProjectPolicy
+ projectPolicy: ProjectPolicy,
+ reuseSysCVEVWhitelist: string,
+ projectWhitelist: object
): Observable
;
/**
@@ -107,7 +108,9 @@ export class ProjectDefaultService extends ProjectService {
public updateProjectPolicy(
projectId: number | string,
- projectPolicy: ProjectPolicy
+ projectPolicy: ProjectPolicy,
+ reuseSysCVEVWhitelist: string,
+ projectWhitelist: object
): any {
let baseUrl: string = this.config.projectBaseEndpoint
? this.config.projectBaseEndpoint
@@ -117,12 +120,14 @@ export class ProjectDefaultService extends ProjectService {
`${baseUrl}/${projectId}`,
{
metadata: {
- public: projectPolicy.Public ? "true" : "false",
- enable_content_trust: projectPolicy.ContentTrust ? "true" : "false",
- prevent_vul: projectPolicy.PreventVulImg ? "true" : "false",
- severity: projectPolicy.PreventVulImgSeverity,
- auto_scan: projectPolicy.ScanImgOnPush ? "true" : "false"
- }
+ public: projectPolicy.Public ? "true" : "false",
+ enable_content_trust: projectPolicy.ContentTrust ? "true" : "false",
+ prevent_vul: projectPolicy.PreventVulImg ? "true" : "false",
+ severity: projectPolicy.PreventVulImgSeverity,
+ auto_scan: projectPolicy.ScanImgOnPush ? "true" : "false",
+ reuse_sys_cve_whitelist: reuseSysCVEVWhitelist
+ },
+ cve_whitelist: projectWhitelist
},
HTTP_JSON_OPTIONS
)
diff --git a/src/portal/lib/src/service/system-info.service.ts b/src/portal/lib/src/service/system-info.service.ts
index f7679d0f4..ae4eb7c8c 100644
--- a/src/portal/lib/src/service/system-info.service.ts
+++ b/src/portal/lib/src/service/system-info.service.ts
@@ -1,10 +1,10 @@
-import { Inject, Injectable } from '@angular/core';
+import {ElementRef, Inject, Injectable} from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map, catchError } from "rxjs/operators";
import { Observable, throwError as observableThrowError } from "rxjs";
-import { SystemInfo } from './interface';
+import {SystemCVEWhitelist, SystemInfo} from './interface';
import { SERVICE_CONFIG, IServiceConfig } from '../service.config';
-import { HTTP_GET_OPTIONS } from "../utils";
+import {HTTP_GET_OPTIONS, HTTP_JSON_OPTIONS} from "../utils";
/**
* Get System information about current backend server.
@@ -18,6 +18,20 @@ export abstract class SystemInfoService {
* returns
*/
abstract getSystemInfo(): Observable;
+ /**
+ * get system CEVWhitelist
+ */
+ abstract getSystemWhitelist(): Observable;
+ /**
+ * update systemCVEWhitelist
+ * @param systemCVEWhitelist
+ */
+ abstract updateSystemWhitelist(systemCVEWhitelist: SystemCVEWhitelist): Observable;
+ /**
+ * set null to the date type input
+ * @param ref
+ */
+ abstract resetDateInput(ref: ElementRef);
}
@Injectable()
@@ -33,5 +47,20 @@ export class SystemInfoDefaultService extends SystemInfoService {
.pipe(map(systemInfo => systemInfo as SystemInfo)
, catchError(error => observableThrowError(error)));
}
+ public getSystemWhitelist(): Observable {
+ return this.http.get("/api/system/CVEWhitelist", HTTP_GET_OPTIONS)
+ .pipe(map(systemCVEWhitelist => systemCVEWhitelist as SystemCVEWhitelist)
+ , catchError(error => observableThrowError(error)));
+ }
+ public updateSystemWhitelist(systemCVEWhitelist: SystemCVEWhitelist): Observable {
+ return this.http.put("/api/system/CVEWhitelist", JSON.stringify(systemCVEWhitelist), HTTP_JSON_OPTIONS)
+ .pipe(map(response => response)
+ , catchError(error => observableThrowError(error)));
+ }
+ public resetDateInput(ref: ElementRef) {
+ if (ref) {
+ ref.nativeElement.value = null ;
+ }
+ }
}
diff --git a/src/portal/package-lock.json b/src/portal/package-lock.json
index c0e61a87f..19af5ed29 100644
--- a/src/portal/package-lock.json
+++ b/src/portal/package-lock.json
@@ -176,13 +176,15 @@
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==",
- "dev": true
+ "dev": true,
+ "optional": true
},
"mime-types": {
"version": "2.1.24",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
"dev": true,
+ "optional": true,
"requires": {
"mime-db": "1.40.0"
}
@@ -3146,7 +3148,8 @@
"acorn": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz",
- "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA=="
+ "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==",
+ "dev": true
},
"acorn-dynamic-import": {
"version": "4.0.0",
@@ -6491,7 +6494,8 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"aproba": {
"version": "1.2.0",
@@ -6515,13 +6519,15 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -6538,19 +6544,22 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -6681,7 +6690,8 @@
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"ini": {
"version": "1.3.5",
@@ -6695,6 +6705,7 @@
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"dev": true,
+ "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -6711,6 +6722,7 @@
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -6719,13 +6731,15 @@
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"minipass": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz",
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
"dev": true,
+ "optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@@ -6746,6 +6760,7 @@
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
+ "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -6834,7 +6849,8 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -6848,6 +6864,7 @@
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
+ "optional": true,
"requires": {
"wrappy": "1"
}
@@ -6943,7 +6960,8 @@
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
- "dev": true
+ "dev": true,
+ "optional": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -6985,6 +7003,7 @@
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"dev": true,
+ "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -7006,6 +7025,7 @@
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true,
+ "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -7054,13 +7074,15 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"yallist": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
- "dev": true
+ "dev": true,
+ "optional": true
}
}
},
@@ -10632,7 +10654,8 @@
},
"ansi-regex": {
"version": "2.1.1",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"aproba": {
"version": "1.2.0",
@@ -10650,11 +10673,13 @@
},
"balanced-match": {
"version": "1.0.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -10667,15 +10692,18 @@
},
"code-point-at": {
"version": "1.1.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"concat-map": {
"version": "0.0.1",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -10778,7 +10806,8 @@
},
"inherits": {
"version": "2.0.3",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"ini": {
"version": "1.3.5",
@@ -10788,6 +10817,7 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
+ "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -10800,17 +10830,20 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
+ "optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -10827,6 +10860,7 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
+ "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -10899,7 +10933,8 @@
},
"number-is-nan": {
"version": "1.0.1",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -10909,6 +10944,7 @@
"once": {
"version": "1.4.0",
"bundled": true,
+ "optional": true,
"requires": {
"wrappy": "1"
}
@@ -10984,7 +11020,8 @@
},
"safe-buffer": {
"version": "5.1.2",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -11014,6 +11051,7 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
+ "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -11031,6 +11069,7 @@
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
+ "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -11069,11 +11108,13 @@
},
"wrappy": {
"version": "1.0.2",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"yallist": {
"version": "3.0.3",
- "bundled": true
+ "bundled": true,
+ "optional": true
}
}
},
@@ -17118,7 +17159,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"aproba": {
"version": "1.2.0",
@@ -17139,12 +17181,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -17159,17 +17203,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -17286,7 +17333,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"ini": {
"version": "1.3.5",
@@ -17298,6 +17346,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -17312,6 +17361,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -17319,12 +17369,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -17343,6 +17395,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -17423,7 +17476,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -17435,6 +17489,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"wrappy": "1"
}
@@ -17520,7 +17575,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -17556,6 +17612,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -17575,6 +17632,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -17618,12 +17676,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
}
}
},
@@ -18718,7 +18778,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"aproba": {
"version": "1.2.0",
@@ -18739,12 +18800,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -18759,17 +18822,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -18886,7 +18952,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"ini": {
"version": "1.3.5",
@@ -18898,6 +18965,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -18912,6 +18980,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -18919,12 +18988,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -18943,6 +19014,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -19023,7 +19095,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -19035,6 +19108,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"wrappy": "1"
}
@@ -19120,7 +19194,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -19156,6 +19231,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -19175,6 +19251,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -19218,12 +19295,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
}
}
},
diff --git a/src/portal/src/app/base/harbor-shell/harbor-shell.component.html b/src/portal/src/app/base/harbor-shell/harbor-shell.component.html
index 637fab370..f7a085a63 100644
--- a/src/portal/src/app/base/harbor-shell/harbor-shell.component.html
+++ b/src/portal/src/app/base/harbor-shell/harbor-shell.component.html
@@ -2,8 +2,9 @@