From 5a59c983372afdb7b631c026606d3e2ffacb39df Mon Sep 17 00:00:00 2001 From: AllForNothing Date: Fri, 4 Aug 2023 14:31:13 +0800 Subject: [PATCH] Update ui to fix some issues 1. Add digest filter for vulnerability search, for #19023 2. Fixes #19104 Signed-off-by: AllForNothing --- .../security-hub.component.ts | 18 ++++++++++++++---- .../security-hub.interface.ts | 2 ++ .../vulnerability-filter.component.ts | 2 ++ .../vulnerability-summary.component.html | 4 ++-- .../vulnerability-summary.component.ts | 7 ++++--- .../src/app/services/app-config.service.ts | 10 ++++++++++ .../app-level-alerts.component.html | 1 + .../app-level-alerts.component.ts | 9 +++++++++ 8 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts b/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts index fdb9159f7d1..0af10f67a36 100644 --- a/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts +++ b/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts @@ -19,6 +19,7 @@ import { } from './security-hub.interface'; import { ProjectService } from '../../../../../../ng-swagger-gen/services/project.service'; import { VulnerabilityFilterComponent } from './vulnerability-filter/vulnerability-filter.component'; +import { DangerousArtifact } from '../../../../../../ng-swagger-gen/models/dangerous-artifact'; @Component({ selector: 'app-security-hub', @@ -174,8 +175,11 @@ export class SecurityHubComponent { this.currentPage = 1; this.clrDgRefresh(this.state, [`${OptionType.CVE_ID}=${cveId}`]); } - searchRepo(repoName: string) { - this.vulnerabilityFilterComponent.selectedOptions = [OptionType.REPO]; + searchRepo(artifact: DangerousArtifact) { + this.vulnerabilityFilterComponent.selectedOptions = [ + OptionType.REPO, + OptionType.DIGEST, + ]; this.vulnerabilityFilterComponent.candidates = [ OptionType.CVE_ID, OptionType.SEVERITY, @@ -185,8 +189,14 @@ export class SecurityHubComponent { OptionType.TAG, ]; this.vulnerabilityFilterComponent.valueMap = {}; - this.vulnerabilityFilterComponent.valueMap[OptionType.REPO] = repoName; + this.vulnerabilityFilterComponent.valueMap[OptionType.REPO] = + artifact?.repository_name; + this.vulnerabilityFilterComponent.valueMap[OptionType.DIGEST] = + artifact?.digest; this.currentPage = 1; - this.clrDgRefresh(this.state, [`${OptionType.REPO}=${repoName}`]); + this.clrDgRefresh(this.state, [ + `${OptionType.REPO}=${artifact?.repository_name}`, + `${OptionType.DIGEST}=${artifact?.digest}`, + ]); } } diff --git a/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.interface.ts b/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.interface.ts index b6fc8607c74..fc677aea797 100644 --- a/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.interface.ts +++ b/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.interface.ts @@ -21,6 +21,7 @@ export enum OptionType { PACKAGE = 'package', TAG = 'tag', PROJECT_ID = 'project_id', + DIGEST = 'digest', } export const OptionType_I18n_Map = { @@ -32,6 +33,7 @@ export const OptionType_I18n_Map = { [OptionType.PACKAGE]: 'VULNERABILITY.GRID.COLUMN_PACKAGE', [OptionType.TAG]: 'REPLICATION.TAG', [OptionType.PROJECT_ID]: 'SECURITY_HUB.OPTION_PROJECT_ID_NAME', + [OptionType.DIGEST]: 'P2P_PROVIDER.DIGEST', }; export interface OptionTypeValueMap { diff --git a/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-filter/vulnerability-filter.component.ts b/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-filter/vulnerability-filter.component.ts index f58526a7475..7b16febecbf 100644 --- a/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-filter/vulnerability-filter.component.ts +++ b/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-filter/vulnerability-filter.component.ts @@ -24,6 +24,7 @@ export class VulnerabilityFilterComponent { OptionType.REPO, OptionType.PACKAGE, OptionType.TAG, + OptionType.DIGEST, ]; allOptions: string[] = [ OptionType.CVE_ID, @@ -33,6 +34,7 @@ export class VulnerabilityFilterComponent { OptionType.REPO, OptionType.PACKAGE, OptionType.TAG, + OptionType.DIGEST, ]; valueMap: OptionTypeValueMap = {}; diff --git a/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-summary/vulnerability-summary.component.html b/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-summary/vulnerability-summary.component.html index 45708d905be..e0e3bec0e0c 100644 --- a/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-summary/vulnerability-summary.component.html +++ b/src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-summary/vulnerability-summary.component.html @@ -88,7 +88,7 @@

{{ securitySummary?.none_cnt || 0 }} -
+
@@ -121,7 +121,7 @@

class="search" href="javascript:void(0)" appScrollAnchor="{{ vulId }}" - (click)="searchRepoClick(item?.repository_name)" + (click)="searchRepoClick(item)" title="{{ item.repository_name }}"> (); @Output() - searchRepo = new EventEmitter(); + searchRepo = new EventEmitter(); securitySummary: SecuritySummary; readonly vulId: string = VUL_ID; readonly severityText = severityText; @@ -175,8 +176,8 @@ export class VulnerabilitySummaryComponent implements OnInit, OnDestroy { this.searchCVE.emit(cveId); } - searchRepoClick(repoName: string) { - this.searchRepo.emit(repoName); + searchRepoClick(artifact: DangerousArtifact) { + this.searchRepo.emit(artifact); } getColorByTheme(): string { diff --git a/src/portal/src/app/services/app-config.service.ts b/src/portal/src/app/services/app-config.service.ts index 4cade95195e..e9b011db438 100644 --- a/src/portal/src/app/services/app-config.service.ts +++ b/src/portal/src/app/services/app-config.service.ts @@ -37,8 +37,18 @@ export class AppConfigService { // Store the application configuration configurations: AppConfig = new AppConfig(); + private _bannerMessageClosed: boolean = false; + constructor(private http: HttpClient, private cookie: CookieService) {} + setBannerMessageClosed(v: boolean) { + this._bannerMessageClosed = v; + } + + getBannerMessageClosed(): boolean { + return this._bannerMessageClosed; + } + public load(): Observable { return this.http.get(systemInfoEndpoint, HTTP_GET_OPTIONS).pipe( map(response => { diff --git a/src/portal/src/app/shared/components/app-level-alerts/app-level-alerts.component.html b/src/portal/src/app/shared/components/app-level-alerts/app-level-alerts.component.html index 42031014934..4e2555f8a92 100644 --- a/src/portal/src/app/shared/components/app-level-alerts/app-level-alerts.component.html +++ b/src/portal/src/app/shared/components/app-level-alerts/app-level-alerts.component.html @@ -3,6 +3,7 @@ *ngIf="hasValidBannerMessage()" [clrAlertType]="getBannerMessageType()" [clrAlertAppLevel]="true" + [(clrAlertClosed)]="bannerMessageClosed" [clrAlertClosable]="getBannerMessageClosable()">