Skip to content

Commit

Permalink
NVSHAS-9265: Incomplete and Incorrect Vulnerability Scan Results on P…
Browse files Browse the repository at this point in the history
…RE PCI Environment (UI)
  • Loading branch information
xingzhang-suse authored and rushk014 committed Feb 28, 2025
1 parent aad97b3 commit 80b7cd6
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface VulnerabilitiesQuerySessionData {

export interface VulnerabilitiesQueryData {
query_token: string;
status: string;
summary: VulnerabilitiesQuerySummary;
total_matched_records: number;
total_records: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div *ngIf="iconName" class="eos-icons {{ iconColor }}">{{ iconName }}</div>
<div [ngClass]="noRowsClass">{{ noRowsMsg }}</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AgGridNoRowOverlayComponent } from './ag-grid-no-row-overlay.component';

describe('AgGridNoRowOverlayComponent', () => {
let component: AgGridNoRowOverlayComponent;
let fixture: ComponentFixture<AgGridNoRowOverlayComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AgGridNoRowOverlayComponent],
}).compileComponents();

fixture = TestBed.createComponent(AgGridNoRowOverlayComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component, OnInit, Input } from '@angular/core';
import { INoRowsOverlayAngularComp } from 'ag-grid-angular';
import { TranslateService } from '@ngx-translate/core';
import { ICellRendererParams } from 'ag-grid-community';

@Component({
selector: 'app-ag-grid-no-row-overlay',
templateUrl: './ag-grid-no-row-overlay.component.html',
styleUrls: ['./ag-grid-no-row-overlay.component.scss'],
})
export class AgGridNoRowOverlayComponent implements INoRowsOverlayAngularComp {
noRowsClass: string = '';
noRowsMsg: string = this.translate.instant('general.NO_ROWS');
iconName: string;
iconColor: string;

constructor(private translate: TranslateService) {}

agInit(params: ICellRendererParams): void {
this.noRowsMsg = params.context.noRowsMsg;
this.noRowsClass = params.context.noRowsClass;
this.iconName = params.context.iconName;
this.iconColor = params.context.iconColor;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AgGridNoRowOverlayComponent } from './ag-grid-no-row-overlay.component';

@NgModule({
declarations: [AgGridNoRowOverlayComponent],
imports: [CommonModule],
exports: [AgGridNoRowOverlayComponent],
})
export class AgGridNoRowOverlayModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { NvCommonModule } from '@common/nvCommon.module';
import { PdfGenerationDialogComponent } from './pdf-generation-dialog/pdf-generation-dialog.component';
import { VulnerabilitiesGridModule } from '@components/vulnerabilities-grid/vulnerabilities-grid.module';
import { RiskAssetsLegendModule } from '@components/ui/risk-assets-legend/risk-assets-legend.module';
import { AgGridNoRowOverlayModule } from '@components/ui/ag-grid-no-row-overlay/ag-grid-no-row-overlay.module';
const routes: Routes = [{ path: '', component: VulnerabilitiesComponent }];

@NgModule({
Expand Down Expand Up @@ -71,6 +72,7 @@ const routes: Routes = [{ path: '', component: VulnerabilitiesComponent }];
AssetsViewReportModule,
VulnerabilitiesGridModule,
RiskAssetsLegendModule,
AgGridNoRowOverlayModule,
],
})
export class VulnerabilitiesModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class VulnerabilitiesService {
activeCount!: number;
sortModel: SortModelItem[];
activeSummary!: VulnerabilitiesQuerySummary;
status: string;
private activeSummarySubject$ = new Subject();
activeSummary$ = this.activeSummarySubject$.asObservable();
vulnerabilitiesData$ = this.vulnerabilitiesFilterService.vulQuery$.pipe(
Expand All @@ -39,6 +40,7 @@ export class VulnerabilitiesService {
query_token: '',
total_matched_records: 0,
total_records: 0,
status: '',
summary: {
count_distribution: {
high: 0,
Expand All @@ -63,6 +65,7 @@ export class VulnerabilitiesService {
tap(queryData => {
this.activeToken = queryData.query_token;
this.activeSummary = queryData.summary;
this.status = queryData.status;
this.activeSummarySubject$.next();
this.vulnerabilitiesFilterService.filteredCount =
queryData.total_matched_records;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
[remoteGridBinding]="remoteGridBinding"
(remoteGridReady)="onGridReady($event)"
(modelUpdated)="onModelUpdated()"
noRowsOverlayComponent="noRowsOverlayRenderer"
id="vulnerability-grid"
class="ag-theme-alpine"
style="width: 100%; height: calc(100% - 70px)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { VulnerabilitiesService } from '../../vulnerabilities.service';
import { VulnerabilitiesFilterService } from '../../vulnerabilities.filter.service';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { VulnerabilityItemsTableFilterComponent } from './vulnerability-items-table-filter/vulnerability-items-table-filter.component';
import { AgGridNoRowOverlayComponent } from '@components/ui/ag-grid-no-row-overlay/ag-grid-no-row-overlay.component';
import {
debounceTime,
distinctUntilChanged,
Expand Down Expand Up @@ -198,14 +199,30 @@ export class VulnerabilityItemsTableComponent
paginationPageSize: this.vulnerabilitiesFilterService.paginationPageSize,
onGridReady: event => this.onGridReady(event),
onSelectionChanged: event => this.onSelectionChanged(event),
context: {
noRowsMsg: this.translate.instant(
this.vulnerabilitiesService.status === 'pending'
? 'scan.message.DATA_PENDING'
: 'general.NO_ROWS'
),
noRowsClass:
this.vulnerabilitiesService.status === 'pending' ? 'text-danger' : '',
iconName:
this.vulnerabilitiesService.status === 'pending' ? 'warning' : '',
iconColor:
this.vulnerabilitiesService.status === 'pending'
? 'text-caution'
: '',
},
components: {
impactCellRenderer: VulnerabilityItemsTableImpactCellComponent,
actionCellRenderer: VulnerabilityItemsTableActionCellComponent,
scoreCellRenderer: VulnerabilityItemsTableScoreCellComponent,
severityCellRenderer: VulnerabilityItemsTableSevertiyCellComponent,
noRowsOverlayRenderer: AgGridNoRowOverlayComponent,
},
overlayNoRowsTemplate: this.translate.instant('general.NO_ROWS'),
};

this.quickFilter.valueChanges
.pipe(debounceTime(500), distinctUntilChanged())
.subscribe(filterText => {
Expand Down Expand Up @@ -302,6 +319,7 @@ export class VulnerabilityItemsTableComponent

onGridReady(params): void {
this.gridApi = params.api;
this.gridApi.showNoRowsOverlay();
this.vulnerabilitiesService.gridApi = this.gridApi;

setTimeout(() => {
Expand Down
5 changes: 3 additions & 2 deletions admin/webapp/websrc/assets/i18n/en-common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,8 @@
},
"message": {
"CONFIG_ERR": "Error happened when getting scan configuration",
"OS_ERR": "No OS"
"OS_ERR": "No OS",
"DATA_PENDING": "The data is being prepared during controller is restarting, please click refresh button a moment later"
}
},
"registry": {
Expand All @@ -1296,7 +1297,7 @@
"DELETE_REPO": "Delete registry",
"REGISTRY_TYPE": "Registry type",
"FILTER_HINT": "Sample: gliderlabs/dockerbox:latest, gliderlabs/*, gliderlabs/*:*, gliderlabs/n*:3*",
"GITHUB_CONTAINER_FILTER_HINT": "Filter '*' is not allowed, the namespace must be specified (e.g. 'my_org/*' or 'my_user/*'",
"GITHUB_CONTAINER_FILTER_HINT": "Filter '*' is not allowed, the namespace must be specified (e.g. 'my_org/*' or 'my_user/*')",
"AMAZON_URL_HINT": "Sample: https://<aws_account_id>.dkr.ecr.<region>.amazonaws.com",
"AZURE_URL_HINT": "Sample: https://<companyname>.azurecr.io/",
"JFROG_URL_HINT": "Sample: https://docker-virtual.<10.1.7.122:8081> for subdomain, https://<10.1.7.122:8081> for repository or port",
Expand Down
5 changes: 3 additions & 2 deletions admin/webapp/websrc/assets/i18n/zh_cn-common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,8 @@
},
"message": {
"CONFIG_ERR": "获取扫描配置时发生错误",
"OS_ERR": "无OS"
"OS_ERR": "无OS",
"DATA_PENDING": "控制器重启过程中, 正在准备数据, 请稍后按刷新按钮"
}
},
"registry": {
Expand All @@ -1296,7 +1297,7 @@
"DELETE_REPO": "删除镜像库",
"REGISTRY_TYPE": "镜像库类型",
"FILTER_HINT": "样本: gliderlabs/dockerbox:latest, gliderlabs/*, gliderlabs/*:*, gliderlabs/n*:3*",
"GITHUB_CONTAINER_FILTER_HINT": "过滤器 '*' 是不允许的, 您需要制定代码库 'myrepo/'",
"GITHUB_CONTAINER_FILTER_HINT": "过滤器 '*' 是不允许的, 命名空间需要被指定 (例如 'my_org/*' or 'my_user/*)",
"AMAZON_URL_HINT": "样本: https://<aws_account_id>.dkr.ecr.<region>.amazonaws.com",
"AZURE_URL_HINT": "样本: https://<companyname>.azurecr.io/",
"JFROG_URL_HINT": "样本: https://docker-virtual.<10.1.7.122:8081> - 子域, https://<10.1.7.122:8081> - 镜像库或端口",
Expand Down

0 comments on commit 80b7cd6

Please sign in to comment.